Add ability to customize robot user agents

This commit is contained in:
Kijin Sung 2019-09-14 21:42:02 +09:00
parent 72651ed095
commit 82213ce11a
5 changed files with 28 additions and 0 deletions

View file

@ -151,6 +151,16 @@ class UA
return self::$_robot_cache[$ua] = true;
}
// Use the custom user-agent list.
$customlist = Config::get('security.robot_user_agents') ?: array();
foreach ($customlist as $item)
{
if (strpos($ua, $item) !== false)
{
return self::$_robot_cache[$ua] = true;
}
}
// If we're here, it's probably not a robot.
return self::$_robot_cache[$ua] = false;
}