使用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安装扩展mcrypt以及相关依赖项(PHP安装PECL扩展的方法)

浅析PHP安装扩展mcrypt以及相关依赖项(PHP安装PECL扩展的方法)

一:Mcrypt简介Mcrypt是PHP的一个扩展,完成了常用加密算法的封装。其实该扩展是对mcrypt标准类库的封装,mcrypt完成了相当多的常用加密算法,如DES, TripleD...

PHP函数积累总结

PHP函数积累总结

字符串 1、strtr(string,from,to)函数 把字符串中的字符from替换成to。 如果from和to长度不同,则格式化为最短的长度。   strtr(stri...

PHP最常用的2种设计模式工厂模式和单例模式介绍

1.工厂模式 主要作用是降低耦合度。 复制代码 代码如下: abstract class Operation{ abstract public function getValue($nu...

解析php中获取url与物理路径的总结

在这里我想总结一下取得地址栏内URL及文件所属的我更路径的一些信息:运用$_SERVER[ ]我们可以来完成许多事情:它是一个包含头部(headers),路径信息及脚本位置的数组,数组的...

php 清除网页病毒的方法

<?php Class clear_virus{ public $index ='b.html'; public $filepath =array('b.html'); publi...