connect to Whois server via proxy and proxy chaining

Hello experts
My first question here :)
The following code from
Should  get the continent of a page via proxy  ( I have not tried but it should be fine )
function proxy_url($proxy_url)
   $proxy_name = '';
   $proxy_port = 4001;
   $proxy_user = "user";    // added
   $proxy_pass = "password";    // added
   $proxy_cont = '';

   $proxy_fp = fsockopen($proxy_name, $proxy_port);
   if (!$proxy_fp)    {return false;}
   fputs($proxy_fp, "GET $proxy_url HTTP/1.0\r\nHost: $proxy_name\r\n");
   fputs($proxy_fp, "Proxy-Authorization: Basic " . base64_encode ("$proxy_user:$proxy_pass") . "\r\n\r\n");    // added
   while(!feof($proxy_fp)) {$proxy_cont .= fread($proxy_fp,4096);}
   $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);
   return $proxy_cont;

The following code from
 ( I have not tried but it should be fine )

function lookup($lookup){  
            $whois = "";  
            $fp = fsockopen($whois, 43, &$errno, &$errstr, 30);  
            if (!$fp){  
                printf("Error: %s (%s)", $errstr, $errno);  
                $data = 0;  
            } else {  
                $lookup .= "\n";  
                fputs($fp, $lookup);  
                $data = fread( $fp, 16384 );  
            return $data;  

should connect to whois and gives the whois result ( I have not tried but it should be fine )

Now my questions
say I have two proxy servers

1-How to connect to whois server via proxy ( the script connects to proxy1 then proxy1 connect to the whois server and get the result )
2- How to do proxy chaining  ( the script connect to proxy1 then proxy1 connects to proxy2 then get the result from  for example )
3- How to do proxy chaining to connect to whois server ( the script connect to proxy1 then proxy1 connects to proxy2 then get the result from whois server  )

Please provide complete code
Thank you in advance
LVL 10
Who is Participating?
smackadooConnect With a Mentor Commented:
of course they will block your server ip.
People running whoiservers pay to run their whois queries and don't allow people to hijack their websites, sucking their bandwidth so you can show it to users on your site (probably making money by showing ads aswell)

Instead of showing their information on your pages, link to their site where they can see the information on their pages.

I'd expect if the whois sites spotted you were abusing their webpages by proxy or by other means, some of them have been known to send a lawyers letter with a bill for all the bandwidth you have used) (eg
honestman31Author Commented:
Hello experts .
Are my questions difficult or do you need more clarification ?
Please let me know
Proxy chaining is more of a network issue then PHP issue.  So if you are doing [ workstation --> proxy1 --> proxy2 --> Web Server ] connection, you need to setup the proxy chain from proxy1 --> proxy2 first.  There is nothing to do with the PHP script.
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

honestman31Author Commented:
slyong ,
Do you mean Proxy chaining  cannot be done in PHP ?
Also what about connecting to whois via proxy ? cannot be done in PHP too?
Thank you

Yes proxy chaining is not to be done on PHP, it can be done in PHP but it is a huge proxy hacking through sockets and things like that.  There is a PHP proxy implementation here:  You can also do use other proxy chaining tools like:

To connect to whois via proxy can be done in PHP with Curl extension:

The code example can be found here
What OS are you using?
honestman31Author Commented:
I use windows xp sp2 ( PHP Version 4.3.11 )
and also I have shared hosting uses linux (PHP Version 4.4.2)
I was asking, because it might be easier to use an external program (like whois on linux).
If you call it with exec() in PHP you can 'catch' the output for use in your PHP script
honestman31Author Commented:
I cannot install any program on my shared hosting.
My problem is that I provide whois look up in my site after some queries the whois server will block the server IP for a one day  , So I was thinking to query whois via proxies . and even I want to make it more efficient by using  proxy chaining
Good point :)
honestman31Author Commented:
I have not accepted this answer nor I recieved a notification of the Administrative Comment  dated  08/19/2006 11:45AM PDT,
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.