From 560d1918d2f6f906c45140800bd353963c968e74 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 10 Sep 2023 23:46:38 +0200 Subject: [PATCH 1/4] Simple anti-spam mechanism --- inc/config.php | 9 ++++++++- post.php | 6 ++++++ templates/post_form.html | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index c5fa69d9..c107051f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -308,9 +308,16 @@ '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. $config['recaptcha'] = false; diff --git a/post.php b/post.php index fc2a2583..0cdff6b9 100644 --- a/post.php +++ b/post.php @@ -478,6 +478,12 @@ function handle_post(){ } } + if ($config['simple_spam'] && $post['op']) { + if(!isset($_POST['simple_spam']) || $config['simple_spam']['answer'] != $_POST['simple_spam'])){ + $config['error']['spam']; + } + } + if(isset($config['securimage']) && $config['securimage']){ if(!isset($_POST['captcha'])){ diff --git a/templates/post_form.html b/templates/post_form.html index bf02ad1a..f583beff 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -203,6 +203,16 @@ {{ antibot.html() }} {% endif %} + {% if config.simple_anti_spam and not id %} + + {{ config.simple_anti_spam.prompt }} + {{ antibot.html() }} + + + + {{ antibot.html() }} + + {% endif %} {{ antibot.html(true) }} -- 2.25.1 From 3bb71dd9f2777325e3b5f6b4dc6217a37cae9023 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 10 Sep 2023 23:54:38 +0200 Subject: [PATCH 2/4] Simple anti-spam mechanism --- templates/post_form.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/post_form.html b/templates/post_form.html index f583beff..21789381 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -203,13 +203,13 @@ {{ antibot.html() }} {% endif %} - {% if config.simple_anti_spam and not id %} + {% if config.simple_spam and not id %} - {{ config.simple_anti_spam.prompt }} + {{ config.simple_spam.prompt }} {{ antibot.html() }} - + {{ antibot.html() }} {% endif %} -- 2.25.1 From 2f8989d2a9bf11384a4e034905454de2ff805f0d Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 10 Sep 2023 23:57:52 +0200 Subject: [PATCH 3/4] Simple anti-spam mechanism --- inc/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index c107051f..3f78e6d5 100644 --- a/inc/config.php +++ b/inc/config.php @@ -314,7 +314,7 @@ // Enable simple anti-spam measure. $config['simple_spam'] = array ( - 'question' => 'What is 2 + 2?', + 'prompt' => 'What is 2 + 2?', 'answer' => '4' ); -- 2.25.1 From c7528b49b45ce2b93b6935bafe2912f0fdd10971 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 11 Sep 2023 01:17:39 +0200 Subject: [PATCH 4/4] Simple anti-spam mechanism --- inc/config.php | 3 ++- post.php | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/inc/config.php b/inc/config.php index 3f78e6d5..9e83d5b8 100644 --- a/inc/config.php +++ b/inc/config.php @@ -313,11 +313,12 @@ ); // Enable simple anti-spam measure. + /* $config['simple_spam'] = array ( 'prompt' => 'What is 2 + 2?', 'answer' => '4' ); - + */ // Enable reCaptcha to make spam even harder. Rarely necessary. $config['recaptcha'] = false; diff --git a/post.php b/post.php index 0cdff6b9..8a6b155b 100644 --- a/post.php +++ b/post.php @@ -478,9 +478,9 @@ function handle_post(){ } } - if ($config['simple_spam'] && $post['op']) { - if(!isset($_POST['simple_spam']) || $config['simple_spam']['answer'] != $_POST['simple_spam'])){ - $config['error']['spam']; + if (isset($config['simple_spam']) && $post['op']) { + if(!isset($_POST['simple_spam']) || $config['simple_spam']['answer'] != $_POST['simple_spam']){ + error($config['error']['spam']); } } -- 2.25.1