note 72698 deleted from reserved.variables by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 18:26:56 +0000 |
| Subject: | note 72698 deleted from reserved.variables by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134361@lists.php.net to get a copy of this message | ||
Note Submitter: borg at sven-of-nine dot de
----
Simple function to determine if a visitor is an agent or not
function isbot($agent="")
{
//Handfull of Robots
$bot_array =array("jeevesteoma",
"msnbot",
"slurp",
"jeevestemoa",
"gulper",
"googlebot",
"linkwalker",
"validator",
"webaltbot",
"wget");
//no agent given => read from globals
if ($agent=="")
{
@$agent=$_SERVER["HTTP_USER_AGENT"];
}
//replace all but alpha
$agent=strtolower(preg_replace("/[^a-zA-Z _]*/","",$agent));
//check für intersections
return((BOOL)count(array_intersect(explode(" ",$agent),$bot_array)));
}