diff --git a/software-license-manager/includes/slm-api-listener.php b/software-license-manager/includes/slm-api-listener.php index 16c2414..b3dad5f 100644 --- a/software-license-manager/includes/slm-api-listener.php +++ b/software-license-manager/includes/slm-api-listener.php @@ -32,7 +32,10 @@ function creation_api_listener() { SLM_API_Utility::verify_secret_key_for_creation(); //Verify the secret key first. - $slm_debug_logger->log_debug("API - license creation request received."); + $slm_debug_logger->log_debug("API - license creation (slm_create_new) request received."); + + //Action hook + do_action('slm_api_listener_slm_create_new'); $fields = array(); if (isset($_REQUEST['license_key']) && !empty($_REQUEST['license_key'])){ @@ -83,7 +86,10 @@ function activation_api_listener() { SLM_API_Utility::verify_secret_key(); //Verify the secret key first. - $slm_debug_logger->log_debug("API - license activation request received."); + $slm_debug_logger->log_debug("API - license activation (slm_activate) request received."); + + //Action hook + do_action('slm_api_listener_slm_activate'); $fields = array(); $fields['lic_key'] = trim(strip_tags($_REQUEST['license_key'])); @@ -149,7 +155,10 @@ function deactivation_api_listener() { SLM_API_Utility::verify_secret_key(); //Verify the secret key first. - $slm_debug_logger->log_debug("API - license deactivation request received."); + $slm_debug_logger->log_debug("API - license deactivation (slm_deactivate) request received."); + + //Action hook + do_action('slm_api_listener_slm_deactivate'); if (empty($_REQUEST['registered_domain'])) { $args = (array('result' => 'error', 'message' => 'Registered domain information is missing')); @@ -178,6 +187,43 @@ function deactivation_api_listener() { 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, + )); + //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); + } } } diff --git a/software-license-manager/readme.txt b/software-license-manager/readme.txt index 6a30a22..4b300b5 100644 --- a/software-license-manager/readme.txt +++ b/software-license-manager/readme.txt @@ -3,8 +3,8 @@ Contributors: Tips and Tricks HQ, Peter Petreski, Ruhul Amin Donate link: https://www.tipsandtricks-hq.com/software-license-manager-plugin-for-wordpress Tags: license key, serial key, manager, license, serial, key, selling, sell, license activation, manage license, software license, software license manager Requires at least: 3.0 -Tested up to: 4.2 -Stable tag: 1.7 +Tested up to: 4.3 +Stable tag: 1.8 License: GPLv2 or later Create and manage license keys for your software applications easily @@ -19,6 +19,7 @@ This plugin is very useful for creating a license server and doing the following - Check the status of a license key from from your application (remotely) - Activate a license key from your application (remotely) - Deactivate a license key (remotely) +- Check a license key (remotely) - Track where the license key is being used. You can also create license keys manually from the admin dashboard of this plugin. @@ -45,6 +46,11 @@ See the following page: https://www.tipsandtricks-hq.com/software-license-manager-plugin-for-wordpress == Changelog == + += 1.8 = +- Added new hooks before the API query is executed. This allows a developer to override the API query and do custom stuff. +- Added a new API to check the details of an existing license key. + = 1.7 = * The license key is also included with the response sent to the new license creation request. Below is an example response: {"result":"success","message":"License successfully created","key":"5580effe188d3"} diff --git a/software-license-manager/slm_bootstrap.php b/software-license-manager/slm_bootstrap.php index 5e87e38..44b283a 100644 --- a/software-license-manager/slm_bootstrap.php +++ b/software-license-manager/slm_bootstrap.php @@ -1,7 +1,7 @@