From 7e83ddf80e02c0e2d321c24befc06eca9ed3753d Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 24 May 2020 16:54:22 +0000 Subject: [PATCH] [FIX] Fix 'Trying to access array offset on value of type null' in AntiBrutePlugin and SimpleCaptchaPlugin when using scripts --- plugins/AntiBrute/AntiBrutePlugin.php | 4 +++- plugins/SimpleCaptcha/SimpleCaptchaPlugin.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/AntiBrute/AntiBrutePlugin.php b/plugins/AntiBrute/AntiBrutePlugin.php index e51ac4aa54..ad7d469f51 100644 --- a/plugins/AntiBrute/AntiBrutePlugin.php +++ b/plugins/AntiBrute/AntiBrutePlugin.php @@ -14,7 +14,9 @@ class AntiBrutePlugin extends Plugin { { // This probably needs some work. For example with IPv6 you can easily generate new IPs... $client_ip = common_client_ip(); - $this->client_ip = $client_ip[0] ?: $client_ip[1]; // [0] is proxy, [1] should be the real IP + if (!empty($client_ip)) { + $this->client_ip = $client_ip[0] ?: $client_ip[1]; // [0] is proxy, [1] should be the real IP + } } public function onStartCheckPassword($nickname, $password, &$authenticatedUser) diff --git a/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php b/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php index 62be401d78..5b3450d09e 100644 --- a/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php +++ b/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php @@ -31,7 +31,9 @@ class SimpleCaptchaPlugin extends Plugin { // This probably needs some work. For example with IPv6 you can easily generate new IPs... $client_ip = common_client_ip(); - $this->client_ip = $client_ip[0] ?: $client_ip[1]; // [0] is proxy, [1] should be the real IP + if (!empty($client_ip)) { + $this->client_ip = $client_ip[0] ?: $client_ip[1]; // [0] is proxy, [1] should be the real IP + } } public function onEndRegistrationFormData(Action $action)