Home >php教程 >PHP源码 >蜘蛛统计php版

蜘蛛统计php版

PHP中文网
PHP中文网Original
2016-05-25 17:09:525381browse

php代码

<?php
$useragent = addslashes(strtolower($_SERVER[&#39;HTTP_USER_AGENT&#39;]));
if (strpos($useragent, &#39;googlebot&#39;)!== false){$bot = &#39;Google&#39;;}
elseif (strpos($useragent,&#39;mediapartners-google&#39;) !== false){$bot = &#39;Google Adsense&#39;;}
elseif (strpos($useragent,&#39;baiduspider&#39;) !== false){$bot = &#39;Baidu&#39;;}
elseif (strpos($useragent,&#39;sogou spider&#39;) !== false){$bot = &#39;Sogou&#39;;}
elseif (strpos($useragent,&#39;sogou web&#39;) !== false){$bot = &#39;Sogou web&#39;;}
elseif (strpos($useragent,&#39;sosospider&#39;) !== false){$bot = &#39;SOSO&#39;;}
elseif (strpos($useragent,&#39;yahoo&#39;) !== false){$bot = &#39;Yahoo&#39;;}
elseif (strpos($useragent,&#39;msn&#39;) !== false){$bot = &#39;MSN&#39;;}
elseif (strpos($useragent,&#39;msnbot&#39;) !== false){$bot = &#39;msnbot&#39;;}
elseif (strpos($useragent,&#39;sohu&#39;) !== false){$bot = &#39;Sohu&#39;;}
elseif (strpos($useragent,&#39;yodaoBot&#39;) !== false){$bot = &#39;Yodao&#39;;}
elseif (strpos($useragent,&#39;twiceler&#39;) !== false){$bot = &#39;Twiceler&#39;;}
elseif (strpos($useragent,&#39;ia_archiver&#39;) !== false){$bot = &#39;Alexa_&#39;;}
elseif (strpos($useragent,&#39;iaarchiver&#39;) !== false){$bot = &#39;Alexa&#39;;}
elseif (strpos($useragent,&#39;slurp&#39;) !== false){$bot = &#39;雅虎&#39;;}
elseif (strpos($useragent,&#39;bot&#39;) !== false){$bot = &#39;其它蜘蛛&#39;;}
if(isset($bot)){
$fp = @fopen(&#39;bot.txt&#39;,&#39;a&#39;);
fwrite($fp,date(&#39;Y-m-d H:i:s&#39;)."\t".$_SERVER["REMOTE_ADDR"]."\t".$bot."\t".&#39;http://&#39;.$_SERVER[&#39;SERVER_NAME&#39;].$_SERVER["REQUEST_URI"]."\r\n");
fclose($fp);
}
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn