From 2c3a744e2e2c9fd923fbb42b6b75bcc1c14d97a7 Mon Sep 17 00:00:00 2001 From: Timothy Allen Date: Sat, 26 Sep 2026 00:19:21 +0200 Subject: [PATCH] Turn the captcha off when RECAPTCHA_SITE_KEY is empty. --- .env.example | 3 ++- captcha.lib.php | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index c0c54f4..26f060b 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,8 @@ DB_USER=xxx DB_PASS= DB_NAME=xxx -# Google reCAPTCHA v2 keys (https://www.google.com/recaptcha/admin) +# Google reCAPTCHA v2 keys (https://www.google.com/recaptcha/admin). +# Leave RECAPTCHA_SITE_KEY empty to turn the captcha off. RECAPTCHA_SITE_KEY= RECAPTCHA_SECRET= diff --git a/captcha.lib.php b/captcha.lib.php index 8d43894..4c5ec1a 100644 --- a/captcha.lib.php +++ b/captcha.lib.php @@ -1,25 +1,38 @@ '; } function captcha_widget() { + if (!captcha_enabled()) + return ''; return '
'; } // Ask Google whether the captcha in this POST was solved function captcha_verify_response() { + if (!captcha_enabled()) + return TRUE; $response = $_POST['g-recaptcha-response'] ?? ''; if (!is_string($response) || $response === '') return FALSE;