<? PHP
Function isspider (){
$ Bots = array (
'Google '=> 'bot bot ',
'Yahoo '=> 'yahoo slurp ',
'Sososo' => 'sosospider ',
'Msn '=> 'msnbot ',
'Maid => 'scooter ',
'Sogou' => 'sogou spider ',
'Bing' => 'bing ',
'Yodao '=> 'yodaobot ',
);
$ Useragent = strtolower ($ _ server ['HTTP _ user_agent ']);
Foreach ($ bots as $ K =>v v ){
If (strstr ($ useragent, $ k )){
Return $ V;
Break;
}
}
Return false;
}
$ SPI = isspider ();
If ($ SPI ){
$ Tlc_thispage = addslashes ($ _ server ['HTTP _ user_agent ']);
// $ File = 'r.txt ';
$ Time = Date ('Y-m-d h: I: s', mktime ());
// $ Handle = fopen ($ file, 'a + ');
$ Pr = $ _ server ['request _ URI '];
Mysql_connect ("localhost", "root", ""); // connect to MySQL
Mysql_select_db ("DB"); // select a database
$ SQL = "insert into robots (website, robot, URL, agent, time) values ('website', '$ SPI', '$ Pr',' $ tlc_thispage ', '$ Time ')";
Mysql_query ($ SQL); // use SQL statements to insert data
Mysql_close (); // close the MySQL connection
// Echo "Time: {$ time} ROBOT: {$ SPI} Agent: {$ tlc_thispage} URL: {$ PR} \ n \ r ";
// Fwrite ($ handle, "Time: {$ time} ROBOT: {$ SPI} Agent: {$ tlc_thispage} URL: {$ PR} \ n \ r ");
// Fclose ($ handle );
}
?>
Create Table 'robots '(
'Id' int (11) not null auto_increment,
'Website' varchar (20) not null,
'Url' varchar (300) not null,
'Robot 'varchar (20) not null,
'Time' datetime default null,
'Agent' varchar (50) default '',
Primary Key ('id '),
Key 'id' ('id ')
) Engine = InnoDB auto_increment = 6 default charset = Latin1;