<?
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Yandex')){ $bot='Yandex';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Googlebot')){$bot='Google';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mediapartners-Google')){$bot='Mediapartners-Google (Adsense)';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Slurp')){$bot='Hot Bot search';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'WebCrawler')){$bot='WebCrawler search';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'ZyBorg')){$bot='Wisenut search';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'scooter')){$bot='AltaVista';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'StackRambler')){$bot='Rambler';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'Aport')){$bot='Aport';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'lycos')){$bot='Lycos';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'WebAlta')){$bot='WebAlta';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'yahoo')){$bot='Yahoo';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'msnbot')){$bot='msnbot/1.0';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'ia_archiver')){$bot='Alexa';}
else if (strstr($_SERVER['HTTP_USER_AGENT'], 'FAST')){$bot='AllTheWeb';}
if($bot !=""){
$tdiff = 3600 * 0; // เปลี่ยนจาก 0 เป็น 7 ถ้า Server นอก (GMT) หรือเพิ่มลดได้ตามแต่ Time Zone อยู่ที่ได (GMT -12 ถึง GMT +13)
$file = "bots.txt";
$day = date("d/m/Y",time() + $tdiff);
$time = date("H:i:s",time() + $tdiff);
$ip = $_SERVER['REMOTE_ADDR'];
$fh = fopen($file, "a");
fwrite($fh, "$day|$time|$bot|$ip\n");
fclose($fh);
}
$month[1] = "January";
$month[2] = "February";
$month[3] = "March";
$month[4] = "April";
$month[5] = "May";
$month[6] = "June";
$month[7] = "July";
$month[8] = "August";
$month[9] = "September";
$month[10] = "October";
$month[11] = "November";
$month[12] = "December";
$file = "bots.txt";
if(file_exists($file)) {
$fh = fopen($file, "r");
$s = filesize($file);
if($s == 0) {
$out = "<strong>Non Search Engine Bot Detect</strong>";
}else{
echo "<strong>Last 9 Search Engine Bot Dectect<br> ";
// Read entries file into an array.
$text = file($file);
// How many entries we have.
$lines = count($text);
// เปลี่ยน เลข 9 เป็นเลขอื่น ถ้าต้องการให้แสดงมากกว่า 9 ตัว
for ($i=$lines-1;$i>=$lines-9;$i--)
{
$info = explode("|",$text[$i]);
$day = explode("/",$info[0]);
$m = number_format($day[1]);
$tm = explode(":",$info[1]);
$agent = $info[2];
$ip = $info[3];
$out = " ".$agent." ( $ip) ";
if(date('d',time()) == $day[0]){
$out .= " Today";
}else{
$out .=" Date : ".$day[0]." ".$month[$m]." ". ($day[2]);
}
$out .= " Time ". $tm[0]. ".".$tm[1]." <br>";
echo $out;
}
}
fclose($fh);
}
?>
ตามนี้เลยครับ
สคลิปผมก็เหมือนกันแต่ทำไมมันโชว์ตัวเดียวครับ