PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.2
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.2
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.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 All 130 releases
jetformbuilder / modules / captcha / hcaptcha / verify-token-action.php
verify-token-action.php
57 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace JFB_Modules\Captcha\Hcaptcha;
5
6 use Jet_Form_Builder\Exceptions\Gateway_Exception;
7 use JFB_Modules\Captcha\Module;
8 use JFB_Modules\Captcha\Re_Captcha_V3\Verify_Token_Action as BaseVerify;
9
10 class Verify_Token_Action extends BaseVerify {
11
12 private $site_key;
13
14 public function base_url(): string {
15 return 'https://hcaptcha.com/';
16 }
17
18 public function before_make_request() {
19 parent::before_make_request();
20
21 if ( $this->site_key ) {
22 return;
23 }
24
25 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
26 throw new Gateway_Exception( Module::SPAM_EXCEPTION, 'Empty site key. Spammer detected' );
27 }
28
29 public function send_request() {
30 $this->request();
31 $this->response_body_as_array();
32
33 $response = $this->get_response_body();
34
35 if ( ! empty( $response['success'] ) ) {
36 return $response;
37 }
38
39 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
40 throw new Gateway_Exception( Module::SPAM_EXCEPTION );
41 }
42
43 public function set_site_key( string $site_key ): Verify_Token_Action {
44 $this->site_key = $site_key;
45
46 return $this;
47 }
48
49 public function action_body() {
50 return array_merge(
51 parent::action_body(),
52 array( 'sitekey' => $this->site_key )
53 );
54 }
55
56 }
57