PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 3.3.1
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v3.3.1
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 2.10.0 2.10.1 All 138 releases
← All changes | includes/Core/Integration/MailChimp/MailChimpHandler.php +46 -15 2.10.03.3.1 View file →
@@ -6,10 +6,15 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\MailChimp;
9 9
10 +if (!defined('ABSPATH')) {
11 + exit;
12 +}
13 +
10 14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
11 15 use BitCode\BitForm\Core\Util\HttpHelper;
16 +use BitCode\BitForm\GlobalHelper;
12 17 use WP_Error;
13 18
14 19 /**
15 20 * Provide functionality for MailChimp integration
@@ -17,11 +22,15 @@
17 22 class MailChimpHandler
18 23 {
19 24 private $_integrationID;
20 25
26 + private $formId;
27 +
21 28 public function __construct($integrationID, $fromID)
22 29 {
23 30 $this->_integrationID = $integrationID;
31 +
32 + $this->formId = $fromID;
24 33 }
25 34
26 35 /**
27 36 * MailChimp API Endpoint
@@ -50,12 +59,18 @@
50 59 * @return JSON zoho crm api response and status
51 60 */
52 61 public static function generateTokens()
53 62 {
54 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
63 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
55 64 $authorizationHeader = null;
56 - $inputJSON = file_get_contents('php://input');
57 - $requestsParams = json_decode($inputJSON);
65 +
66 + GlobalHelper::requirePostMethod();
67 +
68 + try {
69 + $requestsParams = GlobalHelper::formatRequestData();
70 + } catch (\InvalidArgumentException $e) {
71 + wp_send_json_error($e->getMessage(), 400);
72 + }
58 73 if (
59 74 empty($requestsParams->clientId)
60 75 || empty($requestsParams->clientSecret)
61 76 || empty($requestsParams->redirectURI)
@@ -113,13 +128,18 @@
113 128 * @return JSON MailChimp data
114 129 */
115 130 public static function refreshAudienceAjaxHelper()
116 131 {
117 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
132 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
118 133 $authorizationHeader = null;
119 - $inputJSON = file_get_contents('php://input');
120 - $queryParams = json_decode($inputJSON);
121 134
135 + GlobalHelper::requirePostMethod();
136 +
137 + try {
138 + $queryParams = GlobalHelper::formatRequestData();
139 + } catch (\InvalidArgumentException $e) {
140 + wp_send_json_error($e->getMessage(), 400);
141 + }
122 142 if (
123 143 empty($queryParams->tokenDetails)
124 144 || empty($queryParams->clientId)
125 145 || empty($queryParams->clientSecret)
@@ -151,9 +171,9 @@
151 171 }
152 172 uksort($allList, 'strnatcasecmp');
153 173
154 174 $response['audiencelist'] = $allList;
155 - // wp_send_json_success($response, 200);
175 + // wp_send_json_success($response, 200);
156 176 } else {
157 177 wp_send_json_error(
158 178 $audienceResponse->response->error->message,
159 179 400
@@ -178,12 +198,17 @@
178 198 public static function refreshAudienceFields()
179 199 {
180 200 $authorizationHeader = null;
181 201 $response = null;
182 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
183 - $inputJSON = file_get_contents('php://input');
184 - $queryParams = json_decode($inputJSON);
202 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
185 203 // wp_send_json_success($queryParams);
204 + GlobalHelper::requirePostMethod();
205 +
206 + try {
207 + $queryParams = GlobalHelper::formatRequestData();
208 + } catch (\InvalidArgumentException $e) {
209 + wp_send_json_error($e->getMessage(), 400);
210 + }
186 211 if (
187 212 empty($queryParams->tokenDetails)
188 213 || empty($queryParams->listId)
189 214 || empty($queryParams->tokenDetails->dc)
@@ -234,12 +259,17 @@
234 259 public static function refreshTagsAjaxHelper()
235 260 {
236 261 $authorizationHeader = null;
237 262 $response = null;
238 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
239 - $inputJSON = file_get_contents('php://input');
240 - $queryParams = json_decode($inputJSON);
241 - // wp_send_json_success($queryParams);
263 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
264 + GlobalHelper::requirePostMethod();
265 +
266 + try {
267 + $queryParams = GlobalHelper::formatRequestData();
268 + } catch (\InvalidArgumentException $e) {
269 + wp_send_json_error($e->getMessage(), 400);
270 + }
271 +
242 272 if (
243 273 empty($queryParams->tokenDetails)
244 274 || empty($queryParams->listId)
245 275 || empty($queryParams->tokenDetails->dc)
@@ -313,9 +343,10 @@
313 343 $defaultDataConf,
314 344 $fieldValues,
315 345 $fieldMap,
316 346 $actions,
317 - $addressFields
347 + $addressFields,
348 + $this->formId
318 349 );
319 350
320 351 if (is_wp_error($mChimpApiResponse)) {
321 352 return $mChimpApiResponse;