Fix #2008 Add support for Cloudflare Turnstile

This commit is contained in:
Lastorder 2023-05-04 14:46:43 +09:00
parent 32ffc94dee
commit bd44b4ef54
5 changed files with 80 additions and 10 deletions

View file

@ -225,7 +225,7 @@ class spamfilterController extends spamfilter
function triggerCheckCaptcha(&$obj)
{
$config = ModuleModel::getModuleConfig('spamfilter');
if (!isset($config) || !isset($config->captcha) || $config->captcha->type !== 'recaptcha' || !$config->captcha->site_key || !$config->captcha->secret_key)
if (!isset($config) || !isset($config->captcha) || !in_array($config->captcha->type, ['recaptcha','turnstile']) || !$config->captcha->site_key || !$config->captcha->secret_key)
{
return;
}
@ -261,15 +261,15 @@ class spamfilterController extends spamfilter
if (count($target_actions))
{
include_once __DIR__ . '/spamfilter.lib.php';
spamfilter_reCAPTCHA::init($config->captcha);
spamfilter_captcha::init($config->captcha);
if (strncasecmp('proc', $obj->act, 4) === 0)
{
spamfilter_reCAPTCHA::check();
spamfilter_captcha::check();
}
else
{
$captcha = new spamfilter_reCAPTCHA();
$captcha = new spamfilter_captcha();
$captcha->setTargetActions($target_actions);
$captcha->addScripts();
Context::set('captcha', $captcha);