From 6d06f34e2dcbdc4a5cb8e4652a3b1aacefb4e266 Mon Sep 17 00:00:00 2001 From: Daniel Winzen Date: Fri, 5 Sep 2025 10:43:01 +0200 Subject: [PATCH] Change simple and moderate captchas so that characters are no longer in fixed positions. Also avoid using fixed colours. In the moderate captcha, use filled, blurred rectangles instead of dots and lines to obscure the solution. In setup page, remove deprecation from both captchas. --- chat.php | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/chat.php b/chat.php index 88495d7..ec8c93f 100644 --- a/chat.php +++ b/chat.php @@ -677,29 +677,34 @@ function send_captcha(): void } else { echo _('Type the characters in the image:'); } - if($difficulty===1){ - $im=imagecreatetruecolor(55, 24); - $bg=imagecolorallocate($im, 0, 0, 0); - $fg=imagecolorallocate($im, 255, 255, 255); + if($difficulty===1 || $difficulty===2){ + $fontwidth = imagefontwidth(5); + $fontheight = imagefontheight(5); + $CAPTCHAWIDTH = $fontwidth * 5 * 3; + $CAPTCHAHEIGHT = $fontheight * 3; + $im=imagecreatetruecolor($CAPTCHAWIDTH, $CAPTCHAHEIGHT); + $bg=imagecolorallocate($im, mt_rand(0, 255), mt_rand(0, 255), mt_rand(0, 255)); imagefill($im, 0, 0, $bg); - imagestring($im, 5, 5, 5, $code, $fg); - echo ''._('Moderate (deprecated)').''; + echo '>'._('Moderate').''; echo '