Trying to get a webpage through a proxy...
Posted: Sun Feb 12, 2006 1:05 pm
Trying to get a webpage through a proxy...
Can someone tell me where I went wrong on this script and messed up? It doesn't work.
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);
?>