From f37366b2d05e103b31e606155c2c47c9472f668d Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Tue, 6 Sep 2016 12:34:05 -0400 Subject: [PATCH] move more into request --- controller/Actions.class.php | 15 --------------- controller/Request.class.php | 11 +++++++++++ controller/action/DownloadActions.class.php | 2 +- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/controller/Actions.class.php b/controller/Actions.class.php index 76d1dc0b..44959bd6 100644 --- a/controller/Actions.class.php +++ b/controller/Actions.class.php @@ -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()); - } } \ No newline at end of file diff --git a/controller/Request.class.php b/controller/Request.class.php index 1b8ef7cb..3337a4e0 100644 --- a/controller/Request.class.php +++ b/controller/Request.class.php @@ -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()); + } } \ No newline at end of file diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index 29be474b..f9710854 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -178,7 +178,7 @@ class DownloadActions extends Actions } } - if (static::isForRobot()) + if (Request::isRobot()) { return null; }