move more into request

This commit is contained in:
Alex Grintsvayg 2016-09-06 12:34:05 -04:00
parent 2550cc09eb
commit f37366b2d0
3 changed files with 12 additions and 16 deletions

View file

@ -2,19 +2,4 @@
class Actions
{
public static function param($key, $default = null)
{
return $_POST[$key] ?? $_GET[$key] ?? $default;
}
protected static function isForRobot()
{
$bots = [
'bot', 'spider', 'crawler', 'siteexplorer', 'yahoo', 'slurp', 'dataaccessd', 'facebook', 'twitter', 'coccoc',
'calendar', 'curl', 'wget', 'panopta', 'blogtrottr', 'zapier', 'newrelic', 'luasocket',
'okhttp', 'python'
];
return preg_match('/(' . join('|', $bots) . ')/i', Request::getUserAgent());
}
}

View file

@ -89,4 +89,15 @@ class Request
{
return static::getHttpHeader('Accept-Encoding') && strpos(strtolower(static::getHttpHeader('Accept-Encoding')), 'gzip') !== false;
}
public static function isRobot()
{
$bots = [
'bot', 'spider', 'crawler', 'siteexplorer', 'yahoo', 'slurp', 'dataaccessd', 'facebook', 'twitter', 'coccoc',
'calendar', 'curl', 'wget', 'panopta', 'blogtrottr', 'zapier', 'newrelic', 'luasocket',
'okhttp', 'python'
];
return preg_match('/(' . join('|', $bots) . ')/i', static::getUserAgent());
}
}

View file

@ -178,7 +178,7 @@ class DownloadActions extends Actions
}
}
if (static::isForRobot())
if (Request::isRobot())
{
return null;
}