diff --git a/license-manager/api_tester.php b/license-manager/client-side/api_tester.php similarity index 100% rename from license-manager/api_tester.php rename to license-manager/client-side/api_tester.php diff --git a/license-manager/client-side/index.html b/license-manager/client-side/index.html new file mode 100644 index 0000000..e69de29 diff --git a/license-manager/deactivation_tester.php b/license-manager/deactivation_tester.php deleted file mode 100644 index 8d8be60..0000000 --- a/license-manager/deactivation_tester.php +++ /dev/null @@ -1,17 +0,0 @@ - \ No newline at end of file diff --git a/license-manager/lic_manager_installer.php b/license-manager/lic_manager_installer.php index ea60803..960cf74 100644 --- a/license-manager/lic_manager_installer.php +++ b/license-manager/lic_manager_installer.php @@ -21,17 +21,18 @@ date_renewed datetime NOT NULL DEFAULT '0000-00-00 00:00:00', date_expiry datetime NOT NULL DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (id) - )ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + )ENGINE=MyISAM DEFAULT CHARSET=utf8;"; dbDelta($lk_tbl_sql); $ld_tbl_sql = "CREATE TABLE " .$lic_domain_table. " ( - id INT NOT NULL AUTO_INCREMENT , - lic_key_id INT NOT NULL , - lic_key varchar(255) NOT NULL , - registered_domain VARCHAR( 100 ) NOT NULL , - PRIMARY KEY ( id ) - )ENGINE=MyISAM DEFAULT CHARSET=utf8;"; + id INT NOT NULL AUTO_INCREMENT , + lic_key_id INT NOT NULL , + lic_key varchar(255) NOT NULL , + registered_domain VARCHAR( 100 ) NOT NULL , + PRIMARY KEY ( id ) + )ENGINE=MyISAM DEFAULT CHARSET=utf8;"; dbDelta($ld_tbl_sql); + // Add default options update_option("wp_lic_mgr_db_version", WP_LICENSE_MANAGER_DB_VERSION); diff --git a/license-manager/menu/admin_includes1.php b/license-manager/menu/admin_includes1.php deleted file mode 100644 index e6f9c9c..0000000 --- a/license-manager/menu/admin_includes1.php +++ /dev/null @@ -1,10 +0,0 @@ - - - \ No newline at end of file diff --git a/license-manager/menu/lic_add_licenses.php b/license-manager/menu/lic_add_licenses.php index e47bc3c..137c703 100644 --- a/license-manager/menu/lic_add_licenses.php +++ b/license-manager/menu/lic_add_licenses.php @@ -1,25 +1,17 @@ '; echo '

Add/Edit Licenses

'; echo '
'; //If product is being edited, grab current product info - if ($_GET['edit_record']!='') - { + if ($_GET['edit_record'] != '') { $id = $_GET['edit_record']; - $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME," id = ".$id); + $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, " id = " . $id); } - if (isset($_POST['save_record'])) - { - global $wpdb; + if (isset($_POST['save_record'])) { + global $wpdb; //Save the entry to the database $fields = array(); $fields['license_key'] = $_POST['license_key']; @@ -33,196 +25,190 @@ function wp_lic_mgr_add_licenses_menu() $fields['manual_reset_count'] = $_POST['manual_reset_count']; $id = $_POST['edit_record']; - if(empty($id))//Insert into database - { - $updated = LicMgrDbAccess::insert(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $fields); + if (empty($id)) {//Insert into database + $updated = LicMgrDbAccess::insert(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $fields); //Retrieve the added record $id = mysql_insert_id(); - $cond = " id = ".$id; - $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME,$cond); - } - else //Update recored - { - $cond = " id = ". $id; + $cond = " id = " . $id; + $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $cond); + } else { //Update recored + $cond = " id = " . $id; $updated = LicMgrDbAccess::update(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $cond, $fields); //Retrieve the updated record - $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME,$cond); + $editing_record = LicMgrDbAccess::find(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $cond); } $message = "Record successfully saved!"; echo '

'; echo $message; echo '

'; - } - lic_mgr_add_lic_view($editing_record,$id); + lic_mgr_add_lic_view($editing_record, $id); echo 'Manage Licenses

'; echo '
'; echo ''; } -function lic_mgr_add_lic_view($editing_record,$id='') -{ +function lic_mgr_add_lic_view($editing_record, $id = '') { ?> You can add a new license or edit an existing one from this interface.

