Page 1 of 1

Trying to get a webpage through a proxy...

Posted: Sun Feb 12, 2006 1:05 pm
by jclarkkent2003
Trying to get a webpage through a proxy...

Code: Select all

<?php
function get_thru_proxy($request_url)
{
   $proxy_name = '127.0.0.1';
   $proxy_port = 8118;
   $proxy_user = "";
   $proxy_pass = "";
   $proxy_cont = '';
//   $request_url = "http://status.icq.com/online.gif?icq=$uin";

   $proxy_fp = fsockopen($proxy_name, $proxy_port);
   if (!$proxy_fp)
       return false;
   fputs($proxy_fp, "GET $request_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");
   while(!feof($proxy_fp)){
       $proxy_cont .= fread($proxy_fp,4096);
   }
   fclose($proxy_fp);
   $proxy_cont = substr($proxy_cont, strpos($proxy_cont,"\r\n\r\n")+4);

/*   if (strstr($proxy_cont, 'online1'))
       return 'online';
   if (strstr($proxy_cont, 'online0'))
       return 'offline';
   if (strstr($proxy_cont, 'online2'))
       return 'disabled';
*/
	echo $proxy_cont;
	return $proxy_cont;
}

$data = get_thru_proxy("http://www.whatismyip.com/");

//echo "data [ $data ] ";
//echo "User is ".icq_uin(123456789012345);
?>
Can someone tell me where I went wrong on this script and messed up? It doesn't work.

Posted: Sun Feb 12, 2006 1:28 pm
by Chris Corbyn
First thing I see is that you need HTTP/1.1 for the HOST directive as far as I know.

I'm not 100% how proxies handle requests, but why do you tell the proxy server it's own name?

Posted: Sun Feb 12, 2006 3:55 pm
by jclarkkent2003
it's a modified function of a icq online handler, it checks if a person is online on icq through proxies, i just modified to get whatismyip.com instead and return the entire webpage and not just a reg exp value.

Anybody else know how to get a page through a proxy, or how i can use the 70 ip's on binded to my server to go out on the world..

Like I have 70 ip's binded to my centos 4 linux cpanel/whm server, and I need to write a php script that will file_get_contents ( whatismyip.com ) and each time it uses a differnt proxy from the 70 in my ip_list.txt .

( script will be used for a different authentication method than just checking proxy on whatismyip.com ) but nothing bad purposes.