← All changes
|
includes/Core/Integration/ZohoSign/ZohoSignHandler.php
+36
-12
2.10.1
→
3.3.1
View file →
| @@ -6,11 +6,16 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | namespace BitCode\BitForm\Core\Integration\ZohoSign; |
| 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; |
| 12 | 16 | use BitCode\BitForm\Core\Util\IpTool; |
| 17 | +use BitCode\BitForm\GlobalHelper; | |
| 13 | 18 | use WP_Error; |
| 14 | 19 | |
| 15 | 20 | /** |
| 16 | 21 | * Provide functionality for ZohoCrm integration |
| @@ -44,11 +49,16 @@ | ||
| 44 | 49 | * @return JSON zoho crm api response and status |
| 45 | 50 | */ |
| 46 | 51 | public static function generateTokens() |
| 47 | 52 | { |
| 48 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 49 | - $inputJSON = file_get_contents('php://input'); | |
| 50 | - $requestsParams = json_decode($inputJSON); | |
| 53 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 54 | + GlobalHelper::requirePostMethod(); | |
| 55 | + | |
| 56 | + try { | |
| 57 | + $requestsParams = GlobalHelper::formatRequestData(); | |
| 58 | + } catch (\InvalidArgumentException $e) { | |
| 59 | + wp_send_json_error($e->getMessage(), 400); | |
| 60 | + } | |
| 51 | 61 | if ( |
| 52 | 62 | empty($requestsParams->{'accounts-server'}) |
| 53 | 63 | || empty($requestsParams->dataCenter) |
| 54 | 64 | || empty($requestsParams->clientId) |
| @@ -157,14 +167,21 @@ | ||
| 157 | 167 | |
| 158 | 168 | $integrationHandler->updateIntegration($integrationID, $zsignDetails[0]->integration_name, 'Zoho Sign', wp_json_encode($newDetails), 'form'); |
| 159 | 169 | } |
| 160 | 170 | |
| 161 | - public function refreshTemplatesAjaxHelper() | |
| 171 | + public static function refreshTemplatesAjaxHelper() | |
| 162 | 172 | { |
| 163 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 173 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 164 | 174 | $authorizationHeader = null; |
| 165 | - $inputJSON = file_get_contents('php://input'); | |
| 166 | - $queryParams = json_decode($inputJSON); | |
| 175 | + | |
| 176 | + GlobalHelper::requirePostMethod(); | |
| 177 | + | |
| 178 | + try { | |
| 179 | + $queryParams = GlobalHelper::formatRequestData(); | |
| 180 | + } catch (\InvalidArgumentException $e) { | |
| 181 | + wp_send_json_error($e->getMessage(), 400); | |
| 182 | + } | |
| 183 | + | |
| 167 | 184 | if ( |
| 168 | 185 | empty($queryParams->tokenDetails) |
| 169 | 186 | || empty($queryParams->dataCenter) |
| 170 | 187 | || empty($queryParams->clientId) |
| @@ -219,14 +236,21 @@ | ||
| 219 | 236 | ); |
| 220 | 237 | } |
| 221 | 238 | } |
| 222 | 239 | |
| 223 | - public function refreshTemplateDetailsAjaxHelper() | |
| 240 | + public static function refreshTemplateDetailsAjaxHelper() | |
| 224 | 241 | { |
| 225 | - if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 242 | + if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 226 | 243 | $authorizationHeader = null; |
| 227 | - $inputJSON = file_get_contents('php://input'); | |
| 228 | - $queryParams = json_decode($inputJSON); | |
| 244 | + | |
| 245 | + GlobalHelper::requirePostMethod(); | |
| 246 | + | |
| 247 | + try { | |
| 248 | + $queryParams = GlobalHelper::formatRequestData(); | |
| 249 | + } catch (\InvalidArgumentException $e) { | |
| 250 | + wp_send_json_error($e->getMessage(), 400); | |
| 251 | + } | |
| 252 | + | |
| 229 | 253 | if ( |
| 230 | 254 | empty($queryParams->tokenDetails) |
| 231 | 255 | || empty($queryParams->dataCenter) |
| 232 | 256 | || empty($queryParams->clientId) |
| @@ -307,9 +331,9 @@ | ||
| 307 | 331 | } |
| 308 | 332 | } |
| 309 | 333 | |
| 310 | 334 | // $actions = $integrationDetails->actions; |
| 311 | - $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID); | |
| 335 | + $recordApiHelper = new RecordApiHelper($tokenDetails, $this->_integrationID, $logID, $this->_formID, $entryID); | |
| 312 | 336 | |
| 313 | 337 | $zsignApiResponse = $recordApiHelper->executeRecordApi( |
| 314 | 338 | $dataCenter, |
| 315 | 339 | $template, |