蛛丝记录器_PHP
// 这个文件名为 zsmj.php
// 函数分析 $_SERVER["HTTP_USER_AGENT"] 信息,如果是搜索机器的特征字,就返回相应的值
// 否则返回 false
// 联系QQ 733905
// email zj#52linux.com (#换成@)
// homepage http://www.52linux.com
// good luck :)
function 52linux.com_zsmj()
{
$useragent = strtolower($_SERVER["HTTP_USER_AGENT"]);
if (strpos($useragent, "googlebot") !== false){
return "Googlebot";
}
if (strpos($useragent, "msnbot") !== false){
return "MSNbot";
}
if (strpos($useragent, "slurp") !== false){
return "Yahoobot";
}
if (strpos($useragent, "baiduspider") !== false){
return "Baiduspider";
}
if (strpos($useragent, "sohu-search") !== false){
return "Sohubot";
}
if (strpos($useragent, "lycos") !== false){
return "Lycos";
}
if (strpos($useragent, "robozilla") !== false){
return "Robozilla";
}
return false;
}
?>
调用方法:
//调用程序
//作者 张建
// QQ 733905
// email zj#52linux.com (#换成@)
// 主页 http://52linux.com
//
//
$mysql_link_host="";
$mysql_link_name="";
$mysql_link_pass="";
$mysql_link_db ="";
// 上面改成符合你的 mysql连接参数
include('zsmj.php');
$sebotname = get_naps_bot();
if($sebotname )
{
$thispage = addslashes($_SERVER["HTTP_REFERER"]);
$sebotagent=addslashes($_SERVER["HTTP_USER_AGENT"]);
$remote_ip=addslashes($_SERVER["REMOTE_ADDR"]);
$sql="INSERT INTO `zsmj` SET botname='$sebotname',bottag='$sebotname',botagent='$sebotagent' ,botlast=NOW(),botlasturl='$thispage',botip='$remote_ip'";
$mysql=@mysql_connect($mysql_link_host,$mysql_link_name,$mysql_link_pass);
@mysql_db_query($mysql_link_db,$sql);
@mysql_close($mysql);
}
print "document.write(\"
?>
数据库设计如下
create database zsmj;
use zsmj;
CREATE TABLE `zsmj` (
`botid` int(10) unsigned NOT NULL auto_increment,
`botname` varchar(100) NOT NULL default "",
`botagent` varchar(200) NOT NULL default "",
`bottag` varchar(100) NOT NULL default "",
`botlast` datetime NOT NULL default "0000-00-00 00:00:00",
`botlasturl` varchar(250) NOT NULL default "",
`botip` varchar(20) NOT NULL default "",
UNIQUE KEY `botid` (`botid`),
KEY `botname` (`botname`)
) TYPE=MyISAM AUTO_INCREMENT=9 ;