20070712 搜索引擎 蜘蛛 捕捉
http://www.yippeesoft.com
网上下载的一个PHP捕捉,修改了保存路径和搜索引擎蜘蛛类别判断
<?php
/**
* @author Tmpbin (tmpbin@163.com)
* @copyright Www.Ruanzai.Net
* @package ccount.php
* @version 1.0
* @lastupdate 2006-12-10
* @link http://www.ruanzai.net
*/
$datadir=$_SERVER[SCRIPT_FILENAME];
//日志所在目录,请用绝对路径如 d:/host/web/log/
$len=strlen($path)-9;
$datadir=substr($path,0,$len);
session_start();
$datafile=$datadir."system_bot.php";
$lang = $_SERVER[\'HTTP_ACCEPT_LANGUAGE\'];
$urlhead .= "Accept-Encoding: ".$_SERVER[\'HTTP_ACCEPT_ENCODING\']."&line;";
$urlhead .= "User-Agent: ".$_SERVER[\'HTTP_USER_AGENT\']."&line;";
$urlhead .= "Host: ".$_SERVER[\'HTTP_HOST\']."&line;";
$cookie = $_SERVER[\'HTTP_COOKIE\'];
$time=time();
$userip = $_SERVER["HTTP_X_FORWARDED_FOR"];
If ($userip == "") $userip = $_SERVER["REMOTE_ADDR"];
$urlPar = $_SERVER["SCRIPT_NAME"];
if (trim($_SERVER["QUERY_STRING"]) != "")
$urlPar = $urlPar."?".$_SERVER["QUERY_STRING"];
$info_cot=$time."&line;".$userip."&line;".$urlPar."&line;".$urlhead."\\n";
if (empty($cookie)) &leftsign;
if (empty($lang))&leftsign;
$fnum=@fopen("$datafile","a");
flock($fnum,LOCK_EX);
$file_data=fwrite($fnum,$info_cot);
fclose($fnum);
&rightsign;
&rightsign;
?>
function get_naps_bot($iee)
&leftsign;
$useragent = strtolower($iee);
if (strpos($useragent, \’googlebot\’) !== false)&leftsign;
return \’Googlebot\’;
&rightsign;
if (strpos($useragent, \’msnbot\’) !== false)&leftsign;
return \’MSNbot\’;
&rightsign;
if (strpos($useragent, \’slurp\’) !== false)&leftsign;
return \’Yahoobot\’;
&rightsign;
if (strpos($useragent, \’baiduspider\’) !== false)&leftsign;
return \’Baiduspider\’;
&rightsign;
if (strpos($useragent, \’sohu-search\’) !== false)&leftsign;
return \’Sohubot\’;
&rightsign;
if (strpos($useragent, \’lycos\’) !== false)&leftsign;
return \’Lycos\’;
&rightsign;
if (strpos($useragent, \’robozilla\’) !== false)&leftsign;
return \’Robozilla\’;
&rightsign;
return $iee;
&rightsign;
$thisprog="log.php";
$_SESSION[\'login\']="ok";
if ($job=="") &leftsign;
$a=2;
$str=file("$datafile");
$count = count($str);
for ($i=0;$i<$count;$i++)&leftsign;
$file.= $str[$i];
&rightsign;
$new_info=explode("\\n",$file);
$count=count($new_info);
for ($i=0; $i<$count-1; $i++) &leftsign;
list($time,$ip,$url,$ae,$ie,$host)=explode("&line;","$new_info[$i]");
$time=date("Y-m-d(H:i:s)",$time);;
$ie=get_naps_bot($ie);
#$iet=get_naps_bot($ie);
$show=$show."<tr class=\’row$a\’><td width=10%>$time</td><td width=5%>$ip
</td><td width=20%>$url</td><td width=30% title=\\"$iet\\">$ie</td><td width=5%>$ae</td><td width=20%>$host</td></tr>\\n";
$a=$a-1;
if ($a<1) $a=2;
&rightsign;
print <<<EOT
<table width=98% align=center cellSpacing=1 cellPadding=1 style="border-collapse: collapse;background: #E5ECFA; border: 1px solid #5296FF ">
<tr align=\’center\’>共$count 条日志
<td style="color: #000000"><b>机器人到访日志查看</b></td>
</tr>
<tr>
<td>
<table width=99% align=center cellSpacing=1 cellPadding=1 style="border-collapse: collapse;background: #E5ECFA; border: 1px solid #5296FF ">
<tr class=\’rowcat\’>
<td width=10%> 到访时间
</td><td width=5%>蜘蛛Ip
</td><td width=20%>访问地址
</td><td width=30%>蜘蛛信息
</td><td width=5%>Accept-Encoding
</td><td width=20%>主机
</td></tr>
$show
历史博文
- 20080812 c# wpf scroll text - 2009
- 1027 vfw 枚举 编码解码器 CODEC DECODEC - 2007
- 0203 SIP gettimeofday 编译 - 2006
- 面向对象设计模式疑惑 - 2005
- MPICH并行程序+Minidoochun - 2005
- redhat 8.0 linux技巧集萃 - 2005
- MessageQueue编程 - 2005
- EventLog编程 - 2005