mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-23 06:35:45 -07:00
Updated
This commit is contained in:
parent
0d4a99c51b
commit
e171443d80
2 changed files with 8 additions and 1 deletions
|
@ -2070,6 +2070,7 @@ function bb_captcha(string $mode): bool|string
|
||||||
'hCaptcha' => \TorrentPier\Captcha\HCaptcha::class,
|
'hCaptcha' => \TorrentPier\Captcha\HCaptcha::class,
|
||||||
'yandex' => \TorrentPier\Captcha\YandexSmartCaptcha::class,
|
'yandex' => \TorrentPier\Captcha\YandexSmartCaptcha::class,
|
||||||
'cloudflare' => \TorrentPier\Captcha\CloudflareTurnstileCaptcha::class,
|
'cloudflare' => \TorrentPier\Captcha\CloudflareTurnstileCaptcha::class,
|
||||||
|
'text' => \TorrentPier\Captcha\TextCaptcha::class
|
||||||
];
|
];
|
||||||
if (!isset($captchaClasses[$settings['service']])) {
|
if (!isset($captchaClasses[$settings['service']])) {
|
||||||
bb_die(sprintf('Captcha service (%s) not supported', $settings['service']));
|
bb_die(sprintf('Captcha service (%s) not supported', $settings['service']));
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
namespace TorrentPier\Captcha;
|
namespace TorrentPier\Captcha;
|
||||||
|
|
||||||
use Gregwar\Captcha\CaptchaBuilder;
|
use Gregwar\Captcha\CaptchaBuilder;
|
||||||
|
use Gregwar\Captcha\PhraseBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TextCaptcha
|
* Class TextCaptcha
|
||||||
|
@ -33,6 +34,8 @@ class TextCaptcha implements CaptchaInterface
|
||||||
*/
|
*/
|
||||||
public function __construct(array $settings)
|
public function __construct(array $settings)
|
||||||
{
|
{
|
||||||
|
session_start();
|
||||||
|
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
$this->captcha = new CaptchaBuilder;
|
$this->captcha = new CaptchaBuilder;
|
||||||
}
|
}
|
||||||
|
@ -44,8 +47,10 @@ class TextCaptcha implements CaptchaInterface
|
||||||
*/
|
*/
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
|
$this->captcha->build();
|
||||||
return "
|
return "
|
||||||
<img src=" . $builder->inline() . " />
|
<img src=" . $this->captcha->inline() . " />
|
||||||
|
<input type='text' name='captcha_phrase' />
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,5 +61,6 @@ class TextCaptcha implements CaptchaInterface
|
||||||
*/
|
*/
|
||||||
public function check(): bool
|
public function check(): bool
|
||||||
{
|
{
|
||||||
|
return (isset($_SESSION['phrase']) && PhraseBuilder::comparePhrases($_SESSION['phrase'], $_POST['captcha_phrase']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue