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/ZohoAnalytics/ZohoAnalyticsHandler.php +60 -18 2.10.03.3.1 View file →
@@ -6,12 +6,17 @@
6 6 */
7 7
8 8 namespace BitCode\BitForm\Core\Integration\ZohoAnalytics;
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\ApiResponse as UtilApiResponse;
12 16 use BitCode\BitForm\Core\Util\HttpHelper;
13 17 use BitCode\BitForm\Core\Util\IpTool;
18 +use BitCode\BitForm\GlobalHelper;
14 19 use WP_Error;
15 20
16 21 /**
17 22 * Provide functionality for ZohoCrm integration
@@ -50,11 +55,17 @@
50 55 * @return JSON zoho crm api response and status
51 56 */
52 57 public static function generateTokens()
53 58 {
54 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
55 - $inputJSON = file_get_contents('php://input');
56 - $requestsParams = json_decode($inputJSON);
59 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
60 + GlobalHelper::requirePostMethod();
61 +
62 + try {
63 + $requestsParams = GlobalHelper::formatRequestData();
64 + } catch (\InvalidArgumentException $e) {
65 + wp_send_json_error($e->getMessage(), 400);
66 + }
67 +
57 68 if (
58 69 empty($requestsParams->{'accounts-server'})
59 70 || empty($requestsParams->dataCenter)
60 71 || empty($requestsParams->clientId)
@@ -106,12 +117,18 @@
106 117 * @return JSON crm module data
107 118 */
108 119 public static function refreshWorkspacesAjaxHelper()
109 120 {
110 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
121 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
111 122 $authorizationHeader = null;
112 - $inputJSON = file_get_contents('php://input');
113 - $queryParams = json_decode($inputJSON);
123 +
124 + GlobalHelper::requirePostMethod();
125 +
126 + try {
127 + $queryParams = GlobalHelper::formatRequestData();
128 + } catch (\InvalidArgumentException $e) {
129 + wp_send_json_error($e->getMessage(), 400);
130 + }
114 131 if (
115 132 empty($queryParams->tokenDetails)
116 133 || empty($queryParams->dataCenter)
117 134 || empty($queryParams->clientId)
@@ -166,12 +183,19 @@
166 183 }
167 184
168 185 public static function refreshUsersAjaxHelper()
169 186 {
170 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
187 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
171 188 $authorizationHeader = null;
172 - $inputJSON = file_get_contents('php://input');
173 - $queryParams = json_decode($inputJSON);
189 +
190 + GlobalHelper::requirePostMethod();
191 +
192 + try {
193 + $queryParams = GlobalHelper::formatRequestData();
194 + } catch (\InvalidArgumentException $e) {
195 + wp_send_json_error($e->getMessage(), 400);
196 + }
197 +
174 198 if (
175 199 empty($queryParams->tokenDetails)
176 200 || empty($queryParams->dataCenter)
177 201 || empty($queryParams->clientId)
@@ -231,12 +255,18 @@
231 255 * @return JSON crm layout data
232 256 */
233 257 public static function refreshTablesAjaxHelper()
234 258 {
235 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
259 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
236 260 $authorizationHeader = null;
237 - $inputJSON = file_get_contents('php://input');
238 - $queryParams = json_decode($inputJSON);
261 +
262 + GlobalHelper::requirePostMethod();
263 +
264 + try {
265 + $queryParams = GlobalHelper::formatRequestData();
266 + } catch (\InvalidArgumentException $e) {
267 + wp_send_json_error($e->getMessage(), 400);
268 + }
239 269 if (
240 270 empty($queryParams->workspace)
241 271 || empty($queryParams->tokenDetails)
242 272 || empty($queryParams->dataCenter)
@@ -299,12 +329,17 @@
299 329 * @return JSON crm layout data
300 330 */
301 331 public static function refreshTableHeadersAjaxHelper()
302 332 {
303 - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) {
333 + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
304 334 $authorizationHeader = null;
305 - $inputJSON = file_get_contents('php://input');
306 - $queryParams = json_decode($inputJSON);
335 +
336 + GlobalHelper::requirePostMethod();
337 + try {
338 + $queryParams = GlobalHelper::formatRequestData();
339 + } catch (\InvalidArgumentException $e) {
340 + wp_send_json_error($e->getMessage(), 400);
341 + }
307 342 if (
308 343 empty($queryParams->workspace)
309 344 || empty($queryParams->table)
310 345 || empty($queryParams->tokenDetails)
@@ -444,8 +479,15 @@
444 479 $dataCenter = $integrationDetails->dataCenter;
445 480 $fieldMap = $integrationDetails->field_map;
446 481 $actions = $integrationDetails->actions;
447 482 $defaultDataConf = $integrationDetails->default;
483 +
484 + $entryDetails = [
485 + 'formId' => $this->_formID,
486 + 'entryId' => $entryID,
487 + 'fieldValues' => $fieldValues
488 + ];
489 +
448 490 if (
449 491 empty($tokenDetails)
450 492 || empty($workspace)
451 493 || empty($table)
@@ -451,9 +493,9 @@
451 493 || empty($table)
452 494 || empty($fieldMap)
453 495 ) {
454 496 $error = new WP_Error('REQ_FIELD_EMPTY', __('workspace, table, fields are required for zoho analytics api', 'bit-form'));
455 - $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error);
497 + $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error, $entryDetails);
456 498 return $error;
457 499 }
458 500
459 501 $requiredParams = null;
@@ -469,9 +511,9 @@
469 511 }
470 512 }
471 513
472 514 // $actions = $integrationDetails->actions;
473 - $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID);
515 + $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID, $this->_formID, $entryID);
474 516
475 517 $zanalyticsApiResponse = $recordApiHelper->executeRecordApi(
476 518 $workspace,
477 519 $table,
@@ -487,5 +529,5 @@
487 529 return $zanalyticsApiResponse;
488 530 }
489 531 return $zanalyticsApiResponse;
490 532 }
491 -}
533 +}