commitcaptcha/bootstrap.php

26 lines
709 B
PHP
Raw Permalink Normal View History

2020-06-17 18:37:12 +03:00
<?php declare(strict_types=1);
2020-07-10 16:54:28 +03:00
use commitcaptcha\CaptchaManager;
2020-06-17 18:37:12 +03:00
function captcha_template(): string
{
$html = <<<'HTML'
<div class="captcha">
2020-07-10 16:54:28 +03:00
<img src="/commitcaptcha/captcha.webp" alt="Captcha" style="margin-bottom: 8px; width: 130px;" />
2020-06-17 18:37:12 +03:00
<br/>
<input type="text" name="captcha" placeholder="Enter 8 characters" />
</div>
HTML;
2020-07-10 16:54:28 +03:00
return COMMITCAPTCHA_ROOT_CONF["commitcaptcha"]["enable"] ? $html : "You have already verified that you are not a robot.";
2020-06-17 18:37:12 +03:00
}
2021-01-11 21:27:59 +03:00
function check_captcha(?string $input = NULL): bool
2020-06-17 18:37:12 +03:00
{
2021-01-11 21:27:59 +03:00
if(!$input)
$input = $_POST["captcha"] ?? 0;
2020-06-17 18:37:12 +03:00
return CaptchaManager::i()->verifyCaptcha((string) $input);
}
2020-07-10 16:54:28 +03:00
return (function() {});