mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Add target actions to CAPTCHA object #1815
This commit is contained in:
parent
dba78c46fe
commit
37aa3dea3b
2 changed files with 17 additions and 4 deletions
|
|
@ -239,19 +239,19 @@ class spamfilterController extends spamfilter
|
|||
return;
|
||||
}
|
||||
|
||||
$enable = false;
|
||||
$target_actions = [];
|
||||
foreach (['signup', 'login', 'recovery', 'document', 'comment'] as $action)
|
||||
{
|
||||
if ($config->captcha->target_actions[$action])
|
||||
{
|
||||
if (preg_match(self::$_captcha_actions[$action], $obj->act) || ($action === 'comment' && (!$obj->act || $obj->act === 'dispBoardContent') && Context::get('document_srl')))
|
||||
{
|
||||
$enable = true;
|
||||
$target_actions[$action] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($enable)
|
||||
if (count($target_actions))
|
||||
{
|
||||
include_once __DIR__ . '/spamfilter.lib.php';
|
||||
spamfilter_reCAPTCHA::init($config->captcha);
|
||||
|
|
@ -262,7 +262,9 @@ class spamfilterController extends spamfilter
|
|||
}
|
||||
else
|
||||
{
|
||||
Context::set('captcha', new spamfilter_reCAPTCHA());
|
||||
$captcha = new spamfilter_reCAPTCHA();
|
||||
$captcha->setTargetActions($target_actions);
|
||||
Context::set('captcha', $captcha);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ class spamfilter_reCAPTCHA
|
|||
protected static $scripts_added = false;
|
||||
protected static $instances_inserted = 0;
|
||||
protected static $sequence = 1;
|
||||
protected $_target_actions = [];
|
||||
|
||||
public static function init($config)
|
||||
{
|
||||
|
|
@ -60,6 +61,16 @@ class spamfilter_reCAPTCHA
|
|||
}
|
||||
}
|
||||
|
||||
public function setTargetActions(array $target_actions)
|
||||
{
|
||||
$this->_target_actions = $target_actions;
|
||||
}
|
||||
|
||||
public function isTargetAction(string $action): bool
|
||||
{
|
||||
return isset($this->_target_actions[$action]);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf('<div id="recaptcha-instance-%d" class="g-recaptcha"></div>', self::$instances_inserted++);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue