diff --git a/phpBB/adm/style/captcha_recaptcha_v3_acp.html b/phpBB/adm/style/captcha_recaptcha_v3_acp.html
index 8a1e0a7bce..ef9896a742 100644
--- a/phpBB/adm/style/captcha_recaptcha_v3_acp.html
+++ b/phpBB/adm/style/captcha_recaptcha_v3_acp.html
@@ -48,13 +48,13 @@
{{ lang('RECAPTCHA_V3_METHOD_EXPLAIN') }}
- {% for method, constant in RECAPTCHA_V3_METHODS %}
+ {% for method, available in RECAPTCHA_V3_METHODS %}
{% endfor %}
@@ -65,17 +65,14 @@
{{ lang('RECAPTCHA_V3_THRESHOLDS_EXPLAIN') }}
-
- -
-
-
{{ lang('RECAPTCHA_V3_THRESHOLD_EXPLAIN') }}
-
-
-
-
{% for threshold in thresholds %}
-
+ -
+
+ {% if lang_defined(threshold.key|upper ~ '_EXPLAIN') %}
+
{{ lang(threshold.key|upper ~ '_EXPLAIN') }}
+ {% endif %}
+
{% endfor %}
diff --git a/phpBB/language/en/captcha_recaptcha.php b/phpBB/language/en/captcha_recaptcha.php
index fcdde312c2..10eace67df 100644
--- a/phpBB/language/en/captcha_recaptcha.php
+++ b/phpBB/language/en/captcha_recaptcha.php
@@ -47,6 +47,7 @@ $lang = array_merge($lang, array(
'RECAPTCHA_INCORRECT' => 'The solution you provided was incorrect',
'RECAPTCHA_NOSCRIPT' => 'Please enable JavaScript in your browser to load the challenge.',
'RECAPTCHA_NOT_AVAILABLE' => 'In order to use reCaptcha, you must create an account on www.google.com/recaptcha.',
+ 'RECAPTCHA_INVISIBLE' => 'This CAPTCHA is actually invisible. To verify that it works, a small icon should appear in right bottom corner of this page.',
'RECAPTCHA_PUBLIC' => 'Site key',
'RECAPTCHA_PUBLIC_EXPLAIN' => 'Your site reCAPTCHA key. Keys can be obtained on www.google.com/recaptcha. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.',
@@ -55,21 +56,21 @@ $lang = array_merge($lang, array(
'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your secret reCAPTCHA key. Keys can be obtained on www.google.com/recaptcha. Please, use reCAPTCHA v2 > Invisible reCAPTCHA badge type.',
'RECAPTCHA_V3_PRIVATE_EXPLAIN' => 'Your secret reCAPTCHA key. Keys can be obtained on www.google.com/recaptcha. Please, use reCAPTCHA v3.',
- 'RECAPTCHA_INVISIBLE' => 'This CAPTCHA is actually invisible. To verify that it works, a small icon should appear in right bottom corner of this page.',
-
'RECAPTCHA_V3_DOMAIN' => 'Request domain',
'RECAPTCHA_V3_DOMAIN_EXPLAIN' => 'The domain to fetch the script from and to use when verifying the request.
Use recaptcha.net when google.com is not accessible.',
+
'RECAPTCHA_V3_METHOD' => 'Request method',
'RECAPTCHA_V3_METHOD_EXPLAIN' => 'The method to use when verifying the request.
Disabled options are not available within your setup.',
'RECAPTCHA_V3_METHOD_CURL' => 'cURL',
'RECAPTCHA_V3_METHOD_POST' => 'POST',
'RECAPTCHA_V3_METHOD_SOCKET' => 'Socket',
- 'RECAPTCHA_V3_THRESHOLD' => 'Default threshold',
- 'RECAPTCHA_V3_THRESHOLD_EXPLAIN' => 'Used when none of the other actions are applicable.',
- 'RECAPTCHA_V3_THRESHOLD_LOGIN' => 'Login threshold',
- 'RECAPTCHA_V3_THRESHOLD_POST' => 'Post threshold',
- 'RECAPTCHA_V3_THRESHOLD_REGISTER' => 'Register threshold',
- 'RECAPTCHA_V3_THRESHOLD_REPORT' => 'Report threshold',
- 'RECAPTCHA_V3_THRESHOLDS' => 'Thresholds',
- 'RECAPTCHA_V3_THRESHOLDS_EXPLAIN' => 'reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). Here you can set the minimum score per action.',
+
+ 'RECAPTCHA_V3_THRESHOLD_DEFAULT' => 'Default threshold',
+ 'RECAPTCHA_V3_THRESHOLD_DEFAULT_EXPLAIN' => 'Used when none of the other actions are applicable.',
+ 'RECAPTCHA_V3_THRESHOLD_LOGIN' => 'Login threshold',
+ 'RECAPTCHA_V3_THRESHOLD_POST' => 'Post threshold',
+ 'RECAPTCHA_V3_THRESHOLD_REGISTER' => 'Register threshold',
+ 'RECAPTCHA_V3_THRESHOLD_REPORT' => 'Report threshold',
+ 'RECAPTCHA_V3_THRESHOLDS' => 'Thresholds',
+ 'RECAPTCHA_V3_THRESHOLDS_EXPLAIN' => 'reCAPTCHA v3 returns a score (1.0 is very likely a good interaction, 0.0 is very likely a bot). Here you can set the minimum score per action.',
));
diff --git a/phpBB/phpbb/captcha/plugins/recaptcha_v3.php b/phpBB/phpbb/captcha/plugins/recaptcha_v3.php
index f04d44a275..ceea796d96 100644
--- a/phpBB/phpbb/captcha/plugins/recaptcha_v3.php
+++ b/phpBB/phpbb/captcha/plugins/recaptcha_v3.php
@@ -31,17 +31,26 @@ class recaptcha_v3 extends captcha_abstract
const GOOGLE = 'google.com';
const RECAPTCHA = 'recaptcha.net';
- /** @var string Default action when no other applies */
- static protected $action = 'default';
-
- /** @var array CAPTCHA types mapped to their action with threshold */
+ /** @var array CAPTCHA types mapped to their action */
static protected $actions = [
+ 0 => 'default',
CONFIRM_REG => 'register',
CONFIRM_LOGIN => 'login',
CONFIRM_POST => 'post',
CONFIRM_REPORT => 'report',
];
+ /**
+ * Get CAPTCHA types mapped to their action.
+ *
+ * @static
+ * @return array
+ */
+ static public function get_actions()
+ {
+ return self::$actions;
+ }
+
/**
* Execute.
*
@@ -116,7 +125,7 @@ class recaptcha_v3 extends captcha_abstract
}
/**
- * Whether or not this CAPTCHA plugin is available.
+ * Whether or not this CAPTCHA plugin is available and setup.
*
* @return bool
*/
@@ -170,7 +179,6 @@ class recaptcha_v3 extends captcha_abstract
$config->set('recaptcha_v3_secret', $request->variable('recaptcha_v3_secret', '', true));
$config->set('recaptcha_v3_domain', $request->variable('recaptcha_v3_domain', '', true));
$config->set('recaptcha_v3_method', $request->variable('recaptcha_v3_method', '', true));
- $config->set('recaptcha_v3_threshold', $request->variable('recaptcha_v3_threshold', 0.50));
foreach (self::$actions as $action)
{
@@ -196,22 +204,17 @@ class recaptcha_v3 extends captcha_abstract
'RECAPTCHA_V3_KEY' => $config['recaptcha_v3_key'] ?? '',
'RECAPTCHA_V3_SECRET' => $config['recaptcha_v3_secret'] ?? '',
- 'RECAPTCHA_V3_THRESHOLD' => $config['recaptcha_v3_threshold'] ?? 0.5,
'RECAPTCHA_V3_DOMAIN' => $config['recaptcha_v3_domain'] ?? self::GOOGLE,
'RECAPTCHA_V3_DOMAINS' => [self::GOOGLE, self::RECAPTCHA],
'RECAPTCHA_V3_METHOD' => $config['recaptcha_v3_method'] ?? self::POST,
'RECAPTCHA_V3_METHODS' => [
- 'POST' => self::POST,
- 'CURL' => self::CURL,
- 'SOCKET' => self::SOCKET,
+ self::POST => ini_get('allow_url_fopen') && function_exists('file_get_contents'),
+ self::CURL => extension_loaded('curl') && function_exists('curl_init'),
+ self::SOCKET => function_exists('fsockopen'),
],
- 'S_RECAPTCHA_V3_CURL' => extension_loaded('curl') && function_exists('curl_init'),
- 'S_RECAPTCHA_V3_POST' => ini_get('allow_url_fopen') && function_exists('file_get_contents'),
- 'S_RECAPTCHA_V3_SOCKET' => function_exists('fsockopen'),
-
'U_ACTION' => $module->u_action,
]);
}
@@ -257,7 +260,7 @@ class recaptcha_v3 extends captcha_abstract
$template->assign_vars([
'CONFIRM_EXPLAIN' => $language->lang($explain, '', ''),
- 'RECAPTCHA_ACTION' => self::$actions[$this->type] ?? self::$action,
+ 'RECAPTCHA_ACTION' => self::$actions[$this->type] ?? reset(self::$actions),
'RECAPTCHA_KEY' => $config['recaptcha_v3_key'] ?? '',
'U_RECAPTCHA_SCRIPT' => sprintf('//%s/recaptcha/api.js?render=%s', $domain, $render),
@@ -299,9 +302,10 @@ class recaptcha_v3 extends captcha_abstract
*/
global $config, $language, $request, $user;
- $action = $request->variable('recaptcha_action', self::$action, true);
$token = $request->variable('recaptcha_token', '', true);
- $threshold = (double) $config["recaptcha_v3_threshold_{$action}"] ?? $config['recaptcha_v3_threshold'] ?? 0.5;
+ $action = $request->variable('recaptcha_action', '', true);
+ $action = in_array($action, self::$actions) ? $action : reset(self::$actions);
+ $threshold = (double) $config["recaptcha_v3_threshold_{$action}"] ?? 0.5;
// No token was provided, discard spam submissions
if (empty($token))