| @@ -15,9 +15,9 @@ | ||
| 15 | 15 | add_action('init', array($this, 'api')); |
| 16 | 16 | } |
| 17 | 17 | public function api(){ |
| 18 | 18 | |
| 19 | - if ( isset( $_GET['action'] ) && sanitize_text_field( wp_unslash( $_GET['action'] ) ) === 'qcld_dfv2_api' ) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 19 | + if(isset($_GET['action']) && $_GET['action']=='qcld_dfv2_api'){ | |
| 20 | 20 | $session_id = 'asd2342sde'; |
| 21 | 21 | $language = get_option('qlcd_wp_chatbot_dialogflow_agent_language'); |
| 22 | 22 | //project ID |
| 23 | 23 | $project_ID = get_option('qlcd_wp_chatbot_dialogflow_project_id'); |
| @@ -28,14 +28,14 @@ | ||
| 28 | 28 | } |
| 29 | 29 | if($JsonFileContents==''){ |
| 30 | 30 | echo wp_json_encode(array('error'=>'Key is empty'));exit; |
| 31 | 31 | } |
| 32 | - if(!isset($_POST['dfquery']) || wp_unslash($_POST['dfquery'])==''){ | |
| 32 | + if(!isset($_POST['dfquery']) || $_POST['dfquery']==''){ | |
| 33 | 33 | echo wp_json_encode(array('error'=>'Query text is not added!'));exit; |
| 34 | 34 | } |
| 35 | - $query = sanitize_text_field(wp_unslash($_POST['dfquery'])); | |
| 36 | - if(isset($_POST['sessionid']) && wp_unslash($_POST['sessionid'])!=''){ | |
| 37 | - $session_id = sanitize_text_field(wp_unslash($_POST['sessionid'])); | |
| 35 | + $query = sanitize_text_field($_POST['dfquery']); | |
| 36 | + if(isset($_POST['sessionid']) && $_POST['sessionid']!=''){ | |
| 37 | + $session_id = sanitize_text_field($_POST['sessionid']); | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | if(file_exists(QCLD_wpCHATBOT_GC_DIRNAME.'/autoload.php')){ |
| @@ -80,11 +80,11 @@ | ||
| 80 | 80 | |
| 81 | 81 | add_action('wp_ajax_qcld_wp_df_api_call', 'qcld_wp_df_api_call'); |
| 82 | 82 | add_action('wp_ajax_nopriv_qcld_wp_df_api_call', 'qcld_wp_df_api_call'); |
| 83 | 83 | function qcld_wp_df_api_call(){ |
| 84 | - $nonce = sanitize_text_field(wp_unslash($_POST['nonce'])); | |
| 84 | + $nonce = sanitize_text_field($_POST['nonce']); | |
| 85 | 85 | if ((! wp_verify_nonce($nonce,'wp_chatbot')) && ( ! wp_verify_nonce($nonce,'qcsecretbotnonceval123qc'))) { |
| 86 | - wp_send_json(array('success' => false, 'msg' => esc_html__('Failed in Security check', 'chatbot'))); | |
| 86 | + wp_send_json(array('success' => false, 'msg' => esc_html__('Failed in Security check', 'sm'))); | |
| 87 | 87 | wp_die(); |
| 88 | 88 | |
| 89 | 89 | }else{ |
| 90 | 90 | $session_id = 'asd2342sde'; |
| @@ -93,19 +93,19 @@ | ||
| 93 | 93 | $project_ID = get_option('qlcd_wp_chatbot_dialogflow_project_id'); |
| 94 | 94 | // Service Account Key json file |
| 95 | 95 | $JsonFileContents = get_option('qlcd_wp_chatbot_dialogflow_project_key'); |
| 96 | 96 | if($project_ID==''){ |
| 97 | - echo wp_json_encode(array('error'=>'Project ID is empty'));exit; | |
| 97 | + echo json_encode(array('error'=>'Project ID is empty'));exit; | |
| 98 | 98 | } |
| 99 | 99 | if($JsonFileContents==''){ |
| 100 | - echo wp_json_encode(array('error'=>'Key is empty'));exit; | |
| 100 | + echo json_encode(array('error'=>'Key is empty'));exit; | |
| 101 | 101 | } |
| 102 | - if(!isset($_POST['dfquery']) || wp_unslash($_POST['dfquery'])==''){ | |
| 103 | - echo wp_json_encode(array('error'=>'Query text is not added!'));exit; | |
| 102 | + if(!isset($_POST['dfquery']) || $_POST['dfquery']==''){ | |
| 103 | + echo json_encode(array('error'=>'Query text is not added!'));exit; | |
| 104 | 104 | } |
| 105 | - $query = sanitize_text_field(wp_unslash($_POST['dfquery'])); | |
| 106 | - if(isset($_POST['sessionid']) && wp_unslash($_POST['sessionid'])!=''){ | |
| 107 | - $session_id = sanitize_text_field(wp_unslash($_POST['sessionid'])); | |
| 105 | + $query = sanitize_text_field($_POST['dfquery']); | |
| 106 | + if(isset($_POST['sessionid']) && $_POST['sessionid']!=''){ | |
| 107 | + $session_id = sanitize_text_field($_POST['sessionid']); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | |
| 111 | 111 | if(file_exists(QCLD_wpCHATBOT_GC_DIRNAME.'/autoload.php')){ |
| @@ -134,13 +134,13 @@ | ||
| 134 | 134 | |
| 135 | 135 | exit; |
| 136 | 136 | |
| 137 | 137 | }catch(Exception $e) { |
| 138 | - echo wp_json_encode(array('error'=>$e->getMessage()));exit; | |
| 138 | + echo json_encode(array('error'=>$e->getMessage()));exit; | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | }else{ |
| 142 | - echo wp_json_encode(array('error'=>'API client not found'));exit; | |
| 142 | + echo json_encode(array('error'=>'API client not found'));exit; | |
| 143 | 143 | } |
| 144 | 144 | die(); |
| 145 | 145 | } |
| 146 | 146 | } |