From 6dabfa08bc1d2a80c6bbe44eeef8fd9c51afcbb9 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 10 Sep 2023 23:46:38 +0200 Subject: [PATCH] Simple anti-spam mechanism --- inc/config.php | 10 +++++++++- post.php | 5 +++++ templates/post_form.html | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index 1d2b3966..ae097ae8 100644 --- a/inc/config.php +++ b/inc/config.php @@ -303,7 +303,14 @@ 'json_response', 'user_flag', 'no_country', - 'tag' + 'tag', + 'simple_spam' + ); + + // Enable simple anti-spam measure. + $config['simple_spam'] = array ( + 'question' => 'What is 2 + 2?', + 'answer' => '4' ); // Enable reCaptcha to make spam even harder. Rarely necessary. @@ -1158,6 +1165,7 @@ $config['error']['flood'] = _('Flood detected; Post discarded.'); $config['error']['too_many_threads'] = _('The hourly thread limit has been reached. Please post in an existing thread.'); $config['error']['spam'] = _('Your request looks automated; Post discarded.'); + $config['error']['simple_spam'] = _('You must answer the question to make a new thread. See the last field.'); $config['error']['unoriginal'] = _('Unoriginal content!'); $config['error']['muted'] = _('Unoriginal content! You have been muted for %d seconds.'); $config['error']['youaremuted'] = _('You are muted! Expires in %d seconds.'); diff --git a/post.php b/post.php index 2c94fca6..ddfb1f18 100644 --- a/post.php +++ b/post.php @@ -558,6 +558,11 @@ if (isset($_POST['delete'])) { if (!$dropped_post) { + if (isset($config['simple_spam']) && $config['simple_spam'] && $post['op']) { + if (!isset($_POST['simple_spam']) || $config['simple_spam']['answer'] != $_POST['simple_spam']) { + error($config['error']['simple_spam']); + } + } // Check if banned checkBan($board['uri']); diff --git a/templates/post_form.html b/templates/post_form.html index 80e4e1ca..a1142ea2 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -215,6 +215,16 @@ {{ antibot.html() }} {% endif %} + {% if config.simple_spam and not id %} + + {{ config.simple_spam.prompt }} + {{ antibot.html() }} + + + + {{ antibot.html() }} + + {% endif %} {{ antibot.html(true) }}