-

-
+

+
-
"> - + "> +
'; - } - else - { + if ($id != '') { + echo ''; + } else { //Auto generate unique key $lic_key_prefix = get_option('wp_lic_mgr_key_prefix'); - $editing_record->license_key = uniqid($lic_key_prefix);//uniqid('', true); + $editing_record->license_key = uniqid($lic_key_prefix); //uniqid('', true); } ?> - - - - - - - - - - - - - - - get_results(" SELECT * FROM $reg_table WHERE lic_key_id= '$id'", OBJECT ); - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
License Key -
The unique license key. When adding a new record it automatically generates a unique key in this field for you. You can change this value to customize the key if you like.
Maximum Allowed Domains
Number of domains in which this license can be used.
License Status - -
Registered Domains0){ - ?> -
-
- - - > - - - - -
registered_domain;?>id ?>>X
-
- -
First Name
License user's first name
Last Name
License user's last name
Email Address
License user's email address
Company Name
License user's company name
Unique Transaction ID
The unique transaction ID associated with this license key
Manual Reset Count -
The number of times this license has been manually reset by the admin (use it if you want to keep track of it). It can be helpful for the admin to keep track of manual reset counts.
Date Created -
Creation date of license.
Date Renewed -
Renewal date of license.
Date of Expiry -
Expiry date of license.
- -
- -
-
-
+ + License Key + +
The unique license key. When adding a new record it automatically generates a unique key in this field for you. You can change this value to customize the key if you like. + + + + Maximum Allowed Domains +
Number of domains in which this license can be used. + + + + License Status + + + + + get_results(" SELECT * FROM $reg_table WHERE lic_key_id= '$id'", OBJECT); + ?> + + Registered Domains + 0) { + ?> +
+
+ + + > + + + + +
registered_domain; ?>id ?>>X
+
+ + + + + + + First Name +
License user's first name + + + + Last Name +
License user's last name + + + + Email Address +
License user's email address + + + + Company Name +
License user's company name + + + + Unique Transaction ID +
The unique transaction ID associated with this license key + + + + Manual Reset Count + +
The number of times this license has been manually reset by the admin (use it if you want to keep track of it). It can be helpful for the admin to keep track of manual reset counts. + + + + Date Created + +
Creation date of license. + + + + Date Renewed + +
Renewal date of license. + + + + Date of Expiry + +
Expiry date of license. + + + + +
+ +
+ +
diff --git a/license-manager/menu/lic_manage_licenses.php b/license-manager/menu/lic_manage_licenses.php index c99e513..472bb36 100644 --- a/license-manager/menu/lic_manage_licenses.php +++ b/license-manager/menu/lic_manage_licenses.php @@ -1,42 +1,34 @@ '; echo '

Manage Licenses

'; echo '
'; - ?>
-

-
-delete_licnses(strip_tags($_REQUEST['id'])); - } +

+
+ delete_licnses(strip_tags($_REQUEST['id'])); } - //Fetch, prepare, sort, and filter our data... - $license_list->prepare_items(); - //echo "put table of locked entries here"; - ?> -
- - - - display(); ?> -
- -
+ } + //Fetch, prepare, sort, and filter our data... + $license_list->prepare_items(); + //echo "put table of locked entries here"; + ?> +
+ + + + display(); ?> +
+ +
'; diff --git a/license-manager/menu/lic_mgr_integration_help_page.php b/license-manager/menu/lic_mgr_integration_help_page.php index 6d36a51..e0d9d42 100644 --- a/license-manager/menu/lic_mgr_integration_help_page.php +++ b/license-manager/menu/lic_mgr_integration_help_page.php @@ -1,125 +1,122 @@ + + '; echo '
'; - lic_mgr_admin_general_css(); - echo '

WP License Manager Integration Help v'.WP_LICENSE_MANAGER_VERSION.'

'; - - $LicenseCreationPostURL = WP_LICENSE_MANAGER_URL.'/api/create.php'; - echo "The License Creation POST URL For Your Installation"; - echo '
'.$LicenseCreationPostURL.'
'; + echo '

WP License Manager Integration Help v' . WP_LICENSE_MANAGER_VERSION . '

