php防采集代码

<?php
$HTTP_REFERER = $_SERVER[“HTTP_REFERER”];
$HTTP_USER_AGENT = $_SERVER[“HTTP_USER_AGENT”];
$SERVER_NAME = $_SERVER[“SERVER_NAME”];
$CompCharArr = explode(“,”,”Baiduspider,Scooter,ia_archiver,Googlebot,FAST-WebCrawler,MSNBOT,Slurp”);
$CompCharArrSize = sizeof($CompCharArr);
$CheckSign = “”;
for($i=0;$i<$CompCharArrSize;$i++)
{
$ComChar = trim($CompCharArr[$i]);
if($CompChar<>”” && eregi($CompChar,$HTTP_USER_AGENT))
{
$CheckSign = “T”;
}
}
$SERVER_NAME_M = “http://”.$SERVER_NAME;//strlen
$EndLenth = strlen($SERVER_NAME_M) + 1;
$CompServerName = “http://”.$SERVER_NAME.”/”;
if(empty($CheckSign) && ($HTTP_REFERER == “” or substr($HTTP_REFERER,0,$EndLenth) <> $CompServerName ))
{
?>
<html>
<body>
<form action=” name=checkrefer id=checkrefer method=post></form>
<script>
document.all.checkrefer.action=document.URL;
document.all.checkrefer.submit();</script>
</body></html>
<?php }?>

滚动至顶部