error_reporting( E_ERROR | E_WARNING | E_PARSE );
set_time_limit(0);
$server = 'www.goalercn.com'; // IP address
$host = 'www.goalercn.com'; // Domain name
$target = '/test.php?x=1'; // Specific program
$referer = 'http://www.goalercn.com/down/redirect.php?x=downurl&id=39&urlid=65'; // Referer
$port = 80;
$re = fsockopen($server, $port, $errno, $errstr, 30);
if (!$re){
echo "<h1>无法连接远程服务器</h1><h3>$errstr ($errno)</h3/>\n";
}
else {
$strhead = "GET $target HTTP/1.1\r\n";
$strhead .= "Host: $host\r\n";
//$strhead .= "Cookie: PHPSESSIONIDSQTBQSDA=DFCAPKLBBFICDAFMHNKIGKEG\r\n";
$strhead .= "Referer: $referer\r\n";
$strhead .= "Connection: Close\r\n\r\n";
fwrite($re, $strhead);
while (!feof($re)){
echo fgets($re, 128);
}
fclose($re);
}
运行上述代码,返回如下:
以下为引用的内容: HTTP/1.1 200 OK Connection: close Date: Sat, 11 Jul 2009 04:33:05 GMT Content-Type: text/html Server: Microsoft-IIS/6.0 X-Powered-By: ASP.NET X-Powered-By: PHP/5.2.3 http://www.goalercn.com/down/redirect.php?x=downurl&id=39&urlid=65