PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 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 All 134 releases
jetformbuilder / modules / captcha / friendly-captcha / verify-token-action.php

verify-token-action.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at modules/captcha/friendly-captcha/verify-token-action.php

77 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
4 namespace JFB_Modules\Captcha\Friendly_Captcha;
5
6 use Jet_Form_Builder\Exceptions\Gateway_Exception;
7 use JFB_Modules\Captcha\Module;
8 use JFB_Modules\Gateways\Actions_Abstract\Action_Application_Raw_Body_It;
9 use JFB_Modules\Gateways\Base_Gateway_Action;
10
11 class Verify_Token_Action extends Base_Gateway_Action implements
12 Action_Application_Raw_Body_It {
13
14 private $secret;
15 private $solution;
16 private $site_key;
17
18 public function action_endpoint() {
19 return 'siteverify';
20 }
21
22 public function base_url(): string {
23 return 'https://api.friendlycaptcha.com/api/v1/';
24 }
25
26 public function send_request() {
27 $response = parent::send_request();
28
29 if ( ! empty( $response['success'] ) ) {
30 return $response;
31 }
32
33 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
34 throw new Gateway_Exception( Module::SPAM_EXCEPTION, $response, $this->get_request_args() );
35 }
36
37 /**
38 * @throws Gateway_Exception
39 */
40 public function before_make_request() {
41 if ( $this->solution && $this->secret && $this->site_key ) {
42 return;
43 }
44
45 // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
46 throw new Gateway_Exception( Module::SPAM_EXCEPTION, 'Empty solution. Spammer detected' );
47 }
48
49 public function set_secret( string $secret ): Verify_Token_Action {
50 $this->secret = $secret;
51
52 return $this;
53 }
54
55 public function set_solution( string $solution ): Verify_Token_Action {
56 $this->solution = $solution;
57
58 return $this;
59 }
60
61 public function set_site_key( string $key ): Verify_Token_Action {
62 $this->site_key = $key;
63
64 return $this;
65 }
66
67
68 public function action_body() {
69 return array(
70 'secret' => $this->secret,
71 'solution' => $this->solution,
72 'sitekey' => $this->site_key,
73 );
74 }
75
76 }
77