熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> PHP編程 >> 正文

使用PHP實現蜘蛛訪問日志統計

2013-11-15 12:33:07  來源: PHP編程 
本篇文章是對使用PHP實現蜘蛛訪問日志統計的代碼進行了詳細的分析介紹需要的朋友參考下   復制代碼 代碼如下:

  
$useragent = addslashes(strtolower($_SERVER[HTTP_USER_AGENT]));

 if (strpos($useragent googlebot)!== false){$bot = Google;}
 elseif (strpos($useragentmediapartnersgoogle) !== false){$bot = Google Adsense;}
 elseif (strpos($useragentbaiduspider) !== false){$bot = Baidu;}
 elseif (strpos($useragentsogou spider) !== false){$bot = Sogou;}
 elseif (strpos($useragentsogou web) !== false){$bot = Sogou web;}
 elseif (strpos($useragentsosospider) !== false){$bot = SOSO;}
 elseif (strpos($useragentspider) !== false){$bot = Spider;}
 elseif (strpos($useragentyahoo) !== false){$bot = Yahoo;}
 elseif (strpos($useragentmsn) !== false){$bot = MSN;}
 elseif (strpos($useragentmsnbot) !== false){$bot = msnbot;}
 elseif (strpos($useragentsohu) !== false){$bot = Sohu;}
 elseif (strpos($useragentyodaoBot) !== false){$bot = Yodao;}
 elseif (strpos($useragenttwiceler) !== false){$bot = Twiceler;}
 elseif (strpos($useragentia_archiver) !== false){$bot = Alexa_;}
 elseif (strpos($useragentiaarchiver) !== false){$bot = Alexa;}
 elseif (strpos($useragentslurp) !== false){$bot = 雅虎;}
 elseif (strpos($useragentbot) !== false){$bot = 其它蜘蛛;}
 if(isset($bot)){
     $fp = @fopen(bottxta);
     fwrite($fpdate(Ymd H:i:s)"t"$_SERVER["REMOTE_ADDR"]"t"$bot"t"http://$_SERVER[SERVER_NAME]$_SERVER["REQUEST_URI"]"rn");
     fclose($fp);
 }


From:http://tw.wingwit.com/Article/program/PHP/201311/21162.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.