From b7ed54f91c373aef452b3540c8cd352d11305c30 Mon Sep 17 00:00:00 2001 From: arf20 Date: Wed, 1 Jul 2026 20:15:42 +0200 Subject: Add captcha --- mlmmj.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'mlmmj.php') diff --git a/mlmmj.php b/mlmmj.php index c4ff7d3..70d6488 100644 --- a/mlmmj.php +++ b/mlmmj.php @@ -24,6 +24,8 @@ // error_reporting(E_ALL); +require 'CaptchasDotNet.php'; + class mlmmj { var $email; @@ -53,7 +55,9 @@ class mlmmj !isset($_POST["mailinglist"]) && !isset($_POST["job"]) && !isset($_POST["redirect_success"]) && - !isset($_POST["redirect_failure"])) + !isset($_POST["redirect_failure"]) && + !isset($_POST["random"])) && + !isset($_POST["captcha"])) { $this->errors = TRUE; if(isset($_POST["redirect_failure"])) { @@ -64,6 +68,28 @@ class mlmmj die("An error occurred. Please check contrib/web/php-user/README for details."); } else { + $captchas = new CaptchasDotNet ('arf20', '7QOD8AEp5n9ib5bp', + '/tmp/captchasnet-random-strings','3600', + 'abcdefghkmnopqrstuvwxyz','6', + '240','80','000088'); + + // Check the random string to be valid and return an error message + // otherwise. + if (!$captchas->validate ($random_string)) + { + $this->error( + "The session key (random) does not exist, please go back and reload form.
" + ."In case you are the administrator of this page, " + ."please check if random keys are stored correct.
" + ."See http://captchas.net/sample/php/ 'Problems with save mode'"); + } + // Check, that the right CAPTCHA password has been entered and + // return an error message otherwise. + elseif (!$captchas->verify ($password)) + { + $this->error("You entered the wrong password. Aren't you human? Please use back button and reload."; + } + if ($this->is_email($_POST["email"])) $this->email = $_POST["email"]; else -- cgit v1.2.3