From ef5ed10eb9af1b0da1a279e49a9c41db64f6e1aa Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 8 Feb 2016 17:51:21 +0100 Subject: [PATCH] Log failed captcha entries --- plugins/SimpleCaptcha/SimpleCaptchaPlugin.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php b/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php index 9a3f5c7489..5f5cd204f2 100644 --- a/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php +++ b/plugins/SimpleCaptcha/SimpleCaptchaPlugin.php @@ -25,6 +25,13 @@ if (!defined('GNUSOCIAL')) { exit(1); } */ class SimpleCaptchaPlugin extends Plugin { + public function initialize() + { + // 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 + } + public function onEndRegistrationFormData(Action $action) { $action->elementStart('li'); @@ -46,6 +53,7 @@ class SimpleCaptchaPlugin extends Plugin public function onStartRegistrationTry(Action $action) { if ($action->arg('simplecaptcha') !== $this->getCaptchaText()) { + common_log(LOG_INFO, 'Stopped non-sentient registration of nickname '._ve($action->trimmed('nickname')).' from IP: '._ve($this->client_ip)); throw new ClientException(_m('Captcha does not match!')); } return true; -- 2.39.5