PHP Tutorial record search engine Tutorials Spider Crawl page code
Error_reporting (E_all & ~e_notice);
$TLC _thispage = addslashes ($_server[' http_referer '].$_server[' php_self '));/* ($_server [' http_host '].$_SERVER[' PHP _self ']);($_server[' http_user_agent ']);
Add Spider crawl Record
$searchbot = get_naps tutorial _bot ();
if ($searchbot) {
@mysql tutorial _connect (' localhost ', ' root ') or die (' Can't link Database Tutorial '. mysql_error ());
@mysql_select_db (' spider ') or Die (' cannot select Database '. mysql_error ());
mysql_query ("UPDATE bot SET botcount=botcount+1, Botlast=now (), botlasturl= ' $TLC _thispage ' WHERE botname= ' $searchbot ' ");
}
Mysql_close ();
function Get_naps_bot ()
{
$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 ';
}
if (Strpos ($useragent, ' MSIE 6.0 ')!==false) {//This is my own test (my browser is ie6.0)
return ' MSIE 6.0 ';
}
return false;
}
?>
</body>
</html>