หัวข้อ: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: krapalm ที่ 05 พฤษภาคม 2010, 15:06:08
ผมจะเช็ค bot ที่เข้ามาเก็บข้อมูลโดยใช้ Code จากเว็บนี้แหละครับ แต่พอไปวางมันขึ้น error ตามภาพ (http://lh5.ggpht.com/_Sp8Go_h3zLw/S-EmciFZZCI/AAAAAAAAHp4/OrhWOwgFrbw/Capture.PNG) code <?php error_reporting(E_ALL);
//file_put_contents on php4 if (!function_exists('file_put_contents')) { function file_put_contents($filename, $data) { $f = @fopen($filename, 'w'); if (!$f) { return false; } else { $bytes = fwrite($f, $data); fclose($f); chmod($filename, 0666); return $bytes; } } }
$bot = ""; 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='msnbot1.0';} else if (strstr($_SERVER['HTTP_USER_AGENT'], 'ia_archiver')){$bot='Alexa search engine';} else if (strstr($_SERVER['HTTP_USER_AGENT'], 'FAST')){$bot='AllTheWeb';}
//File bot cache $file_bot = "bot.txt"; $tdiff = 3600 * 7; // เปลี่ยนจาก 0 เป็น 7 ถ้า Server นอก (GMT) หรือเพิ่มลดได้ตามแต่ Time Zone อยู่ที่ได (GMT -12 ถึง GMT +13)
if(!file_exists($file_bot)) { file_put_contents($file_bot, serialize(array())); }
if(!empty($bot)) { //Get old data $bot_list = unserialize(file_get_contents($file_bot)); $day = date("d/m/Y",time() + $tdiff); $time = date("H:i:s",time() + $tdiff); $ip = $_SERVER['REMOTE_ADDR'];
$bot_list[$bot] = array($day, $time, $ip);
//Save new data file_put_contents($file_bot, serialize($bot_list)); }
$thai_month[1] = "มกราคม"; $thai_month[2] = "กุมภาพันธ์"; $thai_month[3] = "มีนาคม"; $thai_month[4] = "เมษายน"; $thai_month[5] = "พฤษภาคม"; $thai_month[6] = "มิถุยายน"; $thai_month[7] = "กรกฎาคม"; $thai_month[8] = "สิงหาคม"; $thai_month[9] = "กันยายน"; $thai_month[10] = "ตุลาคม"; $thai_month[11] = "พฤศจิกายน"; $thai_month[12] = "ธันวาคม";
function showbot($botname) { global $bot_list, $file_bot, $thai_month, $tdiff; if(!isset($bot_list)) { $bot_list = unserialize(file_get_contents($file_bot)); }
if(!isset($bot_list[$botname])) { $out = "<dd><strong>บอทยังไม่ได้มาเก็บข้อมูล</strong></dd>"; } else { list($day, $month, $year) = explode("/",$bot_list[$botname][0]); $month = number_format($month); list($hour, $minute, $second) = explode(":",$bot_list[$botname][1]); $ip = $bot_list[$botname][2];
$out = "<dd>- บอท ".$botname ." ($ip) "; if(date('d/m/Y',time()+$tdiff) == $bot_list[$botname][0]){ $out .= " มา วันนี้"; }else{ $out .=" มา เมื่อวันที่ ".$day." ".$thai_month[$month]." ". ($year+543); } $out .= " เวลา ". $hour. ".".$minute." น.</dd>"; } return $out; }
//Show last bot echo showbot('Google'); echo showbot('Alexa search engine'); echo showbot('Hot Bot search'); echo showbot('msnbot1.0'); ?> แล้วแทรกสคลิปนี้ลงใน footer {php}include('/home/krapalmc/domains/krapalm.com/public_html/bookmarks/checkvbot.php');{/php}
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: เก๋าลัดคุง ที่ 05 พฤษภาคม 2010, 15:14:27
file_get_contents น่าเกิดจากระบุบ path ผิดหาไฟล์ไม่เจอครับ
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: krapalm ที่ 05 พฤษภาคม 2010, 15:57:54
file_get_contents น่าเกิดจากระบุบ path ผิดหาไฟล์ไม่เจอครับ
pังหาไม่เจอเลยครับว่าเกิดจากตรงไหน
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: monthonsite ที่ 05 พฤษภาคม 2010, 16:29:36
bot.txt chmod เป็น 777 หรือยัง
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: ชนเผ่าอาข่า ที่ 05 พฤษภาคม 2010, 16:29:49
file_get_contents น่าเกิดจากระบุบ path ผิดหาไฟล์ไม่เจอครับ
pังหาไม่เจอเลยครับว่าเกิดจากตรงไหน ลองทำตามกระทู้นี้ดูครับ http://www.thaiseoboard.com/index.php/topic,56232.160.html
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: krapalm ที่ 05 พฤษภาคม 2010, 17:32:41
bot.txt chmod เป็น 777 หรือยัง
ทำแล้วครับ ที่นี้ไม่ขึ้นอะไรเลย อาจจะเป็นไปได้ว่าบอทยังไม่มาเพราะพึ่งทำเสร็จใหม่ๆ ครับ
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: krapalm ที่ 05 พฤษภาคม 2010, 17:34:58
file_get_contents น่าเกิดจากระบุบ path ผิดหาไฟล์ไม่เจอครับ
pังหาไม่เจอเลยครับว่าเกิดจากตรงไหน ลองทำตามกระทู้นี้ดูครับ [url]http://www.thaiseoboard.com/index.php/topic,56232.160.html[/url] ทำแล้วครับ ที่นี้ไม่ขึ้นอะไรเลย
หัวข้อ: Re: จะเช็ค bot ที่เข้ามาเก็บข้อมูลแต่ Error
เริ่มหัวข้อโดย: กระเทยหัวล้าน ที่ 05 พฤษภาคม 2010, 20:52:23
ลองดูการเก็บ bot แบบเว็บนี้ซิ http://www.xn--c3c2aex8b9c7a8cn8d.com/
|