I wont be able to test until I am back in work... but just a little question, from the code below how will I get the source code of "www.google.com" into $string? (I am a newbie)
Code:
Based on a previous code, here is the getThroughProxy function, with proxy Basic authentification :
function getthroughproxy
($myfiles,
$proxyhost="0.0.0.0",
$proxyport=0,
$proxyuser = '',
$proxypass = ''
)
{
$errno = '';
$errstr = '';
$datei = fsockopen($proxyhost, $proxyport, &$errno, &$errstr,30);
if( !$datei )
{
return array('headers'=>false,
'content'=>false,
'errno'=>$errno,
'errstr'=>$errstr);
// ^^^ proxy not available
} else
{
fputs($datei,"GET $myfiles HTTP/1.0\n");
if ('' !== $proxyuser)
{
fputs($datei, 'Proxy-Authorization: Basic '.base64_encode("$proxyuser:$proxypass")."\n");
}
fputs($datei, "\n\n");
$zeile = '';
while (!feof($datei))
{
$zeile =$zeile.fread($datei,4096);
}
}
fclose($datei);
return array('headers'=>substr($zeile,0,strpos($zeile,"\r\n\r\n")),
'content'=>substr($zeile,strpos($zeile,"\r\n\r\n")+4),
'errno'=>$errno,
'errstr'=>$errstr);
}