服务报价 | 域名主机 | 网络营销 | 软件工具| [加入收藏]
 热线电话: #
当前位置: 主页 > php教程 > php教程 >

php记录蜘蛛并生成日志的相关代码

时间:2012-03-05 22:59来源:未知 作者:最模板 点击:
这个是最模板从一小偷程序里提取的。判断是否为蜘蛛,然后写入 zhizhu.txt 文件当中! 缺点就是蜘蛛天天来,那这文件会每天都增大,必须定期清理!偶尔测试下网站 是否正常,SEO还

 这个是最模板从一小偷程序里提取的。判断是否为蜘蛛,然后写入zhizhu.txt 文件当中! 缺点就是蜘蛛天天来,那这文件会每天都增大,必须定期清理!偶尔测试下网站

是否正常,SEO还是有点作用!

 

  1. <?php 
  2. $ServerName = $_SERVER ["SERVER_NAME"]; 
  3. $ServerPort = $_SERVER ["SERVER_PORT"]; 
  4. $serverip = $_SERVER ["REMOTE_ADDR"]; 
  5. $url_this =  "http://".$_SERVER ['HTTP_HOST'].$_SERVER["HTTP_X_REWRITE_URL"]; 
  6. $Url = "http://" . $ServerName; 
  7. If ($ServerPort != "80") { 
  8.     $Url = $Url . ":" . $ServerPort; 
  9. } else { 
  10.     $Url = $_SERVER ['HTTP_REFERER']; 
  11. $GetLocationURL = $Url; 
  12. $agent1 = $_SERVER ["HTTP_USER_AGENT"]; 
  13. $agent = strtolower ( $agent1 ); 
  14. $Bot = ""
  15. if (stripos ( $agent, "bot" ) > - 1) { 
  16.     $Bot = "其它蜘蛛"
  17. if (stripos ( $agent, "googlebot" ) > - 1) { 
  18.     $Bot = "Google"
  19. if (stripos ( $agent, "mediapartners-google" ) > - 1) { 
  20.  
  21.     $Bot = "Google Adsense"
  22. if (stripos ( $agent, "baiduspider" ) > - 1) { 
  23.     $Bot = "Baidu"
  24. if (stripos ( $agent, "sogou" ) > - 1) { 
  25.     $Bot = "Sogou"
  26. if (stripos ( $agent, "yahoo" ) > - 1) { 
  27.     $Bot = "Yahoo!"
  28. if (stripos ( $agent, "msn" ) > - 1) { 
  29.     $Bot = "MSN"
  30. if (stripos ( $agent, "ia_archiver" ) > - 1) { 
  31.     $Bot = "Alexa"
  32. if (stripos ( $agent, "iaarchiver" ) > - 1) { 
  33.     $Bot = "Alexa"
  34. if (stripos ( $agent, "sohu" ) > - 1) { 
  35.     $Bot = "Sohu"
  36. if (stripos ( $agent, "sqworm" ) > - 1) { 
  37.     $Bot = "AOL"
  38. if (stripos ( $agent, "yodaoBot" ) > - 1) { 
  39.     $Bot = "Yodao"
  40. if (stripos ( $agent, "iaskspider" ) > - 1) { 
  41.     $Bot = "新浪爱问"
  42. $shijian = date ( "Y-m-d h:i:s", time () ); 
  43. define ( 'IP_FILE', VV_ROOT."/zhizhu.txt" ); 
  44. $ip = getip().'---'.$Bot.'---'.$url_this.'---'.$shijian; 
  45. if (!empty($Bot) && !file_exists(IP_FILE)){ 
  46. write(IP_FILE,$ip); 
  47. }else if (!empty($Bot) && file_exists(IP_FILE)){ 
  48. $i=count(file(IP_FILE)); 
  49. $oldip=read(IP_FILE); 
  50. $newip=$ip."\r\n"; 
  51. $iplist=$newip.$oldip; 
  52. write(IP_FILE,$iplist); 
  53. ?> 

 

(责任编辑:最模板)
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
栏目列表
热点内容