本文实例分析了php中HTTP_REFERER函数用法。分享给大家供大家参考。具体分析如下:

利用php的http_referer函数来判断用户的来路,这是比较简单的,实例代码如下:
复制代码 代码如下:<"The page you were on previously was {$_SERVER['HTTP_REFERER']}<br />";
   } else {
     print "You didn't click any links to get here<br />";
      }
    "refer.php">Click me!</a>
下面是我们让用户不知道我们的来路处理,实例代码如下:
复制代码 代码如下:<"www.jb51.net";
$referer = "http://".$host;
$fp = fsockopen ($host, 80, $errno, $errstr, 30);
if (!$fp){
        echo "$errstr ($errno)<br>;n";
}else{
$request = "
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */"."*
Referer: http://$host
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Host: $host
Connection: Close"
."rnrn";
 
fputs ($fp, "$request");
while (!feof($fp))
{
   $res[] = fgets($fp,1024);
}
$html = join("",$res);
fclose ($fp);
$fp = file_put_contents("123cha.html",$html);
echo "done";
}
这不就行了"codetitle">复制代码 代码如下:<"www.jb51.net";
$html = file_get_contents("http://".$host);
$fp = file_put_contents("hao123.html",$html);
echo "done";
"codetitle">复制代码 代码如下:<"$errstr($errno)<br />n";

else{
$out = "
GET $target HTTP/1.1
Host: $host
Referer: $referer
Connection: Closernrn";
fwrite($fp, $out);
while (!feof($fp)){
echo fgets($fp, 1024);
}
fclose($fp);
}
"codetitle">复制代码 代码如下:<"<hr />";
echo $_SERVER["HTTP_REFERER"];
?>

希望本文所述对大家的php程序设计有所帮助。

标签:
php,HTTP_REFERER,函数,用法

免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
桃源资源网 Design By www.nqtax.com

评论“php中HTTP_REFERER函数用法实例”

暂无“php中HTTP_REFERER函数用法实例”评论...