'; - $LicenseVerificationPostURL = WP_LICENSE_MANAGER_URL.'/api/verify.php'; - echo "The License Verification POST URL For Your Installation"; - echo '
'.$LicenseVerificationPostURL.'
'; - - $LicenseDeactivationPostURL = WP_LICENSE_MANAGER_URL.'/api/deactivate.php'; - echo "The License Deactivation POST URL For Your Installation"; - echo '
'.$LicenseDeactivationPostURL.'
'; - ?> -

3rd Party Integration

+ $LicenseCreationPostURL = WP_LICENSE_MANAGER_URL . '/api/create.php'; + echo "The License Creation POST URL For Your Installation"; + echo '
' . $LicenseCreationPostURL . '
'; -Integrating a 3rd party payment system or shopping cart with WP License Manager is possible. -

-The integration process can be accomplished in three steps, namely: -
-
1. Generate POST data -
2. Send POST data to the POST URL -
3. Process the returned data -

-POST Values -
-WP License Manager expects a certain set of variables to be sent to it via HTTP POST. These variables are: -

-Mandatory Variables -
----------------- -
a. Secret Key: A Secret API key (you can find this value in the settings menu of this plugin) -

-Optional Variables -
---------------- -
b. Customer First Name: The first name of the customer -
c. Customer Last Name: The last name of the customer -
d. Customer Email: The email address of the customer -
e. Company Name: The customer's company name -
f. Maximum Domains Allowed: The number of domains this license key can be used on -
g. Transaction ID: A unique transaction ID to reference the transaction -

-Return Value -
-Upon successful processing, WP License Manager will return a plain text message that will have two or three lines similar to the following: -
-
-Success -
License key -
WPLICMGR4bc29fd61e471 -
-or -
-Error -
Secret key is invalid -
+ $LicenseVerificationPostURL = WP_LICENSE_MANAGER_URL . '/api/verify.php'; + echo "The License Verification POST URL For Your Installation"; + echo '
' . $LicenseVerificationPostURL . '
'; -1. The first line is an indication of success or error -
2. The second line is the result. -
3. The third line is additional message that resulted from the request. -

-Sample PHP Code -
-Below is a sample PHP code that shows how easy it is to integrate with WP License Manager -
+ $LicenseDeactivationPostURL = WP_LICENSE_MANAGER_URL . '/api/deactivate.php'; + echo "The License Deactivation POST URL For Your Installation"; + echo '
' . $LicenseDeactivationPostURL . '
'; + ?> +

3rd Party Integration

-
-/*** Mandatory data ***/ -
// Post URL -
$postURL = ""; -
// The Secret key -
$secretKey = ""; -
-
/*** Optional Data ***/ -
$firstname = "John"; -
$lastname = "Doe"; -
$email = "john.doe@gmail.com"; -
-
// prepare the data -
$data = array (); -
$data['secret_key'] = $secretKey; -
$data['source_file'] = $fileURL; -
$data['first_name'] = $firstname; -
$data['last_name'] = $lastname; -
$data['email'] = $email; -
-
// send data to post URL -
$ch = curl_init ($postURL); -
curl_setopt ($ch, CURLOPT_POST, true); -
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); -
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); -
$returnValue = curl_exec ($ch); -
-
// Process the return values -
list ($status, $msg, $additionalMsg) = explode ("\n", $returnValue); -
if(strpos($status,"Success") !== false) -
{ -
$license_key = trim($additionalMsg); -
echo "The generated license key is: ".$license_key; -
} -
else -
{ -
echo "An error occured while trying to create license! Error details: ".$msg; -
} -
- -
+ The integration process can be accomplished in three steps, namely: +
+
1. Generate POST data +
2. Send POST data to the POST URL +
3. Process the returned data +

+ POST Values +
+ WP License Manager expects a certain set of variables to be sent to it via HTTP POST. These variables are: +

+ Mandatory Variables +
+ ---------------- +
a. Secret Key: A Secret API key (you can find this value in the settings menu of this plugin) +

+ Optional Variables +
+ --------------- +
b. Customer First Name: The first name of the customer +
c. Customer Last Name: The last name of the customer +
d. Customer Email: The email address of the customer +
e. Company Name: The customer's company name +
f. Maximum Domains Allowed: The number of domains this license key can be used on +
g. Transaction ID: A unique transaction ID to reference the transaction +

+ Return Value +
+ Upon successful processing, WP License Manager will return a plain text message that will have two or three lines similar to the following: +
+
+ Success +
License key +
WPLICMGR4bc29fd61e471 +
+ or +
+ Error +
Secret key is invalid +
+ + 1. The first line is an indication of success or error +
2. The second line is the result. +
3. The third line is additional message that resulted from the request. +

