From 08c890d65101f559ff3e8459089460acb488562b Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 3 May 2019 12:25:13 +0200 Subject: [PATCH] Avoid warnings --- blockbot/blockbot.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/blockbot/blockbot.php b/blockbot/blockbot.php index 9e590a99..41f31827 100644 --- a/blockbot/blockbot.php +++ b/blockbot/blockbot.php @@ -27,6 +27,10 @@ function blockbot_uninstall() { function blockbot_init_1(App $a) { $crawlerDetect = new CrawlerDetect(); + if (empty($_SERVER['HTTP_USER_AGENT'])) { + return; + } + $logdata = ['agent' => $_SERVER['HTTP_USER_AGENT'], 'uri' => $_SERVER['REQUEST_URI']]; if (!$crawlerDetect->isCrawler()) { @@ -39,7 +43,7 @@ function blockbot_init_1(App $a) { 'curl', 'zgrab', 'Go-http-client', 'curb', 'github.com', 'reqwest', 'Feedly/', 'Python-urllib/', 'Liferea/', 'aiohttp/', 'WordPress.com Reader', 'hackney/', 'Faraday v', 'okhttp', 'UniversalFeedParser', 'PixelFedBot', 'python-requests', - 'WordPress/', 'http.rb/']; + 'WordPress/', 'http.rb/', 'Apache-HttpClient/', 'WordPress.com;']; foreach ($agents as $agent) { if (stristr($_SERVER['HTTP_USER_AGENT'], $agent)) { @@ -58,10 +62,10 @@ function blockbot_init_1(App $a) { foreach ($agents as $agent) { if (stristr($_SERVER['HTTP_USER_AGENT'], $agent)) { - System::httpExit(403, 'Bots are not allowed'); + System::httpExit(403, ['title' => 'Bots are not allowed']); } } logger::info('Blocked bot', $logdata); - System::httpExit(403, 'Bots are not allowed'); + System::httpExit(403, ['title' => 'Bots are not allowed']); } -- 2.39.5