使用PHP实现蜘蛛访问日志统计

yipeiwu_com5年前PHP代码库
复制代码 代码如下:

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

 if (strpos($useragent, 'googlebot')!== false){$bot = 'Google';}
 elseif (strpos($useragent,'mediapartners-google') !== false){$bot = 'Google Adsense';}
 elseif (strpos($useragent,'baiduspider') !== false){$bot = 'Baidu';}
 elseif (strpos($useragent,'sogou spider') !== false){$bot = 'Sogou';}
 elseif (strpos($useragent,'sogou web') !== false){$bot = 'Sogou web';}
 elseif (strpos($useragent,'sosospider') !== false){$bot = 'SOSO';}
 elseif (strpos($useragent,'360spider') !== false){$bot = '360Spider';}
 elseif (strpos($useragent,'yahoo') !== false){$bot = 'Yahoo';}
 elseif (strpos($useragent,'msn') !== false){$bot = 'MSN';}
 elseif (strpos($useragent,'msnbot') !== false){$bot = 'msnbot';}
 elseif (strpos($useragent,'sohu') !== false){$bot = 'Sohu';}
 elseif (strpos($useragent,'yodaoBot') !== false){$bot = 'Yodao';}
 elseif (strpos($useragent,'twiceler') !== false){$bot = 'Twiceler';}
 elseif (strpos($useragent,'ia_archiver') !== false){$bot = 'Alexa_';}
 elseif (strpos($useragent,'iaarchiver') !== false){$bot = 'Alexa';}
 elseif (strpos($useragent,'slurp') !== false){$bot = '雅虎';}
 elseif (strpos($useragent,'bot') !== false){$bot = '其它蜘蛛';}
 if(isset($bot)){
     $fp = @fopen('bot.txt','a');
     fwrite($fp,date('Y-m-d H:i:s')."\t".$_SERVER["REMOTE_ADDR"]."\t".$bot."\t".'http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]."\r\n");
     fclose($fp);
 }

相关文章

php 5.3.5安装memcache注意事项小结

php 5.3.5安装memcache注意事项小结

安装php扩展:windows 下的 memcache步骤 1.下载php的扩展dll:http://downloads.php.net/pierre/ (如果上述目录没有符合你的php...

PHP正则表达式处理函数(PCRE 函数)实例小结

本文实例讲述了PHP正则表达式处理函数。分享给大家供大家参考,具体如下: 有时候在一些特定的业务场景中需要匹配,或者提取一些关键的信息,例如匹配网页中的一些链接, 提取一些数据时,可能会...

浅谈php提交form表单

处理GET请求 实现的功能是输入姓名后页面显示“Hello XXX” 创建html文件hello.html: <!DOCTYPE html> <html>...

php统计数组元素个数的方法

count():对数组中的元素个数进行统计; sizeof():和count()具有同样的用途,这两个函数都可以返回数组元素个数.可以得到一个常规标量变量中的元素个数,如果传递给这个函数...

用php实现像JSP,ASP里Application那样的全局变量

复制代码 代码如下:<?php /**  * 功能:实现像JSP,ASP里Application那样的全局变量  * author:&nbs...