static function verify_secret_key_for_creation()
 {
     $slm_options = get_option('slm_plugin_options');
     $right_secret_key = $slm_options['lic_creation_secret'];
     $received_secret_key = strip_tags($_REQUEST['secret_key']);
     if ($received_secret_key != $right_secret_key) {
         $args = array('result' => 'error', 'message' => 'License Creation API secret key is invalid');
         SLM_API_Utility::output_api_response($args);
     }
 }
 function check_api_listener()
 {
     if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_check') {
         //Handle the license check API query
         global $slm_debug_logger;
         SLM_API_Utility::verify_secret_key();
         //Verify the secret key first.
         $slm_debug_logger->log_debug("API - license check (slm_check) request received.");
         $fields = array();
         $fields['lic_key'] = trim(strip_tags($_REQUEST['license_key']));
         $slm_debug_logger->log_debug("License key: " . $fields['lic_key']);
         //Action hook
         do_action('slm_api_listener_slm_check');
         global $wpdb;
         $tbl_name = SLM_TBL_LICENSE_KEYS;
         $reg_table = SLM_TBL_LIC_DOMAIN;
         $key = $fields['lic_key'];
         $sql_prep1 = $wpdb->prepare("SELECT * FROM {$tbl_name} WHERE license_key = %s", $key);
         $retLic = $wpdb->get_row($sql_prep1, OBJECT);
         $sql_prep2 = $wpdb->prepare("SELECT * FROM {$reg_table} WHERE lic_key = %s", $key);
         $reg_domains = $wpdb->get_results($sql_prep2, OBJECT);
         if ($retLic) {
             //A license key exists
             $args = array('result' => 'success', 'message' => 'License key details retrieved.', 'status' => $retLic->lic_status, 'max_allowed_domains' => $retLic->max_allowed_domains, 'email' => $retLic->email, 'registered_domains' => $reg_domains, 'date_created' => $retLic->date_created, 'date_renewed' => $retLic->date_renewed, 'date_expiry' => $retLic->date_expiry);
             //Output the license details
             SLM_API_Utility::output_api_response($args);
         } else {
             $args = array('result' => 'error', 'message' => 'Invalid license key');
             SLM_API_Utility::output_api_response($args);
         }
     }
 }