mirror of
https://github.com/getgrav/grav.git
synced 2026-02-09 16:17:56 +01:00
Add a isHuman() method to the Browser class with some basic checks on bot or human request
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user