+ Sample PHP Code +
+ Below is a sample PHP code that shows how easy it is to integrate with WP License Manager +
+ +
+ /*** Mandatory data ***/ +
// Post URL +
$postURL = ""; +
// The Secret key +
$secretKey = ""; +
+
/*** Optional Data ***/ +
$firstname = "John"; +
$lastname = "Doe"; +
$email = "john.doe@gmail.com"; +
+
// prepare the data +
$data = array (); +
$data['secret_key'] = $secretKey; +
$data['source_file'] = $fileURL; +
$data['first_name'] = $firstname; +
$data['last_name'] = $lastname; +
$data['email'] = $email; +
+
// send data to post URL +
$ch = curl_init ($postURL); +
curl_setopt ($ch, CURLOPT_POST, true); +
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); +
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); +
$returnValue = curl_exec ($ch); +
+
// Process the return values +
list ($status, $msg, $additionalMsg) = explode ("\n", $returnValue); +
if(strpos($status,"Success") !== false) +
{ +
$license_key = trim($additionalMsg); +
echo "The generated license key is: ".$license_key; +
} +
else +
{ +
echo "An error occured while trying to create license! Error details: ".$msg; +
} +
+ +
'; - echo '
'; + echo ''; } -?> \ No newline at end of file diff --git a/license-manager/menu/lic_settings.php b/license-manager/menu/lic_settings.php index 4c9f804..b79d68b 100644 --- a/license-manager/menu/lic_settings.php +++ b/license-manager/menu/lic_settings.php @@ -1,13 +1,9 @@ '; - echo '

WP License Manager Settings v'.WP_LICENSE_MANAGER_VERSION.'

'; + echo '

WP License Manager Settings v' . WP_LICENSE_MANAGER_VERSION . '

'; echo '
'; wp_lic_mgr_general_settings(); @@ -16,81 +12,72 @@ function wp_lic_mgr_settings_menu() echo '
'; } -function wp_lic_mgr_general_settings() -{ - if (isset($_POST['info_update'])) - { - update_option('wp_lic_mgr_reg_secret_key', (string)$_POST["wp_lic_mgr_reg_secret_key"]); - update_option('wp_lic_mgr_key_prefix', (string)$_POST["wp_lic_mgr_key_prefix"]); - if(is_numeric($_POST["wp_lic_mgr_max_num_domain"]))update_option('wp_lic_mgr_max_num_domain', (string)$_POST["wp_lic_mgr_max_num_domain"]); - update_option('wp_lic_mgr_verification_secret_key', (string)$_POST["wp_lic_mgr_verification_secret_key"]); +function wp_lic_mgr_general_settings() { + if (isset($_POST['info_update'])) { + update_option('wp_lic_mgr_reg_secret_key', (string) $_POST["wp_lic_mgr_reg_secret_key"]); + update_option('wp_lic_mgr_key_prefix', (string) $_POST["wp_lic_mgr_key_prefix"]); + if (is_numeric($_POST["wp_lic_mgr_max_num_domain"])) + update_option('wp_lic_mgr_max_num_domain', (string) $_POST["wp_lic_mgr_max_num_domain"]); + update_option('wp_lic_mgr_verification_secret_key', (string) $_POST["wp_lic_mgr_verification_secret_key"]); //update_option('eStore_enable_wishlist_int', ($_POST['eStore_enable_wishlist_int']=='1') ? '1':'' ); } $secret_key = get_option('wp_lic_mgr_reg_secret_key'); - if(empty($secret_key)) - { - $secret_key = uniqid('',true); + if (empty($secret_key)) { + $secret_key = uniqid('', true); } $secret_verification_key = get_option('wp_lic_mgr_verification_secret_key'); - if(empty($secret_verification_key)) - { - $secret_verification_key = uniqid('',true); + if (empty($secret_verification_key)) { + $secret_verification_key = uniqid('', true); } - ?> -

For information, updates and detailed documentation, please visit the WP License Manager Documentation Site or - The main plugin page WP License Manager

+

For information, updates and detailed documentation, please visit the WP License Manager Documentation Site or + The main plugin page WP License Manager

-

-
+

+
-

1. First register a key at purchase time.

-

2. Add the code so at activation time it asks for the key.

-

3. Integrate the real time online key verification part.

-
+

1. First register a key at purchase time.

+

