create domain authentication script with php external file

Discussion in 'PHP' started by missyswan, Feb 9, 2012.

  1. #1
    hello i just made wordpress theme and want to use php script to authenticate my client domain, but it doesn't work.

    Here is script that running on client server (ex: client.com).

    $domain = $_SERVER['HTTP_HOST'];
      $data = file_get_contents('http://myserver.com/amasense.php');
      $rows = explode("\n", $data);
      $verify = "false";
    	
    	
      for($i = 0; $i < count($rows); $i++){
    	
    		if($domain == $rows[$i]){
    			$verify = "true";	
    
    			echo "<br/>";
    			echo "$verify -> ver<br/>";
    			echo "$domain -> dom<br/>";
    			echo "$rows[$i] -> rows<br/>";
                            dosomethinghere();
    			break;
    		}else{
    			echo "<br/>";
    			echo "$verify -> ver<br/>";
    			echo "$domain -> dom<br/>";
    			echo "$rows[$i] -> row<br/>";
                            tellclienttoauthenticate();
    		}
    	
      }
    PHP:

    and here is the content for amasense.php that running on my server


    
    othersite.com
    client.com
    anothersite.com
    
    PHP:

    my expected output the script will return $verify = "true" if its run on my client website (client.com). but above script will always return $verify as "false" even i run it on client.com server.

    is there something wrong with my code?

    or is there any ready to use script to do this thing?
    thank you very much for your help sir.
     
    missyswan, Feb 9, 2012 IP
  2. krishmk

    krishmk Well-Known Member

    Messages:
    1,376
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    185
    #2
    I believe $_SERVER[HTTP_HOST] returns "www.client.com" instead of the "client.com". I would say var_dump both $domain and $data and see if it really contains the desired value.
    Also remote URL access might be disabled by some hosting companies so you may need to warn that as well to the script user.
     
    krishmk, Feb 10, 2012 IP
  3. missyswan

    missyswan Member

    Messages:
    120
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #3
    do you know any ready to use script out there that we can use for authentification?
     
    missyswan, Feb 11, 2012 IP