PHP防采集方法代码

<?php
/**
* FileName:test.php
* Summary: 防采集
*/
$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();
<?php }?>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。