2. Add the code so at activation time it asks for the key.

+

3. Integrate the real time online key verification part.

+
"> -
-

-
- - - - - - +
+

+
+
Secret Key for License Creation -
This secret key will be used to authenticate any license creation request. You can change it with something random.
- - - - + + + + - - - - - - - - + + + + - + + + + + + + + -
License Key Prefix -
You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.
Secret Key for License Creation +
This secret key will be used to authenticate any license creation request. You can change it with something random.
Secret Key for License Verification Requests -
This secret key will be used to authenticate any license verification request from customer's site. Important! Do not change this value once your customer's start to use your product(s)!
Maximum Allowed Domains -
Maximum number of domains which each license is valid for.
License Key Prefix +
You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.
Secret Key for License Verification Requests +
This secret key will be used to authenticate any license verification request from customer's site. Important! Do not change this value once your customer's start to use your product(s)!
Maximum Allowed Domains +
Maximum number of domains which each license is valid for.
-
+ + -
- -
+
+ +
diff --git a/license-manager/menu/product_license.php b/license-manager/menu/product_license.php deleted file mode 100644 index 9a61ae0..0000000 --- a/license-manager/menu/product_license.php +++ /dev/null @@ -1,71 +0,0 @@ -'; - echo '

Product License

'; - echo '
'; - - $message = ""; - if(isset($_POST['activate_license'])) - { - $retData = wp_lic_mgr_lic_verify($_POST['lic_key']); - if ($retData['result'] == 'Success') - { - // something else is to be done to store the license key. - update_option('wp_lic_mgr_lic_key',$_POST['lic_key']); - $message .= "License key is valid! Product activated."; - } - else - { - $message .= "License key is invalid!"; - $message .= "
".$retData['msg']; - } - } - if(isset($_POST['deactivate_license'])) - { - $retData = wp_lic_mgr_deactivate_lic($_POST['lic_key']); - if ($retData['result'] == 'Success') - { - // Reset the license key - update_option('wp_lic_mgr_lic_key',''); - $message .= "License key deactivated!"; - } - else - { - $message .= "License key deactivation failed!"; - $message .= "
".$retData['msg']; - } - } - if(!empty($message)) - { - echo '

'; - echo $message; - echo '

'; - } - - ?> -
-

-
- -

Please enter the license key for this product to activate it -

- - - - - -
-

- - -

-
-

-
-
'; - echo '
'; -} -?> \ No newline at end of file diff --git a/license-manager/menu/wp-lic-mgr-list-licenses.php b/license-manager/menu/wp-lic-mgr-list-licenses.php index a146d9d..21801a6 100644 --- a/license-manager/menu/wp-lic-mgr-list-licenses.php +++ b/license-manager/menu/wp-lic-mgr-list-licenses.php @@ -18,10 +18,10 @@ function column_default($item, $column_name){ } function column_id($item){ - $price_list_id = $item['id']; + $row_id = $item['id']; $actions = array( - 'edit' => sprintf('Edit',$price_list_id), - 'delete' => sprintf('Delete',$price_list_id), + 'edit' => sprintf('Edit', $row_id), + 'delete' => sprintf('Delete',$row_id), ); return sprintf('%1$s %2$s', /*$1%s*/ $item['id'], diff --git a/license-manager/menu/wp_lic_mgr_admin_fnc.php b/license-manager/menu/wp_lic_mgr_admin_fnc.php index 1dd2a2d..a5559e0 100644 --- a/license-manager/menu/wp_lic_mgr_admin_fnc.php +++ b/license-manager/menu/wp_lic_mgr_admin_fnc.php @@ -1,55 +1,48 @@ '; echo '

License Manager Admin Functions

'; - echo '
'; + echo '
'; + + if (isset($_POST['send_deactivation_request'])) { + $postURL = $_POST['lic_mgr_deactivation_req_url']; + $secretKeyForVerification = get_option('wp_lic_mgr_verification_secret_key'); + $data = array(); + $data['secret_key'] = $secretKeyForVerification; - if(isset($_POST['send_deactivation_request'])) - { - $postURL = $_POST['lic_mgr_deactivation_req_url']; - $secretKeyForVerification = get_option('wp_lic_mgr_verification_secret_key'); - $data = array (); - $data['secret_key'] = $secretKeyForVerification; - - $ch = curl_init ($postURL); - curl_setopt ($ch, CURLOPT_POST, true); - curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); - $returnValue = curl_exec ($ch); + $ch = curl_init($postURL); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $data); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $returnValue = curl_exec($ch); - $msg = ""; - if($returnValue == "Success"){ - $msg .= "Success message returned from the remote host."; - } + $msg = ""; + if ($returnValue == "Success") { + $msg .= "Success message returned from the remote host."; + } echo '

