Add a isHuman() method to the Browser class with some basic checks on bot or human request

This commit is contained in:
Flavio Copes
2015-09-30 18:46:22 +02:00
parent 9a2906e9db
commit b8a38c2fb6

View File

@@ -38,4 +38,20 @@ class Browser
$version = explode('.', $this->getLongVersion());
return intval($version[0]);
}
/**
* Determine if the request comes from a human, or from a bot/crawler
*/
public function isHuman()
{
if (empty($this->getBrowser())) {
return false;
}
if (preg_match('~(bot|crawl)~i', $this->getBrowser())) {
return false;
}
return true;
}
}