← All changes
|
includes/Core/Integration/Dropbox/DropboxHandler.php
+7
-27
3.3.1
→
2.15.3
View file →
| @@ -1,18 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace BitCode\BitForm\Core\Integration\Dropbox; |
| 4 | 4 | |
| 5 | -if (!defined('ABSPATH')) { | |
| 6 | - exit; | |
| 7 | -} | |
| 8 | - | |
| 9 | 5 | use BitCode\BitForm\Core\Integration\Dropbox\RecordApiHelper as DropboxRecordApiHelper; |
| 10 | 6 | use BitCode\BitForm\Core\Integration\IntegrationHandler; |
| 11 | 7 | use BitCode\BitForm\Core\Util\ApiResponse; |
| 12 | 8 | use BitCode\BitForm\Core\Util\HttpHelper; |
| 13 | 9 | use BitCode\BitForm\Core\Util\IpTool; |
| 14 | -use BitCode\BitForm\GlobalHelper; | |
| 15 | 10 | use WP_Error; |
| 16 | 11 | |
| 17 | 12 | class DropboxHandler |
| 18 | 13 | { |
| @@ -44,20 +39,15 @@ | ||
| 44 | 39 | * @return JSON |
| 45 | 40 | */ |
| 46 | 41 | public static function checkAuthorization() |
| 47 | 42 | { |
| 48 | - if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 43 | + if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 49 | 44 | wp_send_json_error(__('Token expired', 'bit-form'), 401); |
| 50 | 45 | } |
| 51 | 46 | |
| 52 | - GlobalHelper::requirePostMethod(); | |
| 47 | + $inputJSON = file_get_contents('php://input'); | |
| 48 | + $queryParams = json_decode($inputJSON); | |
| 53 | 49 | |
| 54 | - try { | |
| 55 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 56 | - } catch (\InvalidArgumentException $e) { | |
| 57 | - wp_send_json_error($e->getMessage(), 400); | |
| 58 | - } | |
| 59 | - | |
| 60 | 50 | if (empty($queryParams->accessCode) || empty($queryParams->apiKey) || empty($queryParams->apiSecret)) { |
| 61 | 51 | wp_send_json_error(__('Requested parameter is empty', 'bit-form'), 400); |
| 62 | 52 | } |
| 63 | 53 | |
| @@ -84,20 +74,15 @@ | ||
| 84 | 74 | * @return JSON |
| 85 | 75 | */ |
| 86 | 76 | public static function getAllFolders() |
| 87 | 77 | { |
| 88 | - if (!isset($_REQUEST['_ajax_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) { | |
| 78 | + if (!isset($_REQUEST['_ajax_nonce']) && !wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { | |
| 89 | 79 | wp_send_json_error(__('Token expired', 'bit-form'), 401); |
| 90 | 80 | } |
| 91 | 81 | |
| 92 | - GlobalHelper::requirePostMethod(); | |
| 82 | + $inputJSON = file_get_contents('php://input'); | |
| 83 | + $queryParams = json_decode($inputJSON); | |
| 93 | 84 | |
| 94 | - try { | |
| 95 | - $queryParams = GlobalHelper::formatRequestData(); | |
| 96 | - } catch (\InvalidArgumentException $e) { | |
| 97 | - wp_send_json_error($e->getMessage(), 400); | |
| 98 | - } | |
| 99 | - | |
| 100 | 85 | if (empty($queryParams->tokenDetails) || empty($queryParams->apiKey) || empty($queryParams->apiSecret)) { |
| 101 | 86 | wp_send_json_error(__('Requested parameter is empty', 'bit-form'), 400); |
| 102 | 87 | } |
| 103 | 88 | |
| @@ -205,16 +190,11 @@ | ||
| 205 | 190 | |
| 206 | 191 | public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) |
| 207 | 192 | { |
| 208 | 193 | $integrationDetails = json_decode($integrationData->integration_details); |
| 209 | - $entryDetails = [ | |
| 210 | - 'formId' => $this->formID, | |
| 211 | - 'entryId' => $entryID, | |
| 212 | - 'fieldValues' => $fieldValues | |
| 213 | - ]; | |
| 214 | 194 | |
| 215 | 195 | if (empty($integrationDetails->tokenDetails->access_token)) { |
| 216 | - (new ApiResponse())->apiResponse($logID, $this->integrationID, ['type' => 'record', 'type_name' => 'insert'], 'error', 'Not Authorization By Dropbox.', $entryDetails); | |
| 196 | + (new ApiResponse())->apiResponse($logID, $this->integrationID, ['type' => 'record', 'type_name' => 'insert'], 'error', 'Not Authorization By Dropbox.'); | |
| 217 | 197 | return; |
| 218 | 198 | } |
| 219 | 199 | |
| 220 | 200 | $actions = $integrationDetails->actions; |