'; echo 'Request sent to the specified URL!'; - echo '
'.$msg; - echo '

'; + echo '
' . $msg; + echo '

'; } ?>
-

-
-
Enter the URL where the license deactivation message will be sent to -

-
+

+
+
Enter the URL where the license deactivation message will be sent to +

+ - -
- -
- -
+ +
+ +
+ +
'; - echo '
'; + echo ''; } -?> \ No newline at end of file diff --git a/license-manager/slm_plugin_core.php b/license-manager/slm_plugin_core.php new file mode 100644 index 0000000..aa0a559 --- /dev/null +++ b/license-manager/slm_plugin_core.php @@ -0,0 +1,83 @@ +prefix . "lic_key_tbl"); +define('WPLM_TBL_LIC_DOMAIN', $wpdb->prefix . "lic_reg_domain_tbl"); + +//Includes +include_once('lic_db_access.php'); +//Include admin side only files +if (is_admin()){ + include_once('menu/includes/wp-license-mgr-list-table.php'); //Load our own WP List Table class +} + +//Action hooks +add_action('init', 'wp_lic_mgr_init'); +add_action('plugins_loaded', 'wp_lic_mgr_plugins_loaded_handler'); + + +function wp_lic_mgr_init() +{ + //Load all common scripts and styles only + wp_enqueue_script('jquery'); + + if(is_admin())//Load all admin side scripts and styles only + { + wp_enqueue_script('jquery-ui-datepicker'); + + wp_enqueue_script('jquery-ui-core'); + wp_enqueue_script('jquery-ui-widget'); + wp_enqueue_script('jquery-ui-position'); + wp_enqueue_script('jquery-ui-mouse'); + wp_enqueue_script('jquery-ui-dialog'); + } +} + + +function wp_lic_mgr_plugins_loaded_handler() +{ + //Runs when plugins_loaded action gets fired + if(is_admin()){ + //Check if db update needed + if (get_option('wp_lic_mgr_db_version') != WP_LICENSE_MANAGER_DB_VERSION) { + require_once(dirname(__FILE__).'/lic_manager_installer.php'); + } + } +} + +add_action('wp_ajax_del_dom', 'del_reg_dom'); +function del_reg_dom(){ + $reg_table = WP_LICENSE_MANAGER_REG_DOMAIN_TABLE_NAME; + global $wpdb; + $ret = $wpdb->query("DELETE FROM $reg_table WHERE id =" . $_GET['id']); + echo ($ret)? 'success' :'failed'; + exit(0); +} + +//Add the Admin Menus +define("LIC_MGR_MANAGEMENT_PERMISSION", "edit_themes"); +if (is_admin()) +{ + function wp_lic_mgr_add_admin_menu() + { + add_menu_page("License Mgr", "License Mgr", LIC_MGR_MANAGEMENT_PERMISSION, __FILE__, "wp_lic_mgr_manage_licenses_menu"); + add_submenu_page(__FILE__, "Manage Licenses", "Manage Licenses", LIC_MGR_MANAGEMENT_PERMISSION, __FILE__, "wp_lic_mgr_manage_licenses_menu"); + add_submenu_page(__FILE__, "Add/Edit Licenses", "Add/Edit Licenses", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_addedit', "wp_lic_mgr_add_licenses_menu"); + add_submenu_page(__FILE__, "Settings", "Settings", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_settings', "wp_lic_mgr_settings_menu"); + add_submenu_page(__FILE__, "Admin Functions", "Admin Functions", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_admin_fnc', "wp_lic_mgr_admin_fnc_menu"); + add_submenu_page(__FILE__, "Integration Help", "Integration Help", LIC_MGR_MANAGEMENT_PERMISSION, 'lic_mgr_integration_help_page', "lic_mgr_integration_help_menu"); + } + //Include menus + require_once(dirname(__FILE__).'/menu/lic_manage_licenses.php'); + require_once(dirname(__FILE__).'/menu/lic_add_licenses.php'); + require_once(dirname(__FILE__).'/menu/lic_settings.php'); + require_once(dirname(__FILE__).'/menu/wp_lic_mgr_admin_fnc.php'); + require_once(dirname(__FILE__).'/menu/lic_mgr_integration_help_page.php'); +} + +// Insert the options page to the admin menu +if (is_admin()) +{ + add_action('admin_menu','wp_lic_mgr_add_admin_menu'); +} diff --git a/license-manager/to-do.txt b/license-manager/to-do.txt new file mode 100644 index 0000000..03bc49c --- /dev/null +++ b/license-manager/to-do.txt @@ -0,0 +1,7 @@ + +//Add datepicker on the date fields in add/edit license interface +//Fix the date time columns so it can save just the "date" value (no time) +//Add more columns to the manage licenses interface +//Move the content of the "api" folder to a class and execute it from the front end of the site +//Convert CURL requests to WordPress's http query functions + diff --git a/license-manager/wp_license_manager.php b/license-manager/wp_license_manager.php index 9b27537..94b6333 100644 --- a/license-manager/wp_license_manager.php +++ b/license-manager/wp_license_manager.php @@ -2,13 +2,22 @@ /* Plugin Name: License Manager Version: v1.9 -Plugin URI: http://tipsandtricks-hq.com +Plugin URI: https://www.tipsandtricks-hq.com Author: Tips and Tricks HQ -Author URI: http://www.tipsandtricks-hq.com/ +Author URI: https://www.tipsandtricks-hq.com/ Description: Software license management solution for your web applications (WordPress plugins, Themes, PHP based membership script etc.) */ + +if(!defined('ABSPATH'))exit; //Exit if accessed directly + +//Short name/slug "SLM" or "slm" + define('WP_LICENSE_MANAGER_VERSION', "1.9"); -include_once('wp_license_manager1.php'); +define('WP_LICENSE_MANAGER_DB_VERSION', '1.2'); +define('WP_LICENSE_MANAGER_FOLDER', dirname(plugin_basename(__FILE__))); +define('WP_LICENSE_MANAGER_URL', plugins_url('',__FILE__)); + +include_once('slm_plugin_core.php'); //Installer function wp_lic_manager_install () diff --git a/license-manager/wp_license_manager1.php b/license-manager/wp_license_manager1.php deleted file mode 100644 index 845bcf3..0000000 --- a/license-manager/wp_license_manager1.php +++ /dev/null @@ -1,166 +0,0 @@ -prefix . "lic_key_tbl"); -define('WPLM_TBL_LIC_DOMAIN', $wpdb->prefix . "lic_reg_domain_tbl"); - -if (is_admin()){ //Load admin side only files - include_once('menu/includes/wp-license-mgr-list-table.php'); //Load our own WP List Table class -} - -add_action('init', 'wp_lic_mgr_init'); - -function wp_lic_mgr_init() -{ - //Load all common scripts and styles only - wp_enqueue_script('jquery'); - - if(is_admin())//Load all admin side scripts and styles only - { - wp_enqueue_script('jquery-ui-datepicker'); - - wp_enqueue_script('jquery-ui-core'); - wp_enqueue_script('jquery-ui-widget'); - wp_enqueue_script('jquery-ui-position'); - wp_enqueue_script('jquery-ui-mouse'); - wp_enqueue_script('jquery-ui-dialog'); - } -} - -function wp_lic_mgr_deactivate_lic($lic) -{ - // Post URL - $postURL = WP_LICENSE_MGR_LIC_DEACTIVATION_POST_URL; - // The Secret key - $secretKey = WP_LICENSE_MGR_LIC_SECRET_KEY; - // The License key - $licenseKey = $lic;//take this input from the user - $data = array (); - $data['secret_key'] = $secretKey; - $data['license_key'] = $licenseKey; - $data['registered_domain'] = $_SERVER['SERVER_NAME']; - - // send data to post URL - $ch = curl_init ($postURL); - curl_setopt ($ch, CURLOPT_POST, true); - curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); - $returnValue = curl_exec ($ch); - //print_r($returnValue); - list ($result, $msg, $additionalMsg) = explode ("\n", $returnValue); - $retData = array(); - $retData['result'] = $result; - $retData['msg'] = $msg; - $retData['additional_msg'] = $additionalMsg; - return $retData; -} - -function wp_lic_mgr_lic_verify($lic) -{ - // Post URL - $postURL = WP_LICENSE_MGR_LIC_ACTIVATION_POST_URL; - // The Secret key - $secretKey = WP_LICENSE_MGR_LIC_SECRET_KEY; - // The License key - $licenseKey = $lic; //take this input from the user - $data = array (); - $data['secret_key'] = $secretKey; - $data['license_key'] = $licenseKey; - $data['registered_domain'] = $_SERVER['SERVER_NAME']; - - // send data to post URL - $ch = curl_init ($postURL); - curl_setopt ($ch, CURLOPT_POST, true); - curl_setopt ($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); - $returnValue = curl_exec ($ch); - //print_r($returnValue); - list ($result, $msg, $additionalMsg) = explode ("\n", $returnValue); - $retData = array(); - $retData['result'] = $result; - $retData['msg'] = $msg; - $retData['additional_msg'] = $additionalMsg; - return $retData; -} -function wp_lic_mgr_is_license_valid() -{ - return true; - $is_valid = false; - $license_key = get_option('wp_lic_mgr_lic_key'); - if(!empty($license_key)) - { - $is_valid = true; - } - return $is_valid; -} - -function wp_lic_mgr_lic_warning() -{ - if(!wp_lic_mgr_is_license_valid()) - { - echo '
License Manager is almost ready. You must provide a valid License key here to make it work.
'; - } -} -add_action('admin_notices', 'wp_lic_mgr_lic_warning'); -/*** End! Everything to do with License verification, activation, deactivation ***/ - - -add_action('wp_ajax_del_dom', 'del_reg_dom'); -function del_reg_dom(){ - $reg_table = WP_LICENSE_MANAGER_REG_DOMAIN_TABLE_NAME; - global $wpdb; - $ret = $wpdb->query("DELETE FROM $reg_table WHERE id =" . $_GET['id']); - echo ($ret)? 'success' :'failed'; - exit(0); -} - -//Add the Admin Menus -define("LIC_MGR_MANAGEMENT_PERMISSION", "edit_themes"); -if (is_admin()) -{ - function wp_lic_mgr_add_admin_menu() - { - add_menu_page("License Mgr", "License Mgr", LIC_MGR_MANAGEMENT_PERMISSION, __FILE__, "wp_lic_mgr_manage_licenses_menu"); - add_submenu_page(__FILE__, "Manage Licenses", "Manage Licenses", LIC_MGR_MANAGEMENT_PERMISSION, __FILE__, "wp_lic_mgr_manage_licenses_menu"); - add_submenu_page(__FILE__, "Add/Edit Licenses", "Add/Edit Licenses", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_addedit', "wp_lic_mgr_add_licenses_menu"); - add_submenu_page(__FILE__, "Settings", "Settings", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_settings', "wp_lic_mgr_settings_menu"); - add_submenu_page(__FILE__, "Admin Functions", "Admin Functions", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_admin_fnc', "wp_lic_mgr_admin_fnc_menu"); - add_submenu_page(__FILE__, "Product License", "Product License", LIC_MGR_MANAGEMENT_PERMISSION, 'wp_lic_mgr_product_license', "wp_lic_mgr_product_license_menu"); - add_submenu_page(__FILE__, "Integration Help", "Integration Help", LIC_MGR_MANAGEMENT_PERMISSION, 'lic_mgr_integration_help_page', "lic_mgr_integration_help_menu"); - } - //Include menus - require_once(dirname(__FILE__).'/menu/lic_manage_licenses.php'); - require_once(dirname(__FILE__).'/menu/lic_add_licenses.php'); - require_once(dirname(__FILE__).'/menu/lic_settings.php'); - require_once(dirname(__FILE__).'/menu/wp_lic_mgr_admin_fnc.php'); - require_once(dirname(__FILE__).'/menu/product_license.php'); - require_once(dirname(__FILE__).'/menu/lic_mgr_integration_help_page.php'); -} - -// Insert the options page to the admin menu -if (is_admin()) -{ - add_action('admin_menu','wp_lic_mgr_add_admin_menu'); -} - -add_action('plugins_loaded','wp_lic_mgr_plugins_loaded_handler');//plugins loaded hook - -function wp_lic_mgr_plugins_loaded_handler() -{ - //Runs when plugins_loaded action gets fired - if(is_admin()){ - //Check if db update needed - if (get_option('wp_lic_mgr_db_version') != WP_LICENSE_MANAGER_DB_VERSION) { - require_once(dirname(__FILE__).'/lic_manager_installer.php'); - } - } -} \ No newline at end of file