PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.3.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.3.2
V3.3.3 V3.3.2 3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 All 140 releases
← All changes | includes/Core/Integration/Getgist/GetgistHandler.php +36 -8 2.10.0 → V3.3.2 View file →
@@ -1,10 +1,15 @@
1 1 <?php
2 2
3 3 namespace BitCode\BitForm\Core\Integration\Getgist;
4 4
5 +if (!defined('ABSPATH')) {
6 + exit;
7 +}
8 +
5 9 use BitCode\BitForm\Core\Integration\IntegrationHandler;
6 10 use BitCode\BitForm\Core\Util\HttpHelper;
11 +use BitCode\BitForm\GlobalHelper;
7 12 use WP_Error;
8 13
9 14 class GetgistHandler
10 15 {
@@ -9,8 +14,18 @@
9 14 class GetgistHandler
10 15 {
11 16 public static $api_endpoint = 'https://api.getgist.com';
12 17
18 + private $integrationID;
19 +
20 + private $formId;
21 +
22 + public function __construct($integrationID, $fromID)
23 + {
24 + $this->integrationID = $integrationID;
25 + $this->formId = $fromID;
26 + }
27 +
13 28 public static function registerAjax()
14 29 {
15 30 add_action('wp_ajax_bitforms_getgist_authorize', [__CLASS__, 'getgistAuthorize']);
16 31 add_action('wp_ajax_bitforms_getgist_tags', [__CLASS__, 'getAllTags']);
@@ -17,13 +32,19 @@
17 32 }
18 33
19 34 public static function getgistAuthorize()
20 35 {
21 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
36 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
22 37 $authorizationHeader = null;
23 - $inputJSON = file_get_contents('php://input');
24 - $requestsParams = json_decode($inputJSON);
25 38
39 + GlobalHelper::requirePostMethod();
40 +
41 + try {
42 + $requestsParams = GlobalHelper::formatRequestData();
43 + } catch (\InvalidArgumentException $e) {
44 + wp_send_json_error($e->getMessage(), 400);
45 + }
46 +
26 47 if (empty($requestsParams->api_key)) {
27 48 wp_send_json_error(
28 49 __(
29 50 'Requested parameter is empty',
@@ -49,13 +70,19 @@
49 70 }
50 71
51 72 public static function getAllTags()
52 73 {
53 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
74 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
54 75 $authorizationHeader = null;
55 - $inputJSON = file_get_contents('php://input');
56 - $requestsParams = json_decode($inputJSON);
57 76
77 + GlobalHelper::requirePostMethod();
78 +
79 + try {
80 + $requestsParams = GlobalHelper::formatRequestData();
81 + } catch (\InvalidArgumentException $e) {
82 + wp_send_json_error($e->getMessage(), 400);
83 + }
84 +
58 85 if (empty($requestsParams->apiKey)) {
59 86 wp_send_json_error(
60 87 __(
61 88 'Requested parameter is empty',
@@ -106,14 +133,15 @@
106 133 || empty($fieldMap)
107 134 ) {
108 135 return new WP_Error('REQ_FIELD_EMPTY', __('module, fields are required for Gist api', 'bit-form'));
109 136 }
110 - $recordApiHelper = new RecordApiHelper($api_key, $integId, $logID);
137 + $recordApiHelper = new RecordApiHelper($api_key, $integId, $logID, $entryID);
111 138 $getgistApiResponse = $recordApiHelper->execute(
112 139 $integId,
113 140 $fieldValues,
114 141 $fieldMap,
115 - $integrationDetails
142 + $integrationDetails,
143 + $this->formId,
116 144 );
117 145
118 146 if (is_wp_error($getgistApiResponse)) {
119 147 return $getgistApiResponse;