PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.5.4
JetFormBuilder — Dynamic Blocks Form Builder v3.5.4
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / captcha / re-captcha-v3 / verify-token-action.php
jetformbuilder / modules / captcha / re-captcha-v3 Last commit date
re-captcha-v3.php 1 year ago verify-token-action.php 1 year ago
verify-token-action.php
102 lines
1 <?php
2
3
4 namespace JFB_Modules\Captcha\Re_Captcha_V3;
5
6 use Jet_Form_Builder\Exceptions\Gateway_Exception;
7 use JFB_Modules\Gateways\Actions_Abstract\Action_Application_Raw_Body_It;
8 use JFB_Modules\Gateways\Base_Gateway_Action;
9 use JFB_Modules\Captcha\Module;
10
11 // If this file is called directly, abort.
12 if ( ! defined( 'WPINC' ) ) {
13 die;
14 }
15
16 class Verify_Token_Action extends Base_Gateway_Action implements
17 Action_Application_Raw_Body_It {
18
19 private $secret;
20 private $token;
21 private $action;
22 private $threshold = 0.5;
23
24 public function action_endpoint() {
25 return 'siteverify';
26 }
27
28 public function base_url(): string {
29 return 'https://www.google.com/recaptcha/api/';
30 }
31
32 public function send_request() {
33 $response = parent::send_request();
34
35 $action = $response['action'] ?? '';
36 $score = $response['score'] ?? 0;
37
38 if ( $this->action === $action && $score > $this->threshold ) {
39 return $response;
40 }
41
42 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
43 throw new Gateway_Exception( Module::SPAM_EXCEPTION, $response, $this->get_request_args() );
44 }
45
46 /**
47 * @throws Gateway_Exception
48 */
49 public function before_make_request() {
50 if ( ! $this->action ) {
51 $this->set_action( jet_fb_live()->form_id );
52 }
53
54 if ( $this->token && $this->secret ) {
55 return;
56 }
57
58 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
59 throw new Gateway_Exception( Module::SPAM_EXCEPTION, 'Empty token. Spammer detected' );
60 }
61
62 public function set_secret( string $secret ): Verify_Token_Action {
63 $this->secret = $secret;
64
65 return $this;
66 }
67
68 public function set_token( string $token ): Verify_Token_Action {
69 $this->token = $token;
70
71 return $this;
72 }
73
74 /**
75 * @param string|int $action
76 *
77 * @return $this
78 */
79 public function set_action( $action ): Verify_Token_Action {
80 $this->action = is_numeric( $action ) ? Module::PREFIX . $action : $action;
81
82 return $this;
83 }
84
85 /**
86 * @param float|string|int $threshold
87 */
88 public function set_threshold( $threshold ): Verify_Token_Action {
89 $this->threshold = floatval( $threshold );
90
91 return $this;
92 }
93
94 public function action_body() {
95 return array(
96 'secret' => $this->secret,
97 'response' => $this->token,
98 );
99 }
100
101 }
102