php如何实现禁止采集

来自:互联网
时间:2021-11-25
阅读:
免费资源网,https://freexyz.cn/

php如何实现禁止采集?

PHP防采集方法代码

 1 <?php 
 2        /**
 3       *        FileName:test.php
 4       *        Summary: 防采集
 5       *        Author: sinob
 6       *        CreateTime: 2005-10-18    
 7       *        LastModifed:2005-10-18 
 8       *        请参见http://mall.yi85.com/
 9        */
10        $HTTP_REFERER = $_SERVER["HTTP_REFERER"];
11        $HTTP_USER_AGENT = $_SERVER["HTTP_USER_AGENT"];
12        $SERVER_NAME = $_SERVER["SERVER_NAME"];
13        $CompCharArr = explode(",","Baiduspider,Scooter,ia_archiver,Googlebot,FAST-WebCrawler,MSNBOT,Slurp");
14        $CompCharArrSize = sizeof($CompCharArr);
15        $CheckSign = "";
16        for($i=0;$i<$CompCharArrSize;$i++)
17        {
18             $ComChar = trim($CompCharArr[$i]);
19             if($CompChar<>"" && eregi($CompChar,$HTTP_USER_AGENT))
20             {
21                      $CheckSign = "T";
22             }
23        }
24        $SERVER_NAME_M = "http://".$SERVER_NAME;//strlen
25         $EndLenth = strlen($SERVER_NAME_M) + 1;
26        $CompServerName = "http://".$SERVER_NAME."/";
27        if(empty($CheckSign) && ($HTTP_REFERER == "" or substr($HTTP_REFERER,0,$EndLenth) <> $CompServerName ))
28        {
29 ?>
30 <html>
31 <body>
32 <form action=' name=checkrefer id=checkrefer method=post></form>
33 <script>
34 document.all.checkrefer.action=document.URL;
35 document.all.checkrefer.submit();
36 <?php }?>
免费资源网,https://freexyz.cn/
返回顶部
顶部