PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 5.2.9
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v5.2.9
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Modules / ReCaptcha / ReCaptcha.php

ReCaptcha.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 5.2.9, at app/Modules/ReCaptcha/ReCaptcha.php

58 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\ReCaptcha;
4
5 use FluentForm\Framework\Helpers\ArrayHelper;
6
7 class ReCaptcha
8 {
9 /**
10 * Verify reCaptcha response.
11 *
12 * @param string $token response from the user.
13 * @param null $secret provided or already stored secret key.
14 *
15 * @return bool
16 */
17 public static function validate($token, $secret = null, $version = 'v2_visible')
18 {
19 $verifyUrl = 'https://www.google.com/recaptcha/api/siteverify';
20
21 $secret = $secret ?: ArrayHelper::get(get_option('_fluentform_reCaptcha_details'), 'secretKey');
22
23 $response = wp_remote_post($verifyUrl, [
24 'method' => 'POST',
25 'body' => [
26 'secret' => $secret,
27 'response' => $token
28 ],
29 ]);
30
31
32 $isValid = false;
33
34 if (! is_wp_error($response)) {
35 $result = json_decode(wp_remote_retrieve_body($response));
36 if($version == 'v3_invisible' && $result->success) {
37 $score = $result->score;
38 $value = 0.5;
39 $value = apply_filters_deprecated(
40 'fluentforms_recaptcha_v3_ref_score',
41 [
42 $value
43 ],
44 FLUENTFORM_FRAMEWORK_UPGRADE,
45 'fluentform/recaptcha_v3_ref_score',
46 'Use fluentform/recaptcha_v3_ref_score instead of fluentforms_recaptcha_v3_ref_score.'
47 );
48 $checkScore = apply_filters('fluentform/recaptcha_v3_ref_score', $value);
49 $isValid = $score >= $checkScore;
50 } else {
51 $isValid = $result->success;
52 }
53 }
54
55 return $isValid;
56 }
57 }
58