php - Use fsockopen with proxy -


i have simple whois script

    if($conn = fsockopen ($whois_server, 43)) {         fputs($conn, $domain."\r\n");         while(!feof($conn)) {             $output .= fgets($conn, 128);         }         fclose($conn);         return $output;     } 

$whois_server = whois.afilias.info; //whois server info domains

but want run in through proxy. need connect proxy -> connect whois server -> , make request. this?

$fp = fsockopen($ip,$port);  fputs($fp, "connect $whois_server:43\r\n $domain\r\n"); 

but doesn't work, don't know if i'm making second connection right.

sending request proxy should like:

<?php     $proxy = "1.2.3.4"; // proxy      $port = 8080; // proxy port      $fp = fsockopen($proxy,$port); // connect proxy     fputs($fp, "connect $whois_server:43\r\n $domain\r\n");      $data="";     while (!feof($fp)) $data.=fgets($fp,1024);     fclose($fp);     var_dump($data); ?> 

rather doing recommend using curl in combination with:

curl_setopt($ch, curlopt_proxy, 1.2.3.4); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -