PHP
·
发表于 5年以前
·
阅读量:8308
Ç°ÑÔ
ÏaÐÅÐi¶aµÄÕ¾³¤¡¢²(C)Ö÷¿ÉÄÜ×i¹ØÐĵÄÎÞǾÍÊÇ×Ô¼ºÍøÕ¾µÄÊÕ¼Çe¿o£¬Ò»°aÇe¿oÏÂÎÒÃÇ¿ÉÒÔͨ¹ý²e¿´¿Õ¼aþÎñÆ÷µÄÈÕÖ¾ÎļþÀ´²e¿´ËÑË÷ÒýÇaeµ½µ×ÅÀÈ¡ÁËÎÒÃÇÄÄÐ(C)¸oÒ³Ãae£¬²»¹ý£¬Èç¹uÓÃphp´uÂeÖÎowebÈÕÖ¾ÖÐÖ(C)ÖeÅÀ³aeºÛ¼££¬ÊDZȽϺÃÓֱȽÏÖ±¹Û½±a²Ù×÷µÄ£¡ÏÂÃaeÊÇʾÀý´uÂe£¬ÓÐÐeÒªµÄÅoÓÑÃÇÏÂÃaeÀ´Ò»Æð¿´¿´°É¡£
ʾÀý´uÂe
<?php
//»ñÈ¡Ö(C)ÖeÅÀ³aeÃu»o*À²É¼¯
function isSpider(){
$bots = array(
'Google' => 'googlebot',
'Baidu' => 'baiduspider',
'Yahoo' => 'yahoo slurp',
'Soso' => 'sosospider',
'Msn' => 'msnbot',
'Altavista' => 'scooter ',
'Sogou' => 'sogou spider',
'Yodao' => 'yodaobot'
);
$userAgent = strtolower($_SERVER['HTTP_USER_AGENT']);
foreach ($bots as $k => $v){
if (strstr($v,$userAgent)){
return $k;
break;
}
}
return false;
}
//»ñÈ¡ÄÄÖÖÖ(C)ÖeÅÀ³aeºo±£´aeÖ(C)ÖeºÛ¼£¡£
//¸u¾Ý²É¼¯Ê±HTTP_USER_AGENTÊÇ*ñΪ¿ÕÀ´*ÀÖ¹²É¼¯
//×¥Ö(C)ÖeÅÀ³ae
$spi = isSpider();
if($spi){
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
$file = 'robot.txt';
$time = date('Y-m-d H:i:s',mktime());
$handle = fopen($file,'a+');
$PR = $_SERVER['REQUEST_URI'];
fwrite($handle, "Time:{$time} ROBOT:{$spi} AGENT:{$tlc_thispage} URL:{$PR} \n\r");
fclose($handle);
}
?>
×ܽa
ÒÔÉϾÍÊÇÕaƪÎÄÕµÄÈ«²¿ÄÚÈÝÁË£¬Ï£Íu±¾ÎĵÄÄÚÈݶԴo¼ÒµÄѧϰ»oÕß¹¤×÷ÄÜ´øÀ´Ò»¶¨µÄ°iÖu£¬Èç¹uÓÐÎÊÌa´o¼Ò¿ÉÒÔÁoÑÔ½»Á÷¡£