From e171443d808c65bf3283721240ca7622c1b39fd8 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sat, 8 Mar 2025 19:51:04 +0300 Subject: [PATCH] Updated --- library/includes/functions.php | 1 + src/Captcha/TextCaptcha.php | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/library/includes/functions.php b/library/includes/functions.php index edb43d26f..89a40d736 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -2070,6 +2070,7 @@ function bb_captcha(string $mode): bool|string 'hCaptcha' => \TorrentPier\Captcha\HCaptcha::class, 'yandex' => \TorrentPier\Captcha\YandexSmartCaptcha::class, 'cloudflare' => \TorrentPier\Captcha\CloudflareTurnstileCaptcha::class, + 'text' => \TorrentPier\Captcha\TextCaptcha::class ]; if (!isset($captchaClasses[$settings['service']])) { bb_die(sprintf('Captcha service (%s) not supported', $settings['service'])); diff --git a/src/Captcha/TextCaptcha.php b/src/Captcha/TextCaptcha.php index 0cfae72d3..90b287de1 100644 --- a/src/Captcha/TextCaptcha.php +++ b/src/Captcha/TextCaptcha.php @@ -10,6 +10,7 @@ namespace TorrentPier\Captcha; use Gregwar\Captcha\CaptchaBuilder; +use Gregwar\Captcha\PhraseBuilder; /** * Class TextCaptcha @@ -33,6 +34,8 @@ class TextCaptcha implements CaptchaInterface */ public function __construct(array $settings) { + session_start(); + $this->settings = $settings; $this->captcha = new CaptchaBuilder; } @@ -44,8 +47,10 @@ class TextCaptcha implements CaptchaInterface */ public function get(): string { + $this->captcha->build(); return " - + + "; } @@ -56,5 +61,6 @@ class TextCaptcha implements CaptchaInterface */ public function check(): bool { + return (isset($_SESSION['phrase']) && PhraseBuilder::comparePhrases($_SESSION['phrase'], $_POST['captcha_phrase'])); } }