<?php
function is_robot()
{
$useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
if (strpos($useragent, 'googlebot') !== false) {
return 'Google';
}
if (strpos($useragent, 'baiduspider') !== false) {
return 'Baidu';
}
if (strpos($useragent, 'msnbot') !== false) {
return 'Bing';
}
if (strpos($useragent, 'slurp') !== false) {
return 'Yahoo';
}
if (strpos($useragent, 'sosospider') !== false) {
return 'Soso';
}
if (strpos($useragent, 'sogou spider') !== false) {
return 'Sogou';
}
if (strpos($useragent, 'yodaobot') !== false) {
return 'Yodao';
}
return false;
}
$searchbot = is_robot();
if ($searchbot) {
$url = "http://".$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$tlc_thispage = addslashes($_SERVER['HTTP_USER_AGENT']);
$file = "./robot-logs-".date('Y-m-d').".txt";
$time = date("Y-m-d G:i:s");
$robotlog = " Time: $time \n Robot: $searchbot \n Spider: $tlc_thispage \n CurrentUrl: $url \n-------------------------------------------------\n\n";
file_put_contents($file, $robotlog, FILE_APPEND);
}
?>
;