mirror of
https://ghproxy.net/https://github.com/michelve/software-license-manager.git
synced 2025-10-04 02:06:37 +08:00
6.1.9
Enhanced security measures, optimized plugin functionality, and resolved minor bugs.
This commit is contained in:
parent
7c18a6ad54
commit
1ab8114235
42 changed files with 3954 additions and 5084 deletions
18
.gitignore
vendored
18
.gitignore
vendored
|
@ -6,4 +6,20 @@ package-lock.json
|
|||
.Icon
|
||||
/node_modules/
|
||||
/node_modules/*
|
||||
.vscode
|
||||
.vscode
|
||||
/samples/
|
||||
samples/LicenseAPI.php
|
||||
samples/LicenseAPI.php
|
||||
samples/GetLicenseInfo.php
|
||||
samples/DeactivateLicense.php
|
||||
samples/CreateLicense.php
|
||||
samples/CoreConfig.php
|
||||
samples/CheckLicense.php
|
||||
samples/LicenseAPI.php
|
||||
samples/GetLicenseInfo.php
|
||||
samples/DeactivateLicense.php
|
||||
samples/CreateLicense.php
|
||||
samples/CoreConfig.php
|
||||
samples/CheckLicense.php
|
||||
samples/GetLicenseInfo.php
|
||||
samples/DeactivateLicense.php
|
||||
|
|
|
@ -6,7 +6,7 @@ function slm_add_daily_cron_schedule($schedules) {
|
|||
// Define a daily interval (24 hours = 86400 seconds)
|
||||
$schedules['slm_daily'] = array(
|
||||
'interval' => 86400,
|
||||
'display' => __('Every 24 Hours', 'slmplus'),
|
||||
'display' => __('Every 24 Hours', 'slm-plus'),
|
||||
);
|
||||
return $schedules;
|
||||
}
|
||||
|
@ -86,8 +86,8 @@ add_action('admin_menu', 'slm_add_manual_license_check_page');
|
|||
function slm_add_manual_license_check_page() {
|
||||
add_submenu_page(
|
||||
'tools.php', // Parent slug, 'Tools' menu
|
||||
__('Run License Check', 'slmplus'), // Page title
|
||||
__('Run License Check', 'slmplus'), // Menu title
|
||||
__('Run License Check', 'slm-plus'), // Page title
|
||||
__('Run License Check', 'slm-plus'), // Menu title
|
||||
'manage_options', // Capability required
|
||||
'slm-manual-license-check', // Menu slug
|
||||
'slm_manual_license_check_page' // Callback function
|
||||
|
@ -110,23 +110,23 @@ function slm_manual_license_check_page() {
|
|||
$expired_licenses = slm_run_license_check();
|
||||
|
||||
if (!empty($expired_licenses)) {
|
||||
echo '<div class="updated"><p>' . __('License check completed. The following licenses have expired:', 'slmplus') . '</p></div>';
|
||||
echo '<div class="updated"><p>' . esc_html__('License check completed. The following licenses have expired:', 'slm-plus') . '</p></div>';
|
||||
} else {
|
||||
echo '<div class="updated"><p>' . __('License check completed. No expired licenses found.', 'slmplus') . '</p></div>';
|
||||
echo '<div class="updated"><p>' . esc_html__('License check completed. No expired licenses found.', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Display the button in the admin area
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2>' . __('Run License Check Manually', 'slmplus') . '</h2>';
|
||||
echo '<h2>' . esc_html__('Run License Check Manually', 'slm-plus') . '</h2>';
|
||||
echo '<form method="post">';
|
||||
wp_nonce_field('slm_manual_check_action', 'slm_manual_check_nonce');
|
||||
echo '<input type="submit" name="slm_manual_check" class="button-primary" value="' . __('Run License Check', 'slmplus') . '">';
|
||||
echo '<input type="submit" name="slm_manual_check" class="button-primary" value="' . esc_attr__('Run License Check', 'slm-plus') . '">';
|
||||
echo '</form>';
|
||||
|
||||
// Output expired licenses if available
|
||||
if (!empty($expired_licenses)) {
|
||||
echo '<h3>' . __('Expired Licenses:', 'slmplus') . '</h3>';
|
||||
echo '<h3>' . esc_html__('Expired Licenses:', 'slm-plus') . '</h3>';
|
||||
echo '<ul>';
|
||||
foreach ($expired_licenses as $license) {
|
||||
echo '<li>' . esc_html($license) . '</li>';
|
||||
|
|
|
@ -2,100 +2,100 @@
|
|||
<li class="stats total-licenses">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-admin-network"></span> </div>
|
||||
<div class="info"> <span class="badge"> <?php echo SLM_Utility::get_total_licenses(); ?></span></div>
|
||||
<div class="info"> <span class="badge"> <?php echo esc_html(SLM_Utility::get_total_licenses()); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Total licenses', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Total licenses', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats total-licenses weekly">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<div class="info"> <span class="badge"> <?php echo SLM_Utility::getstats_licenses('date_created', 7); ?></span></div>
|
||||
<div class="info"> <span class="badge"> <?php echo esc_html(SLM_Utility::getstats_licenses('date_created', 7)); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Licenses this week', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Licenses this week', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats total-licenses monthly">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<div class="info"> <span class="badge"> <?php echo SLM_Utility::getstats_licenses('date_created', 31); ?></span></div>
|
||||
<div class="info"> <span class="badge"> <?php echo esc_html(SLM_Utility::getstats_licenses('date_created', 31)); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Licenses this month', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Licenses this month', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats active-licenses">
|
||||
<div>
|
||||
<div class="icon"><span class="dashicons dashicons-yes-alt"></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('active'); ?> </span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_licenses('active')); ?> </span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Active licenses', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Active licenses', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats pending-licenses">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-warning"></span> </div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('pending '); ?></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_licenses('pending')); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Pending licenses', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Pending licenses', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats blocked-licenses">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-dismiss"></span> </div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('blocked '); ?></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_licenses('blocked')); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Blocked licenses', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Blocked licenses', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats logs">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-media-default"></span></span> </div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_logrequest(); ?></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_logrequest()); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Logs saved', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Logs saved', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats reminders">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-media-default"></span></span> </div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_emailsent(); ?></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_emailsent()); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Reminders sent', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Reminders sent', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats expired-licenses">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('expired'); ?></span></div>
|
||||
<div class="info"> <span class="badge"><?php echo esc_html(SLM_Utility::count_licenses('expired')); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Expired licenses', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Expired licenses', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li class="stats aboutoexpire">
|
||||
<div>
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<div class="info"> <span class="badge"> <?php echo SLM_Utility::get_lic_expiringsoon(); ?></span></div>
|
||||
<div class="info"> <span class="badge"> <?php echo esc_html(SLM_Utility::get_lic_expiringsoon()); ?></span></div>
|
||||
</div>
|
||||
<div class="description">
|
||||
<span><?php _e('Licenses about to expire', 'slmplus');?></span>
|
||||
<span><?php esc_html_e('Licenses about to expire', 'slm-plus'); ?></span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,287 +0,0 @@
|
|||
<?php
|
||||
|
||||
/* * ********************************* */
|
||||
/* * * WP eStore Plugin Integration ** */
|
||||
/* * ********************************* */
|
||||
add_filter('eStore_notification_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Standard sale notification email
|
||||
add_filter('eStore_squeeze_form_email_body_filter', 'slm_handle_estore_email_body_filter', 10, 3); //Squeeze form email
|
||||
|
||||
function slm_handle_estore_email_body_filter($body, $payment_data, $cart_items)
|
||||
{
|
||||
global $slm_debug_logger, $wpdb;
|
||||
$slm_debug_logger->log_debug("WP eStore integration - checking if a license key needs to be created for this transaction.");
|
||||
$products_table_name = $wpdb->prefix . "wp_eStore_tbl";
|
||||
$slm_data = "";
|
||||
|
||||
//Check if this is a recurring payment.
|
||||
if (function_exists('is_paypal_recurring_payment')) {
|
||||
$recurring_payment = is_paypal_recurring_payment($payment_data);
|
||||
if ($recurring_payment) {
|
||||
$slm_debug_logger->log_debug("This is a recurring payment. No need to create a new license key.");
|
||||
do_action('slm_estore_recurring_payment_received', $payment_data, $cart_items);
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($cart_items as $current_cart_item) {
|
||||
$prod_id = $current_cart_item['item_number'];
|
||||
$item_name = $current_cart_item['item_name'];
|
||||
$quantity = $current_cart_item['quantity'];
|
||||
if (empty($quantity)) {
|
||||
$quantity = 1;
|
||||
}
|
||||
$slm_debug_logger->log_debug('License Manager - Item Number: ' . $prod_id . ', Quantity: ' . $quantity . ', Item Name: ' . $item_name);
|
||||
|
||||
$retrieved_product = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$prod_id'", OBJECT);
|
||||
$package_product = eStore_is_package_product($retrieved_product);
|
||||
if ($package_product) {
|
||||
$slm_debug_logger->log_debug('Checking license key generation for package/bundle product.');
|
||||
$product_ids = explode(',', $retrieved_product->product_download_url);
|
||||
foreach ($product_ids as $id) {
|
||||
$id = trim($id);
|
||||
$retrieved_product_for_specific_id = $wpdb->get_row("SELECT * FROM $products_table_name WHERE id = '$id'", OBJECT);
|
||||
//$slm_data .= slm_estore_check_and_generate_key($retrieved_product_for_specific_id, $payment_data, $cart_items, $item_name);
|
||||
$slm_data .= slm_estore_check_and_create_key_for_qty($retrieved_product_for_specific_id, $payment_data, $cart_items, $item_name, $quantity);
|
||||
}
|
||||
} else {
|
||||
$slm_debug_logger->log_debug('Checking license key generation for single item product.');
|
||||
$slm_data .= slm_estore_check_and_create_key_for_qty($retrieved_product, $payment_data, $cart_items, $item_name, $quantity);
|
||||
}
|
||||
}
|
||||
|
||||
$body = str_replace("{slm_data}", $slm_data, $body);
|
||||
return $body;
|
||||
}
|
||||
|
||||
function slm_estore_check_and_create_key_for_qty($retrieved_product, $payment_data, $cart_items, $item_name, $quantity)
|
||||
{
|
||||
$prod_key_data = "";
|
||||
for ($i = 0; $i < $quantity; $i++) {
|
||||
$prod_key_data .= slm_estore_check_and_generate_key($retrieved_product, $payment_data, $cart_items, $item_name);
|
||||
}
|
||||
return $prod_key_data;
|
||||
}
|
||||
|
||||
function slm_estore_check_and_generate_key($retrieved_product, $payment_data, $cart_items, $item_name)
|
||||
{
|
||||
global $slm_debug_logger;
|
||||
$license_data = '';
|
||||
|
||||
if ($retrieved_product->create_license == 1) {
|
||||
$slm_debug_logger->log_debug('Need to create a license key for this product (' . $retrieved_product->id . ')');
|
||||
$slm_key = slm_estore_create_license($retrieved_product, $payment_data, $cart_items, $item_name);
|
||||
$license_data = "\n" . __('Item Name: ', 'slm') . $retrieved_product->name . " - " . __('License Key: ', 'slm') . $slm_key;
|
||||
$slm_debug_logger->log_debug('Liense data: ' . $license_data);
|
||||
$license_data = apply_filters('slm_estore_item_license_data', $license_data);
|
||||
}
|
||||
return $license_data;
|
||||
}
|
||||
|
||||
function slm_estore_create_license($retrieved_product, $payment_data, $cart_items, $item_name)
|
||||
{
|
||||
global $slm_debug_logger;
|
||||
global $wpdb;
|
||||
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
|
||||
|
||||
//Retrieve the default settings values.
|
||||
$options = get_option('slm_plugin_options');
|
||||
$lic_key_prefix = $options['lic_prefix'];
|
||||
$max_domains = $options['default_max_domains'];
|
||||
|
||||
//Lets check any product specific configuration.
|
||||
$prod_id = $retrieved_product->id;
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
|
||||
if ($product_meta) {
|
||||
//Found product specific SLM config data.
|
||||
$max_domains = $product_meta->meta_value;
|
||||
} else {
|
||||
//Use the default value from settings (the $max_domains variable contains the default value already).
|
||||
}
|
||||
//Lets check if any product specific expiry date is set
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
|
||||
if ($product_meta) {
|
||||
//Found product specific SLM config data.
|
||||
$num_days_before_expiry = $product_meta->meta_value;
|
||||
$slm_date_of_expiry = wp_date('Y-m-d', strtotime('+' . $num_days_before_expiry . ' days'));
|
||||
} else {
|
||||
//Use the default value (1 year from today).
|
||||
$current_date_plus_1year = wp_date('Y-m-d', strtotime('+1 year'));
|
||||
$slm_date_of_expiry = $current_date_plus_1year;
|
||||
}
|
||||
|
||||
|
||||
$fields = array();
|
||||
$fields['license_key'] = uniqid($lic_key_prefix);
|
||||
$fields['lic_status'] = 'pending';
|
||||
$fields['first_name'] = $payment_data['first_name'];
|
||||
$fields['last_name'] = $payment_data['last_name'];
|
||||
$fields['email'] = $payment_data['payer_email'];
|
||||
$fields['company_name'] = $payment_data['company_name'];
|
||||
$fields['txn_id'] = $payment_data['txn_id'];
|
||||
$fields['max_allowed_domains'] = $max_domains;
|
||||
$fields['date_created'] = wp_date("Y-m-d"); //Today's date
|
||||
$fields['date_expiry'] = $slm_date_of_expiry;
|
||||
$fields['product_ref'] = $prod_id; //WP eStore product ID
|
||||
$fields['subscr_id'] = isset($payment_data['subscr_id']) ? $payment_data['subscr_id'] : '';
|
||||
|
||||
$slm_debug_logger->log_debug('Inserting license data into the license manager DB table.');
|
||||
$fields = array_filter($fields); //Remove any null values.
|
||||
|
||||
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$result = $wpdb->insert($slm_lic_table, $fields);
|
||||
if (!$result) {
|
||||
$slm_debug_logger->log_debug('Notice! initial database table insert failed on license key table (User Email: ' . $fields['email'] . '). Trying again by converting charset', true);
|
||||
//Convert the default PayPal IPN charset to UTF-8 format
|
||||
$first_name = mb_convert_encoding($fields['first_name'], "UTF-8", "windows-1252");
|
||||
$fields['first_name'] = esc_sql($first_name);
|
||||
$last_name = mb_convert_encoding($fields['last_name'], "UTF-8", "windows-1252");
|
||||
$fields['last_name'] = esc_sql($last_name);
|
||||
$company_name = mb_convert_encoding($fields['company_name'], "UTF-8", "windows-1252");
|
||||
$fields['company_name'] = esc_sql($company_name);
|
||||
|
||||
$result = $wpdb->insert($slm_lic_table, $fields);
|
||||
if (!$result) {
|
||||
$slm_debug_logger->log_debug('Error! Failed to update license key table. DB insert query failed.', false);
|
||||
}
|
||||
}
|
||||
//SLM_API_Utility::insert_license_data_internal($fields);
|
||||
|
||||
$prod_args = array('estore_prod_id' => $prod_id, 'estore_item_name' => $item_name);
|
||||
do_action('slm_estore_license_created', $prod_args, $payment_data, $cart_items, $fields);
|
||||
|
||||
return $fields['license_key'];
|
||||
}
|
||||
|
||||
/* Code to handle the eStore's product add/edit interface for SLM specific product configuration */
|
||||
add_filter('eStore_addon_product_settings_filter', 'slm_estore_product_configuration_html', 10, 2); //Render the product add/edit HTML
|
||||
add_action('eStore_new_product_added', 'slm_estore_new_product_added', 10, 2); //Handle the DB insert after a product add.
|
||||
add_action('eStore_product_updated', 'slm_estore_product_updated', 10, 2); //Handle the DB update after a product edit.
|
||||
add_action('eStore_product_deleted', 'slm_estore_product_deleted'); //Handle the DB delete after a product delete.
|
||||
|
||||
function slm_estore_product_configuration_html($product_config_html, $prod_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
|
||||
|
||||
if (empty($prod_id)) {
|
||||
//New product add
|
||||
$slm_max_allowed_domains = "";
|
||||
$slm_date_of_expiry = "";
|
||||
} else {
|
||||
//Existing product edit
|
||||
|
||||
//Retrieve the max domain value
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
|
||||
if ($product_meta) {
|
||||
$slm_max_allowed_domains = $product_meta->meta_value;
|
||||
} else {
|
||||
$slm_max_allowed_domains = "";
|
||||
}
|
||||
|
||||
//Retrieve the expiry date value
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
|
||||
if ($product_meta) {
|
||||
$slm_date_of_expiry = $product_meta->meta_value;
|
||||
} else {
|
||||
$slm_date_of_expiry = "";
|
||||
}
|
||||
}
|
||||
|
||||
$product_config_html .= '<div class="msg_head">SLM Plus Plugin (Click to Expand)</div><div class="msg_body"><table class="form-table">';
|
||||
|
||||
$product_config_html .= '<tr valign="top"><th scope="row">Maximum Allowed Domains</th><td>';
|
||||
$product_config_html .= '<input name="slm_max_allowed_domains" type="text" id="slm_max_allowed_domains" value="' . $slm_max_allowed_domains . '" size="10" />';
|
||||
$product_config_html .= '<p class="description">Number of domains/installs in which this license can be used. Leave blank if you wish to use the default value set in the license manager plugin settings.</p>';
|
||||
$product_config_html .= '</td></tr>';
|
||||
|
||||
$product_config_html .= '<tr valign="top"><th scope="row">Number of Days before Expiry</th><td>';
|
||||
$product_config_html .= '<input name="slm_date_of_expiry" type="text" id="slm_date_of_expiry" value="' . $slm_date_of_expiry . '" size="10" /> Days';
|
||||
$product_config_html .= '<p class="description">Number of days before expiry. The expiry date of the license will be set based on this value. For example, if you want the key to expire in 6 months then enter a value of 180.</p>';
|
||||
$product_config_html .= '</td></tr>';
|
||||
|
||||
$product_config_html .= '</table></div>';
|
||||
|
||||
return $product_config_html;
|
||||
}
|
||||
|
||||
function slm_estore_new_product_added($prod_dat_array, $prod_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
|
||||
|
||||
//Save max domain value
|
||||
$fields = array();
|
||||
$fields['prod_id'] = $prod_id;
|
||||
$fields['meta_key'] = 'slm_max_allowed_domains';
|
||||
$fields['meta_value'] = $prod_dat_array['slm_max_allowed_domains'];
|
||||
$result = $wpdb->insert($product_meta_table_name, $fields);
|
||||
if (!$result) {
|
||||
//insert query failed
|
||||
}
|
||||
|
||||
//Save expiry date value
|
||||
$fields = array();
|
||||
$fields['prod_id'] = $prod_id;
|
||||
$fields['meta_key'] = 'slm_date_of_expiry';
|
||||
$fields['meta_value'] = $prod_dat_array['slm_date_of_expiry'];
|
||||
$result = $wpdb->insert($product_meta_table_name, $fields);
|
||||
if (!$result) {
|
||||
//insert query failed
|
||||
}
|
||||
}
|
||||
|
||||
function slm_estore_product_updated($prod_dat_array, $prod_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
|
||||
|
||||
//Find the existing value for the max domains field (for the given product)
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_max_allowed_domains'", OBJECT);
|
||||
if ($product_meta) {
|
||||
//Found existing value so lets update it
|
||||
//Better to do specific update (so the other meta values for example "download_limit_count" doesn't get set to empty).
|
||||
$meta_key_name = "slm_max_allowed_domains";
|
||||
$meta_value = $prod_dat_array['slm_max_allowed_domains'];
|
||||
$update_db_qry = "UPDATE $product_meta_table_name SET meta_value='$meta_value' WHERE prod_id='$prod_id' AND meta_key='$meta_key_name'";
|
||||
$results = $wpdb->query($update_db_qry);
|
||||
} else {
|
||||
//No value for this field was there so lets insert one.
|
||||
$fields = array();
|
||||
$fields['prod_id'] = $prod_id;
|
||||
$fields['meta_key'] = 'slm_max_allowed_domains';
|
||||
$fields['meta_value'] = $prod_dat_array['slm_max_allowed_domains'];
|
||||
$result = $wpdb->insert($product_meta_table_name, $fields);
|
||||
}
|
||||
|
||||
//Find the existing value for the expiry date field (for the given product)
|
||||
$product_meta = $wpdb->get_row("SELECT * FROM $product_meta_table_name WHERE prod_id = '$prod_id' AND meta_key='slm_date_of_expiry'", OBJECT);
|
||||
if ($product_meta) {
|
||||
//Found existing value so lets update it
|
||||
//Better to do specific update (so the other meta values for example "download_limit_count" doesn't get set to empty).
|
||||
$meta_key_name = "slm_date_of_expiry";
|
||||
$meta_value = $prod_dat_array['slm_date_of_expiry'];
|
||||
$update_db_qry = "UPDATE $product_meta_table_name SET meta_value='$meta_value' WHERE prod_id='$prod_id' AND meta_key='$meta_key_name'";
|
||||
$results = $wpdb->query($update_db_qry);
|
||||
} else {
|
||||
//No value for this field was there so lets insert one.
|
||||
$fields = array();
|
||||
$fields['prod_id'] = $prod_id;
|
||||
$fields['meta_key'] = 'slm_date_of_expiry';
|
||||
$fields['meta_value'] = $prod_dat_array['slm_date_of_expiry'];
|
||||
$result = $wpdb->insert($product_meta_table_name, $fields);
|
||||
}
|
||||
}
|
||||
|
||||
function slm_estore_product_deleted($prod_id)
|
||||
{
|
||||
global $wpdb;
|
||||
$product_meta_table_name = WP_ESTORE_PRODUCTS_META_TABLE_NAME;
|
||||
|
||||
$result = $wpdb->delete($product_meta_table_name, array('prod_id' => $prod_id, 'meta_key' => 'slm_max_allowed_domains'));
|
||||
$result = $wpdb->delete($product_meta_table_name, array('prod_id' => $prod_id, 'meta_key' => 'slm_date_of_expiry'));
|
||||
}
|
||||
|
||||
/************************************/
|
||||
/*** End of WP eStore integration ***/
|
||||
/************************************/
|
|
@ -13,49 +13,49 @@ function slm_about_menu()
|
|||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="wp-heading-inline">
|
||||
<?php esc_html_e('SLM - About', 'slmplus'); ?>
|
||||
<?php esc_html_e('SLM - About', 'slm-plus'); ?>
|
||||
</h1>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div id="post-body-content">
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><?php esc_html_e('Credits and Authors', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Credits and Authors', 'slm-plus'); ?></h2>
|
||||
<div class="inside">
|
||||
<p><?php esc_html_e('SLM is a comprehensive software license management solution for your web applications, supporting WordPress plugins, themes, applications, and WooCommerce.', 'slmplus'); ?></p>
|
||||
<p><?php esc_html_e('SLM is a comprehensive software license management solution for your web applications, supporting WordPress plugins, themes, applications, and WooCommerce.', 'slm-plus'); ?></p>
|
||||
<table class="widefat fixed striped slm-about-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Information', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('Details', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('Information', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Details', 'slm-plus'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?php esc_html_e('Authors', 'slmplus'); ?></td>
|
||||
<td><?php esc_html_e('Authors', 'slm-plus'); ?></td>
|
||||
<td>
|
||||
<a href="https://github.com/michelve/software-license-manager" target="_blank" rel="noopener noreferrer">
|
||||
Michel Velis
|
||||
</a>
|
||||
<?php esc_html_e('and', 'slmplus'); ?>
|
||||
<?php esc_html_e('and', 'slm-plus'); ?>
|
||||
<a href="https://github.com/Arsenal21/software-license-manager" target="_blank" rel="noopener noreferrer">
|
||||
tipsandtricks
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php esc_html_e('Help and Support', 'slmplus'); ?></td>
|
||||
<td><?php esc_html_e('Help and Support', 'slm-plus'); ?></td>
|
||||
<td>
|
||||
<a href="https://github.com/michelve/software-license-manager/issues" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e('Submit a request', 'slmplus'); ?>
|
||||
<?php esc_html_e('Submit a request', 'slm-plus'); ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php esc_html_e('API Demos', 'slmplus'); ?></td>
|
||||
<td><?php esc_html_e('API Demos', 'slm-plus'); ?></td>
|
||||
<td>
|
||||
<a href="https://documenter.getpostman.com/view/307939/6tjU1FL?version=latest" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e('Postman Demos', 'slmplus'); ?>
|
||||
<?php esc_html_e('Postman Demos', 'slm-plus'); ?>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
//slm_add_licenses_menu
|
||||
|
||||
function slm_add_licenses_menu()
|
||||
{
|
||||
global $wpdb;
|
||||
|
@ -8,7 +6,9 @@ function slm_add_licenses_menu()
|
|||
$slm_wp_date_format = get_option('date_format');
|
||||
$lic_status_table = SLM_TBL_LICENSE_STATUS;
|
||||
|
||||
$id = !empty($_GET['edit_record']) ? intval($_GET['edit_record']) : 0; // Check for 'edit_record' parameter in the URL
|
||||
// Get the 'edit_record' parameter from the URL and sanitize it
|
||||
$id = !empty($_GET['edit_record']) ? intval(sanitize_text_field(wp_unslash($_GET['edit_record']))) : 0;
|
||||
|
||||
$slm_options = get_option('slm_options');
|
||||
|
||||
// Set initial variables for slm_billing_length and slm_billing_interval
|
||||
|
@ -19,85 +19,127 @@ function slm_add_licenses_menu()
|
|||
$date_created = date_i18n($slm_wp_date_format, strtotime('now'));
|
||||
$date_expiry = date_i18n($slm_wp_date_format, strtotime("+$slm_billing_length $slm_billing_interval"));
|
||||
|
||||
|
||||
//Get the active tab from the $_GET param
|
||||
// Get the active tab from the $_GET param
|
||||
$slm_lic_default_tab = null;
|
||||
$slm_lic_tab = isset($_GET['slm_tab']) ? $_GET['slm_tab'] : $slm_lic_default_tab;
|
||||
$slm_lic_tab = isset($_GET['slm_tab']) ? sanitize_text_field(wp_unslash($_GET['slm_tab'])) : $slm_lic_default_tab;
|
||||
|
||||
// Check if the form is submitted
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['slm_save_license'])) {
|
||||
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['slm_save_license'])) {
|
||||
// Verify the nonce before processing the form
|
||||
if (!isset($_POST['slm_nonce']) || !wp_verify_nonce($_POST['slm_nonce'], 'slm_save_license')) {
|
||||
die(__('Security check failed', 'slmplus'));
|
||||
if (empty($_POST['slm_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['slm_nonce'])), 'slm_save_license')) {
|
||||
die(esc_html__('Security check failed', 'slm-plus'));
|
||||
}
|
||||
|
||||
// Sanitize and validate the input data
|
||||
$data = [
|
||||
'license_key' => sanitize_text_field($_POST['license_key']),
|
||||
'max_allowed_domains' => intval($_POST['max_allowed_domains']),
|
||||
'max_allowed_devices' => intval($_POST['max_allowed_devices']),
|
||||
'lic_status' => sanitize_text_field($_POST['lic_status']),
|
||||
'first_name' => sanitize_text_field($_POST['first_name']),
|
||||
'last_name' => sanitize_text_field($_POST['last_name']),
|
||||
'email' => is_email($_POST['email']) ? sanitize_email($_POST['email']) : '',
|
||||
'company_name' => sanitize_text_field($_POST['company_name']),
|
||||
'txn_id' => sanitize_text_field($_POST['txn_id']),
|
||||
'manual_reset_count' => intval($_POST['manual_reset_count']),
|
||||
'purchase_id_' => sanitize_text_field($_POST['purchase_id_']),
|
||||
'date_created' => isset($_POST['date_created']) ? SLM_API_Utility::slm_validate_date($_POST['date_created']) : date_i18n('Y-m-d'), // Default to today's date if not set
|
||||
'date_renewed' => SLM_API_Utility::slm_validate_date($_POST['date_renewed']),
|
||||
'date_activated' => SLM_API_Utility::slm_validate_date($_POST['date_activated']),
|
||||
'product_ref' => sanitize_text_field($_POST['product_ref']),
|
||||
'until' => sanitize_text_field($_POST['until']),
|
||||
'current_ver' => sanitize_text_field($_POST['current_ver']),
|
||||
'subscr_id' => sanitize_text_field($_POST['subscr_id']),
|
||||
'lic_type' => sanitize_text_field($_POST['lic_type']),
|
||||
'date_expiry' => ($_POST['lic_type'] === 'lifetime') ? date('Y-m-d', strtotime('+200 years')) : SLM_API_Utility::slm_validate_date($_POST['date_expiry']),
|
||||
'item_reference' => sanitize_text_field($_POST['item_reference']),
|
||||
'slm_billing_length' => sanitize_text_field($_POST['slm_billing_length']),
|
||||
'slm_billing_interval' => sanitize_text_field($_POST['slm_billing_interval']),
|
||||
'reminder_sent' => intval($_POST['reminder_sent']),
|
||||
'reminder_sent_date' => SLM_API_Utility::slm_validate_date($_POST['reminder_sent_date']),
|
||||
'license_key' => isset($_POST['license_key']) ? sanitize_text_field(wp_unslash($_POST['license_key'])) : '',
|
||||
'max_allowed_domains' => isset($_POST['max_allowed_domains']) ? intval(wp_unslash($_POST['max_allowed_domains'])) : 0,
|
||||
'max_allowed_devices' => isset($_POST['max_allowed_devices']) ? intval(wp_unslash($_POST['max_allowed_devices'])) : 0,
|
||||
'lic_status' => isset($_POST['lic_status']) ? sanitize_text_field(wp_unslash($_POST['lic_status'])) : '',
|
||||
'first_name' => isset($_POST['first_name']) ? sanitize_text_field(wp_unslash($_POST['first_name'])) : '',
|
||||
'last_name' => isset($_POST['last_name']) ? sanitize_text_field(wp_unslash($_POST['last_name'])) : '',
|
||||
'email' => isset($_POST['email']) && is_email(wp_unslash($_POST['email'])) ? sanitize_email(wp_unslash($_POST['email'])) : '', // Ensure unslash before sanitization
|
||||
'company_name' => isset($_POST['company_name']) ? sanitize_text_field(wp_unslash($_POST['company_name'])) : '',
|
||||
'txn_id' => isset($_POST['txn_id']) ? sanitize_text_field(wp_unslash($_POST['txn_id'])) : '',
|
||||
'manual_reset_count' => isset($_POST['manual_reset_count']) ? intval(wp_unslash($_POST['manual_reset_count'])) : 0,
|
||||
'purchase_id_' => isset($_POST['purchase_id_']) ? sanitize_text_field(wp_unslash($_POST['purchase_id_'])) : '',
|
||||
'date_created' => isset($_POST['date_created']) ? SLM_API_Utility::slm_validate_date(sanitize_text_field(wp_unslash($_POST['date_created']))) : date_i18n('Y-m-d'), // Default to today's date if not set
|
||||
'date_renewed' => isset($_POST['date_renewed']) ? SLM_API_Utility::slm_validate_date(sanitize_text_field(wp_unslash($_POST['date_renewed']))) : '',
|
||||
'date_activated' => isset($_POST['date_activated']) ? SLM_API_Utility::slm_validate_date(sanitize_text_field(wp_unslash($_POST['date_activated']))) : '',
|
||||
'product_ref' => isset($_POST['product_ref']) ? sanitize_text_field(wp_unslash($_POST['product_ref'])) : '',
|
||||
'until' => isset($_POST['until']) ? sanitize_text_field(wp_unslash($_POST['until'])) : '',
|
||||
'current_ver' => isset($_POST['current_ver']) ? sanitize_text_field(wp_unslash($_POST['current_ver'])) : '',
|
||||
'subscr_id' => isset($_POST['subscr_id']) ? sanitize_text_field(wp_unslash($_POST['subscr_id'])) : '',
|
||||
'lic_type' => isset($_POST['lic_type']) ? sanitize_text_field(wp_unslash($_POST['lic_type'])) : '',
|
||||
'date_expiry' => isset($_POST['lic_type']) && $_POST['lic_type'] === 'lifetime' ? gmdate('Y-m-d', strtotime('+200 years')) : (isset($_POST['date_expiry']) ? SLM_API_Utility::slm_validate_date(sanitize_text_field(wp_unslash($_POST['date_expiry']))) : ''),
|
||||
'item_reference' => isset($_POST['item_reference']) ? sanitize_text_field(wp_unslash($_POST['item_reference'])) : '',
|
||||
'slm_billing_length' => isset($_POST['slm_billing_length']) ? sanitize_text_field(wp_unslash($_POST['slm_billing_length'])) : '',
|
||||
'slm_billing_interval' => isset($_POST['slm_billing_interval']) ? sanitize_text_field(wp_unslash($_POST['slm_billing_interval'])) : '',
|
||||
'reminder_sent' => isset($_POST['reminder_sent']) ? intval(wp_unslash($_POST['reminder_sent'])) : 0,
|
||||
'reminder_sent_date' => isset($_POST['reminder_sent_date']) ? SLM_API_Utility::slm_validate_date(sanitize_text_field(wp_unslash($_POST['reminder_sent_date']))) : '',
|
||||
];
|
||||
|
||||
// Check for required fields
|
||||
if (empty($data['email']) || empty($data['date_created']) || ($data['lic_type'] !== 'lifetime' && empty($data['date_expiry'])) || empty($data['lic_type'])) {
|
||||
echo '<div class="notice notice-error"><p>' . __('Required fields are missing.', 'slmplus') . '</p></div>';
|
||||
echo '<div class="notice notice-error"><p>' . esc_html__('Required fields are missing.', 'slm-plus') . '</p></div>';
|
||||
} else {
|
||||
// Insert or update the data in the database
|
||||
if ($id) {
|
||||
$wpdb->update(SLM_TBL_LICENSE_KEYS, $data, ['id' => $id]);
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . __('License updated successfully.', 'slmplus') . '</p></div>';
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__('License updated successfully.', 'slm-plus') . '</p></div>';
|
||||
} else {
|
||||
$wpdb->insert(SLM_TBL_LICENSE_KEYS, $data);
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . __('License created successfully.', 'slmplus') . '</p>';
|
||||
echo '<a href="?page=slm_manage_license&edit_record=' . esc_attr($wpdb->insert_id) . '" class="button">' . __('View License', 'slmplus') . '</a></p></div>';
|
||||
echo '<div class="notice notice-success is-dismissible"><p>' . esc_html__('License created successfully.', 'slm-plus') . '</p>';
|
||||
echo '<a href="?page=slm_manage_license&edit_record=' . esc_attr($wpdb->insert_id) . '" class="button">' . esc_html__('View License', 'slm-plus') . '</a></p></div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// If editing, load existing data
|
||||
if ($id) {
|
||||
$license = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE id = %d", $id));
|
||||
// Sanitize the $id to make sure it's an integer
|
||||
$id = intval($id);
|
||||
|
||||
// Define the table name as a constant
|
||||
$table_name = SLM_TBL_LICENSE_KEYS;
|
||||
|
||||
// Use $wpdb->prepare() for the actual query with a placeholder for the ID
|
||||
$query = $wpdb->prepare(
|
||||
"SELECT * FROM {$table_name} WHERE id = %d", // Use %d for the integer placeholder
|
||||
$id
|
||||
);
|
||||
|
||||
// Get the result using the prepared query
|
||||
$license = $wpdb->get_row($query);
|
||||
|
||||
if ($license) {
|
||||
$data = (array) $license;
|
||||
} else {
|
||||
// If the license is not found, reset to create a new record
|
||||
$data = [
|
||||
'license_key' => '',
|
||||
'max_allowed_domains' => SLM_DEFAULT_MAX_DOMAINS,
|
||||
'max_allowed_devices' => SLM_DEFAULT_MAX_DEVICES,
|
||||
'lic_status' => 'pending',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'email' => '',
|
||||
'company_name' => '',
|
||||
'txn_id' => '',
|
||||
'purchase_id_' => '',
|
||||
'date_created' => date_i18n($slm_wp_date_format, strtotime('now')),
|
||||
'date_renewed' => '',
|
||||
'date_activated' => '',
|
||||
'product_ref' => '',
|
||||
'until' => '',
|
||||
'current_ver' => '',
|
||||
'subscr_id' => '',
|
||||
'lic_type' => 'subscription',
|
||||
'date_expiry' => $date_expiry, // Set a default expiry
|
||||
'item_reference' => '',
|
||||
'slm_billing_length' => $slm_billing_length,
|
||||
'slm_billing_interval' => $slm_billing_interval,
|
||||
'reminder_sent' => '0',
|
||||
'manual_reset_count' => '',
|
||||
'reminder_sent_date' => '0000-00-00'
|
||||
];
|
||||
|
||||
// Add error message that license key wasn't found
|
||||
echo '<div class="notice notice-error"><p>' . esc_html__('License key not found. Please create a new license.', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
} else {
|
||||
|
||||
// Prepare empty data for new record
|
||||
// Prepare empty data for a new record
|
||||
$data = [
|
||||
'license_key' => '',
|
||||
'max_allowed_domains' => SLM_DEFAULT_MAX_DOMAINS,
|
||||
'max_allowed_devices' => SLM_DEFAULT_MAX_DEVICES,
|
||||
'lic_status' => 'pending', // Default value
|
||||
'lic_status' => 'pending',
|
||||
'first_name' => '',
|
||||
'last_name' => '',
|
||||
'email' => '',
|
||||
'company_name' => '',
|
||||
'txn_id' => '',
|
||||
'manual_reset_count' => '',
|
||||
'purchase_id_' => '',
|
||||
'date_created' => date_i18n($slm_wp_date_format, strtotime('now')), // Use WP date format
|
||||
'date_created' => date_i18n($slm_wp_date_format, strtotime('now')),
|
||||
'date_renewed' => '',
|
||||
'date_activated' => '',
|
||||
'product_ref' => '',
|
||||
|
@ -105,47 +147,48 @@ function slm_add_licenses_menu()
|
|||
'current_ver' => '',
|
||||
'subscr_id' => '',
|
||||
'lic_type' => 'subscription',
|
||||
'date_expiry' => $date_expiry, // Calculated expiration date
|
||||
'date_expiry' => $date_expiry,
|
||||
'item_reference' => '',
|
||||
'slm_billing_length' => $slm_billing_length,
|
||||
'slm_billing_interval' => $slm_billing_interval,
|
||||
'reminder_sent' => '0',
|
||||
'manual_reset_count' => '',
|
||||
'reminder_sent_date' => '0000-00-00'
|
||||
];
|
||||
|
||||
// Generate a license key if it's a new record
|
||||
if (!isset($editing_record)) {
|
||||
$editing_record = new stdClass();
|
||||
}
|
||||
|
||||
// Generate a license key for new records
|
||||
$data['license_key'] = slm_get_license(KEY_API_PREFIX);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php _e('SLM Plus - License Management', 'slmplus'); ?></h1>
|
||||
<h1><?php esc_html_e('SLM Plus - License Management', 'slm-plus'); ?></h1>
|
||||
|
||||
<div class="slm_ajax_msg"></div>
|
||||
|
||||
<?php
|
||||
$edit_record = isset($_GET['edit_record']) ? sanitize_text_field(wp_unslash($_GET['edit_record'])) : '';
|
||||
?>
|
||||
<nav class="slm nav-tab-wrapper">
|
||||
<a href="?page=slm_manage_license<?php echo isset($_GET['edit_record']) ? '&slm_tab=default&edit_record=' . esc_attr($_GET['edit_record']) : ''; ?>" class="nav-tab <?php if ($slm_lic_tab === null): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php _e('License Information', 'slmplus'); ?>
|
||||
<a href="?page=slm_manage_license<?php echo $edit_record ? '&slm_tab=default&edit_record=' . esc_attr($edit_record) : ''; ?>" class="nav-tab <?php if ($slm_lic_tab === null): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php esc_html_e('License Information', 'slm-plus'); ?>
|
||||
</a>
|
||||
<?php if (isset($_GET['edit_record'])): ?>
|
||||
<a href="?page=slm_manage_license&slm_tab=activation<?php echo isset($_GET['edit_record']) ? '&edit_record=' . esc_attr($_GET['edit_record']) : ''; ?>" class="nav-tab <?php if ($slm_lic_tab === 'activation'): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php _e('Activations', 'slmplus'); ?>
|
||||
<?php if ($edit_record): ?>
|
||||
<a href="?page=slm_manage_license&slm_tab=activation<?php echo '&edit_record=' . esc_attr($edit_record); ?>" class="nav-tab <?php if ($slm_lic_tab === 'activation'): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php esc_html_e('Activations', 'slm-plus'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if (isset($_GET['edit_record'])): ?>
|
||||
<a href="?page=slm_manage_license&slm_tab=activity<?php echo isset($_GET['edit_record']) ? '&edit_record=' . esc_attr($_GET['edit_record']) : ''; ?>" class="nav-tab <?php if ($slm_lic_tab === 'activity'): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php _e('Activity', 'slmplus'); ?>
|
||||
<?php if ($edit_record): ?>
|
||||
<a href="?page=slm_manage_license&slm_tab=activity<?php echo '&edit_record=' . esc_attr($edit_record); ?>" class="nav-tab <?php if ($slm_lic_tab === 'activity'): ?>nav-tab-active<?php endif; ?>">
|
||||
<?php esc_html_e('Activity', 'slm-plus'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
|
||||
|
||||
<div class="slm tab-content">
|
||||
<?php switch ($slm_lic_tab):
|
||||
<?php switch ($slm_lic_tab):
|
||||
|
||||
case 'activity': ?>
|
||||
|
||||
|
@ -156,42 +199,41 @@ function slm_add_licenses_menu()
|
|||
// Fetch the log data using a utility function to handle the database query
|
||||
$log_entries = SLM_Helper_Class::get_license_logs($license_key);
|
||||
|
||||
// Display the log table if there are any log entries
|
||||
if ($log_entries) {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Activity Log', 'slmplus'); ?></h2>
|
||||
<table class="widefat striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e('ID', 'slmplus'); ?></th>
|
||||
<th><?php _e('Action', 'slmplus'); ?></th>
|
||||
<th><?php _e('Time', 'slmplus'); ?></th>
|
||||
<th><?php _e('Source', 'slmplus'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($log_entries as $entry): ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html($entry['id']); ?></td>
|
||||
<td><?php echo esc_html($entry['slm_action']); ?></td>
|
||||
<td><?php echo esc_html($entry['time']); ?></td>
|
||||
<td><?php echo esc_html($entry['source']); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
// Show a message if there are no log entries
|
||||
echo '<p>' . __('No activity log found for this license.', 'slmplus') . '</p>';
|
||||
}
|
||||
// Display the log table if there are any log entries
|
||||
if ($log_entries) {
|
||||
?>
|
||||
|
||||
<?php
|
||||
break;
|
||||
<div class="wrap">
|
||||
<h2><?php esc_html_e('Activity Log', 'slm-plus'); ?></h2>
|
||||
<table class="widefat striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('ID', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Action', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Time', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Source', 'slm-plus'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($log_entries as $entry): ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html($entry['id']); ?></td>
|
||||
<td><?php echo esc_html($entry['slm_action']); ?></td>
|
||||
<td><?php echo esc_html($entry['time']); ?></td>
|
||||
<td><?php echo esc_html($entry['source']); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
} else {
|
||||
// Show a message if there are no log entries
|
||||
echo '<p>' . esc_html__('No activity log found for this license.', 'slm-plus') . '</p>';
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
break;
|
||||
case 'activation': ?>
|
||||
|
||||
<?php
|
||||
|
@ -200,92 +242,92 @@ function slm_add_licenses_menu()
|
|||
global $wpdb;
|
||||
|
||||
$license_key = esc_attr($data['license_key']);
|
||||
|
||||
|
||||
// Fetch the max_allowed_domains and max_allowed_devices from the license key table
|
||||
$license_info = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT max_allowed_domains, max_allowed_devices FROM " . SLM_TBL_LICENSE_KEYS . " WHERE license_key = %s",
|
||||
$license_key
|
||||
));
|
||||
|
||||
|
||||
// Ensure the max values are retrieved and set them to default values if not found
|
||||
$max_domains = isset($license_info->max_allowed_domains) ? intval($license_info->max_allowed_domains) : 0;
|
||||
$max_devices = isset($license_info->max_allowed_devices) ? intval($license_info->max_allowed_devices) : 0;
|
||||
|
||||
|
||||
// Fetch the current number of registered domains for this license key
|
||||
$registered_domains = $wpdb->get_var($wpdb->prepare(
|
||||
"SELECT COUNT(*) FROM " . SLM_TBL_LIC_DOMAIN . " WHERE lic_key = %s",
|
||||
$license_key
|
||||
));
|
||||
|
||||
|
||||
// Fetch the current number of registered devices for this license key
|
||||
$registered_devices = $wpdb->get_var($wpdb->prepare(
|
||||
"SELECT COUNT(*) FROM " . SLM_TBL_LIC_DEVICES . " WHERE lic_key = %s",
|
||||
$license_key
|
||||
));
|
||||
|
||||
|
||||
// Ensure the count values are integers
|
||||
$registered_domains = isset($registered_domains) ? intval($registered_domains) : 0;
|
||||
$registered_devices = isset($registered_devices) ? intval($registered_devices) : 0;
|
||||
|
||||
|
||||
// Calculate how many domains and devices are left
|
||||
$domains_left = $max_domains - $registered_domains;
|
||||
$devices_left = $max_devices - $registered_devices;
|
||||
|
||||
|
||||
// Ensure the result is not negative (to handle edge cases)
|
||||
$domains_left = max(0, $domains_left);
|
||||
$devices_left = max(0, $devices_left);
|
||||
|
||||
|
||||
// Fetch all registered domains for this license key
|
||||
$registered_domains_data = $wpdb->get_results($wpdb->prepare(
|
||||
"SELECT id, registered_domain FROM " . SLM_TBL_LIC_DOMAIN . " WHERE lic_key = %s",
|
||||
$license_key
|
||||
));
|
||||
|
||||
|
||||
// Fetch all registered devices for this license key
|
||||
$registered_devices_data = $wpdb->get_results($wpdb->prepare(
|
||||
"SELECT id, registered_devices FROM " . SLM_TBL_LIC_DEVICES . " WHERE lic_key = %s",
|
||||
$license_key
|
||||
));
|
||||
|
||||
|
||||
$slm_ajax_uri ='';
|
||||
|
||||
$slm_ajax_uri = '';
|
||||
$slm_deactivate_nonce = wp_create_nonce('slmplus_delete_activation_nonce');
|
||||
|
||||
// Render the table
|
||||
?>
|
||||
?>
|
||||
|
||||
<div class="wrap">
|
||||
<h2><?php _e('Activation', 'slmplus'); ?></h2>
|
||||
<h2><?php esc_html_e('Activation', 'slm-plus'); ?></h2>
|
||||
<p>
|
||||
<strong><?php _e('Domains Left', 'slmplus'); ?>:</strong> <?php echo esc_html($domains_left); ?><br>
|
||||
<strong><?php _e('Devices Left', 'slmplus'); ?>:</strong> <?php echo esc_html($devices_left); ?>
|
||||
</p>
|
||||
<strong><?php esc_html_e('Domains Left', 'slm-plus'); ?>:</strong> <?php echo esc_html($domains_left); ?><br>
|
||||
<strong><?php esc_html_e('Devices Left', 'slm-plus'); ?>:</strong> <?php echo esc_html($devices_left); ?>
|
||||
</p>
|
||||
|
||||
<table class="wp-list-table widefat fixed striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e('ID', 'slmplus'); ?></th>
|
||||
<th><?php _e('License Key', 'slmplus'); ?></th>
|
||||
<th><?php _e('Type', 'slmplus'); ?></th>
|
||||
<th><?php _e('Origin', 'slmplus'); ?></th> <!-- New column for Origin -->
|
||||
<th><?php _e('Action', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('ID', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('License Key', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Type', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Origin', 'slm-plus'); ?></th> <!-- New column for Origin -->
|
||||
<th><?php esc_html_e('Action', 'slm-plus'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if ($registered_domains_data): ?>
|
||||
<?php foreach ($registered_domains_data as $domain_entry): ?>
|
||||
<?php
|
||||
$slm_ajax_uri = esc_url(home_url('/')).'?slm_action=slm_deactivate&secret_key=' . VERIFY_KEY_API .'&license_key='.esc_html($license_key).'®istered_domain='. esc_html($domain_entry->registered_domain);
|
||||
$slm_ajax_uri = esc_url(home_url('/')) . '?slm_action=slm_deactivate&secret_key=' . VERIFY_KEY_API . '&license_key=' . esc_html($license_key) . '®istered_domain=' . esc_html($domain_entry->registered_domain);
|
||||
?>
|
||||
<tr id="activation-row-<?php echo esc_attr($domain_entry->id); ?>" class="lic-entry-<?php echo esc_attr($domain_entry->id); ?>">
|
||||
<td><?php echo esc_html($domain_entry->id); ?></td>
|
||||
<td><?php echo esc_html($license_key); ?></td>
|
||||
<td><?php _e('Domain', 'slmplus'); ?></td>
|
||||
<td><?php esc_html_e('Domain', 'slm-plus'); ?></td>
|
||||
<td><?php echo esc_html($domain_entry->registered_domain); ?></td> <!-- Display Domain Origin here -->
|
||||
<td>
|
||||
<button class="button deactivate_registration" data-activation_type="domain" data-id="<?php echo esc_attr($domain_entry->id); ?>" data-device="<?php echo esc_attr($domain_entry->registered_domain); ?>" data-table="registered_domain" data-ajax_uri="<?php echo $slm_ajax_uri; ?>" data-nonce="<?php echo esc_attr($slm_deactivate_nonce); ?>">
|
||||
<?php _e('Remove', 'slmplus'); ?>
|
||||
</button>
|
||||
<button class="button deactivate_registration" data-activation_type="domain" data-id="<?php echo esc_attr($domain_entry->id); ?>" data-device="<?php echo esc_attr($domain_entry->registered_domain); ?>" data-table="registered_domain" data-ajax_uri="<?php echo esc_url($slm_ajax_uri); ?>" data-nonce="<?php echo esc_attr($slm_deactivate_nonce); ?>">
|
||||
<?php esc_html_e('Remove', 'slm-plus'); ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
@ -294,27 +336,28 @@ function slm_add_licenses_menu()
|
|||
<?php if ($registered_devices_data): ?>
|
||||
<?php foreach ($registered_devices_data as $device_entry): ?>
|
||||
<?php
|
||||
$slm_ajax_uri = esc_url(home_url('/')).'?slm_action=slm_deactivate&secret_key=' . VERIFY_KEY_API .'&license_key='.esc_html($license_key).'®istered_devices='. esc_html($device_entry->registered_devices);
|
||||
$slm_ajax_uri = esc_url(home_url('/')) . '?slm_action=slm_deactivate&secret_key=' . VERIFY_KEY_API . '&license_key=' . esc_html($license_key) . '®istered_devices=' . esc_html($device_entry->registered_devices);
|
||||
?>
|
||||
|
||||
<tr id="activation-row-<?php echo esc_attr($device_entry->id); ?>" class="lic-entry-<?php echo esc_attr($device_entry->id); ?>">
|
||||
<td><?php echo esc_html($device_entry->id); ?></td>
|
||||
<td><?php echo esc_html($license_key); ?></td>
|
||||
<td><?php _e('Device', 'slmplus'); ?></td>
|
||||
<td><?php esc_html_e('Device', 'slm-plus'); ?></td>
|
||||
<td><?php echo esc_html($device_entry->registered_devices); ?></td> <!-- Display Device Origin here -->
|
||||
<td>
|
||||
|
||||
|
||||
<button class="button deactivate_registration" data-activation_type="device" data-id="<?php echo esc_attr($device_entry->id); ?>" data-device="<?php echo esc_attr($device_entry->registered_devices); ?>" data-table="registered_devices" data-ajax_uri="<?php echo $slm_ajax_uri; ?>" data-nonce="<?php echo esc_attr($slm_deactivate_nonce); ?>">
|
||||
<?php _e('Remove', 'slmplus'); ?>
|
||||
</button>
|
||||
<button class="button deactivate_registration" data-activation_type="device" data-id="<?php echo esc_attr($device_entry->id); ?>" data-device="<?php echo esc_attr($device_entry->registered_devices); ?>" data-table="registered_devices" data-ajax_uri="<?php echo esc_url($slm_ajax_uri); ?>" data-nonce="<?php echo esc_attr($slm_deactivate_nonce); ?>">
|
||||
<?php esc_html_e('Remove', 'slm-plus'); ?>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$registered_domains_data && !$registered_devices_data): ?>
|
||||
<tr><td colspan="5"><?php _e('No activations found', 'slmplus'); ?></td></tr>
|
||||
<tr>
|
||||
<td colspan="5"><?php esc_html_e('No activations found', 'slm-plus'); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -346,12 +389,12 @@ function slm_add_licenses_menu()
|
|||
_wpnonce: nonce // Include the nonce in the request
|
||||
}, function(response) {
|
||||
////console.log(response); // Debugging to ensure we're getting the response
|
||||
|
||||
|
||||
// Handle success response
|
||||
if (response.result === 'success') {
|
||||
// Show WordPress-style success message
|
||||
$('.slm_ajax_msg').html('<div class="notice notice-success is-dismissible"><p>' + response.message + '</p></div>');
|
||||
|
||||
|
||||
// Remove the entire row or element containing the button
|
||||
$button.closest('tr').remove(); // Adjust the selector to the parent element of the row or item you want to remove
|
||||
} else {
|
||||
|
@ -364,18 +407,17 @@ function slm_add_licenses_menu()
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
// Register AJAX handler for deleting activations (without page reload)
|
||||
add_action('wp_ajax_delete_activation', function() {
|
||||
add_action('wp_ajax_delete_activation', function () {
|
||||
// Security check
|
||||
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'slmplus_delete_activation_nonce')) {
|
||||
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce(wp_unslash($_POST['_wpnonce']), 'slmplus_delete_activation_nonce')) {
|
||||
wp_send_json_error([
|
||||
'result' => 'error',
|
||||
'message' => __('Nonce verification failed.', 'slmplus'),
|
||||
'message' => __('Nonce verification failed.', 'slm-plus'),
|
||||
'error_code' => 401
|
||||
]);
|
||||
}
|
||||
|
@ -383,16 +425,15 @@ function slm_add_licenses_menu()
|
|||
global $wpdb;
|
||||
|
||||
// Check if the activation ID and type are provided and valid
|
||||
if (!isset($_POST['activation_id']) || !is_numeric($_POST['activation_id']) || !isset($_POST['activation_type'])) {
|
||||
if (!isset($_POST['activation_id']) || !is_numeric(wp_unslash($_POST['activation_id'])) || !isset($_POST['activation_type']) || empty($_POST['activation_type'])) {
|
||||
wp_send_json_error([
|
||||
'result' => 'error',
|
||||
'message' => __('Invalid activation data.', 'slmplus'),
|
||||
'message' => __('Invalid activation data.', 'slm-plus'),
|
||||
'error_code' => 400
|
||||
]);
|
||||
}
|
||||
|
||||
$activation_id = intval($_POST['activation_id']);
|
||||
$activation_type = sanitize_text_field($_POST['activation_type']);
|
||||
$activation_id = isset($_POST['activation_id']) ? intval(wp_unslash($_POST['activation_id'])) : 0;
|
||||
$activation_type = isset($_POST['activation_type']) ? sanitize_text_field(wp_unslash($_POST['activation_type'])) : '';
|
||||
|
||||
// Delete the activation from the correct table
|
||||
if ($activation_type === 'domain') {
|
||||
|
@ -402,7 +443,7 @@ function slm_add_licenses_menu()
|
|||
} else {
|
||||
wp_send_json_error([
|
||||
'result' => 'error',
|
||||
'message' => __('Invalid activation type.', 'slmplus'),
|
||||
'message' => __('Invalid activation type.', 'slm-plus'),
|
||||
'error_code' => 400
|
||||
]);
|
||||
}
|
||||
|
@ -411,13 +452,13 @@ function slm_add_licenses_menu()
|
|||
if ($result !== false) {
|
||||
wp_send_json_success([
|
||||
'result' => 'success',
|
||||
'message' => __('The license key has been deactivated for this domain.', 'slmplus'),
|
||||
'message' => __('The license key has been deactivated for this domain.', 'slm-plus'),
|
||||
'error_code' => 360
|
||||
]);
|
||||
} else {
|
||||
wp_send_json_error([
|
||||
'result' => 'error',
|
||||
'message' => __('Error deleting activation.', 'slmplus'),
|
||||
'message' => __('Error deleting activation.', 'slm-plus'),
|
||||
'error_code' => 500
|
||||
]);
|
||||
}
|
||||
|
@ -425,42 +466,42 @@ function slm_add_licenses_menu()
|
|||
?>
|
||||
|
||||
<?php
|
||||
break;
|
||||
break;
|
||||
default: ?>
|
||||
<form method="post" action="" id="slm_license_form">
|
||||
<form method="post" action="" id="slm_license_form">
|
||||
<?php wp_nonce_field('slm_save_license', 'slm_nonce'); ?>
|
||||
<?php if ($id) : ?>
|
||||
<input name="edit_record" type="hidden" value="<?php echo esc_attr($id); ?>" />
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- Subscriber Information Section -->
|
||||
<h2 class="hndle"><?php esc_html_e('Subscriber Information', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Subscriber Information', 'slm-plus'); ?></h2>
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="first_name"><?php _e('First Name', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<th scope="row"><label for="first_name"><?php esc_html_e('First Name', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td>
|
||||
<input name="first_name" type="text" id="first_name" value="<?php echo isset($data['first_name']) ? esc_attr($data['first_name']) : ''; ?>" class="regular-text user-search-input" required autocomplete="off" />
|
||||
<div class="user-search-suggestions wp-core-ui" data-field="first_name"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="last_name"><?php _e('Last Name', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<th scope="row"><label for="last_name"><?php esc_html_e('Last Name', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td>
|
||||
<input name="last_name" type="text" id="last_name" value="<?php echo isset($data['last_name']) ? esc_attr($data['last_name']) : ''; ?>" class="regular-text user-search-input" required autocomplete="off" />
|
||||
<div class="user-search-suggestions wp-core-ui" data-field="last_name"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="email"><?php _e('Email', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<th scope="row"><label for="email"><?php esc_html_e('Email', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td>
|
||||
<input name="email" type="email" id="email" value="<?php echo isset($data['email']) ? esc_attr($data['email']) : ''; ?>" class="regular-text user-search-input" required autocomplete="off" />
|
||||
<div class="user-search-suggestions wp-core-ui" data-field="email"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="company_name"><?php _e('Company Name', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="company_name"><?php esc_html_e('Company Name', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<input name="company_name" type="text" id="company_name" value="<?php echo isset($data['company_name']) ? esc_attr($data['company_name']) : ''; ?>" class="regular-text" />
|
||||
</td>
|
||||
|
@ -473,116 +514,136 @@ function slm_add_licenses_menu()
|
|||
|
||||
|
||||
|
||||
<h2 class="hndle"><?php esc_html_e('License Information', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('License Information', 'slm-plus'); ?></h2>
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<label for="license_key"><?php _e('License Key', 'slmplus'); ?></label>
|
||||
<label for="license_key"><?php esc_html_e('License Key', 'slm-plus'); ?></label>
|
||||
</th>
|
||||
<td>
|
||||
<input name="license_key" type="text" id="license_key" value="<?php echo esc_attr($data['license_key']); ?>" class="regular-text"
|
||||
<input name="license_key" type="text" id="license_key" value="<?php echo esc_attr($data['license_key']); ?>" class="regular-text"
|
||||
<?php if (isset($_GET['edit']) || !empty($id)): ?>readonly<?php endif; ?> />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="max_allowed_domains"><?php _e('Max Allowed Domains', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="max_allowed_domains"><?php esc_html_e('Max Allowed Domains', 'slm-plus'); ?></label></th>
|
||||
<td><input name="max_allowed_domains" type="number" id="max_allowed_domains" value="<?php echo esc_attr($data['max_allowed_domains']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="max_allowed_devices"><?php _e('Max Allowed Devices', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="max_allowed_devices"><?php esc_html_e('Max Allowed Devices', 'slm-plus'); ?></label></th>
|
||||
<td><input name="max_allowed_devices" type="number" id="max_allowed_devices" value="<?php echo esc_attr($data['max_allowed_devices']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="lic_status"><?php _e('License Status', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="lic_status"><?php esc_html_e('License Status', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<?php
|
||||
// Fetch all status records
|
||||
$statuses = $wpdb->get_results("SELECT status_key, status_label FROM $lic_status_table ", ARRAY_A);
|
||||
|
||||
$lic_status_table = esc_sql($lic_status_table);
|
||||
|
||||
// Now prepare the query with placeholders for values, not the table name.
|
||||
$query = "SELECT status_key, status_label FROM $lic_status_table"; // No placeholders needed for table name
|
||||
$statuses = $wpdb->get_results($query, ARRAY_A);
|
||||
|
||||
// Create the <select> element
|
||||
echo '<select name="lic_status" id="lic_status" class="regular-text">';
|
||||
foreach ($statuses as $status) {
|
||||
// Set the selected attribute if the current status matches
|
||||
$selected = selected($data['lic_status'], $status['status_key'], false);
|
||||
echo '<option value="' . esc_attr($status['status_key']) . '"' . $selected . '>' . esc_html($status['status_label']) . '</option>';
|
||||
echo '<option value="' . esc_attr($status['status_key']) . '" ' . esc_attr($selected) . '>' . esc_html($status['status_label']) . '</option>';
|
||||
}
|
||||
echo '</select>';
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="date_created"><?php _e('Date Created', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td><input name="date_created" type="date" id="date_created" value="<?php echo esc_attr($data['date_created']); ?>" <?php if (isset($_GET['edit']) || !empty($id)): ?>readonly<?php endif; ?> class="regular-text datepicker" required/>
|
||||
<p class="description" id="new-admin-email-description"><?php printf(__('Display Format: %s (input: YYYY-MM-DD)', 'slmplus'), $slm_wp_date_format); ?></p>
|
||||
<th scope="row"><label for="date_created"><?php esc_html_e('Date Created', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td><input name="date_created" type="date" id="date_created" value="<?php echo esc_attr($data['date_created']); ?>" <?php if (isset($_GET['edit']) || !empty($id)): ?>readonly<?php endif; ?> class="regular-text datepicker" required />
|
||||
<p class="description" id="new-admin-email-description">
|
||||
<?php
|
||||
// Translators: %s is the date format used for input
|
||||
printf(esc_html__('Display Format: %s (input: YYYY-MM-DD)', 'slm-plus'), esc_html($slm_wp_date_format));
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="lic_type"><?php _e('License Type', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<th scope="row"><label for="lic_type"><?php esc_html_e('License Type', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td>
|
||||
<select name="lic_type" id="lic_type" class="regular-text" required>
|
||||
<option value="subscription" <?php selected($data['lic_type'], 'subscription'); ?>><?php _e('Subscription', 'slmplus'); ?></option>
|
||||
<option value="lifetime" <?php selected($data['lic_type'], 'lifetime'); ?>><?php _e('Lifetime', 'slmplus'); ?></option>
|
||||
<option value="subscription" <?php selected($data['lic_type'], 'subscription'); ?>><?php esc_html_e('Subscription', 'slm-plus'); ?></option>
|
||||
<option value="lifetime" <?php selected($data['lic_type'], 'lifetime'); ?>><?php esc_html_e('Lifetime', 'slm-plus'); ?></option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="date_expiry"><?php _e('Expiration Date', 'slmplus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<th scope="row"><label for="date_expiry"><?php esc_html_e('Expiration Date', 'slm-plus'); ?> <span style="color: red;">*</span></label></th>
|
||||
<td><input name="date_expiry" type="date" id="date_expiry" value="<?php echo esc_attr($data['date_expiry']); ?>" class="regular-text datepicker" required />
|
||||
<p class="description" id="new-admin-email-description"><?php printf(__('Selecting a future date will automatically adjust the renewal term.<br>Choose this date to set when the license should renew or expire. <br>Format: %s (input: YYYY-MM-DD).', 'slmplus'), $slm_wp_date_format); ?></p>
|
||||
<p class="description" id="new-admin-email-description">
|
||||
<?php
|
||||
// Translators: %s is the date format for input
|
||||
printf(esc_html__('Selecting a future date will automatically adjust the renewal term.<br>Choose this date to set when the license should renew or expire. <br>Format: %s (input: YYYY-MM-DD).', 'slm-plus'), esc_html($slm_wp_date_format));
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php _e('Renewal', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label><?php esc_html_e('Renewal', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<div style="display: flex; gap: 10px; width: 350px;">
|
||||
<div style="width: 50%;">
|
||||
<label for="slm_billing_length" style="font-weight: bold; display: block; margin-bottom: 5px;"><?php _e('Billing Length', 'slmplus'); ?></label>
|
||||
<label for="slm_billing_length" style="font-weight: bold; display: block; margin-bottom: 5px;"><?php esc_html_e('Billing Length', 'slm-plus'); ?></label>
|
||||
<input name="slm_billing_length" type="text" id="slm_billing_length" value="<?php echo esc_attr($data['slm_billing_length']); ?>" class="regular-text" style="width: 100%;" />
|
||||
<p class="description" id="billing_length_description" style="margin-top: 5px; font-size: 12px; line-height: 1.2;">
|
||||
<?php _e('Sets how often the license renews. E.g., a length of 2 with a term of years means the license renews every 2 years.','slmplus'); ?>
|
||||
<?php esc_html_e('Sets how often the license renews. E.g., a length of 2 with a term of years means the license renews every 2 years.', 'slm-plus'); ?>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="width: 50%;">
|
||||
<label for="slm_billing_interval" style="font-weight: bold; display: block; margin-bottom: 5px;"><?php _e('Expiration Term', 'slmplus'); ?></label>
|
||||
<label for="slm_billing_interval" style="font-weight: bold; display: block; margin-bottom: 5px;"><?php esc_html_e('Expiration Term', 'slm-plus'); ?></label>
|
||||
<select name="slm_billing_interval" id="slm_billing_interval" class="regular-text" style="width: 100%;">
|
||||
<option value="days" <?php selected($data['slm_billing_interval'], 'days'); ?>><?php _e('Day(s)', 'slmplus'); ?></option>
|
||||
<option value="months" <?php selected($data['slm_billing_interval'], 'months'); ?>><?php _e('Month(s)', 'slmplus'); ?></option>
|
||||
<option value="years" <?php selected($data['slm_billing_interval'], 'years'); ?>><?php _e('Year(s)', 'slmplus'); ?></option>
|
||||
<option value="days" <?php selected($data['slm_billing_interval'], 'days'); ?>><?php esc_html_e('Day(s)', 'slm-plus'); ?></option>
|
||||
<option value="months" <?php selected($data['slm_billing_interval'], 'months'); ?>><?php esc_html_e('Month(s)', 'slm-plus'); ?></option>
|
||||
<option value="years" <?php selected($data['slm_billing_interval'], 'years'); ?>><?php esc_html_e('Year(s)', 'slm-plus'); ?></option>
|
||||
</select>
|
||||
<p class="description" id="expiration_term_description" style="margin-top: 5px; font-size: 12px; line-height: 1.2;">
|
||||
<?php _e('Choose the renewal period: days, months, or years.','slmplus'); ?>
|
||||
<?php esc_html_e('Choose the renewal period: days, months, or years.', 'slm-plus'); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="subscr_id"><?php _e('Subscriber ID', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="subscr_id"><?php esc_html_e('Subscriber ID', 'slm-plus'); ?></label></th>
|
||||
<td><input name="subscr_id" type="text" id="subscr_id" value="<?php echo esc_attr($data['subscr_id']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="date_renewed"><?php _e('Date Renewed', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="date_renewed"><?php esc_html_e('Date Renewed', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<input name="date_renewed" type="date" id="date_renewed"
|
||||
value="<?php echo ($data['date_renewed'] === '0000-00-00' || empty($data['date_renewed'])) ? '' : esc_attr($data['date_renewed']); ?>"
|
||||
<input name="date_renewed" type="date" id="date_renewed"
|
||||
value="<?php echo ($data['date_renewed'] === '0000-00-00' || empty($data['date_renewed'])) ? '' : esc_attr($data['date_renewed']); ?>"
|
||||
class="regular-text datepicker" />
|
||||
<p class="description" id="new-admin-email-description">
|
||||
<?php printf(__('Display Format: %s (input: YYYY-MM-DD)', 'slmplus'), $slm_wp_date_format); ?>
|
||||
<?php
|
||||
// Translators: %s is the date format for input (e.g., YYYY-MM-DD)
|
||||
printf(esc_html__('Display Format: %s (input: YYYY-MM-DD)', 'slm-plus'), esc_html($slm_wp_date_format));
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="date_activated"><?php _e('Date Activated', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="date_activated"><?php esc_html_e('Date Activated', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<input name="date_activated" type="date" id="date_activated"
|
||||
value="<?php echo ($data['date_activated'] === '0000-00-00' || empty($data['date_activated'])) ? '' : esc_attr($data['date_activated']); ?>"
|
||||
<input name="date_activated" type="date" id="date_activated"
|
||||
value="<?php echo ($data['date_activated'] === '0000-00-00' || empty($data['date_activated'])) ? '' : esc_attr($data['date_activated']); ?>"
|
||||
class="regular-text datepicker" />
|
||||
<p class="description" id="new-admin-email-description">
|
||||
<?php printf(__('Display Format: %s (input: YYYY-MM-DD)', 'slmplus'), $slm_wp_date_format); ?>
|
||||
<?php
|
||||
// Translators: %s is the date format for input (e.g., YYYY-MM-DD)
|
||||
printf(esc_html__('Display Format: %s (input: YYYY-MM-DD)', 'slm-plus'), esc_html($slm_wp_date_format));
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -590,28 +651,28 @@ function slm_add_licenses_menu()
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="hndle"><?php esc_html_e('Transaction Information', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Transaction Information', 'slm-plus'); ?></h2>
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="item_reference"><?php _e('Item Reference', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="item_reference"><?php esc_html_e('Item Reference', 'slm-plus'); ?></label></th>
|
||||
<td><input name="item_reference" type="text" id="item_reference" value="<?php echo esc_attr($data['item_reference']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="txn_id"><?php _e('Transaction ID', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="txn_id"><?php esc_html_e('Transaction ID', 'slm-plus'); ?></label></th>
|
||||
<td><input name="txn_id" type="text" id="txn_id" value="<?php echo esc_attr($data['txn_id']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="purchase_id_"><?php _e('Purchase ID', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="purchase_id_"><?php esc_html_e('Purchase ID', 'slm-plus'); ?></label></th>
|
||||
<td><input name="purchase_id_" type="text" id="purchase_id_" value="<?php echo esc_attr($data['purchase_id_']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="product_ref"><?php _e('Product Reference', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="product_ref"><?php esc_html_e('Product Reference', 'slm-plus'); ?></label></th>
|
||||
<td><input name="product_ref" type="text" id="product_ref" value="<?php echo esc_attr($data['product_ref']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
|
||||
|
@ -619,36 +680,39 @@ function slm_add_licenses_menu()
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<h2 class="hndle"><?php esc_html_e('Other', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Other', 'slm-plus'); ?></h2>
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label for="until"><?php _e('Until', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="until"><?php esc_html_e('Until', 'slm-plus'); ?></label></th>
|
||||
<td><input name="until" type="text" id="until" value="<?php echo esc_attr($data['until']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="current_ver"><?php _e('Current Version', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="current_ver"><?php esc_html_e('Current Version', 'slm-plus'); ?></label></th>
|
||||
<td><input name="current_ver" type="text" id="current_ver" value="<?php echo esc_attr($data['current_ver']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="reminder_sent"><?php _e('Reminder Sent', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="reminder_sent"><?php esc_html_e('Reminder Sent', 'slm-plus'); ?></label></th>
|
||||
<td><input name="reminder_sent" type="text" id="reminder_sent" value="<?php echo esc_attr($data['reminder_sent']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="reminder_sent_date"><?php _e('Reminder Sent Date', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="reminder_sent_date"><?php esc_html_e('Reminder Sent Date', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<input name="reminder_sent_date" type="date" id="reminder_sent_date"
|
||||
value="<?php echo ($data['reminder_sent_date'] === '0000-00-00') ? '' : esc_attr($data['reminder_sent_date']); ?>"
|
||||
class="regular-text datepicker"
|
||||
<input name="reminder_sent_date" type="date" id="reminder_sent_date"
|
||||
value="<?php echo ($data['reminder_sent_date'] === '0000-00-00') ? '' : esc_attr($data['reminder_sent_date']); ?>"
|
||||
class="regular-text datepicker"
|
||||
placeholder="YYYY-MM-DD" />
|
||||
<p class="description" id="new-admin-email-description">
|
||||
<?php printf(__('Display Format: %s (input: YYYY-MM-DD)', 'slmplus'), $slm_wp_date_format); ?>
|
||||
<?php
|
||||
// Translators: %s is the date format used for input (e.g., YYYY-MM-DD)
|
||||
printf(esc_html__('Display Format: %s (input: YYYY-MM-DD)', 'slm-plus'), esc_html($slm_wp_date_format));
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label for="manual_reset_count"><?php _e('Manual Reset Count', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="manual_reset_count"><?php esc_html_e('Manual Reset Count', 'slm-plus'); ?></label></th>
|
||||
<td><input name="manual_reset_count" type="number" id="manual_reset_count" value="<?php echo esc_attr($data['manual_reset_count']); ?>" class="regular-text" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -656,9 +720,9 @@ function slm_add_licenses_menu()
|
|||
</div>
|
||||
<?php
|
||||
if (isset($_GET['edit_record']) && !empty($_GET['edit_record'])) : ?>
|
||||
<?php submit_button(__('Update License', 'slmplus'), 'primary', 'slm_save_license'); ?>
|
||||
<?php submit_button(esc_html__('Update License', 'slm-plus'), 'primary', 'slm_save_license'); ?>
|
||||
<?php else: ?>
|
||||
<?php submit_button(__('Create License', 'slmplus'), 'primary', 'slm_save_license'); ?>
|
||||
<?php submit_button(esc_html__('Create License', 'slm-plus'), 'primary', 'slm_save_license'); ?>
|
||||
<?php endif; ?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
@ -666,13 +730,16 @@ function slm_add_licenses_menu()
|
|||
|
||||
form.addEventListener('submit', function(event) {
|
||||
// Scroll to the top immediately
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||
window.scrollTo({
|
||||
top: 0,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</form>
|
||||
<?php
|
||||
break;
|
||||
<?php
|
||||
break;
|
||||
endswitch; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,77 +7,184 @@ if (!defined('WPINC')) {
|
|||
function slm_admin_tools_menu()
|
||||
{
|
||||
if (isset($_POST['slm_backup_db'])) {
|
||||
slm_save_backup_to_uploads();
|
||||
// Verify the nonce
|
||||
if (isset($_POST['slm_backup_nonce_field']) && wp_verify_nonce($_POST['slm_backup_nonce_field'], 'slm_backup_nonce_action')) {
|
||||
// Nonce is valid, proceed with backup
|
||||
SLM_Utility::slm_save_backup_to_uploads();
|
||||
} else {
|
||||
// Nonce is invalid or missing
|
||||
die('Security check failed.'); // You can display an error message or handle it as needed
|
||||
}
|
||||
}
|
||||
|
||||
echo '<div class="wrap">';
|
||||
echo '<h2 class="imgh2">'. __('SLM Plus - Tools', 'slmplus') . '</h2>';
|
||||
echo '<h2 class="imgh2">' . esc_html__('SLM Plus - Tools', 'slm-plus') . '</h2>';
|
||||
echo '<div id="poststuff"><div id="post-body">';
|
||||
|
||||
if (isset($_POST['send_deactivation_request'])) {
|
||||
$postURL = esc_url_raw($_POST['slm_deactivation_req_url']);
|
||||
$secretKeyForVerification = slm_get_option('lic_verification_secret');
|
||||
$data = array('secret_key' => $secretKeyForVerification);
|
||||
// Verify the nonce
|
||||
if (isset($_POST['slm_deactivation_nonce_field']) && wp_verify_nonce($_POST['slm_deactivation_nonce_field'], 'slm_deactivation_nonce_action')) {
|
||||
// Nonce is valid, proceed with the deactivation request
|
||||
|
||||
$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);
|
||||
$postURL = esc_url_raw($_POST['slm_deactivation_req_url']);
|
||||
$secretKeyForVerification = slm_get_option('lic_verification_secret');
|
||||
$data = array('secret_key' => $secretKeyForVerification);
|
||||
|
||||
$msg = "";
|
||||
if ($returnValue == "Success") {
|
||||
$msg .= __('Success message returned from the remote host.', 'slmplus');
|
||||
// Make the POST request using wp_remote_post
|
||||
$response = wp_remote_post($postURL, array(
|
||||
'method' => 'POST',
|
||||
'body' => $data,
|
||||
'timeout' => 15, // Optional timeout value
|
||||
'headers' => array('Content-Type' => 'application/x-www-form-urlencoded')
|
||||
));
|
||||
|
||||
// Check for errors in the response
|
||||
if (is_wp_error($response)) {
|
||||
$error_message = $response->get_error_message();
|
||||
$msg = esc_html__('Request failed: ', 'slm-plus') . esc_html($error_message);
|
||||
} else {
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
|
||||
// Check for success message in response
|
||||
if ($body == "Success") {
|
||||
$msg = esc_html__('Success message returned from the remote host.', 'slm-plus');
|
||||
} else {
|
||||
$msg = esc_html__('Unexpected response: ', 'slm-plus') . esc_html($body);
|
||||
}
|
||||
}
|
||||
|
||||
// Display message
|
||||
echo '<div id="message" class="updated fade"><p>';
|
||||
echo esc_html__('Request sent to the specified URL!', 'slm-plus');
|
||||
echo '<br />' . esc_html($msg);
|
||||
echo '</p></div>';
|
||||
} else {
|
||||
// Nonce is invalid or missing
|
||||
echo '<div id="message" class="error fade"><p>' . esc_html__('Security check failed. Invalid nonce.', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
echo '<div id="message" class="updated fade"><p>';
|
||||
echo __('Request sent to the specified URL!', 'slmplus');
|
||||
echo '<br />' . esc_html($msg);
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['slm_clear_log'])) {
|
||||
global $wpdb, $slm_debug_logger;
|
||||
$table = SLM_TBL_LIC_LOG;
|
||||
$wpdb->query("TRUNCATE TABLE $table");
|
||||
$slm_debug_logger->reset_log_file("log.txt");
|
||||
$slm_debug_logger->reset_log_file("log-cron-job.txt");
|
||||
// Verify the nonce
|
||||
if (isset($_POST['slm_clear_log_nonce_field']) && wp_verify_nonce($_POST['slm_clear_log_nonce_field'], 'slm_clear_log_nonce_action')) {
|
||||
// Nonce is valid, proceed with clearing the log
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>' . esc_html__('Log was cleared successfully!', 'slmplus') . '</p></div>';
|
||||
global $wpdb, $slm_debug_logger;
|
||||
|
||||
// Define the table name using the constant (already assumed to be done securely)
|
||||
$table = SLM_TBL_LIC_LOG;
|
||||
|
||||
// Sanitize the table name if it's dynamically passed (for security)
|
||||
$table = sanitize_key($table); // sanitize_key ensures a safe table name, although here it's already defined
|
||||
|
||||
// Sanitize and validate other variables if used dynamically
|
||||
|
||||
// Direct query execution for truncating the table
|
||||
if ($wpdb->get_var("SHOW TABLES LIKE '$table'")) { // Check if table exists
|
||||
$query = "TRUNCATE TABLE `$table`"; // Backticks are used to prevent issues with reserved SQL keywords
|
||||
$wpdb->query($query); // Direct query execution
|
||||
} else {
|
||||
// Handle the case where the table doesn't exist
|
||||
error_log('Table not found: ' . $table);
|
||||
}
|
||||
|
||||
// Reset log files
|
||||
$slm_debug_logger->reset_log_file("log.txt");
|
||||
$slm_debug_logger->reset_log_file("log-cron-job.txt");
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>' . esc_html__('Log was cleared successfully!', 'slm-plus') . '</p></div>';
|
||||
} else {
|
||||
// Nonce is invalid or missing
|
||||
echo '<div id="message" class="error fade"><p>' . esc_html__('Security check failed. Invalid nonce.', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
<br />
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php _e('Send Deactivation Message for a License', 'slmplus'); ?></label></h3>
|
||||
<h3 class="hndle"><label for="title"><?php esc_html_e('Send Deactivation Message for a License', 'slm-plus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('slm_deactivation_nonce_action', 'slm_deactivation_nonce_field'); ?>
|
||||
<input name="slm_deactivation_req_url" type="text" size="100" value="<?php echo esc_attr($_POST['slm_deactivation_req_url'] ?? ''); ?>" />
|
||||
<div class="submit">
|
||||
<input type="submit" name="send_deactivation_request" value="<?php _e('Send Request', 'slmplus'); ?>" class="button" />
|
||||
<input type="submit" name="send_deactivation_request" value="<?php esc_html_e('Send Request', 'slm-plus'); ?>" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php esc_html_e('Reset Secret Keys', 'slm-plus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<p style="color: red;">
|
||||
<?php esc_html_e('Warning: Resetting these keys cannot be undone. Any API requests that depend on the current keys will break after they are reset.', 'slm-plus'); ?>
|
||||
</p>
|
||||
<form method="post" action="" style="display: flex; gap: 10px;">
|
||||
<?php wp_nonce_field('slm_reset_secret_keys_nonce_action', 'slm_reset_secret_keys_nonce_field'); ?>
|
||||
|
||||
<!-- Reset Button for Creation Secret Key -->
|
||||
<input type="submit" name="reset_creation_secret" value="<?php esc_html_e('Reset Creation Secret Key', 'slm-plus'); ?>" class="button button-secondary" onclick="return confirm('<?php esc_html_e('Are you sure you want to reset the Creation Secret Key?', 'slm-plus'); ?>');" />
|
||||
|
||||
<!-- Reset Button for Verification Secret Key -->
|
||||
<input type="submit" name="reset_verification_secret" value="<?php esc_html_e('Reset Verification Secret Key', 'slm-plus'); ?>" class="button button-secondary" onclick="return confirm('<?php esc_html_e('Are you sure you want to reset the Verification Secret Key?', 'slm-plus'); ?>');" />
|
||||
</form>
|
||||
|
||||
<?php
|
||||
// Display the new keys after reset
|
||||
if (isset($_GET['new_creation_secret'])) {
|
||||
echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html__('New Creation Secret Key:', 'slm-plus') . '</strong> ' . esc_html($_GET['new_creation_secret']) . '</p></div>';
|
||||
}
|
||||
if (isset($_GET['new_verification_secret'])) {
|
||||
echo '<div class="notice notice-success is-dismissible"><p><strong>' . esc_html__('New Verification Secret Key:', 'slm-plus') . '</strong> ' . esc_html($_GET['new_verification_secret']) . '</p></div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// Handle the reset action and display new keys.
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
if (isset($_POST['reset_creation_secret']) && check_admin_referer('slm_reset_secret_keys_nonce_action', 'slm_reset_secret_keys_nonce_field')) {
|
||||
$new_creation_secret = SLM_Utility::create_secret_keys(); // Generate new creation secret
|
||||
update_option('slm_plugin_options', array_merge(get_option('slm_plugin_options', []), ['lic_creation_secret' => $new_creation_secret]));
|
||||
wp_redirect(add_query_arg(['slm_notice' => 'creation_key_reset', 'new_creation_secret' => $new_creation_secret], $_SERVER['REQUEST_URI']));
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['reset_verification_secret']) && check_admin_referer('slm_reset_secret_keys_nonce_action', 'slm_reset_secret_keys_nonce_field')) {
|
||||
$new_verification_secret = SLM_Utility::create_secret_keys(); // Generate new verification secret
|
||||
update_option('slm_plugin_options', array_merge(get_option('slm_plugin_options', []), ['lic_verification_secret' => $new_verification_secret]));
|
||||
wp_redirect(add_query_arg(['slm_notice' => 'verification_key_reset', 'new_verification_secret' => $new_verification_secret], $_SERVER['REQUEST_URI']));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php esc_html_e('Clean Activity Log', 'slm-plus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<p><?php esc_html_e('This will clear/reset license keys activities', 'slm-plus'); ?></p>
|
||||
<form method="post" action="">
|
||||
<div class="submit">
|
||||
<?php wp_nonce_field('slm_clear_log_nonce_action', 'slm_clear_log_nonce_field'); ?>
|
||||
<input type="submit" name="slm_clear_log" value="<?php esc_html_e('Clear Log', 'slm-plus'); ?>" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php _e('Clean Activity Log', 'slmplus'); ?></label></h3>
|
||||
<h3 class="hndle"><label for="title"><?php esc_html_e('Backup Database', 'slm-plus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<p><?php _e('This will clear/reset license keys activities', 'slmplus'); ?></p>
|
||||
<p><?php esc_html_e('This will create a backup of the database tables related to this plugin and save it to the uploads directory.', 'slm-plus'); ?></p>
|
||||
<form method="post" action="">
|
||||
<?php wp_nonce_field('slm_backup_nonce_action', 'slm_backup_nonce_field'); ?>
|
||||
<div class="submit">
|
||||
<input type="submit" name="slm_clear_log" value="<?php _e('Clear Log', 'slmplus'); ?>" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php _e('Backup Database', 'slmplus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<p><?php _e('This will create a backup of the database tables related to this plugin and save it to the uploads directory.', 'slmplus'); ?></p>
|
||||
<form method="post" action="">
|
||||
<div class="submit">
|
||||
<input type="submit" name="slm_backup_db" value="<?php _e('Create Backup', 'slmplus'); ?>" class="button" />
|
||||
<input type="submit" name="slm_backup_db" value="<?php esc_html_e('Create Backup', 'slm-plus'); ?>" class="button" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
@ -87,19 +194,19 @@ function slm_admin_tools_menu()
|
|||
if (!empty($backup_info)) {
|
||||
$backup_url = esc_url($backup_info['url']);
|
||||
$backup_date = esc_html($backup_info['date']);
|
||||
echo '<p>' . __('Last backup created on: ', 'slmplus') . $backup_date . ' - <a href="' . $backup_url . '">' . __('Download Backup', 'slmplus') . '</a></p>';
|
||||
echo '<p>' . esc_html__('Last backup created on: ', 'slm-plus') . esc_html($backup_date) . ' - <a href="' . esc_url($backup_url) . '">' . esc_html__('Download Backup', 'slm-plus') . '</a></p>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<h3 class="hndle"><label for="title"><?php _e('Generate License for WooCommerce Orders', 'slmplus'); ?></label></h3>
|
||||
<h3 class="hndle"><label for="title"><?php esc_html_e('Generate License for WooCommerce Orders', 'slm-plus'); ?></label></h3>
|
||||
<div class="inside">
|
||||
<p class="notice notice-error" style="padding: 10px; margin-top: 5px;">
|
||||
<?php _e('This tool generates bulk licenses for WooCommerce orders placed before the plugin was activated or for orders that lack existing licenses.', 'slmplus'); ?>
|
||||
<strong><?php _e('Warning:', 'slmplus'); ?></strong>
|
||||
<?php _e('This action cannot be undone. Please back up your database before proceeding.', 'slmplus'); ?>
|
||||
<?php esc_html_e('This tool generates bulk licenses for WooCommerce orders placed before the plugin was activated or for orders that lack existing licenses.', 'slm-plus'); ?>
|
||||
<strong><?php esc_html_e('Warning:', 'slm-plus'); ?></strong>
|
||||
<?php esc_html_e('This action cannot be undone. Please back up your database before proceeding.', 'slm-plus'); ?>
|
||||
</p>
|
||||
|
||||
<form id="generate_licenses_form" method="post">
|
||||
|
@ -109,32 +216,32 @@ function slm_admin_tools_menu()
|
|||
<table>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><label for="slm_product_id"><?php _e('Product ID', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="slm_product_id"><?php esc_html_e('Product ID', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<input type="text" id="slm_product_id" name="slm_product_id" class="regular-text" placeholder="<?php _e('Enter Product ID', 'slmplus'); ?>" required />
|
||||
<p class="description"><?php _e('Specify the default product ID for license generation.', 'slmplus'); ?></p>
|
||||
<input type="text" id="slm_product_id" name="slm_product_id" class="regular-text" placeholder="<?php esc_html_e('Enter Product ID', 'slm-plus'); ?>" required />
|
||||
<p class="description"><?php esc_html_e('Specify the default product ID for license generation.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><label for="subscription_type"><?php _e('Subscription Type', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="subscription_type"><?php esc_html_e('Subscription Type', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<select id="subscription_type" name="subscription_type" class="regular-select">
|
||||
<option value="subscription"><?php _e('Subscription', 'slmplus'); ?></option>
|
||||
<option value="lifetime"><?php _e('Lifetime', 'slmplus'); ?></option>
|
||||
<option value="subscription"><?php esc_html_e('Subscription', 'slm-plus'); ?></option>
|
||||
<option value="lifetime"><?php esc_html_e('Lifetime', 'slm-plus'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php _e('Select the type of license for the order.', 'slmplus'); ?></p>
|
||||
<p class="description"><?php esc_html_e('Select the type of license for the order.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<td>
|
||||
<!-- Generate Licenses Button -->
|
||||
<input type="button" id="generate_licenses" value="<?php _e('Generate Licenses', 'slmplus'); ?>" class="button" <?php echo $slm_wc_lic_generator == '1' ? '' : 'disabled'; ?> />
|
||||
<input type="button" id="generate_licenses" value="<?php esc_html_e('Generate Licenses', 'slm-plus'); ?>" class="button" <?php echo $slm_wc_lic_generator == '1' ? '' : 'disabled'; ?> />
|
||||
<?php if ($slm_wc_lic_generator != '1'): ?>
|
||||
<!-- Message if option is not enabled -->
|
||||
<p class="notice notice-info" style="padding: 10px; margin-top: 5px;">
|
||||
<?php _e('Please enable the WooCommerce License Generator option to activate the Generate Licenses tool.', 'slmplus'); ?>
|
||||
<?php esc_html_e('Please enable the WooCommerce License Generator option to activate the Generate Licenses tool.', 'slm-plus'); ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
|
@ -144,7 +251,7 @@ function slm_admin_tools_menu()
|
|||
</form>
|
||||
|
||||
<div id="license-generation-result">
|
||||
<h4><?php _e('License Generation Results:', 'slmplus'); ?></h4>
|
||||
<h4><?php esc_html_e('License Generation Results:', 'slm-plus'); ?></h4>
|
||||
<ul id="license-result-list"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -162,13 +269,13 @@ function slm_admin_tools_menu()
|
|||
|
||||
// Validation: Check if fields are empty
|
||||
if (!productID) {
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php _e("Product ID cannot be empty.", "slmplus"); ?></li>');
|
||||
alert('<?php _e("Product ID is required.", "slmplus"); ?>');
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php esc_html_e("Product ID cannot be empty.", "slm-plus"); ?></li>');
|
||||
alert('<?php esc_html_e("Product ID is required.", "slm-plus"); ?>');
|
||||
return; // Stop submission if Product ID is empty
|
||||
}
|
||||
if (!subscriptionType) {
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php _e("Subscription Type cannot be empty.", "slmplus"); ?></li>');
|
||||
alert('<?php _e("Subscription Type is required.", "slmplus"); ?>');
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php esc_html_e("Subscription Type cannot be empty.", "slm-plus"); ?></li>');
|
||||
alert('<?php esc_html_e("Subscription Type is required.", "slm-plus"); ?>');
|
||||
return; // Stop submission if Subscription Type is empty
|
||||
}
|
||||
|
||||
|
@ -189,24 +296,23 @@ function slm_admin_tools_menu()
|
|||
$.post(ajaxurl, data, function(response) {
|
||||
//console.log('AJAX response:', response);
|
||||
if (response.success) {
|
||||
$('#license-result-list').html(response.data.html);
|
||||
alert('<?php _e('Licenses generated successfully!', 'slmplus'); ?>');
|
||||
$('#license-result-list').html(response.data.html);
|
||||
alert('<?php esc_html_e('Licenses generated successfully!', 'slm-plus'); ?>');
|
||||
} else {
|
||||
$('#license-result-list').html(response.data.html);
|
||||
alert('<?php _e('Some licenses failed to generate. Check the response for details.', 'slmplus'); ?>');
|
||||
alert('<?php esc_html_e('Some licenses failed to generate. Check the response for details.', 'slm-plus'); ?>');
|
||||
}
|
||||
}).fail(function(xhr, status, error) {
|
||||
console.error('AJAX error:', status, error);
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php _e("There was an error processing the request. Please try again.", "slmplus"); ?></li>');
|
||||
alert('<?php _e('There was an error processing the request.', 'slmplus'); ?>');
|
||||
$('#license-result-list').html('<li><strong>Error:</strong> <?php esc_html_e("There was an error processing the request. Please try again.", "slm-plus"); ?></li>');
|
||||
alert('<?php esc_html_e('There was an error processing the request.', 'slm-plus'); ?>');
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
echo '</div></div>';
|
||||
echo '</div>';
|
||||
<?php
|
||||
echo '</div></div></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -215,77 +321,13 @@ function slm_admin_tools_menu()
|
|||
function slm_get_unique_hash()
|
||||
{
|
||||
$hash = slm_get_option('slm_backup_dir_hash');
|
||||
|
||||
if (!$hash) {
|
||||
$hash = wp_generate_password(8, false, false); // Generate random 8-character hash
|
||||
slm_update_option('slm_backup_dir_hash', $hash);
|
||||
}
|
||||
|
||||
return $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a backup of the plugin's database tables in a secure folder.
|
||||
*/
|
||||
function slm_save_backup_to_uploads()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Get the upload directory
|
||||
$upload_dir = wp_upload_dir();
|
||||
$unique_hash = slm_get_unique_hash(); // Generate or retrieve the unique hash
|
||||
$slm_backup_dir = $upload_dir['basedir'] . $unique_hash;
|
||||
|
||||
// Create the slm-plus folder with hash if it doesn't exist
|
||||
if (!file_exists($slm_backup_dir)) {
|
||||
wp_mkdir_p($slm_backup_dir);
|
||||
}
|
||||
|
||||
// Set backup file name and path
|
||||
$backup_file = $slm_backup_dir . '/slm_plugin_backup_' . date('Y-m-d_H-i-s') . '.sql';
|
||||
|
||||
// Get plugin tables
|
||||
$backup_tables = [
|
||||
SLM_TBL_LICENSE_KEYS,
|
||||
SLM_TBL_LIC_DOMAIN,
|
||||
SLM_TBL_LIC_DEVICES,
|
||||
SLM_TBL_LIC_LOG,
|
||||
SLM_TBL_EMAILS,
|
||||
SLM_TBL_LICENSE_STATUS
|
||||
];
|
||||
|
||||
$sql = "";
|
||||
foreach ($backup_tables as $table) {
|
||||
// Get table structure
|
||||
$create_table_query = $wpdb->get_results("SHOW CREATE TABLE $table", ARRAY_N);
|
||||
$sql .= "\n\n" . $create_table_query[0][1] . ";\n\n";
|
||||
|
||||
// Get table data
|
||||
$rows = $wpdb->get_results("SELECT * FROM $table", ARRAY_A);
|
||||
foreach ($rows as $row) {
|
||||
$values = array_map('esc_sql', array_values($row)); // Use esc_sql to escape the values
|
||||
$values = "'" . implode("','", $values) . "'";
|
||||
$sql .= "INSERT INTO $table VALUES ($values);\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Save the SQL to a file in the slm-plus folder
|
||||
if (file_put_contents($backup_file, $sql)) {
|
||||
$backup_url = $upload_dir['baseurl'] . $unique_hash . '/' . basename($backup_file);
|
||||
|
||||
// Save backup info in plugin options
|
||||
$backup_info = [
|
||||
'url' => $backup_url,
|
||||
'date' => date('Y-m-d H:i:s')
|
||||
];
|
||||
slm_update_option('slm_last_backup_info', $backup_info);
|
||||
|
||||
echo '<div class="notice notice-success"><p>' . __('Backup created successfully! Download from: ', 'slmplus') . '<a href="' . esc_url($backup_url) . '">' . esc_html(basename($backup_file)) . '</a></p></div>';
|
||||
} else {
|
||||
echo '<div class="notice notice-error"><p>' . __('Error: Failed to create the backup file.', 'slmplus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves an option from the slm_plugin_options.
|
||||
|
|
|
@ -27,39 +27,39 @@ function slm_add_dashboard_widgets()
|
|||
function add_toolbar_items($admin_bar){
|
||||
$admin_bar->add_menu(array(
|
||||
'id' => 'slm-menu',
|
||||
'title' => '<span class="ab-icon"></span>' . __('SLM Plus', 'slmplus'),
|
||||
'title' => '<span class="ab-icon"></span>' . __('SLM Plus', 'slm-plus'), // Added text domain
|
||||
'href' => admin_url('admin.php?page=slm_overview'),
|
||||
'meta' => array(
|
||||
'title' => __('SLM'),
|
||||
'title' => __('slm-plus', 'slm-plus'), // Added text domain
|
||||
),
|
||||
));
|
||||
$admin_bar->add_menu(array(
|
||||
'id' => 'slm-manage-licenses-overview',
|
||||
'parent' => 'slm-menu',
|
||||
'title' => 'Overview',
|
||||
'title' => __('Overview', 'slm-plus'), // Added text domain
|
||||
'href' => admin_url('admin.php?page=slm_overview'),
|
||||
'meta' => array(
|
||||
'title' => __('Overview'),
|
||||
'title' => __('Overview', 'slm-plus'), // Added text domain
|
||||
'class' => 'slm_overview_menu'
|
||||
),
|
||||
));
|
||||
$admin_bar->add_menu(array(
|
||||
'id' => 'slm-manage-licenses-addnew',
|
||||
'parent' => 'slm-menu',
|
||||
'title' => 'Add new license',
|
||||
'title' => __('Add new license', 'slm-plus'), // Added text domain
|
||||
'href' => admin_url('admin.php?page=slm_manage_license'),
|
||||
'meta' => array(
|
||||
'title' => __( 'Add new license'),
|
||||
'title' => __('Add new license', 'slm-plus'), // Added text domain
|
||||
'class' => 'slm_addlicense_menu'
|
||||
),
|
||||
));
|
||||
$admin_bar->add_menu(array(
|
||||
'id' => 'slm-manage-licenses-settings',
|
||||
'parent' => 'slm-menu',
|
||||
'title' => 'Settings',
|
||||
'title' => __('Settings', 'slm-plus'), // Added text domain
|
||||
'href' => admin_url( 'admin.php?page=slm_settings'),
|
||||
'meta' => array(
|
||||
'title' => __('Settings'),
|
||||
'title' => __('Settings', 'slm-plus'), // Added text domain
|
||||
'class' => 'slm_settings_menu'
|
||||
),
|
||||
));
|
||||
|
@ -72,61 +72,62 @@ function add_toolbar_items($admin_bar){
|
|||
function slm_dashboard_widget_function()
|
||||
{ ?>
|
||||
|
||||
<ul class="slm_status_list">
|
||||
<li class="total-licenses">
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview'); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-admin-network"></span> </div>
|
||||
<strong><?php _e('Manage licenses', 'slmplus'); ?></strong>
|
||||
<?php _e('Total active licenses', 'slmplus'); ?>
|
||||
<span class="badge"><?php echo SLM_Utility::get_total_licenses(); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="active-licenses">
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview&s=active&view=active'); ?>">
|
||||
<div class="icon"><span class="dashicons dashicons-yes-alt"></span></div>
|
||||
<strong><?php echo SLM_Utility::count_licenses('active'); ?></strong>
|
||||
<?php _e('Active licenses', 'slmplus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="pending-licenses">
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview&s=pending&view=pending'); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-warning"></span> </div>
|
||||
<strong><?php echo SLM_Utility::count_licenses('pending'); ?></strong>
|
||||
<?php _e('Pending licenses', 'slmplus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="blocked-licenses">
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview&s=blocked&view=blocked'); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-dismiss"></span> </div>
|
||||
<strong><?php echo SLM_Utility::count_licenses('blocked'); ?></strong>
|
||||
<?php _e('Blocked licenses', 'slmplus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="expired-licenses">
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview&s=expired&view=expired'); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<strong><?php echo SLM_Utility::count_licenses('expired'); ?></strong>
|
||||
<?php _e('Expired licenses', 'slmplus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="slm_status_list">
|
||||
<li class="total-licenses">
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview')); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-admin-network"></span> </div>
|
||||
<strong><?php esc_html_e('Manage licenses', 'slm-plus'); ?></strong>
|
||||
<?php esc_html_e('Total active licenses', 'slm-plus'); ?>
|
||||
<span class="badge"><?php echo esc_html(SLM_Utility::get_total_licenses()); ?></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="active-licenses">
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview&s=active&view=active')); ?>">
|
||||
<div class="icon"><span class="dashicons dashicons-yes-alt"></span></div>
|
||||
<strong><?php echo esc_html(SLM_Utility::count_licenses('active')); ?></strong>
|
||||
<?php esc_html_e('Active licenses', 'slm-plus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="pending-licenses">
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview&s=pending&view=pending')); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-warning"></span> </div>
|
||||
<strong><?php echo esc_html(SLM_Utility::count_licenses('pending')); ?></strong>
|
||||
<?php esc_html_e('Pending licenses', 'slm-plus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="blocked-licenses">
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview&s=blocked&view=blocked')); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-dismiss"></span> </div>
|
||||
<strong><?php echo esc_html(SLM_Utility::count_licenses('blocked')); ?></strong>
|
||||
<?php esc_html_e('Blocked licenses', 'slm-plus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<li class="expired-licenses">
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview&s=expired&view=expired')); ?>">
|
||||
<div class="icon"> <span class="dashicons dashicons-calendar-alt"></span> </div>
|
||||
<strong><?php echo esc_html(SLM_Utility::count_licenses('expired')); ?></strong>
|
||||
<?php esc_html_e('Expired licenses', 'slm-plus'); ?>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="table recent_licenses">
|
||||
<hr>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<?php esc_html_e('Recent Licenses', 'slm-plus'); ?>
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_overview')); ?>"> – <?php esc_html_e('View All', 'slm-plus'); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php SLM_Utility::slm_wp_dashboards_stats('5'); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="table recent_licenses">
|
||||
<hr>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">
|
||||
<?php _e('Recent Licenses', 'slmplus'); ?>
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_overview'); ?>"> – <?php _e('View All', 'slmplus'); ?></a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php SLM_Utility::slm_wp_dashboards_stats('5'); ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
|
|
@ -11,82 +11,84 @@ function slm_integration_help_menu()
|
|||
{
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="wp-heading-inline"><?php esc_html_e('SLM Plus - Integration Help', 'slmplus'); ?></h1>
|
||||
<span class="version"><?php echo esc_html__('Version:', 'slmplus') . ' ' . esc_html(SLM_VERSION); ?></span>
|
||||
<h1 class="wp-heading-inline"><?php esc_html_e('SLM Plus - Integration Help', 'slm-plus'); ?></h1>
|
||||
<span class="version"><?php echo esc_html__('Version:', 'slm-plus') . ' ' . esc_html(SLM_VERSION); ?></span>
|
||||
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div id="post-body-content">
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div id="post-body-content">
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><?php esc_html_e('API Settings', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('API Settings', 'slm-plus'); ?></h2>
|
||||
<div class="inside">
|
||||
<?php
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
// Apply escaping to ensure output is safe
|
||||
$slm_creation_secret_key = esc_attr($slm_options['lic_creation_secret']);
|
||||
$slm_secret_verification_key = esc_attr($slm_options['lic_verification_secret']);
|
||||
$slm_api_query_post_url = esc_url(SLM_SITE_HOME_URL);
|
||||
?>
|
||||
<p><strong><?php esc_html_e('License API Query POST URL for Your Installation', 'slmplus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo $slm_api_query_post_url; ?>" readonly />
|
||||
<p><strong><?php esc_html_e('License API Query POST URL for Your Installation', 'slm-plus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo esc_url($slm_api_query_post_url); ?>" readonly />
|
||||
|
||||
<p><strong><?php esc_html_e('License Activation/Deactivation API Secret Key', 'slmplus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo $slm_secret_verification_key; ?>" readonly />
|
||||
<p><strong><?php esc_html_e('License Activation/Deactivation API Secret Key', 'slm-plus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo esc_attr($slm_secret_verification_key); ?>" readonly />
|
||||
|
||||
<p><strong><?php esc_html_e('License Creation API Secret Key', 'slmplus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo $slm_creation_secret_key; ?>" readonly />
|
||||
<p><strong><?php esc_html_e('License Creation API Secret Key', 'slm-plus'); ?></strong></p>
|
||||
<input class="widefat" type="text" value="<?php echo esc_attr($slm_creation_secret_key); ?>" readonly />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><?php esc_html_e('Documentation and Guides', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Documentation and Guides', 'slm-plus'); ?></h2>
|
||||
<div class="inside">
|
||||
<p><?php esc_html_e('Need more help? Check out the documentation:', 'slmplus'); ?>
|
||||
<p><?php esc_html_e('Need more help? Check out the documentation:', 'slm-plus'); ?>
|
||||
<a href="https://documenter.getpostman.com/view/307939/6tjU1FL?version=latest" target="_blank" rel="noopener noreferrer">
|
||||
<?php esc_html_e('Postman API Demos', 'slmplus'); ?>
|
||||
<?php esc_html_e('Postman API Demos', 'slm-plus'); ?>
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="postbox">
|
||||
<h2 class="hndle"><?php esc_html_e('Error Codes and Descriptions', 'slmplus'); ?></h2>
|
||||
<h2 class="hndle"><?php esc_html_e('Error Codes and Descriptions', 'slm-plus'); ?></h2>
|
||||
<div class="inside">
|
||||
<table class="widefat fixed striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Constant', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('Error Code', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('Description', 'slmplus'); ?></th>
|
||||
<th><?php esc_html_e('Constant', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Error Code', 'slm-plus'); ?></th>
|
||||
<th><?php esc_html_e('Description', 'slm-plus'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$error_codes = [
|
||||
['CREATE_FAILED', '10', __('The license creation failed due to an unknown error.', 'slmplus')],
|
||||
['CREATE_KEY_INVALID', '100', __('The license key provided during creation is invalid.', 'slmplus')],
|
||||
['DOMAIN_ALREADY_INACTIVE', '80', __('The domain associated with this license is already inactive.', 'slmplus')],
|
||||
['DOMAIN_MISSING', '70', __('The domain information is missing in the request.', 'slmplus')],
|
||||
['KEY_CANCELED', '130', __('The license key has been canceled.', 'slmplus')],
|
||||
['KEY_CANCELED_FAILED', '140', __('Failed to cancel the license key.', 'slmplus')],
|
||||
['KEY_DEACTIVATE_DOMAIN_SUCCESS', '360', __('Successfully deactivated the license key for the specified domain.', 'slmplus')],
|
||||
['KEY_DEACTIVATE_SUCCESS', '340', __('The license key was successfully deactivated.', 'slmplus')],
|
||||
['KEY_DELETE_FAILED', '300', __('Failed to delete the license key.', 'slmplus')],
|
||||
['KEY_DELETE_SUCCESS', '320', __('The license key was successfully deleted.', 'slmplus')],
|
||||
['KEY_DELETED', '130', __('The license key has been deleted.', 'slmplus')],
|
||||
['KEY_UPDATE_FAILED', '220', __('Failed to update the license key details.', 'slmplus')],
|
||||
['KEY_UPDATE_SUCCESS', '240', __('The license key was successfully updated.', 'slmplus')],
|
||||
['LICENSE_ACTIVATED', '380', __('The license key was successfully activated.', 'slmplus')],
|
||||
['LICENSE_BLOCKED', '20', __('The license key has been blocked from further use.', 'slmplus')],
|
||||
['LICENSE_CREATED', '400', __('The license key was successfully created.', 'slmplus')],
|
||||
['LICENSE_EXIST', '200', __('The license key already exists in the system.', 'slmplus')],
|
||||
['LICENSE_EXPIRED', '30', __('The license key has expired.', 'slmplus')],
|
||||
['LICENSE_IN_USE', '40', __('The license key is already in use on another domain or device.', 'slmplus')],
|
||||
['LICENSE_INVALID', '60', __('The license key is invalid.', 'slmplus')],
|
||||
['MISSING_KEY_DELETE_FAILED', '280', __('Failed to delete the license key because it was not found.', 'slmplus')],
|
||||
['MISSING_KEY_UPDATE_FAILED', '260', __('Failed to update the license key because it was not found.', 'slmplus')],
|
||||
['REACHED_MAX_DEVICES', '120', __('The license key has reached its maximum allowable devices.', 'slmplus')],
|
||||
['REACHED_MAX_DOMAINS', '50', __('The license key has reached its maximum allowable domains.', 'slmplus')],
|
||||
['VERIFY_KEY_INVALID', '90', __('The key verification failed due to an invalid key.', 'slmplus')],
|
||||
['CREATE_FAILED', '10', __('The license creation failed due to an unknown error.', 'slm-plus')],
|
||||
['CREATE_KEY_INVALID', '100', __('The license key provided during creation is invalid.', 'slm-plus')],
|
||||
['DOMAIN_ALREADY_INACTIVE', '80', __('The domain associated with this license is already inactive.', 'slm-plus')],
|
||||
['DOMAIN_MISSING', '70', __('The domain information is missing in the request.', 'slm-plus')],
|
||||
['KEY_CANCELED', '130', __('The license key has been canceled.', 'slm-plus')],
|
||||
['KEY_CANCELED_FAILED', '140', __('Failed to cancel the license key.', 'slm-plus')],
|
||||
['KEY_DEACTIVATE_DOMAIN_SUCCESS', '360', __('Successfully deactivated the license key for the specified domain.', 'slm-plus')],
|
||||
['KEY_DEACTIVATE_SUCCESS', '340', __('The license key was successfully deactivated.', 'slm-plus')],
|
||||
['KEY_DELETE_FAILED', '300', __('Failed to delete the license key.', 'slm-plus')],
|
||||
['KEY_DELETE_SUCCESS', '320', __('The license key was successfully deleted.', 'slm-plus')],
|
||||
['KEY_DELETED', '130', __('The license key has been deleted.', 'slm-plus')],
|
||||
['KEY_UPDATE_FAILED', '220', __('Failed to update the license key details.', 'slm-plus')],
|
||||
['KEY_UPDATE_SUCCESS', '240', __('The license key was successfully updated.', 'slm-plus')],
|
||||
['LICENSE_ACTIVATED', '380', __('The license key was successfully activated.', 'slm-plus')],
|
||||
['LICENSE_BLOCKED', '20', __('The license key has been blocked from further use.', 'slm-plus')],
|
||||
['LICENSE_CREATED', '400', __('The license key was successfully created.', 'slm-plus')],
|
||||
['LICENSE_EXIST', '200', __('The license key already exists in the system.', 'slm-plus')],
|
||||
['LICENSE_EXPIRED', '30', __('The license key has expired.', 'slm-plus')],
|
||||
['LICENSE_IN_USE', '40', __('The license key is already in use on another domain or device.', 'slm-plus')],
|
||||
['LICENSE_INVALID', '60', __('The license key is invalid.', 'slm-plus')],
|
||||
['MISSING_KEY_DELETE_FAILED', '280', __('Failed to delete the license key because it was not found.', 'slm-plus')],
|
||||
['MISSING_KEY_UPDATE_FAILED', '260', __('Failed to update the license key because it was not found.', 'slm-plus')],
|
||||
['REACHED_MAX_DEVICES', '120', __('The license key has reached its maximum allowable devices.', 'slm-plus')],
|
||||
['REACHED_MAX_DOMAINS', '50', __('The license key has reached its maximum allowable domains.', 'slm-plus')],
|
||||
['VERIFY_KEY_INVALID', '90', __('The key verification failed due to an invalid key.', 'slm-plus')],
|
||||
];
|
||||
|
||||
foreach ($error_codes as $code) {
|
||||
|
|
|
@ -69,7 +69,7 @@ function slm_general_settings()
|
|||
|
||||
// Update the options in the database
|
||||
update_option('slm_plugin_options', $options);
|
||||
echo '<div id="message" class="updated fade"> <p>' . __('Options updated!', 'slmplus') . '</p> </div>';
|
||||
echo '<div id="message" class="updated fade"> <p>' . esc_html__('Options updated!', 'slm-plus') . '</p> </div>';
|
||||
}
|
||||
|
||||
$secret_key = !empty($options['lic_creation_secret']) ? $options['lic_creation_secret'] : SLM_Utility::create_secret_keys();
|
||||
|
@ -82,26 +82,27 @@ function slm_general_settings()
|
|||
<div id="post-body" class="metabox-holder columns-2">
|
||||
|
||||
|
||||
<h1><?php _e('SLM Plus - Settings', 'slmplus'); ?> </h1>
|
||||
<h1><?php esc_html_e('SLM Plus - Settings', 'slm-plus'); ?> </h1>
|
||||
|
||||
<div id="icon-options-general" class="icon32"></div>
|
||||
<div class="nav-tab-wrapper">
|
||||
<?php $base_url = admin_url('admin.php?page=slm_settings'); ?>
|
||||
<a href="<?php echo $base_url ?>" class="nav-tab <?php echo $tab === 'general_settings' ? 'nav-tab-active' : '' ?>">
|
||||
<?php _e('General', 'slmplus'); ?>
|
||||
<a href="<?php echo esc_url($base_url); ?>" class="nav-tab <?php echo esc_attr($tab === 'general_settings' ? 'nav-tab-active' : ''); ?>">
|
||||
<?php esc_html_e('General', 'slm-plus'); ?>
|
||||
</a>
|
||||
|
||||
<a href="<?php echo add_query_arg('tab', 'integrations', $base_url); ?>" class="nav-tab <?php echo $tab === 'integrations' ? 'nav-tab-active' : '' ?>">
|
||||
<?php _e('Integrations', 'slmplus'); ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('tab', 'integrations', $base_url)); ?>" class="nav-tab <?php echo esc_attr($tab === 'integrations' ? 'nav-tab-active' : ''); ?>">
|
||||
<?php esc_html_e('Integrations', 'slm-plus'); ?>
|
||||
</a>
|
||||
|
||||
<a href="<?php echo add_query_arg('tab', 'debug', $base_url); ?>" class="nav-tab <?php echo $tab === 'debug' ? 'nav-tab-active' : '' ?>">
|
||||
<?php _e('Debugging', 'slmplus'); ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('tab', 'debug', $base_url)); ?>" class="nav-tab <?php echo esc_attr($tab === 'debug' ? 'nav-tab-active' : ''); ?>">
|
||||
<?php esc_html_e('Debugging', 'slm-plus'); ?>
|
||||
</a>
|
||||
|
||||
<a href="<?php echo add_query_arg('tab', 'emails', $base_url); ?>" class="nav-tab <?php echo $tab === 'emails' ? 'nav-tab-active' : '' ?>">
|
||||
<?php _e('Emails', 'slmplus'); ?>
|
||||
<a href="<?php echo esc_url(add_query_arg('tab', 'emails', $base_url)); ?>" class="nav-tab <?php echo esc_attr($tab === 'emails' ? 'nav-tab-active' : ''); ?>">
|
||||
<?php esc_html_e('Emails', 'slm-plus'); ?>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
|
||||
<style> .hidepanel { display: none; } .showpanel { display: block !important } #wpbody-content { padding-bottom: 8px; ; } </style>
|
||||
|
@ -112,49 +113,48 @@ function slm_general_settings()
|
|||
<div class="general_settings hidepanel <?php echo ($tab == 'general_settings') ? 'showpanel' : '' ?>">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Secret Key for License Creation', 'slmplus'); ?></th>
|
||||
<td><textarea name="lic_creation_secret" rows="2" cols="50" readonly><?php echo $secret_key; ?>
|
||||
</textarea>
|
||||
<p class=" description"><?php _e('This secret key will be used to authenticate any license creation request. You can change it with something random.', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Secret Key for License Creation', 'slm-plus'); ?></th>
|
||||
<td><textarea name="lic_creation_secret" rows="2" cols="50" readonly><?php echo esc_textarea($secret_key); ?></textarea>
|
||||
<p class=" description"><?php esc_html_e('This secret key will be used to authenticate any license creation request. You can change it with something random.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Secret Key for License Verification Requests', 'slmplus'); ?></th>
|
||||
<td><textarea name="lic_verification_secret" rows="2" cols="50" readonly><?php echo $secret_verification_key; ?></textarea>
|
||||
<p class="description"><?php _e('This secret key will be used to authenticate any license verification request from customer\'s site. Important! Do not change this value once your customers start to use your product(s)!', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Secret Key for License Verification Requests', 'slm-plus'); ?></th>
|
||||
<td><textarea name="lic_verification_secret" rows="2" cols="50" readonly><?php echo esc_textarea($secret_verification_key); ?></textarea> </textarea>
|
||||
<p class="description"><?php esc_html_e('This secret key will be used to authenticate any license verification request from customer\'s site. Important! Do not change this value once your customers start to use your product(s)!', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('License Key Prefix', 'slmplus'); ?></th>
|
||||
<td><input type="text" name="lic_prefix" value="<?php echo $options['lic_prefix']; ?>" size="6" />
|
||||
<p class="description"><?php _e('You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('License Key Prefix', 'slm-plus'); ?></th>
|
||||
<td><input type="text" name="lic_prefix" value="<?php echo esc_attr($options['lic_prefix']); ?>" size="6" />
|
||||
<p class="description"><?php esc_html_e('You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Maximum Allowed Devices', 'slmplus'); ?></th>
|
||||
<td><input type="text" name="default_max_devices" value="<?php echo $options['default_max_devices']; ?>" size="6" />
|
||||
<p class="description"><?php _e('Maximum number of devices which each license is valid for (default value).', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Maximum Allowed Devices', 'slm-plus'); ?></th>
|
||||
<td><input type="text" name="default_max_devices" value="<?php echo esc_attr($options['default_max_devices']); ?>" size="6" />
|
||||
<p class="description"><?php esc_html_e('Maximum number of devices which each license is valid for (default value).', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Maximum Allowed Domains', 'slmplus'); ?></th>
|
||||
<td><input type="text" name="default_max_domains" value="<?php echo $options['default_max_domains']; ?>" size="6" />
|
||||
<p class="description"><?php _e('Maximum number of domains which each license is valid for (default value).', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Maximum Allowed Domains', 'slm-plus'); ?></th>
|
||||
<td><input type="text" name="default_max_domains" value="<?php echo esc_attr($options['default_max_domains']); ?>" size="6" />
|
||||
<p class="description"><?php esc_html_e('Maximum number of domains which each license is valid for (default value).', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Support Until Ver.', 'slmplus'); ?></th>
|
||||
<td><input type="text" name="license_until_version" value="<?php echo $options['license_until_version']; ?>" size="6" />
|
||||
<p class="description"><?php _e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting).', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Support Until Ver.', 'slm-plus'); ?></th>
|
||||
<td><input type="text" name="license_until_version" value="<?php echo esc_attr($options['license_until_version']); ?>" size="6" />
|
||||
<p class="description"><?php esc_html_e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting).', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Current Version', 'slmplus'); ?></th>
|
||||
<td><input type="text" name="license_current_version" value="<?php echo $options['license_current_version']; ?>" size="6" />
|
||||
<p class="description"><?php _e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slmplus'); ?></p>
|
||||
<th scope="row"><?php esc_html_e('Current Version', 'slm-plus'); ?></th>
|
||||
<td><input type="text" name="license_current_version" value="<?php echo esc_attr($options['license_current_version']); ?>" size="6" />
|
||||
<p class="description"><?php esc_html_e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -164,37 +164,37 @@ function slm_general_settings()
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><label for="slm_billing_length"><?php _e('Billing Length', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="slm_billing_length"><?php esc_html_e('Billing Length', 'slm-plus'); ?></label></th>
|
||||
<td><input name="slm_billing_length" type="text" id="slm_billing_length" value="<?php echo esc_attr($slm_billing_length); ?>" class="regular-text" />
|
||||
<p class="description"><?php _e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slmplus'); ?></p></td>
|
||||
<p class="description"><?php esc_html_e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slm-plus'); ?></p></td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><label for="slm_billing_interval"><?php _e('Expiration Term', 'slmplus'); ?></label></th>
|
||||
<th scope="row"><label for="slm_billing_interval"><?php esc_html_e('Expiration Term', 'slm-plus'); ?></label></th>
|
||||
<td>
|
||||
<select name="slm_billing_interval" id="slm_billing_interval" class="regular-text">
|
||||
<option value="days" <?php selected($slm_billing_interval, 'days'); ?>><?php _e('Day(s)', 'slmplus'); ?></option>
|
||||
<option value="months" <?php selected($slm_billing_interval, 'months'); ?>><?php _e('Month(s)', 'slmplus'); ?></option>
|
||||
<option value="years" <?php selected($slm_billing_interval, 'years'); ?>><?php _e('Year(s)', 'slmplus'); ?></option>
|
||||
<option value="days" <?php selected($slm_billing_interval, 'days'); ?>><?php esc_html_e('Day(s)', 'slm-plus'); ?></option>
|
||||
<option value="months" <?php selected($slm_billing_interval, 'months'); ?>><?php esc_html_e('Month(s)', 'slm-plus'); ?></option>
|
||||
<option value="years" <?php selected($slm_billing_interval, 'years'); ?>><?php esc_html_e('Year(s)', 'slm-plus'); ?></option>
|
||||
</select>
|
||||
<p class="description"><?php _e('Frequency period: in days, months, or years', 'softwarelicensemanager'); ?></p>
|
||||
<p class="description"><?php _e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slmplus'); ?></p>
|
||||
<p class="description"><?php esc_html_e('Frequency period: in days, months, or years', 'slm-plus'); ?></p>
|
||||
<p class="description"><?php esc_html_e('This is used to enable bulk license generation for WooCommerce orders placed before the plugin was active or for orders that do not already contain licenses (default setting:).', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"><?php _e('Auto Expire License Keys', 'slmplus'); ?></th>
|
||||
<th scope="row"><?php esc_html_e('Auto Expire License Keys', 'slm-plus'); ?></th>
|
||||
<td><input name="enable_auto_key_expiration" type="checkbox" <?php if (isset($options['enable_auto_key_expiration']) && $options['enable_auto_key_expiration'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable auto expiration ', 'slmplus '); ?>
|
||||
<p class="description"><?php _e(' When enabled, it will automatically set the status of a license key to "Expired" when the expiry date value of the key is reached. It doesn\'t remotely deactivate a key. It simply changes the status of the key in your database to expired.', 'slmplus'); ?></p>
|
||||
<?php esc_html_e('Enable auto expiration ', 'slm-plus'); ?>
|
||||
<p class="description"><?php esc_html_e(' When enabled, it will automatically set the status of a license key to "Expired" when the expiry date value of the key is reached. It doesn\'t remotely deactivate a key. It simply changes the status of the key in your database to expired.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><?php _e('General settings', 'slmplus'); ?></th>
|
||||
<th scope="row"><?php esc_html_e('General settings', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<input name="slm_stats" type="checkbox" <?php if ($options['slm_stats'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable stats in licenses overview page.', 'slmplus'); ?>
|
||||
<?php esc_html_e('Enable stats in licenses overview page.', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -202,25 +202,25 @@ function slm_general_settings()
|
|||
<th scope="row"></th>
|
||||
<td>
|
||||
<input name="slm_adminbar" type="checkbox" <?php if ($options['slm_adminbar'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable admin bar shortcut link', 'slmplus'); ?>
|
||||
<?php esc_html_e('Enable admin bar shortcut link', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php _e('Multiple items validation', 'slmplus'); ?></th>
|
||||
<th scope="row"><?php esc_html_e('Multiple items validation', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<input name="slm_multiple_items" type="checkbox" <?php if ($options['slm_multiple_items'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable verification of Item reference.', 'slmplus'); ?>
|
||||
<p class="description"><?php _e("When enabled, there will be another field in Licenced product - Item reference. This field should correspond to the API parameter item_reference of your software.", 'slmplus'); ?></p>
|
||||
<?php esc_html_e('Enable verification of Item reference.', 'slm-plus'); ?>
|
||||
<p class="description"><?php esc_html_e("When enabled, there will be another field in Licenced product - Item reference. This field should correspond to the API parameter item_reference of your software.", 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row"><?php _e('User permissions', 'slmplus'); ?></th>
|
||||
<th scope="row"><?php esc_html_e('User permissions', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<input name="allow_user_activation_removal" type="checkbox" <?php if ($options['allow_user_activation_removal'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Allow users to remove domains/devices in My account.', 'slmplus'); ?>
|
||||
<p class="description"><?php _e("When enabled, users will be able to remove registered domains or devices in their account.", 'slmplus'); ?></p>
|
||||
<?php esc_html_e('Allow users to remove domains/devices in My account.', 'slm-plus'); ?>
|
||||
<p class="description"><?php esc_html_e("When enabled, users will be able to remove registered domains or devices in their account.", 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -229,14 +229,14 @@ function slm_general_settings()
|
|||
|
||||
<div class="integrations hidepanel <?php echo ($tab == 'integrations') ? 'showpanel' : '' ?>">
|
||||
<div class="inside">
|
||||
<h3><?php _e('WooCommerce Settings', 'slmplus'); ?> </h3>
|
||||
<h3><?php esc_html_e('WooCommerce Settings', 'slm-plus'); ?> </h3>
|
||||
<table class="form-table">
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php _e('WooCommerce', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php esc_html_e('WooCommerce', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<input name="slm_woo" type="checkbox" <?php if ($options['slm_woo'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable WooCommerce Support (A fully customizable, open source eCommerce platform built for WordPress.)', 'slmplus'); ?>
|
||||
<?php esc_html_e('Enable WooCommerce Support (A fully customizable, open source eCommerce platform built for WordPress.)', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -244,11 +244,11 @@ function slm_general_settings()
|
|||
<th scope="row"> </th>
|
||||
<td>
|
||||
<input name="slm_wc_lic_generator" type="checkbox" <?php if ($options['slm_wc_lic_generator'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable WooCommerce Order License Generator', 'slmplus'); ?>
|
||||
<?php esc_html_e('Enable WooCommerce Order License Generator', 'slm-plus'); ?>
|
||||
<p class="notice notice-warning" style="padding: 10px; margin-top: 5px;">
|
||||
<?php _e('This tool generates bulk licenses for WooCommerce orders placed before the plugin was activated or for orders that lack existing licenses.', 'slmplus'); ?>
|
||||
<strong><?php _e('Warning:', 'slmplus'); ?></strong>
|
||||
<?php _e('This action cannot be undone. Please back up your database before proceeding.', 'slmplus'); ?>
|
||||
<?php esc_html_e('This tool generates bulk licenses for WooCommerce orders placed before the plugin was activated or for orders that lack existing licenses.', 'slm-plus'); ?>
|
||||
<strong><?php esc_html_e('Warning:', 'slm-plus'); ?></strong>
|
||||
<?php esc_html_e('This action cannot be undone. Please back up your database before proceeding.', 'slm-plus'); ?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -257,28 +257,28 @@ function slm_general_settings()
|
|||
<th scope="row"></th>
|
||||
<td>
|
||||
<input name="slm_woo_downloads" type="checkbox" <?php if ($options['slm_woo_downloads'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Disable WooCommerce download page. Process downloads though license order info page.', 'slmplus'); ?>
|
||||
<?php esc_html_e('Disable WooCommerce download page. Process downloads though license order info page.', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"></th>
|
||||
<td>
|
||||
<input name="slm_woo_affect_downloads" type="checkbox" <?php if ($options['slm_woo_affect_downloads'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable WooCommerce downloads expiration. Downloads will expire together with corresponding license.', 'slmplus'); ?>
|
||||
<?php esc_html_e('Enable WooCommerce downloads expiration. Downloads will expire together with corresponding license.', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3><?php _e('WP eStores', 'slmplus'); ?> </h3>
|
||||
<!-- <h3><?php // esc_html_e('WP eStores', 'slm-plus'); ?> </h3>
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php _e('WP eStores', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php //_e('WP eStores', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<input name="slm_wpestores" type="checkbox" <?php if ($options['slm_wpestores'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php _e('Enable WordPress eStore Plugin Support.', 'slmplus'); ?>
|
||||
<input name="slm_wpestores" type="checkbox" <?php //if ($options['slm_wpestores'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php //_e('Enable WordPress eStore Plugin Support.', 'slm-plus'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</table> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -286,31 +286,31 @@ function slm_general_settings()
|
|||
<div class=" inside">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php echo __('Enable Debug Logging', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php echo esc_html__('Enable Debug Logging', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<p class="description"><input name="enable_debug" type="checkbox" <?php if ($options['enable_debug'] != '') echo ' checked="checked"'; ?> value="1" />
|
||||
<?php echo __('If checked, debug output will be written to log files.', ' slmplus '); ?></p>
|
||||
<?php echo esc_html__('If checked, debug output will be written to log files.', 'slm-plus'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php echo __('SLM Plus Version', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php echo esc_html__('SLM Plus Version', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<p class="description"> <?php echo SLM_VERSION;?> </p>
|
||||
<p class="description"><?php echo esc_html(SLM_VERSION); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php echo __('SLM Databse Version', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php echo esc_html__('SLM Databse Version', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<p class="description"> <?php echo SLM_DB_VERSION;?> </p>
|
||||
<p class="description"> <?php echo esc_html(SLM_DB_VERSION);?> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php echo __('SLM Rewrite Version', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php echo esc_html__('SLM Rewrite Version', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<p class="description"> <?php echo SLM_REWRITE_VERSION;?> </p>
|
||||
<p class="description"> <?php echo esc_html(SLM_REWRITE_VERSION);?> </p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
@ -323,7 +323,7 @@ function slm_general_settings()
|
|||
<div class=" inside">
|
||||
<table class="form-table">
|
||||
<tr valign="top">
|
||||
<th scope="row"> <?php _e('Expiration reminder', 'slmplus'); ?></th>
|
||||
<th scope="row"> <?php esc_html_e('Expiration reminder', 'slm-plus'); ?></th>
|
||||
<td>
|
||||
<textarea name="expiration_reminder_text" id="expiration_reminder_text" cols="80" rows="20"> <?php echo esc_html($options['expiration_reminder_text']); ?> </textarea>
|
||||
</td>
|
||||
|
@ -333,7 +333,7 @@ function slm_general_settings()
|
|||
</div>
|
||||
|
||||
<div class="submit">
|
||||
<input type="submit" class="button-primary" name="slm_save_settings" value=" <?php _e('Update Options', 'slmplus'); ?>" />
|
||||
<input type="submit" class="button-primary" name="slm_save_settings" value=" <?php esc_html_e('Update Options', 'slm-plus'); ?>" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -24,7 +24,7 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
|
||||
public function no_items()
|
||||
{
|
||||
_e('No licenses avaliable.', 'slmplus');
|
||||
esc_html_e('No licenses avaliable.', 'slm-plus');
|
||||
}
|
||||
|
||||
function get_views()
|
||||
|
@ -40,35 +40,35 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
$link_html,
|
||||
esc_url(remove_query_arg('view', $base)),
|
||||
$current === 'all' || $current == '' ? ' class="current"' : '',
|
||||
esc_html__('All', 'slmplus'),
|
||||
esc_html__('All', 'slm-plus'),
|
||||
SLM_Utility::get_total_licenses()
|
||||
),
|
||||
'active' => sprintf(
|
||||
$link_html,
|
||||
esc_url(add_query_arg('view', 'active', $base . '&s=active')),
|
||||
$current === 'active' ? ' class="current"' : '',
|
||||
esc_html__('active', 'slmplus'),
|
||||
esc_html__('active', 'slm-plus'),
|
||||
SLM_Utility::count_licenses('active')
|
||||
),
|
||||
'pending' => sprintf(
|
||||
$link_html,
|
||||
esc_url(add_query_arg('view', 'pending', $base . '&s=pending')),
|
||||
$current === 'pending' ? ' class="current"' : '',
|
||||
esc_html__('pending', 'slmplus'),
|
||||
esc_html__('pending', 'slm-plus'),
|
||||
SLM_Utility::count_licenses('pending')
|
||||
),
|
||||
'expired' => sprintf(
|
||||
$link_html,
|
||||
esc_url(add_query_arg('view', 'expired', $base . '&s=expired')),
|
||||
$current === 'expired' ? ' class="current"' : '',
|
||||
esc_html__('expired', 'slmplus'),
|
||||
esc_html__('expired', 'slm-plus'),
|
||||
SLM_Utility::count_licenses('expired')
|
||||
),
|
||||
'blocked' => sprintf(
|
||||
$link_html,
|
||||
esc_url(add_query_arg('view', 'blocked', $base . '&s=blocked')),
|
||||
$current === 'blocked' ? ' class="current"' : '',
|
||||
esc_html__('blocked', 'slmplus'),
|
||||
esc_html__('blocked', 'slm-plus'),
|
||||
SLM_Utility::count_licenses('blocked')
|
||||
)
|
||||
);
|
||||
|
@ -81,21 +81,21 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
{
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />', //Render a checkbox
|
||||
'id' => __('ID', 'slmplus'),
|
||||
'lic_status' => __('Status', 'slmplus'),
|
||||
'license_key' => __('Key', 'slmplus'),
|
||||
'item_reference' => __('Item reference', 'slmplus'),
|
||||
'lic_type' => __('License type', 'slmplus'),
|
||||
'email' => __('Email', 'slmplus'),
|
||||
'max_allowed_domains' => __('Domains', 'slmplus'),
|
||||
'max_allowed_devices' => __('Devices', 'slmplus'),
|
||||
'purchase_id_' => __('Order #', 'slmplus'),
|
||||
'date_created' => __('Created on', 'slmplus'),
|
||||
'date_renewed' => __('Renewed on', 'slmplus'),
|
||||
'date_activated' => __('Activated on', 'slmplus'),
|
||||
'date_expiry' => __('Expiration', 'slmplus'),
|
||||
'until' => __('Until Ver.', 'slmplus'),
|
||||
'current_ver' => __('Current Ver.', 'slmplus')
|
||||
'id' => __('ID', 'slm-plus'),
|
||||
'lic_status' => __('Status', 'slm-plus'),
|
||||
'license_key' => __('Key', 'slm-plus'),
|
||||
'item_reference' => __('Item reference', 'slm-plus'),
|
||||
'lic_type' => __('License type', 'slm-plus'),
|
||||
'email' => __('Email', 'slm-plus'),
|
||||
'max_allowed_domains' => __('Domains', 'slm-plus'),
|
||||
'max_allowed_devices' => __('Devices', 'slm-plus'),
|
||||
'purchase_id_' => __('Order #', 'slm-plus'),
|
||||
'date_created' => __('Created on', 'slm-plus'),
|
||||
'date_renewed' => __('Renewed on', 'slm-plus'),
|
||||
'date_activated' => __('Activated on', 'slm-plus'),
|
||||
'date_expiry' => __('Expiration', 'slm-plus'),
|
||||
'until' => __('Until Ver.', 'slm-plus'),
|
||||
'current_ver' => __('Current Ver.', 'slm-plus')
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
@ -117,19 +117,17 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
$date_today = time();
|
||||
|
||||
if ($expiration == '0000-00-00') {
|
||||
return '<span class="tag license-date-valid">'. __(' Lifetime ','slmplus'). '</span>' . '<span class="days-left"> </span>';
|
||||
return '<span class="tag license-date-valid">' . __(' Lifetime ', 'slm-plus') . '</span>' . '<span class="days-left"> </span>';
|
||||
}
|
||||
|
||||
|
||||
if ($expiration != '0000-00-00') {
|
||||
if (strtotime($expiration) < time()) {
|
||||
return '<span class="slm-lic-expired-date"> ' . $expiration . ' </span>' . '<span class="days-left"> ' . SLM_Utility::get_days_remaining($expiration) . ' day(s) due</span>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return '<span class="tag license-date-valid">' . $item[$column_name] . '</span>' . '<span class="days-left"> ' . SLM_Utility::get_days_remaining($expiration) . ' day(s) left</span>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
//return $item[$column_name];
|
||||
return '<span class="tag license-date-null">not set<span>';
|
||||
}
|
||||
|
@ -204,94 +202,94 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
);
|
||||
return $actions;
|
||||
}
|
||||
|
||||
|
||||
function process_bulk_action()
|
||||
{
|
||||
if ('delete' === $this->current_action()) {
|
||||
//Process delete bulk actions
|
||||
if (!isset($_REQUEST['item'])) {
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slmplus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . $error_msg . '</div>';
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slm-plus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . esc_html($error_msg) . '</div>';
|
||||
return;
|
||||
} else {
|
||||
$nvp_key = $this->_args['singular'];
|
||||
$records_to_delete = $_GET[$nvp_key];
|
||||
|
||||
|
||||
foreach ($records_to_delete as $row) {
|
||||
SLM_Utility::delete_license_key_by_row_id($row);
|
||||
}
|
||||
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>Selected records deleted successfully!</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ('blocked' === $this->current_action()) {
|
||||
//Process blocked bulk actions
|
||||
if (!isset($_REQUEST['item'])) {
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slmplus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . $error_msg . '</div>';
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slm-plus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . esc_html($error_msg) . '</div>';
|
||||
return;
|
||||
} else {
|
||||
$nvp_key = $this->_args['singular'];
|
||||
$licenses_to_block = $_GET[$nvp_key];
|
||||
|
||||
|
||||
foreach ($licenses_to_block as $row) {
|
||||
SLM_Utility::block_license_key_by_row_id($row);
|
||||
}
|
||||
|
||||
echo '<div id="message" class="updated fade"><p> ' . $row . ' Selected records blocked successfully!</p></div>';
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>' . esc_html($row) . ' ' . esc_html__('Selected records blocked successfully!', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ('expired' === $this->current_action()) {
|
||||
//Process expired bulk actions
|
||||
if (!isset($_REQUEST['item'])) {
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slmplus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . $error_msg . '</div>';
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slm-plus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . esc_html($error_msg) . '</div>';
|
||||
return;
|
||||
} else {
|
||||
$nvp_key = $this->_args['singular'];
|
||||
$licenses_to_expire = $_GET[$nvp_key];
|
||||
|
||||
|
||||
foreach ($licenses_to_expire as $row) {
|
||||
SLM_Utility::expire_license_key_by_row_id($row);
|
||||
}
|
||||
|
||||
echo '<div id="message" class="updated fade"><p> ' . $row . ' Selected records expired successfully!</p></div>';
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>' . esc_html($row) . ' ' . esc_html__('Selected records expired successfully!', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ('active' === $this->current_action()) {
|
||||
//Process activate bulk actions
|
||||
if (!isset($_REQUEST['item'])) {
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slmplus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . $error_msg . '</div>';
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slm-plus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . esc_html($error_msg) . '</div>';
|
||||
return;
|
||||
} else {
|
||||
$nvp_key = $this->_args['singular'];
|
||||
$liceses_to_activate = $_GET[$nvp_key];
|
||||
|
||||
|
||||
foreach ($liceses_to_activate as $row) {
|
||||
SLM_Utility::active_license_key_by_row_id($row);
|
||||
}
|
||||
|
||||
echo '<div id="message" class="updated fade"><p> ' . $row . ' Selected records activated successfully!</p></div>';
|
||||
|
||||
echo '<div id="message" class="updated fade"><p>' . esc_html($row) . ' ' . esc_html__('Selected records activated successfully!', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Export license data
|
||||
if ('export' === $this->current_action()) {
|
||||
if (!isset($_REQUEST['item'])) {
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slmplus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . $error_msg . '</div>';
|
||||
$error_msg = '<p>' . __('Error - Please select some records using the checkboxes', 'slm-plus') . '</p>';
|
||||
echo '<div id="message" class="error fade">' . esc_html($error_msg) . '</div>';
|
||||
return;
|
||||
} else {
|
||||
$nvp_key = $this->_args['singular'];
|
||||
$licenses_to_export = $_GET[$nvp_key];
|
||||
|
||||
|
||||
// Call the export function
|
||||
$file_urls = self::export_license_data($licenses_to_export);
|
||||
|
||||
|
||||
// Display success message with download links for each license
|
||||
echo '<div id="message" class="updated fade">';
|
||||
echo '<p>Export successful! Download the CSV files:</p>';
|
||||
|
@ -302,58 +300,73 @@ class SLM_List_Licenses extends WP_List_Table
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export function
|
||||
public static function export_license_data($license_ids)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Fetch the custom directory path from options (saved with hash)
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
$custom_dir_hash = isset($slm_options['slm_backup_dir_hash']) ? $slm_options['slm_backup_dir_hash'] : '';
|
||||
public static function export_license_data($license_ids)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Prepare file URLs array
|
||||
$file_urls = [];
|
||||
// Fetch the custom directory path from options (saved with hash)
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
$custom_dir_hash = isset($slm_options['slm_backup_dir_hash']) ? $slm_options['slm_backup_dir_hash'] : '';
|
||||
|
||||
// Get the WordPress upload directory
|
||||
$upload_dir = wp_upload_dir();
|
||||
$custom_dir = $upload_dir['basedir'] . $custom_dir_hash;
|
||||
// Prepare file URLs array
|
||||
$file_urls = [];
|
||||
|
||||
// Ensure the directory exists
|
||||
if (!file_exists($custom_dir)) {
|
||||
mkdir($custom_dir, 0755, true); // Create the directory if it doesn't exist
|
||||
}
|
||||
// Get the WordPress upload directory
|
||||
$upload_dir = wp_upload_dir();
|
||||
$custom_dir = $upload_dir['basedir'] . '/' . $custom_dir_hash;
|
||||
|
||||
// Fetch license data for each selected ID
|
||||
foreach ($license_ids as $license_id) {
|
||||
$data = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE id = %d", $license_id), ARRAY_A);
|
||||
if ($data) {
|
||||
$license_key = $data['license_key'];
|
||||
|
||||
// Prepare file name as "license_key.csv"
|
||||
$file_name = sanitize_file_name($license_key) . '.csv';
|
||||
$file_path = $custom_dir . '/' . $file_name;
|
||||
|
||||
// Open file handle
|
||||
$output = fopen($file_path, 'w');
|
||||
|
||||
// Write CSV headers
|
||||
fputcsv($output, array_keys($data));
|
||||
|
||||
// Write license data to CSV file
|
||||
fputcsv($output, $data);
|
||||
|
||||
// Close the file handle
|
||||
fclose($output);
|
||||
|
||||
// Store the file URL for download
|
||||
$file_urls[] = $upload_dir['baseurl'] . $custom_dir_hash . '/' . $file_name;
|
||||
// Initialize WP_Filesystem for safe file handling
|
||||
if (empty($GLOBALS['wp_filesystem'])) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
WP_Filesystem();
|
||||
}
|
||||
|
||||
// Ensure the directory exists using WP_Filesystem methods
|
||||
if (!is_dir($custom_dir)) {
|
||||
$created = $GLOBALS['wp_filesystem']->mkdir($custom_dir, 0755); // Create the directory if it doesn't exist
|
||||
if (!$created) {
|
||||
return new WP_Error('directory_creation_failed', 'Unable to create the directory.');
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch license data for each selected ID
|
||||
foreach ($license_ids as $license_id) {
|
||||
$data = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE id = %d",
|
||||
$license_id
|
||||
), ARRAY_A);
|
||||
|
||||
if ($data) {
|
||||
$license_key = $data['license_key'];
|
||||
|
||||
// Prepare file name as "license_key.csv"
|
||||
$file_name = sanitize_file_name($license_key) . '.csv';
|
||||
$file_path = $custom_dir . '/' . $file_name;
|
||||
|
||||
// Open file handle using WP_Filesystem methods
|
||||
$file_handle = $GLOBALS['wp_filesystem']->open($file_path, 'w');
|
||||
|
||||
if (!$file_handle) {
|
||||
return new WP_Error('file_creation_failed', 'Unable to open the file for writing.');
|
||||
}
|
||||
|
||||
// Write CSV headers and license data to the file
|
||||
fputcsv($file_handle, array_keys($data));
|
||||
fputcsv($file_handle, $data);
|
||||
|
||||
// Close the file handle
|
||||
$GLOBALS['wp_filesystem']->close($file_handle);
|
||||
|
||||
// Store the file URL for download
|
||||
$file_urls[] = $upload_dir['baseurl'] . '/' . $custom_dir_hash . '/' . $file_name;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the array of file URLs
|
||||
return $file_urls;
|
||||
}
|
||||
|
||||
// Return the array of file URLs
|
||||
return $file_urls;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -365,7 +378,7 @@ public static function export_license_data($license_ids)
|
|||
$success_msg = '<div id="message" class="updated"><p><strong>';
|
||||
$success_msg .= 'The selected entry was deleted successfully!';
|
||||
$success_msg .= '</strong></p></div>';
|
||||
echo $success_msg;
|
||||
echo esc_html($success_msg);
|
||||
}
|
||||
|
||||
function block_license_key($key_row_id)
|
||||
|
@ -374,7 +387,7 @@ public static function export_license_data($license_ids)
|
|||
$success_msg = '<div id="message" class="updated"><p><strong>';
|
||||
$success_msg .= 'The selected entry was blocked successfully!';
|
||||
$success_msg .= '</strong></p></div>';
|
||||
echo $success_msg;
|
||||
echo esc_html($success_msg);
|
||||
}
|
||||
|
||||
private function sort_data($a, $b)
|
||||
|
@ -382,26 +395,34 @@ public static function export_license_data($license_ids)
|
|||
// Set defaults
|
||||
$orderby = 'id';
|
||||
$order = 'desc';
|
||||
// If orderby is set, use this as the sort column
|
||||
|
||||
// Sanitize and unslash input for 'orderby' and 'order'
|
||||
if (!empty($_GET['orderby'])) {
|
||||
$orderby = $_GET['orderby'];
|
||||
$orderby = wp_unslash($_GET['orderby']); // wp_unslash before sanitization
|
||||
$orderby = sanitize_key($orderby); // sanitize for key-based data
|
||||
}
|
||||
// If order is set use this as the order
|
||||
|
||||
if (!empty($_GET['order'])) {
|
||||
$order = $_GET['order'];
|
||||
$order = wp_unslash($_GET['order']); // wp_unslash before sanitization
|
||||
$order = in_array(strtolower($order), ['asc', 'desc']) ? strtolower($order) : 'desc'; // Ensure 'asc' or 'desc' only
|
||||
}
|
||||
if ($orderby == 'id'){
|
||||
if ($a[$orderby]==$b[$orderby]){
|
||||
$result = 0;
|
||||
}else{
|
||||
$result = ($a[$orderby]<$b[$orderby])?-1:1;
|
||||
}
|
||||
}else{
|
||||
$result = strcmp($a[$orderby], $b[$orderby]);
|
||||
|
||||
// Sorting logic
|
||||
if ($orderby == 'id') {
|
||||
if ($a[$orderby] == $b[$orderby]) {
|
||||
$result = 0;
|
||||
} else {
|
||||
$result = ($a[$orderby] < $b[$orderby]) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
$result = strcmp($a[$orderby], $b[$orderby]);
|
||||
}
|
||||
|
||||
// Return based on the order (asc or desc)
|
||||
if ($order === 'asc') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
return -$result;
|
||||
}
|
||||
|
||||
|
@ -416,26 +437,51 @@ public static function export_license_data($license_ids)
|
|||
if (empty($per_page) || $per_page < 1) {
|
||||
$per_page = $screen->get_option('per_page', 'default');
|
||||
}
|
||||
$columns = $this->get_columns();
|
||||
// $hidden = array();
|
||||
$hidden = get_hidden_columns( $screen );
|
||||
$sortable = $this->get_sortable_columns();
|
||||
|
||||
$columns = $this->get_columns();
|
||||
$hidden = get_hidden_columns($screen);
|
||||
$sortable = $this->get_sortable_columns();
|
||||
$this->_column_headers = array($columns, $hidden, $sortable);
|
||||
|
||||
$this->process_bulk_action();
|
||||
$license_table = SLM_TBL_LICENSE_KEYS;
|
||||
$search = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
||||
$search_term = trim(strip_tags($search));
|
||||
$do_search = $wpdb->prepare("SELECT * FROM " . $license_table . " WHERE `license_key` LIKE '%%%s%%' OR `email` LIKE '%%%s%%' OR `lic_status` LIKE '%%%s%%' OR `first_name` LIKE '%%%s%%' OR `last_name` LIKE '%%%s%%'", $search_term, $search_term, $search_term, $search_term, $search_term);
|
||||
|
||||
// Ensure the license table constant is used safely
|
||||
$license_table = esc_sql(SLM_TBL_LICENSE_KEYS); // Sanitize the table name
|
||||
|
||||
// Search handling with esc_like for wildcard search
|
||||
$search = isset($_REQUEST['s']) ? sanitize_text_field(wp_unslash($_REQUEST['s'])) : ''; // Use wp_unslash to handle slashes
|
||||
$search_term = wp_strip_all_tags($search); // Using wp_strip_all_tags instead of strip_tags
|
||||
$search_term_esc = addcslashes($search_term, '_%'); // Escapes underscore and percent characters
|
||||
|
||||
// Prepared query with placeholders and escaped search term
|
||||
$do_search = $wpdb->prepare(
|
||||
"SELECT * FROM $license_table
|
||||
WHERE license_key LIKE %s OR email LIKE %s OR lic_status LIKE %s OR first_name LIKE %s OR last_name LIKE %s",
|
||||
'%' . $search_term_esc . '%', // Apply wildcard to the escaped search term
|
||||
'%' . $search_term_esc . '%',
|
||||
'%' . $search_term_esc . '%',
|
||||
'%' . $search_term_esc . '%',
|
||||
'%' . $search_term_esc . '%'
|
||||
);
|
||||
|
||||
// Execute the query and get the results
|
||||
$data = $wpdb->get_results($do_search, ARRAY_A);
|
||||
|
||||
// Sort data
|
||||
usort($data, array(&$this, 'sort_data'));
|
||||
$current_page = $this->get_pagenum();
|
||||
$total_items = count($data);
|
||||
$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
|
||||
$this->items = $data;
|
||||
|
||||
// Pagination
|
||||
$current_page = $this->get_pagenum();
|
||||
$total_items = count($data);
|
||||
$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
|
||||
|
||||
$this->items = $data;
|
||||
|
||||
// Set pagination arguments
|
||||
$this->set_pagination_args(array(
|
||||
'total_items' => $total_items, //WE have to calculate the total number of items
|
||||
'per_page' => $per_page, //WE have to determine how many items to show on a page
|
||||
'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages
|
||||
'total_items' => $total_items,
|
||||
'per_page' => $per_page,
|
||||
'total_pages' => ceil($total_items / $per_page)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -463,21 +509,22 @@ class SLM_Plugin
|
|||
public function slm_add_admin_menu()
|
||||
{
|
||||
$icon_svg = SLM_ASSETS_URL . 'images/slm_logo_small.svg';
|
||||
add_menu_page(__( 'SLM Plus', 'slmplus'), __( 'SLM Plus', 'slmplus'), SLM_MANAGEMENT_PERMISSION, SLM_MAIN_MENU_SLUG, "slm_manage_licenses_menu", $icon_svg);
|
||||
$hook = add_submenu_page(SLM_MAIN_MENU_SLUG, __('Manage Licenses', 'slmplus'), __('Manage Licenses', 'slmplus'), SLM_MANAGEMENT_PERMISSION, SLM_MAIN_MENU_SLUG, "slm_manage_licenses_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'Create license', 'slmplus'), __( 'Create license', 'slmplus') , SLM_MANAGEMENT_PERMISSION, 'slm_manage_license', "slm_add_licenses_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'Subscribers', 'slmplus'), __( 'Subscribers', 'slmplus'), SLM_MANAGEMENT_PERMISSION, 'slm_subscribers', "slm_subscribers_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'Tools', 'slmplus'), __( 'Tools', 'slmplus'), SLM_MANAGEMENT_PERMISSION, 'slm_admin_tools', "slm_admin_tools_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'Settings', 'slmplus'), __( 'Settings', 'slmplus'), SLM_MANAGEMENT_PERMISSION, 'slm_settings', "slm_settings_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'Help', 'slmplus'), __( 'Help', 'slmplus'), SLM_MANAGEMENT_PERMISSION, 'slm_help', "slm_integration_help_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __( 'About', 'slmplus'),__( 'About', 'slmplus'), SLM_MANAGEMENT_PERMISSION, 'slm_about', "slm_about_menu");
|
||||
add_menu_page(__('SLM Plus', 'slm-plus'), __('SLM Plus', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, SLM_MAIN_MENU_SLUG, "slm_manage_licenses_menu", $icon_svg);
|
||||
$hook = add_submenu_page(SLM_MAIN_MENU_SLUG, __('Manage Licenses', 'slm-plus'), __('Manage Licenses', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, SLM_MAIN_MENU_SLUG, "slm_manage_licenses_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('Create license', 'slm-plus'), __('Create license', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_manage_license', "slm_add_licenses_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('Subscribers', 'slm-plus'), __('Subscribers', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_subscribers', "slm_subscribers_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('Tools', 'slm-plus'), __('Tools', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_admin_tools', "slm_admin_tools_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('Settings', 'slm-plus'), __('Settings', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_settings', "slm_settings_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('Help', 'slm-plus'), __('Help', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_help', "slm_integration_help_menu");
|
||||
add_submenu_page(SLM_MAIN_MENU_SLUG, __('About', 'slm-plus'), __('About', 'slm-plus'), SLM_MANAGEMENT_PERMISSION, 'slm_about', "slm_about_menu");
|
||||
add_action("load-" . $hook, [$this, 'screen_option']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Screen options
|
||||
*/
|
||||
public function screen_option(){
|
||||
public function screen_option()
|
||||
{
|
||||
$option = 'per_page';
|
||||
$args = [
|
||||
'label' => 'Pagination',
|
||||
|
|
|
@ -12,7 +12,7 @@ function get_user_info()
|
|||
if (!current_user_can('manage_licenses')) {
|
||||
$response = array(
|
||||
'success' => false,
|
||||
'message' => _e('You do not have permission to manage this license.', 'slmplus'),
|
||||
'message' => esc_html__('You do not have permission to manage this license.', 'slm-plus'),
|
||||
);
|
||||
echo json_encode($response);
|
||||
die();
|
||||
|
@ -33,9 +33,9 @@ function slm_manage_licenses_menu()
|
|||
<div class="stats">
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<h1><?php _e('SLM Plus - Manage Licenses', 'slmplus'); ?></h1>
|
||||
<h1><?php esc_html_e('SLM Plus - Manage Licenses', 'slm-plus'); ?></h1>
|
||||
<br>
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_manage_license') ?>" class="page-title-action aria-button-if-js" role="button" aria-expanded="false"><?php _e('Add New', 'slmplus'); ?></a>
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_manage_license')); ?>" class="page-title-action aria-button-if-js" role="button" aria-expanded="false"><?php esc_html_e('Add New', 'slm-plus'); ?></a>
|
||||
|
||||
<hr class="wp-header-end">
|
||||
|
||||
|
@ -56,10 +56,10 @@ function slm_manage_licenses_menu()
|
|||
</div>
|
||||
<div class="meta-box-sortables ui-sortable">
|
||||
<form id="licenses-filter" method="get">
|
||||
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
||||
<input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
|
||||
<?php
|
||||
$license_list->prepare_items();
|
||||
$license_list->search_box(__('Search'), 'search-box-id');
|
||||
$license_list->search_box(__('Search', 'slm-plus'), 'search-box-id');
|
||||
$license_list->views();
|
||||
$license_list->display(); ?>
|
||||
</form>
|
||||
|
@ -73,4 +73,4 @@ function slm_manage_licenses_menu()
|
|||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,10 +82,10 @@ class Subscribers_List_Table extends WP_List_Table
|
|||
{
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />', //Render a checkbox
|
||||
'id' => __('ID', 'slmplus'),
|
||||
'first_name' => __('First Name', 'slmplus'),
|
||||
'last_name' => __('Last Name', 'slmplus'),
|
||||
'email' => __('Email Address', 'slmplus')
|
||||
'id' => __('ID', 'slm-plus'),
|
||||
'first_name' => __('First Name', 'slm-plus'),
|
||||
'last_name' => __('Last Name', 'slm-plus'),
|
||||
'email' => __('Email Address', 'slm-plus')
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
@ -116,14 +116,14 @@ class Subscribers_List_Table extends WP_List_Table
|
|||
if (!empty($_GET['order'])) {
|
||||
$order = $_GET['order'];
|
||||
}
|
||||
if ($orderby == 'id'){
|
||||
if ($a[$orderby]==$b[$orderby]){
|
||||
$result = 0;
|
||||
}else{
|
||||
$result = ($a[$orderby]<$b[$orderby])?-1:1;
|
||||
}
|
||||
}else{
|
||||
$result = strcmp($a[$orderby], $b[$orderby]);
|
||||
if ($orderby == 'id') {
|
||||
if ($a[$orderby] == $b[$orderby]) {
|
||||
$result = 0;
|
||||
} else {
|
||||
$result = ($a[$orderby] < $b[$orderby]) ? -1 : 1;
|
||||
}
|
||||
} else {
|
||||
$result = strcmp($a[$orderby], $b[$orderby]);
|
||||
}
|
||||
if ($order === 'asc') {
|
||||
return $result;
|
||||
|
@ -133,11 +133,10 @@ class Subscribers_List_Table extends WP_List_Table
|
|||
|
||||
function prepare_items()
|
||||
{
|
||||
|
||||
$per_page = 24;
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
$per_page = 24;
|
||||
$columns = $this->get_columns();
|
||||
$hidden = array();
|
||||
$sortable = $this->get_sortable_columns();
|
||||
|
||||
$this->_column_headers = array($columns, $hidden, $sortable);
|
||||
$this->process_bulk_action();
|
||||
|
@ -145,24 +144,41 @@ class Subscribers_List_Table extends WP_List_Table
|
|||
global $wpdb;
|
||||
$license_table = SLM_TBL_LICENSE_KEYS;
|
||||
|
||||
$search = (isset($_REQUEST['s'])) ? $_REQUEST['s'] : false;
|
||||
$search_term = trim(strip_tags($search));
|
||||
// Sanitize the search term and strip all tags
|
||||
$search = isset($_REQUEST['s']) ? sanitize_text_field(wp_unslash($_REQUEST['s'])) : false;
|
||||
$search_term = trim(wp_strip_all_tags($search)); // Using wp_strip_all_tags for better sanitization
|
||||
|
||||
$do_search = $wpdb->prepare("SELECT * FROM " . $license_table . " WHERE `email` LIKE '%%%s%%' OR `first_name` LIKE '%%%s%%' OR `last_name` LIKE '%%%s%%' GROUP BY email", $search_term, $search_term, $search_term);
|
||||
// Escape the search term for SQL and add wildcards manually
|
||||
$escaped_search_term = '%' . $wpdb->esc_like($search_term) . '%'; // esc_like handles escaping the term
|
||||
|
||||
// Prepare the query with placeholders to prevent SQL injection
|
||||
$do_search = $wpdb->prepare(
|
||||
"SELECT * FROM {$license_table}
|
||||
WHERE `email` LIKE %s
|
||||
OR `first_name` LIKE %s
|
||||
OR `last_name` LIKE %s
|
||||
GROUP BY `email`",
|
||||
$escaped_search_term, // Use the escaped search term with wildcards
|
||||
$escaped_search_term,
|
||||
$escaped_search_term
|
||||
);
|
||||
|
||||
// Execute the query safely
|
||||
$data = $wpdb->get_results($do_search, ARRAY_A);
|
||||
|
||||
usort($data, array(&$this, 'sort_data'));
|
||||
|
||||
$current_page = $this->get_pagenum();
|
||||
$total_items = count($data);
|
||||
$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
|
||||
$this->items = $data;
|
||||
// Pagination logic
|
||||
$current_page = $this->get_pagenum();
|
||||
$total_items = count($data);
|
||||
$data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
|
||||
$this->items = $data;
|
||||
|
||||
// Set pagination arguments
|
||||
$this->set_pagination_args(array(
|
||||
'total_items' => $total_items, //WE have to calculate the total number of items
|
||||
'per_page' => $per_page, //WE have to determine how many items to show on a page
|
||||
'total_pages' => ceil($total_items / $per_page) //WE have to calculate the total number of pages
|
||||
'total_items' => $total_items,
|
||||
'per_page' => $per_page,
|
||||
'total_pages' => ceil($total_items / $per_page)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -170,12 +186,13 @@ class Subscribers_List_Table extends WP_List_Table
|
|||
function slm_subscribers_menu()
|
||||
{
|
||||
$subscribers_list = new Subscribers_List_Table();
|
||||
if (isset($_REQUEST['slm_subscriber_edit']) && $_REQUEST['slm_subscriber_edit'] == 'true') : ?>
|
||||
$slm_subscriber_edit = isset($_REQUEST['slm_subscriber_edit']) ? sanitize_text_field($_REQUEST['slm_subscriber_edit']) : '';
|
||||
if ($slm_subscriber_edit === 'true') : ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h1><?php _e('Overview - Manage Subscribers', 'slmplus'); ?></h1>
|
||||
<h1><?php esc_html_e('Overview - Manage Subscribers', 'slm-plus'); ?></h1>
|
||||
<br>
|
||||
<a href="<?php echo admin_url('admin.php?page=slm_subscribers') ?>" class="page-title-action aria-button-if-js" role="button" aria-expanded="false"><?php _e('View all', 'slmplus'); ?></a>
|
||||
<a href="<?php echo esc_url(admin_url('admin.php?page=slm_subscribers')); ?>" class="page-title-action aria-button-if-js" role="button" aria-expanded="false"><?php esc_html_e('View all', 'slm-plus'); ?></a>
|
||||
<hr class="wp-header-end">
|
||||
|
||||
<div id="poststuff">
|
||||
|
@ -184,12 +201,11 @@ function slm_subscribers_menu()
|
|||
<div class="manage-user">
|
||||
<table class="wp-list-table widefat fixed striped items">
|
||||
<tr>
|
||||
<th scope="col" style="width: 32px"><?php _e('ID', 'slmplus'); ?></th>
|
||||
<th scope="col"><?php _e('License key', 'slmplus'); ?></th>
|
||||
<th scope="col"><?php _e('Status', 'slmplus'); ?></th>
|
||||
<th scope="col" style="width: 32px"><?php esc_html__('ID', 'slm-plus'); ?></th>
|
||||
<th scope="col"><?php esc_html__('License key', 'slm-plus'); ?></th>
|
||||
<th scope="col"><?php esc_html__('Status', 'slm-plus'); ?></th>
|
||||
<th scope="col"> </th>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
SLM_Utility::get_subscriber_licenses();
|
||||
?>
|
||||
|
@ -203,7 +219,7 @@ function slm_subscribers_menu()
|
|||
<?php else : ?>
|
||||
|
||||
<div class="wrap">
|
||||
<h1><?php _e('Overview - All Subscribers', 'slmplus'); ?></h1>
|
||||
<h1><?php esc_html_e('Overview - All Subscribers', 'slm-plus'); ?></h1>
|
||||
<br>
|
||||
<hr class="wp-header-end">
|
||||
<div id="poststuff">
|
||||
|
@ -211,10 +227,10 @@ function slm_subscribers_menu()
|
|||
<div id="post-body-content">
|
||||
<div class="meta-box-sortables ui-sortable">
|
||||
<form id="licenses-filter" method="get">
|
||||
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
|
||||
<input type="hidden" name="page" value="<?php echo esc_attr($_REQUEST['page']); ?>" />
|
||||
<?php
|
||||
$subscribers_list->prepare_items();
|
||||
$subscribers_list->search_box(__('Search', 'slmplus'), 'search-box-id');
|
||||
$subscribers_list->search_box(__('Search', 'slm-plus'), 'search-box-id');
|
||||
$subscribers_list->views();
|
||||
$subscribers_list->display(); ?>
|
||||
</form>
|
||||
|
|
1553
i18n/languages/slm-plus.pot
Normal file
1553
i18n/languages/slm-plus.pot
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -38,10 +38,10 @@ dbDelta($status_table_sql);
|
|||
$status_count = $wpdb->get_var("SELECT COUNT(*) FROM $lic_status_table");
|
||||
if ($status_count == 0) {
|
||||
$default_statuses = array(
|
||||
array('status_key' => 'pending', 'status_label' => __('Pending', 'slmplus')),
|
||||
array('status_key' => 'active', 'status_label' => __('Active', 'slmplus')),
|
||||
array('status_key' => 'blocked', 'status_label' => __('Blocked', 'slmplus')),
|
||||
array('status_key' => 'expired', 'status_label' => __('Expired', 'slmplus'))
|
||||
array('status_key' => 'pending', 'status_label' => __('Pending', 'slm-plus')),
|
||||
array('status_key' => 'active', 'status_label' => __('Active', 'slm-plus')),
|
||||
array('status_key' => 'blocked', 'status_label' => __('Blocked', 'slm-plus')),
|
||||
array('status_key' => 'expired', 'status_label' => __('Expired', 'slm-plus'))
|
||||
);
|
||||
|
||||
foreach ($default_statuses as $status) {
|
||||
|
|
|
@ -33,8 +33,10 @@
|
|||
*/
|
||||
|
||||
|
||||
class SLM_API_Listener{
|
||||
function __construct(){
|
||||
class SLM_API_Listener
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && isset($_REQUEST['secret_key'])) {
|
||||
do_action('slm_api_listener_init');
|
||||
$this->creation_api_listener();
|
||||
|
@ -46,32 +48,33 @@ class SLM_API_Listener{
|
|||
}
|
||||
}
|
||||
|
||||
function creation_api_listener() {
|
||||
function creation_api_listener()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_create_new') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$options = get_option('slm_plugin_options');
|
||||
$lic_key_prefix = $options['lic_prefix'] ?? 'SLM-'; // Use default prefix if missing
|
||||
|
||||
|
||||
// Security check: Verify secret key
|
||||
SLM_API_Utility::verify_secret_key_for_creation();
|
||||
|
||||
|
||||
// Logging for debugging
|
||||
$slm_debug_logger->log_debug("API - license creation (slm_create_new) request received.");
|
||||
|
||||
|
||||
// Trigger action hook for external integrations
|
||||
do_action('slm_api_listener_slm_create_new');
|
||||
|
||||
|
||||
// Initialize fields array
|
||||
$fields = [];
|
||||
|
||||
|
||||
// License key handling
|
||||
if (!empty($_REQUEST['license_key'])) {
|
||||
$fields['license_key'] = sanitize_text_field($_REQUEST['license_key']);
|
||||
} else {
|
||||
$fields['license_key'] = slm_get_license($lic_key_prefix); // Generate if not provided
|
||||
}
|
||||
|
||||
|
||||
// Sanitize and prepare other fields
|
||||
$fields['lic_status'] = !empty($_REQUEST['lic_status']) ? sanitize_text_field($_REQUEST['lic_status']) : 'pending';
|
||||
$fields['first_name'] = sanitize_text_field($_REQUEST['first_name']);
|
||||
|
@ -92,7 +95,7 @@ class SLM_API_Listener{
|
|||
$fields['lic_type'] = !empty($_REQUEST['lic_type']) ? sanitize_text_field($_REQUEST['lic_type']) : '';
|
||||
$fields['slm_billing_length'] = !empty($_REQUEST['slm_billing_length']) ? sanitize_text_field($_REQUEST['slm_billing_length']) : '';
|
||||
$fields['slm_billing_interval'] = !empty($_REQUEST['slm_billing_interval']) ? sanitize_text_field($_REQUEST['slm_billing_interval']) : '';
|
||||
|
||||
|
||||
// Validation for subscription-type licenses
|
||||
if ($fields['lic_type'] === 'subscription') {
|
||||
if (empty($fields['slm_billing_length'])) {
|
||||
|
@ -110,10 +113,10 @@ class SLM_API_Listener{
|
|||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Insert the license into the database
|
||||
$result = $wpdb->insert($slm_lic_table, $fields);
|
||||
|
||||
|
||||
// Error handling for database insertion
|
||||
if ($result === false) {
|
||||
SLM_API_Utility::output_api_response([
|
||||
|
@ -129,28 +132,29 @@ class SLM_API_Listener{
|
|||
'key' => $fields['license_key'],
|
||||
'code' => SLM_Error_Codes::LICENSE_CREATED
|
||||
];
|
||||
|
||||
|
||||
// Log license creation
|
||||
SLM_Utility::create_log($fields['license_key'], 'slm_create_new');
|
||||
|
||||
|
||||
// Output API response
|
||||
SLM_API_Utility::output_api_response($response_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function activation_api_listener() {
|
||||
|
||||
function activation_api_listener()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_activate') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
$sql_prep1 = "";
|
||||
$options = get_option('slm_plugin_options');
|
||||
|
||||
|
||||
// Verify secret key first for security
|
||||
SLM_API_Utility::verify_secret_key();
|
||||
|
||||
|
||||
// Trigger action hook for external integrations
|
||||
do_action('slm_api_listener_slm_activate');
|
||||
|
||||
|
||||
// Initialize fields
|
||||
$fields = [];
|
||||
$fields['lic_key'] = sanitize_text_field($_REQUEST['license_key']);
|
||||
|
@ -158,12 +162,12 @@ class SLM_API_Listener{
|
|||
$registered_devices = isset($_REQUEST['registered_devices']) ? sanitize_text_field($_REQUEST['registered_devices']) : '';
|
||||
$item_reference = isset($_REQUEST['item_reference']) ? sanitize_text_field($_REQUEST['item_reference']) : '';
|
||||
|
||||
|
||||
|
||||
// Table names
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$reg_domain_table = SLM_TBL_LIC_DOMAIN;
|
||||
$reg_table_devices = SLM_TBL_LIC_DEVICES;
|
||||
|
||||
|
||||
// Check if multiple items need verification
|
||||
if (!empty($item_reference) && $options['slm_multiple_items'] == 1) {
|
||||
$sql_prep1 = $wpdb->prepare("SELECT * FROM $slm_lic_table WHERE license_key = %s AND item_reference = %s", $fields['lic_key'], $item_reference);
|
||||
|
@ -176,30 +180,30 @@ class SLM_API_Listener{
|
|||
|
||||
SLM_Helper_Class::write_log('User ID (subscr_id): ' . $sql_prep1);
|
||||
|
||||
|
||||
|
||||
if (!$retLic) {
|
||||
$args = ['result' => 'error', 'message' => 'Invalid license key, key was not found.', 'error_code' => SLM_Error_Codes::LICENSE_INVALID];
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
|
||||
|
||||
// Check if the license is blocked or expired
|
||||
if ($retLic->lic_status === 'blocked') {
|
||||
do_action('slm_api_listener_slm_activate_key_blocked', $fields['lic_key']);
|
||||
$args = ['result' => 'error', 'message' => 'Your license key is blocked', 'error_code' => SLM_Error_Codes::LICENSE_BLOCKED];
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
|
||||
|
||||
if ($retLic->lic_status === 'expired') {
|
||||
do_action('slm_api_listener_slm_activate_key_expired', $fields['lic_key']);
|
||||
$args = ['result' => 'error', 'message' => 'Your license key has expired', 'error_code' => SLM_Error_Codes::LICENSE_EXPIRED];
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
|
||||
|
||||
// Handling registered domains
|
||||
if (!empty($registered_domain)) {
|
||||
$sql_prep2 = $wpdb->prepare("SELECT * FROM $reg_domain_table WHERE lic_key = %s", $fields['lic_key']);
|
||||
$reg_domains = $wpdb->get_results($sql_prep2, OBJECT);
|
||||
|
||||
|
||||
if (count($reg_domains) < intval($retLic->max_allowed_domains)) {
|
||||
foreach ($reg_domains as $reg_domain) {
|
||||
|
||||
|
@ -233,19 +237,19 @@ class SLM_API_Listener{
|
|||
|
||||
// Insert into the registered domain table
|
||||
$wpdb->insert($reg_domain_table, $fields);
|
||||
|
||||
|
||||
// Update license status to active
|
||||
$current_date = wp_date('Y-m-d');
|
||||
$wpdb->update($slm_lic_table, ['lic_status' => 'active', 'date_activated' => $current_date], ['id' => $retLic->id]);
|
||||
|
||||
//SLM_Helper_Class::write_log('LOG: ' . $url);
|
||||
|
||||
|
||||
// Send activation email
|
||||
$lic_email = SLM_Utility::slm_get_lic_email($fields['lic_key']);
|
||||
$subject = 'Your license key was activated';
|
||||
$message = 'Your license key: <strong>' . $fields['lic_key'] . '</strong> was activated successfully on ' . wp_date("F j, Y, g:i a") . '.';
|
||||
SLM_Utility::slm_send_mail($lic_email, $subject, $message, 'success');
|
||||
|
||||
|
||||
// Return success response
|
||||
$args = [
|
||||
'result' => 'success',
|
||||
|
@ -257,25 +261,22 @@ class SLM_API_Listener{
|
|||
];
|
||||
SLM_Utility::create_log($fields['lic_key'], 'License key activated for domain ' . $registered_domain);
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$args = [
|
||||
'result' => 'error',
|
||||
'message' => 'Reached maximum allowable domains',
|
||||
'result' => 'error',
|
||||
'message' => 'Reached maximum allowable domains',
|
||||
'error_code' => SLM_Error_Codes::REACHED_MAX_DOMAINS
|
||||
];
|
||||
SLM_Utility::create_log($fields['lic_key'], 'Reached maximum allowable domains');
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handling registered devices
|
||||
if (!empty($registered_devices)) {
|
||||
$sql_prep3 = $wpdb->prepare("SELECT * FROM $reg_table_devices WHERE lic_key = %s", $fields['lic_key']);
|
||||
$reg_devices = $wpdb->get_results($sql_prep3, OBJECT);
|
||||
|
||||
|
||||
if (count($reg_devices) < intval($retLic->max_allowed_devices)) {
|
||||
foreach ($reg_devices as $reg_device) {
|
||||
if (!empty($_REQUEST['migrate_from']) && $reg_device->registered_devices === sanitize_text_field($_REQUEST['migrate_from'])) {
|
||||
|
@ -294,7 +295,7 @@ class SLM_API_Listener{
|
|||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Register new device
|
||||
// If the registered device is provided, add it to the fields
|
||||
$fields['registered_devices'] = $registered_devices;
|
||||
|
@ -304,17 +305,17 @@ class SLM_API_Listener{
|
|||
|
||||
// Insert into the registered device table
|
||||
$wpdb->insert($reg_table_devices, $fields);
|
||||
|
||||
|
||||
// Update license status
|
||||
$current_date = wp_date('Y-m-d');
|
||||
$wpdb->update($slm_lic_table, ['lic_status' => 'active', 'date_activated' => $current_date], ['id' => $retLic->id]);
|
||||
|
||||
|
||||
// Send activation email
|
||||
$lic_email = SLM_Utility::slm_get_lic_email($fields['lic_key']);
|
||||
$subject = 'Your license key was activated';
|
||||
$message = 'Your license key: <strong>' . $fields['lic_key'] . '</strong> was activated successfully on ' . wp_date("F j, Y, g:i a") . '.';
|
||||
SLM_Utility::slm_send_mail($lic_email, $subject, $message, 'success');
|
||||
|
||||
|
||||
// Return success response
|
||||
$args = [
|
||||
'result' => 'success',
|
||||
|
@ -325,9 +326,7 @@ class SLM_API_Listener{
|
|||
];
|
||||
SLM_Utility::create_log($fields['lic_key'], 'License key activated for device ' . $registered_devices);
|
||||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
$args = [
|
||||
'result' => 'error',
|
||||
'icon_url' => SLM_Utility::slm_get_icon_url('1x', 'f-remove.png'),
|
||||
|
@ -340,32 +339,33 @@ class SLM_API_Listener{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deactivation_api_listener() {
|
||||
|
||||
function deactivation_api_listener()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_deactivate') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
|
||||
|
||||
// Verify the secret key for security
|
||||
SLM_API_Utility::verify_secret_key();
|
||||
$slm_debug_logger->log_debug("API - license deactivation (slm_deactivate) request received.");
|
||||
|
||||
|
||||
// Trigger deactivation hook for other integrations
|
||||
do_action('slm_api_listener_slm_deactivate');
|
||||
|
||||
|
||||
// Sanitize inputs
|
||||
$license_key = sanitize_text_field($_REQUEST['license_key']);
|
||||
$registered_domain = isset($_REQUEST['registered_domain']) ? sanitize_text_field($_REQUEST['registered_domain']) : '';
|
||||
$registered_devices = isset($_REQUEST['registered_devices']) ? sanitize_text_field($_REQUEST['registered_devices']) : '';
|
||||
|
||||
|
||||
|
||||
// Handle domain deactivation if domain info is provided
|
||||
if (!empty($registered_domain)) {
|
||||
$registered_dom_table = SLM_TBL_LIC_DOMAIN;
|
||||
|
||||
|
||||
// Prepare SQL query for domain deactivation
|
||||
$sql_prep = $wpdb->prepare("DELETE FROM $registered_dom_table WHERE lic_key = %s AND registered_domain = %s", $license_key, $registered_domain);
|
||||
$delete = $wpdb->query($sql_prep);
|
||||
|
||||
|
||||
// Check result of the deletion query
|
||||
if ($delete === false) {
|
||||
$slm_debug_logger->log_debug("Error - failed to delete the registered domain from the database.");
|
||||
|
@ -390,15 +390,15 @@ class SLM_API_Listener{
|
|||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle device deactivation if device info is provided
|
||||
if (!empty($registered_devices)) {
|
||||
$registered_device_table = SLM_TBL_LIC_DEVICES;
|
||||
|
||||
|
||||
// Prepare SQL query for device deactivation
|
||||
$sql_prep2 = $wpdb->prepare("DELETE FROM $registered_device_table WHERE lic_key = %s AND registered_devices = %s", $license_key, $registered_devices);
|
||||
$delete2 = $wpdb->query($sql_prep2);
|
||||
|
||||
|
||||
// Check result of the deletion query
|
||||
if ($delete2 === false) {
|
||||
$slm_debug_logger->log_debug("Error - failed to delete the registered device from the database.");
|
||||
|
@ -423,7 +423,7 @@ class SLM_API_Listener{
|
|||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If neither domain nor device info is provided, return an error response
|
||||
if (empty($registered_domain) && empty($registered_devices)) {
|
||||
$args = ['result' => 'error', 'message' => 'No deactivation target specified. Either a domain or device must be provided.', 'error_code' => SLM_Error_Codes::DOMAIN_MISSING];
|
||||
|
@ -431,19 +431,19 @@ class SLM_API_Listener{
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function update_api_listener() {
|
||||
|
||||
function update_api_listener()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_update') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
|
||||
|
||||
// Verify secret key for security
|
||||
SLM_API_Utility::verify_secret_key_for_creation();
|
||||
$slm_debug_logger->log_debug("API - license update (slm_update) request received.");
|
||||
|
||||
|
||||
// Trigger update hook for integrations
|
||||
do_action('slm_api_listener_slm_update');
|
||||
|
||||
|
||||
// Sanitize inputs and build the update fields array
|
||||
$fields = array(
|
||||
'license_key' => sanitize_text_field($_REQUEST['license_key']),
|
||||
|
@ -456,7 +456,7 @@ class SLM_API_Listener{
|
|||
'lic_status' => isset($_REQUEST['lic_status']) ? sanitize_text_field($_REQUEST['lic_status']) : 'active',
|
||||
'item_reference' => isset($_REQUEST['item_reference']) ? sanitize_text_field($_REQUEST['item_reference']) : '',
|
||||
);
|
||||
|
||||
|
||||
// Validate that the license key is provided
|
||||
if (empty($fields['license_key'])) {
|
||||
$args = array(
|
||||
|
@ -468,12 +468,12 @@ class SLM_API_Listener{
|
|||
SLM_API_Utility::output_api_response($args);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Update the license in the database
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$where_clause = array('license_key' => $fields['license_key']);
|
||||
$update_result = $wpdb->update($slm_lic_table, $fields, $where_clause);
|
||||
|
||||
|
||||
// Handle update result
|
||||
if ($update_result === false) {
|
||||
$args = array(
|
||||
|
@ -504,41 +504,41 @@ class SLM_API_Listener{
|
|||
SLM_API_Utility::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function check_api_listener()
|
||||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_check') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
|
||||
|
||||
// Verify secret key for security
|
||||
SLM_API_Utility::verify_secret_key();
|
||||
|
||||
|
||||
$slm_debug_logger->log_debug("API - license check (slm_check) request received.");
|
||||
|
||||
|
||||
// Sanitize input
|
||||
$license_key = sanitize_text_field($_REQUEST['license_key']);
|
||||
$slm_debug_logger->log_debug("Checking license key: " . $license_key);
|
||||
|
||||
|
||||
// Action hook for additional integrations
|
||||
do_action('slm_api_listener_slm_check');
|
||||
|
||||
|
||||
// Query license key details
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$reg_domain_table = SLM_TBL_LIC_DOMAIN;
|
||||
$reg_table_devices = SLM_TBL_LIC_DEVICES;
|
||||
|
||||
|
||||
// Retrieve the license key details from the database
|
||||
$license_query = $wpdb->prepare("SELECT * FROM $slm_lic_table WHERE license_key = %s", $license_key);
|
||||
$retLic = $wpdb->get_row($license_query, OBJECT);
|
||||
|
||||
|
||||
if ($retLic) {
|
||||
// If the license exists, retrieve domain and device information
|
||||
$domain_query = $wpdb->prepare("SELECT * FROM $reg_domain_table WHERE lic_key = %s", $license_key);
|
||||
$device_query = $wpdb->prepare("SELECT * FROM $reg_table_devices WHERE lic_key = %s", $license_key);
|
||||
|
||||
|
||||
$registered_domains = $wpdb->get_results($domain_query, OBJECT);
|
||||
$registered_devices = $wpdb->get_results($device_query, OBJECT);
|
||||
|
||||
|
||||
// Prepare response with license and registration data
|
||||
$response_args = apply_filters('slm_check_response_args', array(
|
||||
'result' => 'success',
|
||||
|
@ -565,11 +565,10 @@ class SLM_API_Listener{
|
|||
'until' => $retLic->until,
|
||||
'current_ver' => $retLic->current_ver,
|
||||
));
|
||||
|
||||
|
||||
// Log and send the response
|
||||
SLM_Utility::create_log($license_key, 'License check successful');
|
||||
SLM_API_Utility::output_api_response($response_args);
|
||||
|
||||
} else {
|
||||
// Invalid license key case
|
||||
$error_args = array(
|
||||
|
@ -577,7 +576,7 @@ class SLM_API_Listener{
|
|||
'message' => 'Invalid license key',
|
||||
'error_code' => SLM_Error_Codes::LICENSE_INVALID
|
||||
);
|
||||
|
||||
|
||||
// Log the error and respond
|
||||
SLM_Utility::create_log($license_key, 'License check failed: Invalid license key');
|
||||
SLM_API_Utility::output_api_response($error_args);
|
||||
|
@ -589,36 +588,36 @@ class SLM_API_Listener{
|
|||
{
|
||||
if (isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) === 'slm_info') {
|
||||
global $slm_debug_logger, $wpdb;
|
||||
|
||||
|
||||
// Verify secret key for security
|
||||
SLM_API_Utility::verify_secret_key();
|
||||
|
||||
SLM_API_Utility::verify_secret_key();
|
||||
|
||||
// Log the API request
|
||||
$slm_debug_logger->log_debug("API - license info (slm_info) request received.");
|
||||
|
||||
|
||||
// Sanitize input data
|
||||
$license_key = sanitize_text_field($_REQUEST['license_key']);
|
||||
$slm_debug_logger->log_debug("License key: " . $license_key);
|
||||
|
||||
|
||||
// Action hook for additional integrations
|
||||
do_action('slm_api_listener_slm_info');
|
||||
|
||||
|
||||
// Fetch license details from the database
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
$reg_domain_table = SLM_TBL_LIC_DOMAIN;
|
||||
$reg_table_devices = SLM_TBL_LIC_DEVICES;
|
||||
|
||||
|
||||
$license_query = $wpdb->prepare("SELECT * FROM $slm_lic_table WHERE license_key = %s", $license_key);
|
||||
$retLic = $wpdb->get_row($license_query, OBJECT);
|
||||
|
||||
|
||||
if ($retLic) {
|
||||
// If the license exists, fetch associated domains and devices
|
||||
$domain_query = $wpdb->prepare("SELECT * FROM $reg_domain_table WHERE lic_key = %s", $license_key);
|
||||
$device_query = $wpdb->prepare("SELECT * FROM $reg_table_devices WHERE lic_key = %s", $license_key);
|
||||
|
||||
|
||||
$registered_domains = $wpdb->get_results($domain_query, OBJECT);
|
||||
$registered_devices = $wpdb->get_results($device_query, OBJECT);
|
||||
|
||||
|
||||
// Prepare the response with the license and registration data
|
||||
$response_args = apply_filters('slm_info_response_args', array(
|
||||
'result' => 'success',
|
||||
|
@ -643,7 +642,7 @@ class SLM_API_Listener{
|
|||
'until' => $retLic->until,
|
||||
'current_ver' => $retLic->current_ver,
|
||||
));
|
||||
|
||||
|
||||
// Log the successful check
|
||||
SLM_Utility::create_log($license_key, 'info: valid license key');
|
||||
SLM_API_Utility::output_api_response($response_args);
|
||||
|
@ -654,7 +653,7 @@ class SLM_API_Listener{
|
|||
'message' => 'Invalid license key',
|
||||
'error_code' => SLM_Error_Codes::LICENSE_INVALID
|
||||
);
|
||||
|
||||
|
||||
// Log the error
|
||||
SLM_Utility::create_log($license_key, 'info: invalid license key');
|
||||
SLM_API_Utility::output_api_response($error_args);
|
||||
|
|
|
@ -2,36 +2,37 @@
|
|||
|
||||
class SLM_Init_Time_Tasks {
|
||||
|
||||
public function __construct() {
|
||||
$this->load_scripts();
|
||||
// Add other init time operations here
|
||||
add_action('slm_daily_cron_event', array($this, 'slm_daily_cron_event_handler'));
|
||||
}
|
||||
public function __construct() {
|
||||
$this->load_scripts();
|
||||
// Add other init time operations here
|
||||
add_action('slm_daily_cron_event', array($this, 'slm_daily_cron_event_handler'));
|
||||
}
|
||||
|
||||
// Load common and admin-specific scripts and styles
|
||||
public function load_scripts() {
|
||||
wp_enqueue_script('jquery'); // Common scripts
|
||||
// Load common and admin-specific scripts and styles
|
||||
public function load_scripts() {
|
||||
$plugin_version = '1.0.0'; // Replace with your plugin version if available
|
||||
|
||||
if (is_admin()) {
|
||||
wp_enqueue_script('jquery-ui-datepicker');
|
||||
wp_enqueue_script('wplm-custom-admin-js', SLM_ASSETS_URL . 'js/wplm-custom-admin.js', array('jquery-ui-dialog')); // Admin-only JS
|
||||
if (isset($_GET['page']) && $_GET['page'] == 'slm_manage_license') { // Only include if in license management interface
|
||||
wp_enqueue_style('jquery-ui-style', SLM_ASSETS_URL . 'css/jquery-ui.css');
|
||||
}
|
||||
wp_enqueue_script('jquery'); // Common scripts
|
||||
|
||||
if (is_admin()) {
|
||||
wp_enqueue_script('jquery-ui-datepicker');
|
||||
// Enqueue admin-specific JS and add version and load in footer
|
||||
wp_enqueue_script('wplm-custom-admin-js', SLM_ASSETS_URL . 'js/wplm-custom-admin.js', array('jquery-ui-dialog'), $plugin_version, true); // true loads in footer
|
||||
if (isset($_GET['page']) && $_GET['page'] == 'slm_manage_license') { // Only include if in license management interface
|
||||
wp_enqueue_style('jquery-ui-style', SLM_ASSETS_URL . 'css/jquery-ui.css', array(), $plugin_version); // Add version for caching
|
||||
}
|
||||
}
|
||||
|
||||
// Daily cron event handler
|
||||
public function slm_daily_cron_event_handler() {
|
||||
$options = get_option('slm_plugin_options');
|
||||
do_action('slm_daily_cron_event_triggered');
|
||||
|
||||
if (isset($options['enable_auto_key_expiry']) && $options['enable_auto_key_expiry'] == '1') {
|
||||
// Perform auto key expiry task
|
||||
SLM_Debug_Logger::log_debug_st("SLM daily cronjob - auto expiry of license key is enabled.");
|
||||
SLM_Utility::do_auto_key_expiry();
|
||||
}
|
||||
|
||||
// Add any other daily cron job tasks here
|
||||
}
|
||||
}
|
||||
|
||||
// Daily cron event handler
|
||||
public function slm_daily_cron_event_handler() {
|
||||
$options = get_option('slm_plugin_options');
|
||||
do_action('slm_daily_cron_event_triggered');
|
||||
|
||||
if (isset($options['enable_auto_key_expiry']) && $options['enable_auto_key_expiry'] == '1') {
|
||||
// Perform auto key expiry task
|
||||
SLM_Debug_Logger::log_debug_st("SLM daily cronjob - auto expiry of license key is enabled.");
|
||||
SLM_Utility::do_auto_key_expiry();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
* @link http://epikly.com
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//Includes - utilities and cron jobs
|
||||
include_once(ABSPATH . 'wp-admin/includes/plugin.php');
|
||||
require_once(SLM_LIB . 'slm-utility.php');
|
||||
|
@ -27,7 +27,8 @@ if (is_admin()) {
|
|||
}
|
||||
|
||||
if (!function_exists('hyphenate')) {
|
||||
function hyphenate($str) {
|
||||
function hyphenate($str)
|
||||
{
|
||||
return implode("-", str_split($str, 5));
|
||||
}
|
||||
}
|
||||
|
@ -35,31 +36,78 @@ if (!function_exists('hyphenate')) {
|
|||
|
||||
// WP eStores integration
|
||||
if (SLM_Helper_Class::slm_get_option('slm_wpestores') == 1) {
|
||||
require_once(SLM_ADMIN . 'includes/wpestores/slm-wpestores.php');
|
||||
// require_once(SLM_ADMIN . 'includes/wpestores/slm-wpestores.php');
|
||||
}
|
||||
|
||||
// Activation and deactivation hooks
|
||||
function activate_slm_plus() {
|
||||
function activate_slm_plus()
|
||||
{
|
||||
require_once SLM_LIB . 'class-slm-activator.php';
|
||||
$slm_activator->activate();
|
||||
}
|
||||
|
||||
function deactivate_slm_plus() {
|
||||
function deactivate_slm_plus()
|
||||
{
|
||||
require_once SLM_LIB . 'class-slm-deactivator.php';
|
||||
$slm_deactivator->deactivate();
|
||||
}
|
||||
|
||||
function slm_get_license($lic_key_prefix = '')
|
||||
{
|
||||
return strtoupper($lic_key_prefix . hyphenate(md5(uniqid(rand(4, 10), true) . date('Y-m-d H:i:s') . time())));
|
||||
}
|
||||
|
||||
register_activation_hook(__FILE__, 'activate_slm_plus');
|
||||
register_deactivation_hook(__FILE__, 'deactivate_slm_plus');
|
||||
|
||||
// License key generator function
|
||||
function slmplus_get_license($lic_key_prefix = '') {
|
||||
return strtoupper($lic_key_prefix . hyphenate(md5(uniqid(rand(4, 10), true) . date('Y-m-d H:i:s') . time())));
|
||||
// Improved and Shortened License Key Generator Function
|
||||
function slm_get_license($lic_key_prefix = '')
|
||||
{
|
||||
global $wpdb;
|
||||
$max_retries = 5; // Set the maximum number of retries
|
||||
$retry_count = 0;
|
||||
$license_key = '';
|
||||
|
||||
// Use the constant to define the license table
|
||||
$license_table = SLM_TBL_LICENSE_KEYS;
|
||||
|
||||
// Generate a unique license key
|
||||
while ($retry_count < $max_retries) {
|
||||
// Generate a strong, random base using random_int() and uniqid
|
||||
$random_base = uniqid(random_int(1000, 9999), true);
|
||||
|
||||
// Combine random base with the current GMT date and time and the Unix timestamp for additional uniqueness
|
||||
$combined_string = $random_base . gmdate('Y-m-d H:i:s') . time();
|
||||
|
||||
// Create a sha256 hash of the combined string
|
||||
$hashed_string = substr(hash('sha256', $combined_string), 0, 32); // Take first 32 characters of the sha256 hash
|
||||
|
||||
// Ensure the prefix is added correctly
|
||||
$license_key = strtoupper($hashed_string);
|
||||
|
||||
// Add dashes every 4 characters
|
||||
$license_key_with_dashes = implode('-', str_split($license_key, 4));
|
||||
|
||||
// Add the prefix to the formatted key
|
||||
$license_key_with_prefix = $lic_key_prefix . $license_key_with_dashes;
|
||||
|
||||
// Check if the generated license key already exists in the database
|
||||
$existing_license = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $license_table WHERE license_key = %s", $license_key_with_prefix));
|
||||
|
||||
// If the license doesn't exist, break out of the loop and return the key
|
||||
if ($existing_license == 0) {
|
||||
return $license_key_with_prefix;
|
||||
}
|
||||
|
||||
// If the license already exists, increment the retry count and try again
|
||||
$retry_count++;
|
||||
}
|
||||
|
||||
// If we exceed the retry limit, return false or handle the error as needed
|
||||
error_log('Failed to generate a unique license key after ' . $max_retries . ' attempts.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Example hyphenate function (assuming hyphenates every 4 characters)
|
||||
function hyphenate($string)
|
||||
{
|
||||
return implode('-', str_split($string, 4)); // This splits the string into chunks of 4 characters and adds hyphens
|
||||
}
|
||||
|
||||
// Action hooks
|
||||
|
@ -75,13 +123,15 @@ add_action('plugins_loaded', array('SLM_Tabbed_Plugin', 'get_object'));
|
|||
$slm_debug_logger = new SLM_Debug_Logger();
|
||||
|
||||
// Init-time tasks
|
||||
function slmplus_init_handler() {
|
||||
function slmplus_init_handler()
|
||||
{
|
||||
$init_task = new SLM_Init_Time_Tasks();
|
||||
$api_listener = new SLM_API_Listener();
|
||||
}
|
||||
|
||||
// Plugins loaded tasks
|
||||
function slmplus_plugins_loaded_handler() {
|
||||
function slmplus_plugins_loaded_handler()
|
||||
{
|
||||
if (is_admin() && get_option('slm_db_version') != SLM_DB_VERSION) {
|
||||
require_once(SLM_LIB . 'class-slm-installer.php');
|
||||
// TODO - Implement DB update logic here
|
||||
|
@ -89,10 +139,12 @@ function slmplus_plugins_loaded_handler() {
|
|||
}
|
||||
|
||||
// Singleton pattern for the plugin
|
||||
class SLM_Tabbed_Plugin {
|
||||
class SLM_Tabbed_Plugin
|
||||
{
|
||||
private static $classobj = NULL;
|
||||
|
||||
public static function get_object() {
|
||||
public static function get_object()
|
||||
{
|
||||
if (self::$classobj === NULL) {
|
||||
self::$classobj = new self();
|
||||
}
|
||||
|
@ -103,7 +155,8 @@ class SLM_Tabbed_Plugin {
|
|||
}
|
||||
|
||||
// AJAX handlers
|
||||
function slmplus_del_registered_domain() {
|
||||
function slmplus_del_registered_domain()
|
||||
{
|
||||
global $wpdb;
|
||||
$id = strip_tags($_GET['id']);
|
||||
$ret = $wpdb->query($wpdb->prepare("DELETE FROM " . SLM_TBL_LIC_DOMAIN . " WHERE id = %d", $id));
|
||||
|
@ -111,7 +164,8 @@ function slmplus_del_registered_domain() {
|
|||
exit;
|
||||
}
|
||||
|
||||
function slmplus_del_registered_devices() {
|
||||
function slmplus_del_registered_devices()
|
||||
{
|
||||
global $wpdb;
|
||||
$id = strip_tags($_GET['id']);
|
||||
$ret = $wpdb->query($wpdb->prepare("DELETE FROM " . SLM_TBL_LIC_DEVICES . " WHERE id = %d", $id));
|
||||
|
@ -119,7 +173,8 @@ function slmplus_del_registered_devices() {
|
|||
exit;
|
||||
}
|
||||
|
||||
function slmplus_remove_activation() {
|
||||
function slmplus_remove_activation()
|
||||
{
|
||||
global $wpdb;
|
||||
$id = strip_tags($_GET['id']);
|
||||
$activation_type = strip_tags($_GET['activation_type']);
|
||||
|
@ -131,13 +186,15 @@ function slmplus_remove_activation() {
|
|||
}
|
||||
|
||||
// Debugging functions
|
||||
function wc_print_pretty($args) {
|
||||
function wc_print_pretty($args)
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($args);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
function wc_log($msg) {
|
||||
function wc_log($msg)
|
||||
{
|
||||
$log = ABSPATH . DIRECTORY_SEPARATOR . 'slm_log.txt';
|
||||
file_put_contents($log, $msg . '', FILE_APPEND);
|
||||
}
|
||||
|
@ -148,7 +205,7 @@ if (SLM_Helper_Class::slm_get_option('slm_woo') == 1 && is_plugin_active('woocom
|
|||
require_once(SLM_WOO . 'includes/slm-meta-boxes.php');
|
||||
|
||||
require_once SLM_WOO . 'includes/register-template.php';
|
||||
require_once SLM_WOO . 'includes/purchase.php';
|
||||
require_once SLM_WOO . 'includes/purchase.php';
|
||||
require_once SLM_WOO . 'includes/create-license-orders.php';
|
||||
|
||||
// Build WooCommerce tabs
|
||||
|
@ -156,40 +213,43 @@ if (SLM_Helper_Class::slm_get_option('slm_woo') == 1 && is_plugin_active('woocom
|
|||
}
|
||||
|
||||
add_action('wp_ajax_slm_user_search', 'slm_user_search');
|
||||
function slm_user_search() {
|
||||
function slm_user_search()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$value = sanitize_text_field($_POST['value']);
|
||||
|
||||
// Meta query to search for user data
|
||||
$meta_query = [
|
||||
'relation' => 'OR',
|
||||
['key' => 'first_name', 'value' => $value, 'compare' => 'LIKE'],
|
||||
['key' => 'last_name', 'value' => $value, 'compare' => 'LIKE'],
|
||||
['key' => 'billing_first_name', 'value' => $value, 'compare' => 'LIKE'],
|
||||
['key' => 'billing_last_name', 'value' => $value, 'compare' => 'LIKE'],
|
||||
];
|
||||
|
||||
// Arguments to find users
|
||||
$args = [
|
||||
'meta_query' => $meta_query,
|
||||
'number' => 10,
|
||||
];
|
||||
// Direct SQL Query to improve performance
|
||||
$query = $wpdb->prepare(
|
||||
"
|
||||
SELECT u.ID, u.display_name, u.user_email,
|
||||
IFNULL(um_first_name.meta_value, um_billing_first_name.meta_value) AS first_name,
|
||||
IFNULL(um_last_name.meta_value, um_billing_last_name.meta_value) AS last_name
|
||||
FROM {$wpdb->users} u
|
||||
LEFT JOIN {$wpdb->prefix}usermeta um_first_name ON um_first_name.user_id = u.ID AND um_first_name.meta_key = 'first_name'
|
||||
LEFT JOIN {$wpdb->prefix}usermeta um_last_name ON um_last_name.user_id = u.ID AND um_last_name.meta_key = 'last_name'
|
||||
LEFT JOIN {$wpdb->prefix}usermeta um_billing_first_name ON um_billing_first_name.user_id = u.ID AND um_billing_first_name.meta_key = 'billing_first_name'
|
||||
LEFT JOIN {$wpdb->prefix}usermeta um_billing_last_name ON um_billing_last_name.user_id = u.ID AND um_billing_last_name.meta_key = 'billing_last_name'
|
||||
WHERE (um_first_name.meta_value LIKE %s OR um_last_name.meta_value LIKE %s OR um_billing_first_name.meta_value LIKE %s OR um_billing_last_name.meta_value LIKE %s)
|
||||
LIMIT 10
|
||||
",
|
||||
'%' . $wpdb->esc_like($value) . '%',
|
||||
'%' . $wpdb->esc_like($value) . '%',
|
||||
'%' . $wpdb->esc_like($value) . '%',
|
||||
'%' . $wpdb->esc_like($value) . '%'
|
||||
);
|
||||
|
||||
$users = get_users($args);
|
||||
$users = $wpdb->get_results($query);
|
||||
$results = [];
|
||||
|
||||
foreach ($users as $user) {
|
||||
// Fallback to billing info if WooCommerce is active
|
||||
$first_name = get_user_meta($user->ID, 'first_name', true) ?: get_user_meta($user->ID, 'billing_first_name', true);
|
||||
$last_name = get_user_meta($user->ID, 'last_name', true) ?: get_user_meta($user->ID, 'billing_last_name', true);
|
||||
$company_name = get_user_meta($user->ID, 'company_name', true); // Retrieve company name if available
|
||||
|
||||
$results[] = [
|
||||
'ID' => $user->ID,
|
||||
'display_name' => $user->display_name ?: "{$first_name} {$last_name}",
|
||||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'display_name' => $user->display_name ?: "{$user->first_name} {$user->last_name}",
|
||||
'first_name' => $user->first_name,
|
||||
'last_name' => $user->last_name,
|
||||
'email' => $user->user_email,
|
||||
'company_name' => $company_name,
|
||||
'company_name' => get_user_meta($user->ID, 'company_name', true),
|
||||
'subscr_id' => $user->ID, // Pass user ID as the subscription ID
|
||||
];
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ class SLM_Helper_Class
|
|||
}
|
||||
}
|
||||
}
|
||||
public static function get_license_logs($license_key) {
|
||||
public static function get_license_logs($license_key)
|
||||
{
|
||||
global $wpdb;
|
||||
$table_name = SLM_TBL_LIC_LOG;
|
||||
|
||||
|
@ -63,7 +64,7 @@ class SLM_Helper_Class
|
|||
$output = implode(',', $output);
|
||||
|
||||
// print the result into the JavaScript console
|
||||
echo "<script>console.log( 'PHP LOG: " . $output . "' );</script>";
|
||||
echo "<script>console.log('PHP LOG: " . esc_js($output) . "');</script>";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +100,8 @@ class SLM_API_Utility
|
|||
* Validate date format to ensure it's in 'YYYY-MM-DD' format.
|
||||
* Returns the sanitized date or an empty string if invalid.
|
||||
*/
|
||||
public static function slm_validate_date($date) {
|
||||
public static function slm_validate_date($date)
|
||||
{
|
||||
$date = sanitize_text_field($date);
|
||||
$timestamp = strtotime($date);
|
||||
if ($timestamp && date('Y-m-d', $timestamp) === $date) {
|
||||
|
@ -110,39 +112,65 @@ class SLM_API_Utility
|
|||
|
||||
public static function verify_secret_key()
|
||||
{
|
||||
// Get the stored secret key from plugin options
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
$right_secret_key = $slm_options['lic_verification_secret'] ?? '';
|
||||
|
||||
// Sanitize and retrieve the received secret key
|
||||
$received_secret_key = sanitize_text_field($_REQUEST['secret_key'] ?? '');
|
||||
|
||||
// Case-sensitive comparison for the secret keys
|
||||
if ($received_secret_key !== $right_secret_key) {
|
||||
// Prepare the error response with case-sensitivity note
|
||||
$args = array(
|
||||
'result' => 'error',
|
||||
'message' => 'Verification API secret key is invalid',
|
||||
'message' => 'Verification API secret key is invalid. Note: The key comparison is case-sensitive.',
|
||||
'error_code' => SLM_Error_Codes::VERIFY_KEY_INVALID
|
||||
);
|
||||
// Output the API response with the error
|
||||
self::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_slm_option($option)
|
||||
{
|
||||
$slm_options_func = get_option('slm_plugin_options', []);
|
||||
$option = $slm_options_func[$option];
|
||||
return sanitize_text_field($option);
|
||||
// Retrieve the option value from the database
|
||||
$slm_options_func = get_option('slm_plugin_options', []);
|
||||
|
||||
// Check if the option exists; if not, return an empty string
|
||||
if (!isset($slm_options_func[$option])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Get the option value and unslash it (removes slashes from the option value)
|
||||
$option_value = wp_unslash($slm_options_func[$option]);
|
||||
|
||||
// Sanitize the option value (text field sanitization)
|
||||
$sanitized_option = sanitize_text_field($option_value);
|
||||
|
||||
// Return the sanitized and unslashed option value
|
||||
return $sanitized_option;
|
||||
}
|
||||
|
||||
|
||||
public static function verify_secret_key_for_creation()
|
||||
{
|
||||
// Get the stored secret key from plugin options
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
$right_secret_key = $slm_options['lic_creation_secret'] ?? '';
|
||||
|
||||
// Sanitize and retrieve the received secret key
|
||||
$received_secret_key = sanitize_text_field($_REQUEST['secret_key'] ?? '');
|
||||
|
||||
// Case-sensitive comparison for the secret keys
|
||||
if ($received_secret_key !== $right_secret_key) {
|
||||
// Prepare the error response with case-sensitivity note
|
||||
$args = array(
|
||||
'result' => 'error',
|
||||
'message' => 'License Creation API secret key is invalid',
|
||||
'message' => 'Invalid License Creation API Secret Key provided. Note: The key comparison is case-sensitive.',
|
||||
'error_code' => SLM_Error_Codes::CREATE_KEY_INVALID
|
||||
);
|
||||
// Output the API response with the error
|
||||
self::output_api_response($args);
|
||||
}
|
||||
}
|
||||
|
@ -160,6 +188,88 @@ class SLM_API_Utility
|
|||
|
||||
class SLM_Utility
|
||||
{
|
||||
/**
|
||||
* Saves a backup of the plugin's database tables in a secure folder.
|
||||
*/
|
||||
public static function slm_save_backup_to_uploads()
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Get the upload directory
|
||||
$upload_dir = wp_upload_dir();
|
||||
$unique_hash = slm_get_unique_hash(); // Generate or retrieve the unique hash
|
||||
$slm_backup_dir = $upload_dir['basedir'] . $unique_hash;
|
||||
|
||||
// Create the slm-plus folder with hash if it doesn't exist
|
||||
if (!file_exists($slm_backup_dir)) {
|
||||
wp_mkdir_p($slm_backup_dir);
|
||||
}
|
||||
|
||||
// Set backup file name and path
|
||||
$backup_file = $slm_backup_dir . '/slm_plugin_backup_' . gmdate('Y-m-d H:i:s') . '.sql';
|
||||
|
||||
// Get plugin tables
|
||||
$backup_tables = [
|
||||
SLM_TBL_LICENSE_KEYS,
|
||||
SLM_TBL_LIC_DOMAIN,
|
||||
SLM_TBL_LIC_DEVICES,
|
||||
SLM_TBL_LIC_LOG,
|
||||
SLM_TBL_EMAILS,
|
||||
SLM_TBL_LICENSE_STATUS
|
||||
];
|
||||
|
||||
$sql = "";
|
||||
foreach ($backup_tables as $table) {
|
||||
// Get table structure
|
||||
$create_table_query = $wpdb->get_results("SHOW CREATE TABLE $table", ARRAY_N);
|
||||
$sql .= "\n\n" . $create_table_query[0][1] . ";\n\n";
|
||||
|
||||
// Get table data
|
||||
$rows = $wpdb->get_results("SELECT * FROM $table", ARRAY_A);
|
||||
foreach ($rows as $row) {
|
||||
$values = array_map('esc_sql', array_values($row)); // Use esc_sql to escape the values
|
||||
$values = "'" . implode("','", $values) . "'";
|
||||
$sql .= "INSERT INTO $table VALUES ($values);\n";
|
||||
}
|
||||
}
|
||||
|
||||
// Include the WordPress Filesystem API
|
||||
if (! function_exists('request_filesystem_credentials')) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
}
|
||||
|
||||
// Ensure the filesystem is ready
|
||||
if (! WP_Filesystem()) {
|
||||
request_filesystem_credentials(admin_url());
|
||||
}
|
||||
|
||||
global $wp_filesystem;
|
||||
|
||||
// Define the backup file path
|
||||
$backup_path = $upload_dir['basedir'] . '/' . $unique_hash . '/' . basename($backup_file);
|
||||
|
||||
// Create the backup directory if it doesn't exist
|
||||
if (! is_dir(dirname($backup_path))) {
|
||||
$wp_filesystem->mkdir(dirname($backup_path));
|
||||
}
|
||||
|
||||
// Save the SQL to the backup file using the WP Filesystem
|
||||
if ($wp_filesystem->put_contents($backup_path, $sql)) {
|
||||
$backup_url = $upload_dir['baseurl'] . '/' . $unique_hash . '/' . basename($backup_file);
|
||||
|
||||
// Save backup info in plugin options
|
||||
$backup_info = [
|
||||
'url' => $backup_url,
|
||||
'date' => gmdate('Y-m-d H:i:s'),
|
||||
];
|
||||
slm_update_option('slm_last_backup_info', $backup_info);
|
||||
|
||||
echo '<div class="notice notice-success"><p>' . esc_html__('Backup created successfully! Download from: ', 'slm-plus') . '<a href="' . esc_url($backup_url) . '">' . esc_html(basename($backup_file)) . '</a></p></div>';
|
||||
} else {
|
||||
echo '<div class="notice notice-error"><p>' . esc_html__('Error: Failed to create the backup file.', 'slm-plus') . '</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Function to export a single license as a JSON file
|
||||
public static function export_license_to_json($license_id_or_key)
|
||||
{
|
||||
|
@ -211,57 +321,58 @@ class SLM_Utility
|
|||
return false; // Return false if no data was found
|
||||
}
|
||||
|
||||
public static function check_for_expired_lic($lic_key = '') {
|
||||
public static function check_for_expired_lic($lic_key = '')
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
|
||||
// Set up email headers and subject line
|
||||
$headers = array('Content-Type: text/html; charset=UTF-8');
|
||||
$subject = get_bloginfo('name') . ' - Your license has expired';
|
||||
$expiration_reminder_text = SLM_Helper_Class::slm_get_option('expiration_reminder_text');
|
||||
$expired_licenses_list = [];
|
||||
$reinstated_licenses_list = [];
|
||||
|
||||
|
||||
// Query licenses marked as expired but with future expiration dates to correct their status
|
||||
$incorrectly_expired_query = $wpdb->prepare(
|
||||
"SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE lic_status = %s AND date_expiry > NOW()",
|
||||
'expired'
|
||||
);
|
||||
$incorrectly_expired_licenses = $wpdb->get_results($incorrectly_expired_query, ARRAY_A);
|
||||
|
||||
|
||||
// Reinstate incorrectly expired licenses
|
||||
foreach ($incorrectly_expired_licenses as $license) {
|
||||
$license_key = sanitize_text_field($license['license_key']);
|
||||
$id = intval($license['id']);
|
||||
|
||||
|
||||
// Update license status to 'active'
|
||||
$wpdb->update(
|
||||
SLM_TBL_LICENSE_KEYS,
|
||||
['lic_status' => 'active'],
|
||||
['id' => $id]
|
||||
);
|
||||
|
||||
|
||||
self::create_log($license_key, 'status corrected to active');
|
||||
$reinstated_licenses_list[] = $license_key;
|
||||
}
|
||||
|
||||
|
||||
// Log reinstated licenses
|
||||
if (!empty($reinstated_licenses_list)) {
|
||||
SLM_Helper_Class::write_log('Reinstated licenses set to active: ' . implode(', ', $reinstated_licenses_list));
|
||||
}
|
||||
|
||||
|
||||
// Query expired licenses
|
||||
$expired_query = $wpdb->prepare(
|
||||
"SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE date_expiry < NOW() AND date_expiry != %s ORDER BY date_expiry ASC;",
|
||||
'00000000'
|
||||
);
|
||||
$expired_licenses = $wpdb->get_results($expired_query, ARRAY_A);
|
||||
|
||||
|
||||
// Check if any expired licenses were found
|
||||
if (empty($expired_licenses)) {
|
||||
SLM_Helper_Class::write_log('No expired licenses found');
|
||||
return []; // Return an empty array if no licenses found
|
||||
}
|
||||
|
||||
|
||||
// Process each expired license
|
||||
foreach ($expired_licenses as $license) {
|
||||
$id = intval($license['id']);
|
||||
|
@ -270,18 +381,18 @@ class SLM_Utility
|
|||
// $last_name = sanitize_text_field($license['last_name']);
|
||||
$email = sanitize_email($license['email']);
|
||||
$date_expiry = sanitize_text_field($license['date_expiry']);
|
||||
|
||||
|
||||
// Include email template and generate the email body
|
||||
ob_start();
|
||||
include SLM_LIB . 'mails/expired.php';
|
||||
$body = ob_get_clean();
|
||||
|
||||
|
||||
// Check if auto-expiration is enabled and update the license status
|
||||
if (SLM_Helper_Class::slm_get_option('enable_auto_key_expiration') == 1) {
|
||||
$update_data = ['lic_status' => 'expired'];
|
||||
$where_clause = ['id' => $id];
|
||||
$wpdb->update(SLM_TBL_LICENSE_KEYS, $update_data, $where_clause);
|
||||
|
||||
|
||||
// Log and send expiration notification
|
||||
self::create_log($license_key, 'set to expired');
|
||||
$email_result = self::slm_check_sent_emails($license_key, $email, $subject, $body, $headers);
|
||||
|
@ -289,27 +400,28 @@ class SLM_Utility
|
|||
self::create_log($license_key, 'sent expiration email notification');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Add license to the expired list
|
||||
$expired_licenses_list[] = $license_key;
|
||||
}
|
||||
|
||||
|
||||
// Log the total count of expired licenses
|
||||
SLM_Helper_Class::write_log('Expired licenses found and processed: ' . implode(', ', $expired_licenses_list));
|
||||
|
||||
|
||||
return [
|
||||
'expired_licenses' => $expired_licenses_list,
|
||||
'reinstated_licenses' => $reinstated_licenses_list
|
||||
]; // Return both expired and reinstated licenses
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Define return codes for clarity
|
||||
const EMAIL_SENT_FIRST_TIME = '200';
|
||||
const EMAIL_ALREADY_SENT = '400';
|
||||
const EMAIL_SENT_RECORD_NOT_FOUND = '300';
|
||||
|
||||
public static function slm_check_sent_emails($license_key, $email, $subject, $body, $headers) {
|
||||
public static function slm_check_sent_emails($license_key, $email, $subject, $body, $headers)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
// Check if an email has already been sent for this license key
|
||||
|
@ -336,37 +448,38 @@ class SLM_Utility
|
|||
return self::EMAIL_SENT_RECORD_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function do_auto_key_expiry() {
|
||||
|
||||
public static function do_auto_key_expiry()
|
||||
{
|
||||
global $wpdb;
|
||||
$current_date = current_time('Y-m-d');
|
||||
$slm_lic_table = SLM_TBL_LICENSE_KEYS;
|
||||
|
||||
|
||||
// Query for active (non-expired) licenses
|
||||
$licenses = $wpdb->get_results(
|
||||
$wpdb->prepare("SELECT * FROM $slm_lic_table WHERE lic_status != %s", 'expired'),
|
||||
OBJECT
|
||||
);
|
||||
|
||||
|
||||
// Log and return if no licenses are found
|
||||
if (empty($licenses)) {
|
||||
SLM_Debug_Logger::log_debug_st("do_auto_key_expiry() - No active license keys found.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$today_dt = new DateTime($current_date);
|
||||
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$license_key = sanitize_text_field($license->license_key);
|
||||
$expiry_date = sanitize_text_field($license->date_expiry);
|
||||
|
||||
|
||||
// Skip if expiration date is invalid or empty
|
||||
if (empty($expiry_date) || in_array($expiry_date, ['0000-00-00', '00000000'])) {
|
||||
SLM_Debug_Logger::log_debug_st("License key ($license_key) has no valid expiration date set. Skipping expiry check.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Check if the license has expired
|
||||
$expire_dt = new DateTime($expiry_date);
|
||||
if ($today_dt > $expire_dt) {
|
||||
|
@ -374,12 +487,12 @@ class SLM_Utility
|
|||
$data = ['lic_status' => 'expired'];
|
||||
$where = ['id' => intval($license->id)];
|
||||
$updated = $wpdb->update($slm_lic_table, $data, $where);
|
||||
|
||||
|
||||
// Log the expiry and trigger action if successfully updated
|
||||
if ($updated) {
|
||||
SLM_Debug_Logger::log_debug_st("License key ($license_key) expired on $expiry_date. Status set to 'expired'.");
|
||||
do_action('slm_license_key_expired', $license->id);
|
||||
|
||||
|
||||
// Optional: Send expiry reminder email
|
||||
self::check_for_expired_lic($license_key);
|
||||
} else {
|
||||
|
@ -387,10 +500,10 @@ class SLM_Utility
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function get_user_info($by, $value)
|
||||
|
@ -404,46 +517,42 @@ class SLM_Utility
|
|||
return $user;
|
||||
}
|
||||
|
||||
public static function get_days_remaining($date1) {
|
||||
public static function get_days_remaining($date1)
|
||||
{
|
||||
// Validate and sanitize the date input
|
||||
$date1 = sanitize_text_field($date1);
|
||||
|
||||
|
||||
// Retrieve the date format setting from WordPress settings
|
||||
$date_format = get_option('date_format');
|
||||
|
||||
|
||||
try {
|
||||
// Create DateTime objects for future and current dates
|
||||
$future_date = new DateTime($date1);
|
||||
$current_date = new DateTime();
|
||||
|
||||
|
||||
// Check if the future date is valid and in the future
|
||||
if ($future_date < $current_date) {
|
||||
return __('0 days remaining', 'slmplus');
|
||||
return __('0 days remaining', 'slm-plus');
|
||||
}
|
||||
|
||||
|
||||
// Calculate the difference in days
|
||||
$interval = $current_date->diff($future_date);
|
||||
$days_remaining = (int) $interval->days;
|
||||
|
||||
|
||||
// Format and return the result
|
||||
return sprintf(
|
||||
__('%s days remaining until %s', 'slmplus'),
|
||||
// Translators: %1$s is the number of days remaining, %2$s is the formatted future date
|
||||
__('%1$s days remaining until %2$s', 'slm-plus'),
|
||||
$days_remaining,
|
||||
date_i18n($date_format, $future_date->getTimestamp())
|
||||
);
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Return 0 days remaining if date parsing fails
|
||||
return __('0 days remaining', 'slmplus');
|
||||
return __('0 days remaining', 'slm-plus');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Deletes a license key from the licenses table
|
||||
*/
|
||||
public static function delete_license_key_by_row_id($key_row_id)
|
||||
{
|
||||
global $wpdb;
|
||||
|
@ -452,37 +561,133 @@ class SLM_Utility
|
|||
// Sanitize the input
|
||||
$key_row_id = intval($key_row_id);
|
||||
|
||||
// First delete the registered domains entry of this key (if any).
|
||||
SLM_Utility::delete_registered_domains_of_key($key_row_id);
|
||||
// Retrieve the license key associated with this row id
|
||||
$license_key = $wpdb->get_var($wpdb->prepare("SELECT license_key FROM $license_table WHERE id = %d", $key_row_id));
|
||||
|
||||
// Now, delete the key from the licenses table.
|
||||
// Debug: Log the retrieved license key
|
||||
SLM_Helper_Class::write_log("License key retrieved: " . $license_key);
|
||||
|
||||
// First, delete the registered domains entry of this key (if any)
|
||||
SLM_Utility::delete_registered_domains_of_key($key_row_id);
|
||||
SLM_Helper_Class::write_log("Registered domains for key $license_key deleted.");
|
||||
|
||||
// Now, delete the key from the licenses table
|
||||
$wpdb->delete($license_table, array('id' => $key_row_id));
|
||||
SLM_Helper_Class::write_log("License with row ID $key_row_id deleted from the license table.");
|
||||
|
||||
if ($license_key) {
|
||||
|
||||
// Query to get WooCommerce orders using a custom WP_Query with meta_query
|
||||
$args = array(
|
||||
'post_type' => 'shop_order',
|
||||
'posts_per_page' => -1,
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
'key' => 'License Key', // License Key meta field
|
||||
'value' => $license_key,
|
||||
'compare' => '='
|
||||
),
|
||||
array(
|
||||
'key' => '_slm_lic_key', // Fallback License Key meta field
|
||||
'value' => $license_key,
|
||||
'compare' => '='
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$order_query = new WP_Query($args);
|
||||
|
||||
if ($order_query->have_posts()) {
|
||||
while ($order_query->have_posts()) {
|
||||
$order_query->the_post();
|
||||
$order_id = get_the_ID();
|
||||
|
||||
// Get order object
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
// Debugging: Log the order ID
|
||||
SLM_Helper_Class::write_log("Processing order ID: " . $order_id);
|
||||
|
||||
// Meta keys to be removed
|
||||
$meta_keys = [
|
||||
'License Key',
|
||||
'License Type',
|
||||
'Current Version',
|
||||
'Until Version',
|
||||
'Max Devices',
|
||||
'Max Domains'
|
||||
];
|
||||
|
||||
// Remove order-level metadata
|
||||
foreach ($meta_keys as $meta_key) {
|
||||
$meta_value = $order->get_meta($meta_key, true); // Retrieve the metadata value
|
||||
if ($meta_value) {
|
||||
SLM_Helper_Class::write_log("Found meta key $meta_key with value: $meta_value. Deleting...");
|
||||
$order->delete_meta_data($meta_key); // Remove meta data from the order
|
||||
}
|
||||
}
|
||||
|
||||
// Add a note to the order
|
||||
$note_content = sprintf(__('License key %s was deleted on %s', 'slm-plus'), $license_key, date_i18n('F j, Y'));
|
||||
$order->add_order_note($note_content);
|
||||
|
||||
// Process and reset license-related metadata from order items
|
||||
foreach ($order->get_items() as $item_id => $item) {
|
||||
// Remove item-level metadata for the specified keys
|
||||
foreach ($meta_keys as $meta_key) {
|
||||
$meta_value = $item->get_meta($meta_key, true); // Retrieve the metadata value
|
||||
if ($meta_value) {
|
||||
SLM_Helper_Class::write_log("Found meta key $meta_key in order item $item_id with value: $meta_value. Deleting...");
|
||||
$item->delete_meta_data($meta_key); // Remove meta data from the order item
|
||||
}
|
||||
}
|
||||
|
||||
// Save the updated order item
|
||||
$item->save();
|
||||
}
|
||||
|
||||
// Save the updated order
|
||||
$order->save();
|
||||
}
|
||||
|
||||
wp_reset_postdata(); // Reset the post data after custom query
|
||||
} else {
|
||||
// Debugging: Log if no orders were found
|
||||
SLM_Helper_Class::write_log("No orders found for the license key: " . $license_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Retrieves the email associated with a license key
|
||||
*/
|
||||
public static function slm_get_lic_email($license) {
|
||||
public static function slm_get_lic_email($license)
|
||||
{
|
||||
global $wpdb;
|
||||
$lic_key_table = SLM_TBL_LICENSE_KEYS;
|
||||
|
||||
|
||||
// Sanitize the input
|
||||
$license = sanitize_text_field($license);
|
||||
|
||||
|
||||
// Prepare and execute the query to fetch the email
|
||||
$email = $wpdb->get_var(
|
||||
$wpdb->prepare("SELECT email FROM $lic_key_table WHERE license_key = %s", $license)
|
||||
);
|
||||
|
||||
|
||||
// Check if an email was found and is valid
|
||||
if ($email && is_email($email)) {
|
||||
return $email;
|
||||
} else {
|
||||
// Return a WP_Error if the email was not found or invalid
|
||||
return new WP_Error('license_not_found', __('License key not found or invalid email.', 'slmplus'));
|
||||
return new WP_Error('license_not_found', __('License key not found or invalid email.', 'slm-plus'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Sends an email with the specified parameters
|
||||
|
@ -568,7 +773,6 @@ class SLM_Utility
|
|||
font-family: "Open Sans", Helvetica, Arial, Sans-serif;
|
||||
}
|
||||
</style>
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700" rel="stylesheet" type="text/css" />
|
||||
<title>' . esc_html(get_bloginfo('name')) . '</title>
|
||||
</head>
|
||||
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space; background-color: ' . esc_attr($color) . '">
|
||||
|
@ -738,36 +942,70 @@ class SLM_Utility
|
|||
}
|
||||
|
||||
/*
|
||||
* Deletes any registered domains info from the domain table for the given key's row id.
|
||||
*/
|
||||
* Deletes any registered domains and related entries for the given license key's row id.
|
||||
*/
|
||||
static function delete_registered_domains_of_key($key_row_id)
|
||||
{
|
||||
global $slm_debug_logger;
|
||||
global $wpdb;
|
||||
|
||||
// Table constants
|
||||
$reg_domain_table = SLM_TBL_LIC_DOMAIN;
|
||||
$sql_prep = $wpdb->prepare("SELECT * FROM $reg_domain_table WHERE lic_key_id = %s", $key_row_id);
|
||||
$reg_domains = $wpdb->get_results($sql_prep, OBJECT);
|
||||
foreach ($reg_domains as $domain) {
|
||||
$row_to_delete = $domain->id;
|
||||
$wpdb->delete($reg_domain_table, array('id' => $row_to_delete));
|
||||
$slm_debug_logger->log_debug("Registered domain with row id (" . $row_to_delete . ") deleted.");
|
||||
$device_table = SLM_TBL_LIC_DEVICES;
|
||||
$log_table = SLM_TBL_LIC_LOG;
|
||||
$email_table = SLM_TBL_EMAILS;
|
||||
|
||||
// Retrieve the license key associated with this row id
|
||||
$license_key = $wpdb->get_var($wpdb->prepare("SELECT license_key FROM " . SLM_TBL_LICENSE_KEYS . " WHERE id = %d", $key_row_id));
|
||||
|
||||
if ($license_key) {
|
||||
// Step 1: Delete from registered domains table
|
||||
$reg_domains = $wpdb->get_results($wpdb->prepare("SELECT id FROM $reg_domain_table WHERE lic_key_id = %d", $key_row_id));
|
||||
foreach ($reg_domains as $domain) {
|
||||
$wpdb->delete($reg_domain_table, array('id' => $domain->id));
|
||||
$slm_debug_logger->log_debug("Registered domain with row id (" . $domain->id . ") deleted.");
|
||||
}
|
||||
|
||||
// Step 2: Delete from devices table
|
||||
$deleted_devices = $wpdb->delete($device_table, array('lic_key' => $license_key), array('%s'));
|
||||
$slm_debug_logger->log_debug("$deleted_devices entries deleted from devices table for license key ($license_key).");
|
||||
|
||||
// Step 3: Delete from log table
|
||||
$deleted_logs = $wpdb->delete($log_table, array('license_key' => $license_key), array('%s'));
|
||||
$slm_debug_logger->log_debug("$deleted_logs entries deleted from log table for license key ($license_key).");
|
||||
|
||||
// Step 4: Delete from emails table
|
||||
$deleted_emails = $wpdb->delete($email_table, array('lic_key' => $license_key), array('%s'));
|
||||
$slm_debug_logger->log_debug("$deleted_emails entries deleted from emails table for license key ($license_key).");
|
||||
} else {
|
||||
$slm_debug_logger->log_debug("No license key found for row id ($key_row_id). Deletion aborted.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static function create_secret_keys()
|
||||
{
|
||||
$key = strtoupper(implode('-', str_split(substr(strtolower(md5(microtime() . rand(1000, 9999))), 0, 32), 8)));
|
||||
return hash('sha256', $key);
|
||||
// Generate secure random bytes (32 bytes = 256 bits)
|
||||
$random_bytes = openssl_random_pseudo_bytes(32); // 32 bytes (256 bits)
|
||||
|
||||
// Convert the random bytes into a hexadecimal string (64 chars)
|
||||
$random_string = bin2hex($random_bytes);
|
||||
|
||||
// Make the entire string uppercase
|
||||
$key = strtoupper($random_string);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
public static function create_log($license_key, $action) {
|
||||
public static function create_log($license_key, $action)
|
||||
{
|
||||
global $wpdb;
|
||||
$slm_log_table = SLM_TBL_LIC_LOG;
|
||||
|
||||
|
||||
// Sanitize inputs
|
||||
$license_key = sanitize_text_field($license_key);
|
||||
$action = sanitize_text_field($action);
|
||||
|
||||
|
||||
// Determine the request origin
|
||||
if (!empty($_SERVER['HTTP_ORIGIN'])) {
|
||||
$origin = sanitize_text_field($_SERVER['HTTP_ORIGIN']);
|
||||
|
@ -776,7 +1014,7 @@ class SLM_Utility
|
|||
} else {
|
||||
$origin = sanitize_text_field($_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
|
||||
// Prepare log data
|
||||
$log_data = array(
|
||||
'license_key' => $license_key,
|
||||
|
@ -784,18 +1022,19 @@ class SLM_Utility
|
|||
'time' => current_time('mysql'), // Standardized date-time format
|
||||
'source' => $origin,
|
||||
);
|
||||
|
||||
|
||||
// Insert log data into the database
|
||||
$inserted = $wpdb->insert($slm_log_table, $log_data);
|
||||
|
||||
|
||||
// Check for insertion errors
|
||||
if ($inserted === false) {
|
||||
error_log("Failed to insert log for license key: $license_key, action: $action. Error: " . $wpdb->last_error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function create_email_log($lic_key, $sent_to, $status, $sent, $date_sent = null) {
|
||||
|
||||
public static function create_email_log($lic_key, $sent_to, $status, $sent, $date_sent = null)
|
||||
{
|
||||
global $wpdb;
|
||||
$slm_email_table = SLM_TBL_EMAILS;
|
||||
|
||||
|
@ -835,10 +1074,11 @@ class SLM_Utility
|
|||
|
||||
foreach ($result as $license) {
|
||||
echo '<tr>
|
||||
<td>
|
||||
<strong> ' . $license->first_name . ' ' . $license->last_name . ' </strong><br>
|
||||
<a href="' . admin_url('admin.php?page=slm_manage_license&edit_record=' . $license->id . '') . '">' . $license->license_key . ' </td>
|
||||
</tr>';
|
||||
<td>
|
||||
<strong>' . esc_html($license->first_name) . ' ' . esc_html($license->last_name) . '</strong><br>
|
||||
<a href="' . esc_url(admin_url('admin.php?page=slm_manage_license&edit_record=' . $license->id)) . '">' . esc_html($license->license_key) . '</a>
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,17 +1110,24 @@ class SLM_Utility
|
|||
|
||||
if (isset($email) && isset($manage_subscriber) && current_user_can('edit_pages')) {
|
||||
|
||||
echo '<h2>Listing all licenses related to ' . $email . '</h2>';
|
||||
echo '<h2>Listing all licenses related to ' . esc_html($email) . '</h2>';
|
||||
|
||||
$result_array = $wpdb->get_results(
|
||||
$wpdb->prepare(
|
||||
"SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE email LIKE %s ORDER BY `email` DESC LIMIT 0,1000",
|
||||
'%' . $wpdb->esc_like($email) . '%'
|
||||
),
|
||||
ARRAY_A
|
||||
);
|
||||
|
||||
$result_array = $wpdb->get_results("SELECT * FROM " . SLM_TBL_LICENSE_KEYS . " WHERE email LIKE '%" . $email . "%' ORDER BY `email` DESC LIMIT 0,1000", ARRAY_A);
|
||||
|
||||
foreach ($result_array as $slm_user) {
|
||||
echo ' <tr>
|
||||
<td scope="row">' . $slm_user["id"] . '</td>
|
||||
<td scope="row">' . $slm_user["license_key"] . '</td>
|
||||
<td scope="row">' . $slm_user["lic_status"] . '</td>
|
||||
<td scope="row"><a href="' . admin_url('admin.php?page=slm_manage_license&edit_record=' . $slm_user["id"] . '') . '">'. __(' view', 'slmplus'). ' </a></td>
|
||||
</tr>';
|
||||
<td scope="row">' . esc_html($slm_user["id"]) . '</td>
|
||||
<td scope="row">' . esc_html($slm_user["license_key"]) . '</td>
|
||||
<td scope="row">' . esc_html($slm_user["lic_status"]) . '</td>
|
||||
<td scope="row"><a href="' . esc_url(admin_url('admin.php?page=slm_manage_license&edit_record=' . $slm_user["id"])) . '">' . esc_html__('View', 'slm-plus') . ' </a></td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -891,17 +1138,25 @@ class SLM_Utility
|
|||
$slm_log_table = SLM_TBL_LIC_LOG;
|
||||
|
||||
echo '
|
||||
<div class="table-responsive"> <table class="table table-striped table-hover table-sm"> <thead> <tr> <th scope="col">'. __('ID', 'slmplus'). '</th> <th scope="col">'. __('Request', 'slmplus'). '</th> </tr> </thead> <tbody>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">' . esc_html__('ID', 'slm-plus') . '</th>
|
||||
<th scope="col">' . esc_html__('Request', 'slm-plus') . '</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
';
|
||||
$activity = $wpdb->get_results("SELECT * FROM " . $slm_log_table . " WHERE license_key='" . $license_key . "';");
|
||||
foreach ($activity as $log) {
|
||||
echo '
|
||||
<tr>' .
|
||||
'<th scope="row">' . $log->id . '</th>' .
|
||||
'<td> <span class="badge badge-primary">' . $log->slm_action . '</span>' .
|
||||
'<p class="text-muted"> <b>'. __('Source:', 'slmplus'). ' </b> ' . $log->source .
|
||||
'</p><p class="text-muted"> <b>'. __('Time:', 'slmplus'). ' </b> ' . $log->time . '</td>
|
||||
</tr>';
|
||||
<tr>' .
|
||||
'<th scope="row">' . esc_html($log->id) . '</th>' .
|
||||
'<td> <span class="badge badge-primary">' . esc_html($log->slm_action) . '</span>' .
|
||||
'<p class="text-muted"> <b>' . esc_html__('Source:', 'slm-plus') . ' </b> ' . esc_html($log->source) .
|
||||
'</p><p class="text-muted"> <b>' . esc_html__('Time:', 'slm-plus') . ' </b> ' . esc_html($log->time) . '</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</tbody>
|
||||
|
@ -913,7 +1168,7 @@ class SLM_Utility
|
|||
{
|
||||
?>
|
||||
<div class="table">
|
||||
<h5> <?php echo $item_name; ?> </h5>
|
||||
<h5> <?php echo esc_html($item_name); ?> </h5>
|
||||
<?php
|
||||
global $wpdb;
|
||||
$sql_prep = $wpdb->prepare("SELECT * FROM $tablename WHERE lic_key = %s", $license_key);
|
||||
|
@ -921,22 +1176,22 @@ class SLM_Utility
|
|||
|
||||
if (count($activations) > 0) : ?>
|
||||
<div id="slm_ajax_msg"></div>
|
||||
<div class="<?php echo $item_name; ?>_info">
|
||||
<div class="<?php echo esc_attr($item_name); ?>_info">
|
||||
<table cellpadding="0" cellspacing="0" class="table">
|
||||
<?php
|
||||
$count = 0;
|
||||
foreach ($activations as $activation) : ?>
|
||||
<div class="input-group mb-3 lic-entry-<?php echo $activation->id; ?>">
|
||||
<div class="input-group mb-3 lic-entry-<?php echo esc_attr($activation->id); ?>">
|
||||
<?php
|
||||
if ($item_name == 'Devices') {
|
||||
echo '<input type="text" class="form-control" placeholder="' . $activation->registered_devices . '" aria-label="' . $activation->registered_devices . '" aria-describedby="' . $activation->registered_devices . '" value="' . $activation->registered_devices . '" readonly>';
|
||||
echo '<input type="text" class="form-control" placeholder="' . esc_attr($activation->registered_devices) . '" aria-label="' . esc_attr($activation->registered_devices) . '" aria-describedby="' . esc_attr($activation->registered_devices) . '" value="' . esc_attr($activation->registered_devices) . '" readonly>';
|
||||
} else {
|
||||
echo '<input type="text" class="form-control" placeholder="' . $activation->registered_domain . '" aria-label="' . $activation->registered_domain . '" aria-describedby="' . $activation->registered_domain . '" value="' . $activation->registered_domain . '" readonly>';
|
||||
echo '<input type="text" class="form-control" placeholder="' . esc_attr($activation->registered_domain) . '" aria-label="' . esc_attr($activation->registered_domain) . '" aria-describedby="' . esc_attr($activation->registered_domain) . '" value="' . esc_attr($activation->registered_domain) . '" readonly>';
|
||||
}
|
||||
?>
|
||||
<?php if ($allow_removal == true) : ?>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-danger deactivate_lic_key" type="button" data-lic_key="<?php echo $activation->lic_key; ?>'" id="<?php echo $activation->id; ?>" data-activation_type="<?php echo $activation_type;?>" data-id="<?php echo $activation->id; ?>"> Remove</button>
|
||||
<button class="btn btn-danger deactivate_lic_key" type="button" data-lic_key="<?php echo esc_attr($activation->lic_key); ?>" id="<?php echo esc_attr($activation->id); ?>" data-activation_type="<?php echo esc_attr($activation_type); ?>" data-id="<?php echo esc_attr($activation->id); ?>"> Remove</button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
@ -946,7 +1201,7 @@ class SLM_Utility
|
|||
</table>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<?php echo '<div class="alert alert-danger" role="alert">'.__('Not registered yet', 'slmplus').'</div>'; ?>
|
||||
<?php echo '<div class="alert alert-danger" role="alert">' . esc_html__('Not registered yet', 'slm-plus') . '</div>'; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php
|
||||
|
@ -964,7 +1219,7 @@ class SLM_Utility
|
|||
|
||||
if ($product->is_type('slm_license')) {
|
||||
$tabs['shipping'] = array(
|
||||
'title' => __('License information', 'slmplus'),
|
||||
'title' => __('License information', 'slm-plus'),
|
||||
'priority' => 50,
|
||||
'callback' => 'slm_woo_tab_lic_info'
|
||||
);
|
||||
|
@ -976,11 +1231,11 @@ class SLM_Utility
|
|||
{
|
||||
global $product;
|
||||
// The new tab content
|
||||
echo '<h2>'.__('License information', 'slmplus') .'</h2>';
|
||||
echo __('License type: ', 'slmplus') . get_post_meta($product->get_id(), '_license_type', true) . '<br>';
|
||||
echo __('Domains allowed: ', 'slmplus') . get_post_meta($product->get_id(), '_domain_licenses', true) . '<br>';
|
||||
echo __('Devices allowed: ', 'slmplus') . get_post_meta($product->get_id(), '_devices_licenses', true) . '<br>';
|
||||
echo __('Renews every ', 'slmplus') . get_post_meta($product->get_id(), '_license_renewal_period_lenght', true) . ' ' . get_post_meta($product->get_id(), '_license_renewal_period_term', true) . '<br>';
|
||||
echo '<h2>' . esc_html__('License information', 'slm-plus') . '</h2>';
|
||||
echo esc_html__('License type: ', 'slm-plus') . esc_html(get_post_meta($product->get_id(), '_license_type', true)) . '<br>';
|
||||
echo esc_html__('Domains allowed: ', 'slm-plus') . esc_html(get_post_meta($product->get_id(), '_domain_licenses', true)) . '<br>';
|
||||
echo esc_html__('Devices allowed: ', 'slm-plus') . esc_html(get_post_meta($product->get_id(), '_devices_licenses', true)) . '<br>';
|
||||
echo esc_html__('Renews every ', 'slm-plus') . esc_html(get_post_meta($product->get_id(), '_license_renewal_period_lenght', true)) . ' ' . esc_html(get_post_meta($product->get_id(), '_license_renewal_period_term', true)) . '<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,14 +208,14 @@ class WP_Mail
|
|||
$this->attachments = array();
|
||||
foreach ($path as $path_) {
|
||||
if (!file_exists($path_)) {
|
||||
throw new Exception("Attachment not found at $path");
|
||||
throw new Exception(sprintf('Attachment not found at %s', esc_html($path)));
|
||||
} else {
|
||||
$this->attachments[] = $path_;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!file_exists($path)) {
|
||||
throw new Exception("Attachment not found at $path");
|
||||
throw new Exception(sprintf('Attachment not found at %s', esc_html($path)));
|
||||
}
|
||||
$this->attachments = array($path);
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ class WP_Mail
|
|||
|
||||
return $this->parseAsMustache($template, $variables);
|
||||
} else {
|
||||
throw new Exception("Unknown extension {$extension} in path '{$templateFile}'");
|
||||
throw new Exception(sprintf('Unknown extension %s in path %s', esc_html($extension), esc_html($templateFile)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
|
||||
[11/14/2024 3:53 PM] - -------- Log File Reset --------
|
||||
|
|
361
logs/log.txt
361
logs/log.txt
|
@ -0,0 +1,361 @@
|
|||
[11/14/2024 3:53 PM] - -------- Log File Reset --------
|
||||
[11/14/2024 4:25 PM] - SUCCESS : Registered domain with row id (34) deleted.
|
||||
[11/14/2024 4:54 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 4:54 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 4:55 PM] - SUCCESS : No license key found for row id (79). Deletion aborted.
|
||||
[11/14/2024 4:56 PM] - SUCCESS : API Response - Result: success Message: License key activated.
|
||||
[11/14/2024 4:56 PM] - SUCCESS : API Response - Result: success Message: License key activated for device.
|
||||
[11/14/2024 4:57 PM] - SUCCESS : Registered domain with row id (35) deleted.
|
||||
[11/14/2024 4:57 PM] - SUCCESS : 1 entries deleted from devices table for license key (SLM-EE57-76EF-2405-522E-90F4-FD95-1244-67C9).
|
||||
[11/14/2024 4:57 PM] - SUCCESS : 3 entries deleted from log table for license key (SLM-EE57-76EF-2405-522E-90F4-FD95-1244-67C9).
|
||||
[11/14/2024 4:57 PM] - SUCCESS : entries deleted from emails table for license key (SLM-EE57-76EF-2405-522E-90F4-FD95-1244-67C9).
|
||||
[11/14/2024 4:58 PM] - SUCCESS : No license key found for row id (80). Deletion aborted.
|
||||
[11/14/2024 8:36 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 8:36 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 8:36 PM] - SUCCESS : API Response - Result: success Message: License key activated for device.
|
||||
[11/14/2024 8:36 PM] - SUCCESS : API Response - Result: success Message: License key activated.
|
||||
[11/14/2024 8:37 PM] - SUCCESS : Registered domain with row id (36) deleted.
|
||||
[11/14/2024 8:37 PM] - SUCCESS : 1 entries deleted from devices table for license key (SLM-5778-E08F-C6C1-A077-28AE-64C3-EC83-AF8B).
|
||||
[11/14/2024 8:37 PM] - SUCCESS : 3 entries deleted from log table for license key (SLM-5778-E08F-C6C1-A077-28AE-64C3-EC83-AF8B).
|
||||
[11/14/2024 8:37 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-5778-E08F-C6C1-A077-28AE-64C3-EC83-AF8B).
|
||||
[11/14/2024 8:43 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 8:43 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 8:43 PM] - SUCCESS : No license key found for row id (81). Deletion aborted.
|
||||
[11/14/2024 8:43 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-517E-526A-1BE3-B441-45C9-210E-6510-1216).
|
||||
[11/14/2024 8:43 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-517E-526A-1BE3-B441-45C9-210E-6510-1216).
|
||||
[11/14/2024 8:43 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-517E-526A-1BE3-B441-45C9-210E-6510-1216).
|
||||
[11/14/2024 8:47 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 8:47 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 8:47 PM] - SUCCESS : No license key found for row id (82). Deletion aborted.
|
||||
[11/14/2024 8:48 PM] - SUCCESS : No license key found for row id (82). Deletion aborted.
|
||||
[11/14/2024 8:48 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-B92A-33AD-70DD-1A9C-380D-9DEE-9A1A-FECE).
|
||||
[11/14/2024 8:48 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-B92A-33AD-70DD-1A9C-380D-9DEE-9A1A-FECE).
|
||||
[11/14/2024 8:48 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-B92A-33AD-70DD-1A9C-380D-9DEE-9A1A-FECE).
|
||||
[11/14/2024 8:48 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 8:48 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 8:49 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-EC44-E7FB-4A4F-B3AC-5043-DE79-5152-5C00).
|
||||
[11/14/2024 8:49 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-EC44-E7FB-4A4F-B3AC-5043-DE79-5152-5C00).
|
||||
[11/14/2024 8:49 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-EC44-E7FB-4A4F-B3AC-5043-DE79-5152-5C00).
|
||||
[11/14/2024 8:52 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 8:52 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 8:57 PM] - SUCCESS : No license key found for row id (84). Deletion aborted.
|
||||
[11/14/2024 8:57 PM] - SUCCESS : No license key found for row id (84). Deletion aborted.
|
||||
[11/14/2024 8:57 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-BA9D-1485-9B26-FC09-A65D-7982-AF9A-85A0).
|
||||
[11/14/2024 8:57 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-BA9D-1485-9B26-FC09-A65D-7982-AF9A-85A0).
|
||||
[11/14/2024 8:57 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-BA9D-1485-9B26-FC09-A65D-7982-AF9A-85A0).
|
||||
[11/14/2024 9:00 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:00 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:00 PM] - SUCCESS : No license key found for row id (85). Deletion aborted.
|
||||
[11/14/2024 9:00 PM] - SUCCESS : No license key found for row id (85). Deletion aborted.
|
||||
[11/14/2024 9:00 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6605-9268-E33C-AD4A-9DB2-997C-BB20-7D7C).
|
||||
[11/14/2024 9:00 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6605-9268-E33C-AD4A-9DB2-997C-BB20-7D7C).
|
||||
[11/14/2024 9:00 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6605-9268-E33C-AD4A-9DB2-997C-BB20-7D7C).
|
||||
[11/14/2024 9:07 PM] - SUCCESS : No license key found for row id (86). Deletion aborted.
|
||||
[11/14/2024 9:08 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:08 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:09 PM] - SUCCESS : No license key found for row id (86). Deletion aborted.
|
||||
[11/14/2024 9:09 PM] - SUCCESS : No license key found for row id (86). Deletion aborted.
|
||||
[11/14/2024 9:13 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:13 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:15 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:15 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:16 PM] - SUCCESS : No license key found for row id (86). Deletion aborted.
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-BFD7-241E-790D-BF31-312D-96B0-EBDD-E19C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-BFD7-241E-790D-BF31-312D-96B0-EBDD-E19C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-BFD7-241E-790D-BF31-312D-96B0-EBDD-E19C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-8771-12E4-AB7C-1521-037F-3A91-D537-0F64).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-8771-12E4-AB7C-1521-037F-3A91-D537-0F64).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-8771-12E4-AB7C-1521-037F-3A91-D537-0F64).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-84C6-93BE-3840-E581-12FC-AB2F-8ACC-1A0C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-84C6-93BE-3840-E581-12FC-AB2F-8ACC-1A0C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-84C6-93BE-3840-E581-12FC-AB2F-8ACC-1A0C).
|
||||
[11/14/2024 9:16 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:16 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:17 PM] - SUCCESS : No license key found for row id (87). Deletion aborted.
|
||||
[11/14/2024 9:19 PM] - SUCCESS : No license key found for row id (87). Deletion aborted.
|
||||
[11/14/2024 9:21 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-4554-A7F9-4A30-9A6C-A9FB-2702-1384-0988).
|
||||
[11/14/2024 9:21 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-4554-A7F9-4A30-9A6C-A9FB-2702-1384-0988).
|
||||
[11/14/2024 9:21 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-4554-A7F9-4A30-9A6C-A9FB-2702-1384-0988).
|
||||
[11/14/2024 9:22 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:22 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:30 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-CADC-9C52-0BDC-7429-F7A6-C58D-5AC7-1A2C).
|
||||
[11/14/2024 9:30 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-CADC-9C52-0BDC-7429-F7A6-C58D-5AC7-1A2C).
|
||||
[11/14/2024 9:30 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-CADC-9C52-0BDC-7429-F7A6-C58D-5AC7-1A2C).
|
||||
[11/14/2024 9:31 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:31 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/14/2024 9:32 PM] - SUCCESS : No license key found for row id (91). Deletion aborted.
|
||||
[11/14/2024 9:32 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-3BB9-9D7F-4F1F-DE50-FF7A-46E4-B81E-3FF0).
|
||||
[11/14/2024 9:32 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-3BB9-9D7F-4F1F-DE50-FF7A-46E4-B81E-3FF0).
|
||||
[11/14/2024 9:32 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-3BB9-9D7F-4F1F-DE50-FF7A-46E4-B81E-3FF0).
|
||||
[11/14/2024 9:37 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/14/2024 9:37 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-D44E-1DE7-3F8E-29C2-67C2-69CD-CD8E-EEFA).
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 0 entries deleted from log table for license key (SLM-D44E-1DE7-3F8E-29C2-67C2-69CD-CD8E-EEFA).
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-D44E-1DE7-3F8E-29C2-67C2-69CD-CD8E-EEFA).
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-1155-CB30-585F-C72C-3F02-7BF0-9B9D-F705).
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-1155-CB30-585F-C72C-3F02-7BF0-9B9D-F705).
|
||||
[11/15/2024 9:10 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-1155-CB30-585F-C72C-3F02-7BF0-9B9D-F705).
|
||||
[11/15/2024 9:24 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:24 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:24 PM] - SUCCESS : No license key found for row id (93). Deletion aborted.
|
||||
[11/15/2024 9:24 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-4401-2724-A27F-3E82-4654-0E83-738D-1641).
|
||||
[11/15/2024 9:24 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-4401-2724-A27F-3E82-4654-0E83-738D-1641).
|
||||
[11/15/2024 9:24 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-4401-2724-A27F-3E82-4654-0E83-738D-1641).
|
||||
[11/15/2024 9:25 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:25 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:25 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-4504-4439-ECED-1884-8425-CE8B-5500-E2CD).
|
||||
[11/15/2024 9:25 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-4504-4439-ECED-1884-8425-CE8B-5500-E2CD).
|
||||
[11/15/2024 9:25 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-4504-4439-ECED-1884-8425-CE8B-5500-E2CD).
|
||||
[11/15/2024 9:27 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:27 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:27 PM] - SUCCESS : No license key found for row id (96). Deletion aborted.
|
||||
[11/15/2024 9:27 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-309E-344F-2809-F0B8-5687-1C23-92D5-CAC1).
|
||||
[11/15/2024 9:27 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-309E-344F-2809-F0B8-5687-1C23-92D5-CAC1).
|
||||
[11/15/2024 9:27 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-309E-344F-2809-F0B8-5687-1C23-92D5-CAC1).
|
||||
[11/15/2024 9:28 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:28 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:28 PM] - SUCCESS : No license key found for row id (97). Deletion aborted.
|
||||
[11/15/2024 9:28 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-D8C9-95A1-49DE-FDB7-0FD0-E1C1-7418-9044).
|
||||
[11/15/2024 9:28 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-D8C9-95A1-49DE-FDB7-0FD0-E1C1-7418-9044).
|
||||
[11/15/2024 9:28 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-D8C9-95A1-49DE-FDB7-0FD0-E1C1-7418-9044).
|
||||
[11/15/2024 9:29 PM] - SUCCESS : No license key found for row id (98). Deletion aborted.
|
||||
[11/15/2024 9:29 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:29 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:30 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:30 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:32 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:32 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:32 PM] - SUCCESS : No license key found for row id (98). Deletion aborted.
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-7105-479C-85D4-56A7-3A08-AD0A-2723-3C36).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-7105-479C-85D4-56A7-3A08-AD0A-2723-3C36).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-7105-479C-85D4-56A7-3A08-AD0A-2723-3C36).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-C7A8-30C6-2A87-D6C0-7D5A-EC8A-9562-02CF).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-C7A8-30C6-2A87-D6C0-7D5A-EC8A-9562-02CF).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-C7A8-30C6-2A87-D6C0-7D5A-EC8A-9562-02CF).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6988-E35E-574D-5263-B449-E53E-3D9C-BCBC).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6988-E35E-574D-5263-B449-E53E-3D9C-BCBC).
|
||||
[11/15/2024 9:32 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6988-E35E-574D-5263-B449-E53E-3D9C-BCBC).
|
||||
[11/15/2024 9:33 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/15/2024 9:33 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/15/2024 9:33 PM] - SUCCESS : No license key found for row id (99). Deletion aborted.
|
||||
[11/15/2024 9:33 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-E724-EC26-610E-EB10-D4B4-6BA1-FB1B-886D).
|
||||
[11/15/2024 9:33 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-E724-EC26-610E-EB10-D4B4-6BA1-FB1B-886D).
|
||||
[11/15/2024 9:33 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-E724-EC26-610E-EB10-D4B4-6BA1-FB1B-886D).
|
||||
[11/16/2024 12:42 PM] - SUCCESS : No license key found for row id (102). Deletion aborted.
|
||||
[11/16/2024 12:42 PM] - SUCCESS : No license key found for row id (102). Deletion aborted.
|
||||
[11/16/2024 12:43 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:43 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:43 PM] - SUCCESS : No license key found for row id (102). Deletion aborted.
|
||||
[11/16/2024 12:43 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-85A2-0795-DFC0-9E8E-414A-72C5-D8FC-5805).
|
||||
[11/16/2024 12:43 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-85A2-0795-DFC0-9E8E-414A-72C5-D8FC-5805).
|
||||
[11/16/2024 12:43 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-85A2-0795-DFC0-9E8E-414A-72C5-D8FC-5805).
|
||||
[11/16/2024 12:44 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:44 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:44 PM] - SUCCESS : No license key found for row id (103). Deletion aborted.
|
||||
[11/16/2024 12:44 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-E592-0B4C-C5CC-0444-565B-AE5B-9ECC-09E0).
|
||||
[11/16/2024 12:44 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-E592-0B4C-C5CC-0444-565B-AE5B-9ECC-09E0).
|
||||
[11/16/2024 12:44 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-E592-0B4C-C5CC-0444-565B-AE5B-9ECC-09E0).
|
||||
[11/16/2024 12:45 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:45 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:45 PM] - SUCCESS : No license key found for row id (104). Deletion aborted.
|
||||
[11/16/2024 12:45 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-7B4A-7FD5-05C4-69C4-8994-256D-DBE9-EDBA).
|
||||
[11/16/2024 12:45 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-7B4A-7FD5-05C4-69C4-8994-256D-DBE9-EDBA).
|
||||
[11/16/2024 12:45 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-7B4A-7FD5-05C4-69C4-8994-256D-DBE9-EDBA).
|
||||
[11/16/2024 12:46 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:46 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:46 PM] - SUCCESS : No license key found for row id (105). Deletion aborted.
|
||||
[11/16/2024 12:46 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-04CF-8A76-721C-CFF9-A998-D0C3-1B7C-2F5B).
|
||||
[11/16/2024 12:46 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-04CF-8A76-721C-CFF9-A998-D0C3-1B7C-2F5B).
|
||||
[11/16/2024 12:46 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-04CF-8A76-721C-CFF9-A998-D0C3-1B7C-2F5B).
|
||||
[11/16/2024 12:47 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:47 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:47 PM] - SUCCESS : No license key found for row id (106). Deletion aborted.
|
||||
[11/16/2024 12:47 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-E699-C8A8-761E-8E1A-860D-FB63-A4E9-1871).
|
||||
[11/16/2024 12:47 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-E699-C8A8-761E-8E1A-860D-FB63-A4E9-1871).
|
||||
[11/16/2024 12:47 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-E699-C8A8-761E-8E1A-860D-FB63-A4E9-1871).
|
||||
[11/16/2024 12:48 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:48 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:48 PM] - SUCCESS : No license key found for row id (107). Deletion aborted.
|
||||
[11/16/2024 12:48 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-9990-C635-DD8D-C077-092B-8B2F-2C80-19C0).
|
||||
[11/16/2024 12:48 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-9990-C635-DD8D-C077-092B-8B2F-2C80-19C0).
|
||||
[11/16/2024 12:48 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-9990-C635-DD8D-C077-092B-8B2F-2C80-19C0).
|
||||
[11/16/2024 12:51 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:51 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:51 PM] - SUCCESS : No license key found for row id (108). Deletion aborted.
|
||||
[11/16/2024 12:51 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-3AC5-D1F8-C29A-D502-F744-D6A2-2978-9F27).
|
||||
[11/16/2024 12:51 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-3AC5-D1F8-C29A-D502-F744-D6A2-2978-9F27).
|
||||
[11/16/2024 12:51 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-3AC5-D1F8-C29A-D502-F744-D6A2-2978-9F27).
|
||||
[11/16/2024 12:56 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:56 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:56 PM] - SUCCESS : No license key found for row id (109). Deletion aborted.
|
||||
[11/16/2024 12:56 PM] - SUCCESS : No license key found for row id (109). Deletion aborted.
|
||||
[11/16/2024 12:56 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-2440-E86B-D53C-EA9C-05F1-DC1F-8AB0-99DD).
|
||||
[11/16/2024 12:56 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-2440-E86B-D53C-EA9C-05F1-DC1F-8AB0-99DD).
|
||||
[11/16/2024 12:56 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-2440-E86B-D53C-EA9C-05F1-DC1F-8AB0-99DD).
|
||||
[11/16/2024 12:57 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:57 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:57 PM] - SUCCESS : No license key found for row id (110). Deletion aborted.
|
||||
[11/16/2024 12:57 PM] - SUCCESS : No license key found for row id (110). Deletion aborted.
|
||||
[11/16/2024 12:57 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6530-1BB5-9EFB-499B-0E2F-5E30-1D91-CA84).
|
||||
[11/16/2024 12:57 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6530-1BB5-9EFB-499B-0E2F-5E30-1D91-CA84).
|
||||
[11/16/2024 12:57 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6530-1BB5-9EFB-499B-0E2F-5E30-1D91-CA84).
|
||||
[11/16/2024 12:59 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 12:59 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 12:59 PM] - SUCCESS : No license key found for row id (111). Deletion aborted.
|
||||
[11/16/2024 12:59 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-7E96-7D67-6081-002F-970F-3B4D-E0D4-D241).
|
||||
[11/16/2024 12:59 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-7E96-7D67-6081-002F-970F-3B4D-E0D4-D241).
|
||||
[11/16/2024 12:59 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-7E96-7D67-6081-002F-970F-3B4D-E0D4-D241).
|
||||
[11/16/2024 1:00 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 1:00 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 1:00 PM] - SUCCESS : No license key found for row id (112). Deletion aborted.
|
||||
[11/16/2024 1:00 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-A3A7-9E51-FE88-B3CF-2D32-03F9-754A-0C52).
|
||||
[11/16/2024 1:00 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-A3A7-9E51-FE88-B3CF-2D32-03F9-754A-0C52).
|
||||
[11/16/2024 1:00 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-A3A7-9E51-FE88-B3CF-2D32-03F9-754A-0C52).
|
||||
[11/16/2024 1:12 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 1:12 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 1:23 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 1:23 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 1:23 PM] - SUCCESS : No license key found for row id (113). Deletion aborted.
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-0334-18CC-D8D3-4934-0BE8-3CDE-5027-8650).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-0334-18CC-D8D3-4934-0BE8-3CDE-5027-8650).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-0334-18CC-D8D3-4934-0BE8-3CDE-5027-8650).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-5677-AF06-907B-08A5-B32E-9913-AFFB-F4F8).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-5677-AF06-907B-08A5-B32E-9913-AFFB-F4F8).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-5677-AF06-907B-08A5-B32E-9913-AFFB-F4F8).
|
||||
[11/16/2024 1:23 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 1:23 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 1:25 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 1:25 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 1:25 PM] - SUCCESS : No license key found for row id (114). Deletion aborted.
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-CB2B-6D87-E702-594A-809F-6CC9-50D7-31A5).
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-CB2B-6D87-E702-594A-809F-6CC9-50D7-31A5).
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-CB2B-6D87-E702-594A-809F-6CC9-50D7-31A5).
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-3D21-3109-BC19-98F3-9EE8-8891-E33F-0F2A).
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-3D21-3109-BC19-98F3-9EE8-8891-E33F-0F2A).
|
||||
[11/16/2024 1:25 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-3D21-3109-BC19-98F3-9EE8-8891-E33F-0F2A).
|
||||
[11/16/2024 2:37 PM] - SUCCESS : No license key found for row id (117). Deletion aborted.
|
||||
[11/16/2024 2:37 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:37 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 2:38 PM] - SUCCESS : No license key found for row id (117). Deletion aborted.
|
||||
[11/16/2024 2:38 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-4AA8-C044-3F7D-A2D7-0C96-B028-3C0B-8DC6).
|
||||
[11/16/2024 2:38 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-4AA8-C044-3F7D-A2D7-0C96-B028-3C0B-8DC6).
|
||||
[11/16/2024 2:38 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-4AA8-C044-3F7D-A2D7-0C96-B028-3C0B-8DC6).
|
||||
[11/16/2024 2:52 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:52 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 2:52 PM] - SUCCESS : No license key found for row id (118). Deletion aborted.
|
||||
[11/16/2024 2:52 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-2F2D-0A50-589A-2218-FA9D-57CF-CDF1-AFDB).
|
||||
[11/16/2024 2:52 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-2F2D-0A50-589A-2218-FA9D-57CF-CDF1-AFDB).
|
||||
[11/16/2024 2:52 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-2F2D-0A50-589A-2218-FA9D-57CF-CDF1-AFDB).
|
||||
[11/16/2024 2:53 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:53 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 2:53 PM] - SUCCESS : No license key found for row id (119). Deletion aborted.
|
||||
[11/16/2024 2:53 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-5E7A-1E46-65B8-E0A9-20C8-3DCA-405D-0286).
|
||||
[11/16/2024 2:53 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-5E7A-1E46-65B8-E0A9-20C8-3DCA-405D-0286).
|
||||
[11/16/2024 2:53 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-5E7A-1E46-65B8-E0A9-20C8-3DCA-405D-0286).
|
||||
[11/16/2024 2:54 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:54 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 2:55 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:55 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 2:59 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 2:59 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 3:00 PM] - SUCCESS : No license key found for row id (120). Deletion aborted.
|
||||
[11/16/2024 3:01 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-CB3E-34BD-01A2-C01B-C6DA-FA9C-52D9-84E3).
|
||||
[11/16/2024 3:01 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-CB3E-34BD-01A2-C01B-C6DA-FA9C-52D9-84E3).
|
||||
[11/16/2024 3:01 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-CB3E-34BD-01A2-C01B-C6DA-FA9C-52D9-84E3).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-16C2-D95B-90F5-E9B4-5B77-C4D7-17D2-EB74).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-16C2-D95B-90F5-E9B4-5B77-C4D7-17D2-EB74).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-16C2-D95B-90F5-E9B4-5B77-C4D7-17D2-EB74).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-8265-D551-F989-EB4B-B5EF-F2AC-9CC2-E64F).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-8265-D551-F989-EB4B-B5EF-F2AC-9CC2-E64F).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-8265-D551-F989-EB4B-B5EF-F2AC-9CC2-E64F).
|
||||
[11/16/2024 3:02 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 3:02 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 3:02 PM] - SUCCESS : No license key found for row id (122). Deletion aborted.
|
||||
[11/16/2024 3:02 PM] - SUCCESS : No license key found for row id (121). Deletion aborted.
|
||||
[11/16/2024 3:03 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-55AC-E91A-F0FA-61C8-9DF3-1A1F-38C8-82D1).
|
||||
[11/16/2024 3:03 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-55AC-E91A-F0FA-61C8-9DF3-1A1F-38C8-82D1).
|
||||
[11/16/2024 3:03 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-55AC-E91A-F0FA-61C8-9DF3-1A1F-38C8-82D1).
|
||||
[11/16/2024 3:03 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 3:03 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 3:07 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 3:07 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 3:07 PM] - SUCCESS : No license key found for row id (124). Deletion aborted.
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-E488-1E7D-F14C-43D9-F1ED-B23D-EA38-60A9).
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-E488-1E7D-F14C-43D9-F1ED-B23D-EA38-60A9).
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-E488-1E7D-F14C-43D9-F1ED-B23D-EA38-60A9).
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-E4AC-924C-78A2-189D-2633-E4A6-39EE-1E99).
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-E4AC-924C-78A2-189D-2633-E4A6-39EE-1E99).
|
||||
[11/16/2024 3:07 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-E4AC-924C-78A2-189D-2633-E4A6-39EE-1E99).
|
||||
[11/16/2024 3:08 PM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/16/2024 3:08 PM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/16/2024 3:08 PM] - SUCCESS : No license key found for row id (125). Deletion aborted.
|
||||
[11/16/2024 3:08 PM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-BD7C-BACD-412E-D268-61AC-DBF0-A557-B7AE).
|
||||
[11/16/2024 3:08 PM] - SUCCESS : 1 entries deleted from log table for license key (SLM-BD7C-BACD-412E-D268-61AC-DBF0-A557-B7AE).
|
||||
[11/16/2024 3:08 PM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-BD7C-BACD-412E-D268-61AC-DBF0-A557-B7AE).
|
||||
[11/19/2024 1:32 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:32 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:33 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-D799-8DDC-3172-AF54-3A4C-C881-7A9E-C353).
|
||||
[11/19/2024 1:33 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-D799-8DDC-3172-AF54-3A4C-C881-7A9E-C353).
|
||||
[11/19/2024 1:33 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-D799-8DDC-3172-AF54-3A4C-C881-7A9E-C353).
|
||||
[11/19/2024 1:33 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:33 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:36 AM] - SUCCESS : No license key found for row id (128). Deletion aborted.
|
||||
[11/19/2024 1:36 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6540-30EF-63A5-EF6E-3C37-A465-8846-192B).
|
||||
[11/19/2024 1:36 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6540-30EF-63A5-EF6E-3C37-A465-8846-192B).
|
||||
[11/19/2024 1:36 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6540-30EF-63A5-EF6E-3C37-A465-8846-192B).
|
||||
[11/19/2024 1:43 AM] - SUCCESS : No license key found for row id (129). Deletion aborted.
|
||||
[11/19/2024 1:43 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:43 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:43 AM] - SUCCESS : No license key found for row id (129). Deletion aborted.
|
||||
[11/19/2024 1:44 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-AE29-5021-38EE-5C99-9982-72B2-14E2-64A1).
|
||||
[11/19/2024 1:44 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-AE29-5021-38EE-5C99-9982-72B2-14E2-64A1).
|
||||
[11/19/2024 1:44 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-AE29-5021-38EE-5C99-9982-72B2-14E2-64A1).
|
||||
[11/19/2024 1:46 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:46 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:46 AM] - SUCCESS : No license key found for row id (130). Deletion aborted.
|
||||
[11/19/2024 1:47 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-1CD0-1BA9-C29C-C09B-DCFF-19F6-E85C-7859).
|
||||
[11/19/2024 1:47 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-1CD0-1BA9-C29C-C09B-DCFF-19F6-E85C-7859).
|
||||
[11/19/2024 1:47 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-1CD0-1BA9-C29C-C09B-DCFF-19F6-E85C-7859).
|
||||
[11/19/2024 1:50 AM] - SUCCESS : No license key found for row id (131). Deletion aborted.
|
||||
[11/19/2024 1:50 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:50 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:51 AM] - SUCCESS : No license key found for row id (131). Deletion aborted.
|
||||
[11/19/2024 1:52 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6954-42D7-18A2-D4EA-E6B0-341E-1CB8-A6B1).
|
||||
[11/19/2024 1:52 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6954-42D7-18A2-D4EA-E6B0-341E-1CB8-A6B1).
|
||||
[11/19/2024 1:52 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6954-42D7-18A2-D4EA-E6B0-341E-1CB8-A6B1).
|
||||
[11/19/2024 1:52 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:52 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:55 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 1:55 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 1:56 AM] - SUCCESS : No license key found for row id (132). Deletion aborted.
|
||||
[11/19/2024 2:03 AM] - SUCCESS : No license key found for row id (132). Deletion aborted.
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-DFF3-16D6-C4D4-9AA1-65C6-3B48-F90F-ACA0).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-DFF3-16D6-C4D4-9AA1-65C6-3B48-F90F-ACA0).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-DFF3-16D6-C4D4-9AA1-65C6-3B48-F90F-ACA0).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-57B7-0FAD-96D5-08A6-FD2E-6349-309C-E0CF).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-57B7-0FAD-96D5-08A6-FD2E-6349-309C-E0CF).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-57B7-0FAD-96D5-08A6-FD2E-6349-309C-E0CF).
|
||||
[11/19/2024 2:03 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 2:03 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 2:06 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 2:06 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 2:26 AM] - SUCCESS : No license key found for row id (133). Deletion aborted.
|
||||
[11/19/2024 2:27 AM] - SUCCESS : No license key found for row id (133). Deletion aborted.
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-6A1C-C6DC-F906-1A0A-81FD-F747-1F0A-8576).
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-6A1C-C6DC-F906-1A0A-81FD-F747-1F0A-8576).
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-6A1C-C6DC-F906-1A0A-81FD-F747-1F0A-8576).
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-89E4-8139-76B7-1003-C7C0-4BC4-6212-BD35).
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-89E4-8139-76B7-1003-C7C0-4BC4-6212-BD35).
|
||||
[11/19/2024 2:28 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-89E4-8139-76B7-1003-C7C0-4BC4-6212-BD35).
|
||||
[11/19/2024 2:29 AM] - SUCCESS : No license key found for row id (135). Deletion aborted.
|
||||
[11/19/2024 2:32 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 2:32 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 2:32 AM] - SUCCESS : API - license creation (slm_create_new) request received.
|
||||
[11/19/2024 2:32 AM] - SUCCESS : API Response - Result: success Message: License successfully created
|
||||
[11/19/2024 2:33 AM] - SUCCESS : No license key found for row id (135). Deletion aborted.
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-C186-4990-98C2-901D-A226-3965-5D65-F806).
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-C186-4990-98C2-901D-A226-3965-5D65-F806).
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-C186-4990-98C2-901D-A226-3965-5D65-F806).
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 0 entries deleted from devices table for license key (SLM-DAB0-BF76-E594-2E3B-99CF-4EAA-AA48-502E).
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 1 entries deleted from log table for license key (SLM-DAB0-BF76-E594-2E3B-99CF-4EAA-AA48-502E).
|
||||
[11/19/2024 2:33 AM] - SUCCESS : 0 entries deleted from emails table for license key (SLM-DAB0-BF76-E594-2E3B-99CF-4EAA-AA48-502E).
|
52
readme.txt
52
readme.txt
|
@ -3,52 +3,10 @@ Contributors: Michel Velis, Tips and Tricks HQ
|
|||
Donate link: http://paypal.me/mvelis
|
||||
Tags: license, software license, woocommerce, license management
|
||||
Requires at least: 5.6
|
||||
Tested up to: 6.1.0
|
||||
Stable tag: 6.1.0
|
||||
Requires PHP: 7.4
|
||||
Tested up to: 6.7
|
||||
Stable tag: 6.1.9
|
||||
Tags: license manager, license key, license genrator, subscription
|
||||
Requires PHP: 7.2
|
||||
License: GPLv2 or later
|
||||
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
A comprehensive software license management solution for web applications including WordPress plugins, themes, and PHP-based software. Seamlessly integrates with WooCommerce to offer license key generation, management, and validation. Ideal for developers managing software licenses across multiple platforms with built-in multilingual support and performance optimization.
|
||||
|
||||
== Description ==
|
||||
|
||||
SLM Plus provides a powerful solution for managing software licenses for WordPress plugins, themes, and other web applications. With WooCommerce integration, the plugin allows you to generate, activate, and manage licenses for your customers seamlessly.
|
||||
|
||||
## 📦 Features:
|
||||
- Generate and manage license keys for your products
|
||||
- Remote license key validation and activation
|
||||
- Track license key usage across different domains and devices
|
||||
- Manually create licenses from the admin dashboard
|
||||
- Bulk actions for managing licenses
|
||||
- Export licenses for both users and admins (new)
|
||||
- View licenses by subscribers (new)
|
||||
- License info is now included inside WooCommerce order details (new)
|
||||
- License activity logs to track key usage and activations (new)
|
||||
- Admin stats widgets to visualize license usage (new)
|
||||
- Automated emails for license expiration and activation reminders
|
||||
- Multilingual support (English, Spanish)
|
||||
- WooCommerce product type integration to manage licenses through orders
|
||||
- Manage licenses directly from users' "My Account" page
|
||||
- License expiration reminders and notification emails
|
||||
|
||||
== Installation ==
|
||||
|
||||
This section describes how to install the plugin and get it working.
|
||||
|
||||
1. Go to the Add New plugins screen in your WordPress admin area
|
||||
2. Click the Upload tab
|
||||
3. Browse for the plugin file (software-license-manager.zip)
|
||||
4. Click Install Now and then activate the plugin
|
||||
|
||||
== Changelog ==
|
||||
= 6.1.0 =
|
||||
- Improved compatibility with WordPress 6.1 and WooCommerce
|
||||
- Enhanced performance for large license databases
|
||||
- Added multilingual support for Spanish
|
||||
- New admin widgets for tracking licenses
|
||||
- Improved license information in WooCommerce order details
|
||||
|
||||
== Upgrade Notice ==
|
||||
= 6.1.0 =
|
||||
- Please ensure your WordPress version is at least 5.6 and PHP version is 7.4 or higher before updating.
|
||||
SLM Plus offers a powerful solution for managing licenses for WordPress plugins, themes, and web apps. With WooCommerce integration.
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'LicenseAPI.php';
|
||||
|
||||
class ActivateLicense
|
||||
{
|
||||
private $licenseAPI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->licenseAPI = new LicenseAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a license on a specific domain or device.
|
||||
*
|
||||
* @param array $activationData Activation data, including license key, domain, and optionally device.
|
||||
* @return void Outputs the result based on the activation response.
|
||||
*/
|
||||
public function activate($activationData)
|
||||
{
|
||||
$response = $this->licenseAPI->activateLicense($activationData);
|
||||
|
||||
// Handle different scenarios based on the API response
|
||||
if ($response['result'] === 'success') {
|
||||
echo "License activated successfully for domain: " . $activationData['registered_domain'];
|
||||
if (!empty($activationData['registered_devices'])) {
|
||||
echo " and device: " . $activationData['registered_devices'];
|
||||
}
|
||||
} elseif (isset($response['error_code'])) {
|
||||
// Specific error handling based on the API's error code
|
||||
switch ($response['error_code']) {
|
||||
case SLM_Error_Codes::LICENSE_EXPIRED:
|
||||
echo "Error: The license has expired. Please renew your license.";
|
||||
break;
|
||||
case SLM_Error_Codes::LICENSE_BLOCKED:
|
||||
echo "Error: The license is blocked. Contact support for assistance.";
|
||||
break;
|
||||
case SLM_Error_Codes::LICENSE_IN_USE:
|
||||
echo "Error: This license is already in use on the specified domain or device.";
|
||||
break;
|
||||
case SLM_Error_Codes::REACHED_MAX_DOMAINS:
|
||||
echo "Error: Maximum allowed domains reached. Upgrade your license for additional domains.";
|
||||
break;
|
||||
case SLM_Error_Codes::REACHED_MAX_DEVICES:
|
||||
echo "Error: Maximum allowed devices reached. Upgrade your license for additional devices.";
|
||||
break;
|
||||
default:
|
||||
echo "Error: Activation failed. " . ($response['message'] ?? 'Unknown error.');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Generic error message for unexpected issues
|
||||
echo "Error: Unable to activate license. " . ($response['message'] ?? 'Please try again later.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example
|
||||
$activateLicense = new ActivateLicense();
|
||||
|
||||
$activationData = [
|
||||
'license_key' => 'YOUR_LICENSE_KEY',
|
||||
'registered_domain' => 'example.com', // Required: Domain for license activation
|
||||
'registered_devices' => 'Device12345' // Optional: Device identifier (if applicable)
|
||||
];
|
||||
|
||||
$activateLicense->activate($activationData);
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'LicenseAPI.php';
|
||||
|
||||
class CheckLicense
|
||||
{
|
||||
private $licenseAPI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->licenseAPI = new LicenseAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the status of a license.
|
||||
*
|
||||
* @param string $licenseKey The license key to check.
|
||||
* @return void Outputs the result of the license status check.
|
||||
*/
|
||||
public function check($licenseKey)
|
||||
{
|
||||
$data = [
|
||||
'license_key' => $licenseKey,
|
||||
];
|
||||
|
||||
$response = $this->licenseAPI->checkLicenseStatus($data);
|
||||
|
||||
// Interpret the response based on license status and other indicators
|
||||
if ($response['result'] === 'success') {
|
||||
$status = $response['data']['status'];
|
||||
switch ($status) {
|
||||
case 'active':
|
||||
echo "License is active and valid.";
|
||||
break;
|
||||
case 'expired':
|
||||
echo "License has expired. Please renew to continue using the product.";
|
||||
break;
|
||||
case 'blocked':
|
||||
echo "License is blocked. Contact support for further assistance.";
|
||||
break;
|
||||
default:
|
||||
echo "License status: " . ucfirst($status) . ".";
|
||||
break;
|
||||
}
|
||||
} elseif (isset($response['error_code'])) {
|
||||
// Handle specific error codes for license check failure
|
||||
switch ($response['error_code']) {
|
||||
case SLM_Error_Codes::LICENSE_INVALID:
|
||||
echo "Error: Invalid license key provided.";
|
||||
break;
|
||||
default:
|
||||
echo "Error checking license status: " . ($response['message'] ?? 'Unknown error.');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Fallback for unexpected issues
|
||||
echo "Error: Unable to check license status. " . ($response['message'] ?? 'Please try again later.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example
|
||||
$checkLicense = new CheckLicense();
|
||||
|
||||
// License key to check
|
||||
$licenseKey = 'YOUR_LICENSE_KEY';
|
||||
$checkLicense->check($licenseKey);
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
<?php
|
||||
|
||||
class CoreConfig
|
||||
{
|
||||
// Define constants for API URL and Secret Key
|
||||
const API_URL = 'https://yourwebsite.com';
|
||||
const SECRET_KEY = 'YOUR_SECRET_KEY';
|
||||
|
||||
/**
|
||||
* Get the full API URL with action as a query parameter.
|
||||
*
|
||||
* @param string $action The specific action for the API call.
|
||||
* @return string Full API endpoint for the specific action.
|
||||
*/
|
||||
public static function getApiUrl($action)
|
||||
{
|
||||
return rtrim(self::API_URL, '/') . '/?slm_action=' . urlencode($action);
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the API response to ensure correct format and handle errors.
|
||||
*
|
||||
* @param mixed $response Raw JSON response from the API.
|
||||
* @return array Processed response with success/error information.
|
||||
*/
|
||||
public static function processResponse($response)
|
||||
{
|
||||
if (!is_array($response)) {
|
||||
return [
|
||||
'result' => 'error',
|
||||
'message' => 'Invalid response format from the API.',
|
||||
];
|
||||
}
|
||||
|
||||
// Handle success and error cases
|
||||
if (isset($response['result']) && $response['result'] === 'success') {
|
||||
return ['result' => 'success', 'data' => $response];
|
||||
} elseif (isset($response['result']) && $response['result'] === 'error') {
|
||||
self::logError($response['message'] ?? 'Unknown error');
|
||||
return ['result' => 'error', 'message' => $response['message'] ?? 'An error occurred.'];
|
||||
}
|
||||
|
||||
// Fallback for unexpected response structures
|
||||
return ['result' => 'error', 'message' => 'Unexpected response structure.'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Log errors for troubleshooting.
|
||||
*
|
||||
* @param string $message The error message to log.
|
||||
*/
|
||||
public static function logError($message)
|
||||
{
|
||||
error_log("[API ERROR] " . $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize and validate input fields for security.
|
||||
*
|
||||
* @param array $fields Fields to be sanitized.
|
||||
* @return array Sanitized fields.
|
||||
*/
|
||||
public static function sanitizeFields($fields)
|
||||
{
|
||||
foreach ($fields as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'email':
|
||||
$fields[$key] = filter_var($value, FILTER_SANITIZE_EMAIL);
|
||||
break;
|
||||
case 'max_allowed_domains':
|
||||
case 'max_allowed_devices':
|
||||
$fields[$key] = intval($value);
|
||||
break;
|
||||
default:
|
||||
$fields[$key] = htmlspecialchars(strip_tags($value));
|
||||
}
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a secure API request with cURL.
|
||||
*
|
||||
* @param string $action API action name.
|
||||
* @param array $data Data to send in the request.
|
||||
* @return array Processed API response.
|
||||
*/
|
||||
public static function apiRequest($action, $data)
|
||||
{
|
||||
$data['secret_key'] = self::SECRET_KEY;
|
||||
$data = self::sanitizeFields($data);
|
||||
|
||||
$ch = curl_init(self::getApiUrl($action));
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
|
||||
$response = curl_exec($ch);
|
||||
|
||||
if (curl_errno($ch)) {
|
||||
self::logError('cURL Error: ' . curl_error($ch));
|
||||
curl_close($ch);
|
||||
return [
|
||||
'result' => 'error',
|
||||
'message' => 'Network error during API request.',
|
||||
];
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
|
||||
return self::processResponse(json_decode($response, true));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'LicenseAPI.php';
|
||||
|
||||
class CreateLicense
|
||||
{
|
||||
private $licenseAPI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->licenseAPI = new LicenseAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new license using provided data.
|
||||
*
|
||||
* @param array $licenseData Data for license creation.
|
||||
* @return void Displays success or error message based on response.
|
||||
*/
|
||||
public function create($licenseData)
|
||||
{
|
||||
$response = $this->licenseAPI->createLicense($licenseData);
|
||||
|
||||
if ($response['result'] === 'success') {
|
||||
echo "License created successfully. Key: " . $response['data']['key'];
|
||||
} else {
|
||||
echo "Error creating license: " . $response['message'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example
|
||||
$createLicense = new CreateLicense();
|
||||
|
||||
$licenseData = [
|
||||
'first_name' => 'John',
|
||||
'last_name' => 'Doe',
|
||||
'email' => 'johndoe@example.com',
|
||||
'purchase_id_' => '12345',
|
||||
'max_allowed_domains' => 2,
|
||||
'max_allowed_devices' => 1,
|
||||
'date_created' => date('Y-m-d'),
|
||||
'product_ref' => 'ThemePro'
|
||||
];
|
||||
|
||||
$createLicense->create($licenseData);
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'LicenseAPI.php';
|
||||
|
||||
class DeactivateLicense
|
||||
{
|
||||
private $licenseAPI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->licenseAPI = new LicenseAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate a license on a specific domain or device.
|
||||
*
|
||||
* @param array $deactivationData Deactivation data, including license key, domain, and/or device.
|
||||
* @return void Outputs the result based on the deactivation response.
|
||||
*/
|
||||
public function deactivate($deactivationData)
|
||||
{
|
||||
$response = $this->licenseAPI->deactivateLicense($deactivationData);
|
||||
|
||||
// Handle response scenarios
|
||||
if ($response['result'] === 'success') {
|
||||
echo "License deactivated successfully for domain: " . ($deactivationData['registered_domain'] ?? 'N/A');
|
||||
if (!empty($deactivationData['registered_devices'])) {
|
||||
echo " and device: " . $deactivationData['registered_devices'];
|
||||
}
|
||||
} elseif (isset($response['error_code'])) {
|
||||
// Handle specific deactivation error codes
|
||||
switch ($response['error_code']) {
|
||||
case SLM_Error_Codes::DOMAIN_ALREADY_INACTIVE:
|
||||
echo "Error: The license is already inactive on the specified domain or device.";
|
||||
break;
|
||||
case SLM_Error_Codes::DOMAIN_MISSING:
|
||||
echo "Error: The specified domain or device was not found.";
|
||||
break;
|
||||
default:
|
||||
echo "Error: Deactivation failed. " . ($response['message'] ?? 'Unknown error.');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Fallback for unexpected issues
|
||||
echo "Error: Unable to deactivate license. " . ($response['message'] ?? 'Please try again later.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example
|
||||
$deactivateLicense = new DeactivateLicense();
|
||||
|
||||
$deactivationData = [
|
||||
'license_key' => 'YOUR_LICENSE_KEY',
|
||||
'registered_domain' => 'example.com', // Optional: Domain to deactivate the license on
|
||||
'registered_devices' => 'Device12345' // Optional: Device to deactivate (if applicable)
|
||||
];
|
||||
|
||||
// If both domain and device are provided, only one needs to match for deactivation.
|
||||
$deactivateLicense->deactivate($deactivationData);
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'LicenseAPI.php';
|
||||
|
||||
class GetLicenseInfo
|
||||
{
|
||||
private $licenseAPI;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->licenseAPI = new LicenseAPI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve and display detailed information about a license.
|
||||
*
|
||||
* @param string $licenseKey The license key to retrieve information for.
|
||||
* @return void Outputs detailed license information based on the response.
|
||||
*/
|
||||
public function retrieve($licenseKey)
|
||||
{
|
||||
$data = [
|
||||
'license_key' => $licenseKey,
|
||||
];
|
||||
|
||||
$response = $this->licenseAPI->getLicenseInfo($data);
|
||||
|
||||
// Interpret and display license information based on the API response
|
||||
if ($response['result'] === 'success') {
|
||||
$info = $response['data'];
|
||||
|
||||
echo "License Information:\n";
|
||||
echo "-----------------------\n";
|
||||
echo "License Key: " . $info['license_key'] . "\n";
|
||||
echo "Status: " . ucfirst($info['status']) . "\n";
|
||||
echo "Registered User: " . $info['first_name'] . " " . $info['last_name'] . "\n";
|
||||
echo "Email: " . $info['email'] . "\n";
|
||||
echo "Company: " . ($info['company_name'] ?? 'N/A') . "\n";
|
||||
echo "Product: " . $info['product_ref'] . "\n";
|
||||
echo "Created Date: " . $info['date_created'] . "\n";
|
||||
echo "Expiry Date: " . ($info['date_expiry'] ?? 'N/A') . "\n";
|
||||
echo "Max Domains: " . $info['max_allowed_domains'] . "\n";
|
||||
echo "Max Devices: " . $info['max_allowed_devices'] . "\n";
|
||||
|
||||
if (!empty($info['registered_domains'])) {
|
||||
echo "Registered Domains:\n";
|
||||
foreach ($info['registered_domains'] as $domain) {
|
||||
echo " - " . $domain->registered_domain . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($info['registered_devices'])) {
|
||||
echo "Registered Devices:\n";
|
||||
foreach ($info['registered_devices'] as $device) {
|
||||
echo " - " . $device->registered_devices . "\n";
|
||||
}
|
||||
}
|
||||
echo "-----------------------\n";
|
||||
|
||||
} elseif (isset($response['error_code'])) {
|
||||
// Handle specific error codes for information retrieval
|
||||
switch ($response['error_code']) {
|
||||
case SLM_Error_Codes::LICENSE_INVALID:
|
||||
echo "Error: Invalid license key provided.";
|
||||
break;
|
||||
default:
|
||||
echo "Error retrieving license information: " . ($response['message'] ?? 'Unknown error.');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Fallback for unexpected issues
|
||||
echo "Error: Unable to retrieve license information. " . ($response['message'] ?? 'Please try again later.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Usage example
|
||||
$getLicenseInfo = new GetLicenseInfo();
|
||||
|
||||
// License key to retrieve information for
|
||||
$licenseKey = 'YOUR_LICENSE_KEY';
|
||||
$getLicenseInfo->retrieve($licenseKey);
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once 'CoreConfig.php';
|
||||
|
||||
class LicenseAPI
|
||||
{
|
||||
/**
|
||||
* Create a new license.
|
||||
*
|
||||
* @param array $data License data to send with the request.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function createLicense($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_create_new', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing license.
|
||||
*
|
||||
* @param array $data License data to send with the request.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function updateLicense($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_update', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate a license for a specific domain or device.
|
||||
*
|
||||
* @param array $data License activation data.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function activateLicense($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_activate', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate a license from a specific domain or device.
|
||||
*
|
||||
* @param array $data License deactivation data.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function deactivateLicense($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_deactivate', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the status of a license.
|
||||
*
|
||||
* @param array $data License data for checking status.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function checkLicenseStatus($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_check', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve detailed information about a license.
|
||||
*
|
||||
* @param array $data License data for retrieving information.
|
||||
* @return array Response from the API.
|
||||
*/
|
||||
public function getLicenseInfo($data)
|
||||
{
|
||||
return CoreConfig::apiRequest('slm_info', $data);
|
||||
}
|
||||
}
|
||||
|
19
slm-plus.php
19
slm-plus.php
|
@ -1,12 +1,12 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: SLM Plus
|
||||
Version: 6.1.8
|
||||
Version: 6.1.9
|
||||
Plugin URI: https://github.com/michelve/software-license-manager/
|
||||
Author: Michel Velis
|
||||
Author URI: https://github.com/michelve/
|
||||
Description: A comprehensive software license management solution for web applications including WordPress plugins, themes, and PHP-based software. Seamlessly integrates with WooCommerce to offer license key generation, management, and validation. Ideal for developers managing software licenses across multiple platforms with built-in multilingual support and performance optimization.
|
||||
Text Domain: slmplus
|
||||
Text Domain: slm-plus
|
||||
Domain Path: /i18n/languages/
|
||||
WC tested up to: 6.7
|
||||
Requires at least: 5.6
|
||||
|
@ -23,8 +23,9 @@ if (!defined('ABSPATH')) {
|
|||
}
|
||||
|
||||
// Load plugin textdomain for multilingual support
|
||||
function slmplus_load_textdomain() {
|
||||
load_plugin_textdomain('slmplus', false, dirname(plugin_basename(__FILE__)) . '/i18n/languages');
|
||||
function slmplus_load_textdomain()
|
||||
{
|
||||
load_plugin_textdomain('slm-plus', false, dirname(plugin_basename(__FILE__)) . '/i18n/languages');
|
||||
}
|
||||
add_action('plugins_loaded', 'slmplus_load_textdomain');
|
||||
|
||||
|
@ -32,7 +33,7 @@ add_action('plugins_loaded', 'slmplus_load_textdomain');
|
|||
global $wpdb, $slm_debug_logger;
|
||||
|
||||
// Define constants for plugin paths, URLs, and database tables
|
||||
define('SLM_VERSION', '6.1.8');
|
||||
define('SLM_VERSION', '6.1.9');
|
||||
define('SLM_DB_VERSION', '5.1.2');
|
||||
define('SLM_REWRITE_VERSION', '3.0.8');
|
||||
define('SLM_FOLDER', dirname(plugin_basename(__FILE__)));
|
||||
|
@ -65,15 +66,17 @@ if (file_exists(SLM_LIB . 'slm-plugin-core.php')) {
|
|||
require_once SLM_LIB . 'slm-plugin-core.php';
|
||||
}
|
||||
|
||||
function slm_settings_link($links){
|
||||
$settings_link = '<a href="' . esc_url(admin_url('admin.php?page=slm_settings')) . '">' . __('Settings') . '</a>';
|
||||
// $github_link = '<a href="' . esc_url('https://github.com/michelve/software-license-manager') . '" target="_blank">' . __('GitHub') . '</a>';
|
||||
function slm_settings_link($links)
|
||||
{
|
||||
$settings_link = '<a href="' . esc_url(admin_url('admin.php?page=slm_settings')) . '">' . __('Settings', 'slm-plus') . '</a>';
|
||||
// $github_link = '<a href="' . esc_url('https://github.com/michelve/software-license-manager') . '" target="_blank">' . __('GitHub') . '</a>';
|
||||
$links[] = $settings_link;
|
||||
//$links[] = $github_link;
|
||||
return $links;
|
||||
}
|
||||
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'slm_settings_link');
|
||||
|
||||
|
||||
define('SLM_DEFAULT_MAX_DOMAINS', SLM_API_Utility::get_slm_option('default_max_domains'));
|
||||
define('SLM_DEFAULT_MAX_DEVICES', SLM_API_Utility::get_slm_option('default_max_devices'));
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ foreach ($slm_options as $option) {
|
|||
delete_option($option);
|
||||
}
|
||||
|
||||
// Sanitize and list all tables related to the plugin
|
||||
// List all tables related to the plugin
|
||||
$tables_to_drop = array(
|
||||
$wpdb->prefix . 'lic_key_tbl',
|
||||
$wpdb->prefix . 'lic_reg_domain_tbl',
|
||||
|
@ -45,36 +45,45 @@ $tables_to_drop = array(
|
|||
$wpdb->prefix . 'slm_activations_tbl',
|
||||
);
|
||||
|
||||
// Drop custom database tables
|
||||
// Drop custom database tables using the `prepare` method
|
||||
foreach ($tables_to_drop as $table) {
|
||||
$wpdb->query("DROP TABLE IF EXISTS `$table`");
|
||||
// Check if the table exists before attempting to drop it
|
||||
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) !== null) {
|
||||
// Drop the table if it exists
|
||||
$wpdb->query($wpdb->prepare("DROP TABLE IF EXISTS %s", $table));
|
||||
}
|
||||
}
|
||||
|
||||
// Delete Custom Post Type posts and related metadata
|
||||
// Delete Custom Post Type posts and related metadata using the `delete` method
|
||||
$post_types = array('slm_manage_license', 'slm_license_product'); // Add any other custom post types if needed
|
||||
foreach ($post_types as $post_type) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE posts, meta FROM {$wpdb->posts} posts
|
||||
LEFT JOIN {$wpdb->postmeta} meta ON posts.ID = meta.post_id
|
||||
WHERE posts.post_type = %s",
|
||||
$post_type
|
||||
)
|
||||
);
|
||||
// Check if post type data is cached
|
||||
$cached_posts = wp_cache_get($post_type, 'slm_posts');
|
||||
if ($cached_posts) {
|
||||
wp_cache_delete($post_type, 'slm_posts');
|
||||
}
|
||||
|
||||
// Safely delete posts and metadata for this post type
|
||||
$wpdb->delete($wpdb->posts, array('post_type' => $post_type));
|
||||
$wpdb->delete($wpdb->postmeta, array('post_id' => $post_type));
|
||||
}
|
||||
|
||||
// Clean orphaned postmeta entries
|
||||
// Clean orphaned postmeta entries using `DELETE` queries
|
||||
$wpdb->query(
|
||||
"DELETE pm FROM {$wpdb->postmeta} pm
|
||||
LEFT JOIN {$wpdb->posts} p ON pm.post_id = p.ID
|
||||
WHERE p.ID IS NULL"
|
||||
$wpdb->prepare(
|
||||
"DELETE pm FROM {$wpdb->postmeta} pm
|
||||
LEFT JOIN {$wpdb->posts} p ON pm.post_id = p.ID
|
||||
WHERE p.ID IS NULL"
|
||||
)
|
||||
);
|
||||
|
||||
// Clean orphaned term relationships if there are custom taxonomies involved
|
||||
$wpdb->query(
|
||||
"DELETE tr FROM {$wpdb->term_relationships} tr
|
||||
LEFT JOIN {$wpdb->posts} p ON tr.object_id = p.ID
|
||||
WHERE p.ID IS NULL"
|
||||
$wpdb->prepare(
|
||||
"DELETE tr FROM {$wpdb->term_relationships} tr
|
||||
LEFT JOIN {$wpdb->posts} p ON tr.object_id = p.ID
|
||||
WHERE p.ID IS NULL"
|
||||
)
|
||||
);
|
||||
|
||||
// Delete custom user meta related to the plugin (if applicable)
|
||||
|
@ -84,10 +93,14 @@ $user_meta_keys = array(
|
|||
);
|
||||
|
||||
foreach ($user_meta_keys as $meta_key) {
|
||||
$wpdb->query(
|
||||
$wpdb->prepare(
|
||||
"DELETE FROM {$wpdb->usermeta} WHERE meta_key = %s",
|
||||
$meta_key
|
||||
)
|
||||
);
|
||||
// Check if user meta data is cached
|
||||
$cached_meta = wp_cache_get($meta_key, 'slm_usermeta');
|
||||
if ($cached_meta) {
|
||||
wp_cache_delete($meta_key, 'slm_usermeta');
|
||||
}
|
||||
|
||||
$wpdb->delete($wpdb->usermeta, array('meta_key' => $meta_key));
|
||||
}
|
||||
|
||||
// Clear the relevant cache after heavy operations
|
||||
wp_cache_flush();
|
||||
|
|
|
@ -13,7 +13,8 @@ $slm_options = get_option('slm_plugin_options'); // Retrieve plugin options
|
|||
|
||||
add_action('wp_ajax_slm_generate_licenses', 'slm_generate_licenses_callback');
|
||||
|
||||
function slm_generate_licenses_callback() {
|
||||
function slm_generate_licenses_callback()
|
||||
{
|
||||
check_ajax_referer('slm_generate_licenses_nonce', 'security');
|
||||
|
||||
global $wpdb;
|
||||
|
@ -30,16 +31,16 @@ function slm_generate_licenses_callback() {
|
|||
? sanitize_text_field($_POST['subscription_type'])
|
||||
: 'subscription';
|
||||
|
||||
SLM_Helper_Class::write_log("Starting license generation with Product ID: {$default_product_id} and License Type: {$slm_lic_type}.");
|
||||
//SLM_Helper_Class::write_log("Starting license generation with Product ID: {$default_product_id} and License Type: {$slm_lic_type}.");
|
||||
|
||||
// Check if Product ID is missing; if so, log an error, add an error response, and exit.
|
||||
if (empty($default_product_id)) {
|
||||
SLM_Helper_Class::write_log('Error: Product ID is missing in the request.');
|
||||
//SLM_Helper_Class::write_log('Error: Product ID is missing in the request.');
|
||||
|
||||
// Track failure and skip reason for the response
|
||||
$failure_count++;
|
||||
$skipped_orders[] = 0;
|
||||
$skipped_reasons[0] = __('Product ID is missing in the request.', 'slmplus');
|
||||
$skipped_reasons[0] = __('Product ID is missing in the request.', 'slm-plus');
|
||||
|
||||
// Return early with a JSON error response for AJAX display
|
||||
$response_data['html'] .= '<li><strong>Error:</strong> Product ID is missing in the request. Please provide a valid product ID.</li>';
|
||||
|
@ -50,12 +51,12 @@ function slm_generate_licenses_callback() {
|
|||
// Check if the Product ID corresponds to an existing WooCommerce product
|
||||
$product = wc_get_product($default_product_id);
|
||||
if (!$product) {
|
||||
SLM_Helper_Class::write_log("Error: Product with ID $default_product_id does not exist in WooCommerce.");
|
||||
//SLM_Helper_Class::write_log("Error: Product with ID $default_product_id does not exist in WooCommerce.");
|
||||
|
||||
// Track failure and skip reason for the response
|
||||
$failure_count++;
|
||||
$skipped_orders[] = 0;
|
||||
$skipped_reasons[0] = __('The provided Product ID does not correspond to a valid WooCommerce product. Please check the ID and try again.', 'slmplus');
|
||||
$skipped_reasons[0] = __('The provided Product ID does not correspond to a valid WooCommerce product. Please check the ID and try again.', 'slm-plus');
|
||||
|
||||
// Return early with a JSON error response for AJAX display
|
||||
$response_data['html'] .= '<li><strong>Error:</strong> The provided Product ID does not correspond to a valid WooCommerce product. Please check the ID and try again.</li>';
|
||||
|
@ -119,7 +120,7 @@ function slm_generate_licenses_callback() {
|
|||
}
|
||||
}
|
||||
|
||||
SLM_Helper_Class::write_log("Interval: {$slm_billing_interval} - Length: {$slm_billing_length}");
|
||||
//SLM_Helper_Class::write_log("Interval: {$slm_billing_interval} - Length: {$slm_billing_length}");
|
||||
|
||||
$order_items = $order->get_items();
|
||||
|
||||
|
@ -128,7 +129,7 @@ function slm_generate_licenses_callback() {
|
|||
|
||||
$product = wc_get_product($default_product_id);
|
||||
if (!$product) {
|
||||
SLM_Helper_Class::write_log("Error: Product with ID {$default_product_id} does not exist.");
|
||||
//SLM_Helper_Class::write_log("Error: Product with ID {$default_product_id} does not exist.");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -184,12 +185,13 @@ function slm_generate_licenses_callback() {
|
|||
$license_key = sanitize_text_field($api_response['key']);
|
||||
$success_count++;
|
||||
|
||||
$item->add_meta_data('_slm_lic_key', $license_key, true);
|
||||
$item->add_meta_data('_slm_lic_type', $slm_lic_type, true);
|
||||
$order->add_order_note(
|
||||
sprintf(__('License Key generated: %s', 'slmplus'), $license_key)
|
||||
);
|
||||
$item->add_meta_data('License Key', $license_key, true);
|
||||
$item->add_meta_data('License Type', $slm_lic_type, true);
|
||||
|
||||
$order->add_order_note(
|
||||
// Translators: %s is the generated license key
|
||||
sprintf(__('License Key generated: %s', 'slm-plus'), $license_key)
|
||||
);
|
||||
$generated_licenses[] = [
|
||||
'license_key' => $license_key,
|
||||
'order_id' => $order_id,
|
||||
|
@ -233,10 +235,12 @@ function slm_generate_licenses_callback() {
|
|||
$success_count++;
|
||||
$generated_licenses[] = ['license_key' => $license_key, 'order_id' => $order_id];
|
||||
|
||||
$item->add_meta_data('_slm_lic_key', $license_key, true);
|
||||
$item->add_meta_data('_slm_lic_type', $slm_lic_type, true);
|
||||
$item->add_meta_data('License Key', $license_key, true);
|
||||
$item->add_meta_data('License Type', $slm_lic_type, true);
|
||||
|
||||
$order->add_order_note(
|
||||
sprintf(__('License Key generated: %s', 'slmplus'), $license_key)
|
||||
// Translators: %s is the generated license key
|
||||
sprintf(__('License Key generated: %s', 'slm-plus'), $license_key)
|
||||
);
|
||||
} else {
|
||||
$failure_count++;
|
||||
|
@ -251,17 +255,16 @@ function slm_generate_licenses_callback() {
|
|||
}
|
||||
|
||||
if (!empty($skipped_orders)) {
|
||||
foreach ($skipped_orders as $order_id) {
|
||||
SLM_Helper_Class::write_log("Skipping Order ID {$order_id}: {$skipped_reasons[$order_id]}.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($skipped_orders)) {
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(__('%d orders were skipped:', 'slmplus'), count($skipped_orders)) . '</strong><ul>';
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(
|
||||
// Translators: %1$d is the number of orders skipped
|
||||
__('%1$d orders were skipped:', 'slm-plus'),
|
||||
count($skipped_orders)
|
||||
) . '</strong><ul>';
|
||||
foreach ($skipped_orders as $order_id) {
|
||||
if ($order_id !== 0) {
|
||||
$order_link = admin_url('post.php?post=' . $order_id . '&action=edit');
|
||||
$response_data['html'] .= '<li>' . sprintf(__('Order ID %d was skipped due to: %s. <a href="%s" target="_blank">View Order</a>', 'slmplus'), $order_id, esc_html($skipped_reasons[$order_id]), esc_url($order_link)) . '</li>';
|
||||
// Translators: %1$d is the order ID, %2$s is the reason why the order was skipped, %3$s is the order view link
|
||||
$response_data['html'] .= '<li>' . sprintf(__('Order ID %1$d was skipped due to: %2$s. <a href="%3$s" target="_blank">View Order</a>', 'slm-plus'), $order_id, esc_html($skipped_reasons[$order_id]), esc_url($order_link)) . '</li>';
|
||||
} else {
|
||||
$response_data['html'] .= '<li>' . esc_html($skipped_reasons[0]) . '</li>';
|
||||
}
|
||||
|
@ -270,16 +273,25 @@ function slm_generate_licenses_callback() {
|
|||
}
|
||||
|
||||
if ($success_count > 0) {
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(__('%d licenses generated successfully:', 'slmplus'), $success_count) . '</strong><ul>';
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(
|
||||
// Translators: %1$d is the number of successfully generated licenses
|
||||
__('%1$d licenses generated successfully:', 'slm-plus'),
|
||||
$success_count
|
||||
) . '</strong><ul>';
|
||||
foreach ($generated_licenses as $license_data) {
|
||||
$order_link = admin_url('post.php?post=' . $license_data['order_id'] . '&action=edit');
|
||||
$response_data['html'] .= '<li>' . sprintf(__('License Key: %s for Order ID %d - <a href="%s" target="_blank">View Order</a>', 'slmplus'), esc_html($license_data['license_key']), $license_data['order_id'], esc_url($order_link)) . '</li>';
|
||||
// Translators: %1$s is the license key, %2$d is the order ID, %3$s is the order view link
|
||||
$response_data['html'] .= '<li>' . sprintf(__('License Key: %1$s for Order ID %2$d - <a href="%3$s" target="_blank">View Order</a>', 'slm-plus'), esc_html($license_data['license_key']), $license_data['order_id'], esc_url($order_link)) . '</li>';
|
||||
}
|
||||
$response_data['html'] .= '</ul></li>';
|
||||
}
|
||||
|
||||
if ($failure_count > 0) {
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(__('%d licenses failed to generate.', 'slmplus'), $failure_count) . '</strong></li>';
|
||||
$response_data['html'] .= '<li><strong>' . sprintf(
|
||||
// Translators: %1$d is the number of licenses that failed to generate
|
||||
__('%1$d licenses failed to generate.', 'slm-plus'),
|
||||
$failure_count
|
||||
) . '</strong></li>';
|
||||
}
|
||||
|
||||
wp_send_json_success($response_data);
|
||||
|
|
|
@ -32,31 +32,9 @@ if ($affect_downloads) {
|
|||
// Add additional license management after order completion
|
||||
add_action('woocommerce_order_status_completed', 'wc_slm_on_complete_purchase', 10);
|
||||
|
||||
// Hide license key metadata from order item meta table in the backend
|
||||
add_filter('woocommerce_hidden_order_itemmeta', 'slm_hide_order_meta', 10, 1);
|
||||
|
||||
// Display license key information more nicely in the order item meta table
|
||||
add_action('woocommerce_after_order_itemmeta', 'slm_display_nice_item_meta', 10, 3);
|
||||
|
||||
// Uncomment the following if you want to display a message on the thank-you page
|
||||
// add_action('woocommerce_thankyou', 'slm_show_msg', 80);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Disable display of some metadata.
|
||||
*
|
||||
* @param array $hide_meta List of meta data to hide.
|
||||
* @return array Modified list of meta data to hide.
|
||||
* @since 4.5.5
|
||||
*/
|
||||
function slm_hide_order_meta($hide_meta) {
|
||||
// Adding metadata to hide from the order item meta table
|
||||
$hide_meta[] = '_slm_lic_key';
|
||||
$hide_meta[] = '_slm_lic_type';
|
||||
return $hide_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display order meta data in Order items table in a user-friendly way.
|
||||
*
|
||||
|
@ -66,10 +44,11 @@ function slm_hide_order_meta($hide_meta) {
|
|||
*
|
||||
* @since 4.5.5
|
||||
*/
|
||||
function slm_display_nice_item_meta($item_id, $item, $product) {
|
||||
function slm_display_nice_item_meta($item_id, $item, $product)
|
||||
{
|
||||
// Fetch the metadata associated with the license key
|
||||
if ($meta_data = wc_get_order_item_meta($item_id, '_slm_lic_key', false)) {
|
||||
?>
|
||||
?>
|
||||
<div class="view">
|
||||
<table cellspacing="0" class="display_meta">
|
||||
<?php
|
||||
|
@ -87,60 +66,59 @@ function slm_display_nice_item_meta($item_id, $item, $product) {
|
|||
$cur_link = sprintf(
|
||||
'%s - %s',
|
||||
esc_html($lic_key),
|
||||
esc_html__('License no longer exists', 'slmplus')
|
||||
esc_html__('License no longer exists', 'slm-plus')
|
||||
);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo esc_html__('License Key:', 'slmplus'); ?></th>
|
||||
<td><?php echo $cur_link; ?></td>
|
||||
<th><?php echo esc_html__('License Key:', 'slm-plus'); ?></th>
|
||||
<td><?php echo esc_url($cur_link); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wc_slm_on_complete_purchase($order_id) {
|
||||
function wc_slm_on_complete_purchase($order_id)
|
||||
{
|
||||
// Write to the log that the function is being called, useful for debugging.
|
||||
SLM_Helper_Class::write_log('Loading wc_slm_on_complete_purchase for Order ID: ' . intval($order_id));
|
||||
//SLM_Helper_Class::write_log('Loading wc_slm_on_complete_purchase for Order ID: ' . intval($order_id));
|
||||
|
||||
// Check if the essential constants are defined before proceeding.
|
||||
if (defined('SLM_SITE_HOME_URL') && defined('WOO_SLM_API_SECRET') && SLM_SITE_HOME_URL !== '' && WOO_SLM_API_SECRET !== '') {
|
||||
// Sanitize the order ID and create license keys.
|
||||
SLM_Helper_Class::write_log('startign to create lic for order: ' . intval($order_id));
|
||||
//SLM_Helper_Class::write_log('startign to create lic for order: ' . intval($order_id));
|
||||
|
||||
wc_slm_create_license_keys(absint($order_id));
|
||||
}
|
||||
else {
|
||||
SLM_Helper_Class::write_log('Error, not constants for Order ID: ' . intval($order_id));
|
||||
|
||||
} else {
|
||||
//SLM_Helper_Class::write_log('Error, not constants for Order ID: ' . intval($order_id));
|
||||
}
|
||||
}
|
||||
|
||||
function wc_slm_create_license_keys($order_id)
|
||||
{
|
||||
// Write initial log for debugging purposes
|
||||
SLM_Helper_Class::write_log('inside wc_slm_create_license_keys for Order ID: ' . intval($order_id));
|
||||
//SLM_Helper_Class::write_log('inside wc_slm_create_license_keys for Order ID: ' . intval($order_id));
|
||||
|
||||
// Get the order and relevant user details
|
||||
$order = wc_get_order($order_id);
|
||||
if (!$order) {
|
||||
SLM_Helper_Class::write_log('Order ID ' . $order_id . ' not found.');
|
||||
//SLM_Helper_Class::write_log('Order ID ' . $order_id . ' not found.');
|
||||
return; // Stop if the order does not exist
|
||||
}
|
||||
|
||||
$purchase_id_ = $order->get_id();
|
||||
SLM_Helper_Class::write_log('Purchase ID: ' . $purchase_id_);
|
||||
//SLM_Helper_Class::write_log('Purchase ID: ' . $purchase_id_);
|
||||
|
||||
global $user_id;
|
||||
$user_id = $order->get_user_id();
|
||||
SLM_Helper_Class::write_log('User ID: ' . $user_id);
|
||||
//SLM_Helper_Class::write_log('User ID: ' . $user_id);
|
||||
|
||||
if (!$user_id) {
|
||||
SLM_Helper_Class::write_log('User ID not found for Order ID: ' . $order_id);
|
||||
//SLM_Helper_Class::write_log('User ID not found for Order ID: ' . $order_id);
|
||||
return; // Stop if user ID cannot be found
|
||||
}
|
||||
|
||||
|
@ -183,17 +161,10 @@ function wc_slm_create_license_keys($order_id)
|
|||
}
|
||||
|
||||
// Log renewal details
|
||||
SLM_Helper_Class::write_log('Renewal Period: ' . $renewal_period);
|
||||
SLM_Helper_Class::write_log('Expiration Date: ' . $expiration);
|
||||
SLM_Helper_Class::write_log('Renewal Term: ' . $renewal_term);
|
||||
//SLM_Helper_Class::write_log('Renewal Period: ' . $renewal_period);
|
||||
//SLM_Helper_Class::write_log('Expiration Date: ' . $expiration);
|
||||
//SLM_Helper_Class::write_log('Renewal Term: ' . $renewal_term);
|
||||
|
||||
// Get allowed sites/devices and verify them
|
||||
$sites_allowed = wc_slm_get_sites_allowed($product_id);
|
||||
if (!$sites_allowed) {
|
||||
wc_insert_payment_note($purchase_id_, __('License could not be created: Invalid sites allowed number.', 'slmplus'));
|
||||
SLM_Helper_Class::write_log('License could not be created: Invalid sites allowed number');
|
||||
break;
|
||||
}
|
||||
|
||||
// Collect product details
|
||||
$item_data = $values->get_data();
|
||||
|
@ -204,6 +175,7 @@ function wc_slm_create_license_keys($order_id)
|
|||
$license_type = get_post_meta($product_id, '_license_type', true);
|
||||
$lic_item_ref = get_post_meta($product_id, '_license_item_reference', true);
|
||||
$transaction_id = wc_get_payment_transaction_id($order_id);
|
||||
$sites_allowed = wc_slm_get_sites_allowed($product_id);
|
||||
|
||||
// Prepare API parameters for license creation
|
||||
$api_params = array(
|
||||
|
@ -232,7 +204,7 @@ function wc_slm_create_license_keys($order_id)
|
|||
// Send the request to create a license key
|
||||
$url = esc_url_raw(SLM_SITE_HOME_URL) . '?' . http_build_query($api_params);
|
||||
|
||||
SLM_Helper_Class::write_log('URL: ' . $url);
|
||||
//SLM_Helper_Class::write_log('URL: ' . $url);
|
||||
|
||||
$response = wp_safe_remote_get($url, array('timeout' => 20, 'sslverify' => false));
|
||||
$license_key = wc_slm_get_license_key($response);
|
||||
|
@ -251,28 +223,35 @@ function wc_slm_create_license_keys($order_id)
|
|||
'version' => $_license_current_version,
|
||||
'until' => $_license_until_version
|
||||
);
|
||||
|
||||
$item_id = $values->get_id();
|
||||
// Store license details for the product in the order item meta
|
||||
wc_add_order_item_meta($item_id, '_slm_lic_key', sanitize_text_field($license_key));
|
||||
wc_add_order_item_meta($item_id, '_slm_lic_type', sanitize_text_field($license_type));
|
||||
wc_add_order_item_meta($item_id, 'Current Version: ', sanitize_text_field($_license_current_version));
|
||||
wc_add_order_item_meta($item_id, 'Until Version:', sanitize_text_field($_license_until_version));
|
||||
wc_add_order_item_meta($item_id, 'Max Devices', sanitize_text_field($amount_of_licenses_devices));
|
||||
wc_add_order_item_meta($item_id, 'Max Domains', sanitize_text_field($sites_allowed));
|
||||
|
||||
// Update order meta with license details
|
||||
$order = wc_get_order($order_id);
|
||||
if ($order) {
|
||||
$order->update_meta_data('License Key', sanitize_text_field($license_key));
|
||||
$order->update_meta_data('License Type', sanitize_text_field($license_type)); // Save the license type
|
||||
$order->save(); // Save changes to the order
|
||||
}
|
||||
|
||||
// Update order item meta with license details
|
||||
$order_item = new WC_Order_Item_Product($item_id);
|
||||
if ($order_item) {
|
||||
$order_item->update_meta_data('License Key', sanitize_text_field($license_key));
|
||||
$order_item->update_meta_data('License Type', sanitize_text_field($license_type));
|
||||
$order_item->update_meta_data('Current Ver.', sanitize_text_field($_license_current_version));
|
||||
$order_item->update_meta_data('Until Ver.', sanitize_text_field($_license_until_version));
|
||||
$order_item->update_meta_data('Max Devices', sanitize_text_field($amount_of_licenses_devices));
|
||||
$order_item->update_meta_data('Max Domains', sanitize_text_field($sites_allowed));
|
||||
$order_item->save(); // Save changes to the order item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If licenses were successfully generated, add a payment note
|
||||
if (count($licenses) > 0) {
|
||||
wc_slm_payment_note($order_id, $licenses);
|
||||
//slm_add_lic_key_meta_update($order_id, $licenses);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function wc_slm_get_license_key($response)
|
||||
function wc_slm_get_license_key($response)
|
||||
{
|
||||
// Check for error in the response
|
||||
if (is_wp_error($response)) {
|
||||
|
@ -291,7 +270,7 @@ function wc_slm_get_license_key($response)
|
|||
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
// Handle JSON decoding error appropriately, e.g., log the error
|
||||
error_log('Failed to decode JSON response: ' . json_last_error_msg());
|
||||
//SLM_Helper_Class::write_log('Failed to decode JSON response: ' . json_last_error_msg());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -300,7 +279,7 @@ function wc_slm_get_license_key($response)
|
|||
|
||||
if ($cleaned_data === false) {
|
||||
// If the cleaning fails, return false
|
||||
error_log('Failed to clean the JSON response body.');
|
||||
//SLM_Helper_Class::write_log('Failed to clean the JSON response body.');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -315,8 +294,7 @@ function wc_slm_get_license_key($response)
|
|||
return $license_data->key;
|
||||
}
|
||||
|
||||
|
||||
function wc_slm_get_license_id($license)
|
||||
function wc_slm_get_license_id($license)
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
|
@ -334,53 +312,6 @@ function wc_slm_get_license_id($license)
|
|||
return $license_id ? intval($license_id) : false;
|
||||
}
|
||||
|
||||
function wc_slm_payment_note($order_id, $licenses)
|
||||
{
|
||||
// Get the order object
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
// Check if the order is valid and licenses are provided
|
||||
if ($order && !empty($licenses) && is_array($licenses)) {
|
||||
$message = __('License Key(s) generated:', 'slmplus');
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
// Check if required license information is available
|
||||
if (!isset($license['key']) || !isset($license['item'])) {
|
||||
continue; // Skip if data is incomplete
|
||||
}
|
||||
|
||||
$license_key = sanitize_text_field($license['key']);
|
||||
$item_name = sanitize_text_field($license['item']);
|
||||
|
||||
// Fetch the license ID securely
|
||||
$license_id = wc_slm_get_license_id($license_key);
|
||||
|
||||
// Construct the link to the license edit page
|
||||
$license_link = esc_url(
|
||||
add_query_arg(
|
||||
array(
|
||||
'page' => 'slm_manage_license',
|
||||
'edit_record' => $license_id,
|
||||
),
|
||||
admin_url('admin.php')
|
||||
)
|
||||
);
|
||||
|
||||
// Add to the message
|
||||
$message .= '<br />' . esc_html($item_name) . ': <a href="' . $license_link . '">' . esc_html($license_key) . '</a>';
|
||||
}
|
||||
} else {
|
||||
$message = __('License Key(s) could not be created.', 'slmplus');
|
||||
}
|
||||
|
||||
// Add the message as an order note using the correct method
|
||||
if ($order) {
|
||||
$order->add_order_note( wp_kses_post($message) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function wc_slm_access_expiration($order_id, $lic_expiry = '')
|
||||
{
|
||||
global $wpdb;
|
||||
|
@ -432,7 +363,7 @@ function wc_slm_access_expiration($order_id, $lic_expiry = '')
|
|||
}
|
||||
|
||||
// Optionally, log the query for debugging (commented out by default)
|
||||
//SLM_Helper_Class::write_log('log:' . $query);
|
||||
////SLM_Helper_Class::write_log('log:' . $query);
|
||||
}
|
||||
|
||||
|
||||
|
@ -464,20 +395,6 @@ function get_licence_by_key($licence_key)
|
|||
return $record ? $record : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign Licenses to Order
|
||||
*
|
||||
* @param int $order_id WooCommerce Order ID to assign licenses to.
|
||||
* @param array $licenses An array of licenses to be assigned.
|
||||
* @return void
|
||||
*/
|
||||
function wc_slm_assign_licenses($order_id, $licenses)
|
||||
{
|
||||
// Check if licenses are available and valid
|
||||
if (!empty($licenses) && is_array($licenses)) {
|
||||
add_post_meta($order_id, '_wc_slm_payment_licenses', $licenses);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Allowed Number of Sites for a Product
|
||||
|
@ -494,17 +411,6 @@ function wc_slm_get_sites_allowed($product_id)
|
|||
return !empty($wc_slm_sites_allowed) ? $wc_slm_sites_allowed : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get License Type
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return string|false License type or false if not found.
|
||||
*/
|
||||
function wc_slm_get_lic_type($product_id)
|
||||
{
|
||||
$_license_type = get_post_meta($product_id, '_license_type', true);
|
||||
return !empty($_license_type) ? sanitize_text_field($_license_type) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Number of Allowed Devices
|
||||
|
@ -518,17 +424,6 @@ function wc_slm_get_devices_allowed($product_id)
|
|||
return !empty($_devices_licenses) ? $_devices_licenses : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Quantity of Licenses
|
||||
*
|
||||
* @param int $product_id Product ID.
|
||||
* @return int|false Quantity of licenses or false if not set.
|
||||
*/
|
||||
function wc_slm_get_licenses_qty($product_id)
|
||||
{
|
||||
$amount_of_licenses = absint(get_post_meta($product_id, '_amount_of_licenses', true));
|
||||
return !empty($amount_of_licenses) ? $amount_of_licenses : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Licensing Renewal Period
|
||||
|
@ -554,35 +449,6 @@ function wc_slm_get_licensing_renewal_period_term($product_id)
|
|||
return !empty($term) ? sanitize_text_field($term) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Licensing is Enabled
|
||||
*
|
||||
* @param int $download_id Downloadable product ID.
|
||||
* @return bool True if licensing is enabled, false otherwise.
|
||||
*/
|
||||
function wc_slm_is_licensing_enabled($download_id)
|
||||
{
|
||||
$licensing_enabled = absint(get_post_meta($download_id, '_wc_slm_licensing_enabled', true));
|
||||
return $licensing_enabled === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a Payment Note to Order
|
||||
*
|
||||
* @param int $order_id WooCommerce Order ID.
|
||||
* @param string $msg Note to be added to the order.
|
||||
* @return void
|
||||
*/
|
||||
function wc_insert_payment_note($order_id, $msg)
|
||||
{
|
||||
if (!empty($order_id) && !empty($msg)) {
|
||||
$order = wc_get_order($order_id);
|
||||
if ($order) {
|
||||
$order->add_order_note(esc_html($msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Payment Transaction ID
|
||||
*
|
||||
|
@ -624,7 +490,8 @@ function slm_order_completed($order_id)
|
|||
// Create the note text
|
||||
if (!empty($order_billing_email)) {
|
||||
$note = sprintf(
|
||||
__("Order confirmation email sent to: <a href='mailto:%s'>%s</a>", 'slmplus'),
|
||||
// Translators: %1$s is the mailto link, %2$s is the plain email address
|
||||
__("Order confirmation email sent to: <a href='mailto:%1\$s'>%2\$s</a>", 'slm-plus'),
|
||||
esc_attr($order_billing_email),
|
||||
esc_html($order_billing_email)
|
||||
);
|
||||
|
@ -653,8 +520,8 @@ function slm_order_details($order)
|
|||
// Check if product is of type 'slm_license'
|
||||
if ($product->is_type('slm_license')) {
|
||||
// Retrieve license keys and types from the order item meta
|
||||
$lic_keys = wc_get_order_item_meta($item_details->get_id(), '_slm_lic_key', false);
|
||||
$lic_types = wc_get_order_item_meta($item_details->get_id(), '_slm_lic_type', false);
|
||||
$lic_keys = wc_get_order_item_meta($item_details->get_id(), 'License Key', false);
|
||||
$lic_types = wc_get_order_item_meta($item_details->get_id(), 'License Type', false);
|
||||
|
||||
if ($lic_keys && $lic_types) {
|
||||
$licenses_data = array_map(function ($keys, $types) {
|
||||
|
@ -672,12 +539,12 @@ function slm_order_details($order)
|
|||
// Display license details if available
|
||||
if (!empty($licences)) {
|
||||
echo '
|
||||
<h2 class="woocommerce-order-details__title">' . esc_html__('License Details', 'slmplus') . '</h2>
|
||||
<h2 class="woocommerce-order-details__title">' . esc_html__('License Details', 'slm-plus') . '</h2>
|
||||
<table class="woocommerce-table woocommerce-table--order-details shop_table order_details">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="woocommerce-table__product-name product-name">' . esc_html__('License Key', 'slmplus') . '</th>
|
||||
<th class="woocommerce-table__product-table product-total">' . esc_html__('Type', 'slmplus') . '</th>
|
||||
<th class="woocommerce-table__product-name product-name">' . esc_html__('License Key', 'slm-plus') . '</th>
|
||||
<th class="woocommerce-table__product-table product-total">' . esc_html__('Type', 'slm-plus') . '</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -687,7 +554,7 @@ function slm_order_details($order)
|
|||
<tr class="woocommerce-table__line-item order_item">
|
||||
<td class="woocommerce-table__product-name product-name">
|
||||
' . esc_html($lic_row['lic_key']) . ' -
|
||||
<a href="' . esc_url(get_permalink(wc_get_page_id('myaccount'))) . 'my-licenses">' . esc_html__('View My Licenses', 'slmplus') . '</a>
|
||||
<a href="' . esc_url(get_permalink(wc_get_page_id('myaccount'))) . 'my-licenses">' . esc_html__('View My Licenses', 'slm-plus') . '</a>
|
||||
</td>
|
||||
<td class="woocommerce-table__product-total product-total">
|
||||
' . esc_html($lic_row['lic_type']) . '
|
||||
|
@ -744,16 +611,16 @@ function slm_add_license_to_order_confirmation($order, $sent_to_admin, $plain_te
|
|||
|
||||
// If there are licenses, add them to the email
|
||||
if (!empty($licenses)) {
|
||||
?>
|
||||
<h2><?php echo esc_html__('License Keys', 'slmplus'); ?></h2>
|
||||
<table class="td" cellspacing="0" cellpadding="6" border="1" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; margin-bottom: 40px;">
|
||||
?>
|
||||
<h2><?php echo esc_html__('License Keys', 'slm-plus'); ?></h2>
|
||||
<table class="td cart_slm slm_licenses_table" cellspacing="0" cellpadding="6" border="1" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; margin-bottom: 40px;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="td" colspan="2" scope="col" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;">
|
||||
<?php echo esc_html__('Product', 'slmplus'); ?>
|
||||
<?php echo esc_html__('Product', 'slm-plus'); ?>
|
||||
</th>
|
||||
<th class="td" scope="col" style="color: #636363; border: 1px solid #e5e5e5; vertical-align: middle; padding: 12px; text-align: left;">
|
||||
<?php echo esc_html__('License Key', 'slmplus'); ?>
|
||||
<?php echo esc_html__('License Key', 'slm-plus'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -771,6 +638,6 @@ function slm_add_license_to_order_confirmation($order, $sent_to_admin, $plain_te
|
|||
</tbody>
|
||||
</table>
|
||||
<br><br>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,31 +4,38 @@ if (!defined('WPINC')) {
|
|||
die();
|
||||
}
|
||||
|
||||
function slm_register_product_type() {
|
||||
if ( class_exists( 'WC_Product' ) && ! class_exists( 'WC_Product_SLM_License' ) ) {
|
||||
function slm_register_product_type()
|
||||
{
|
||||
if (class_exists('WC_Product') && ! class_exists('WC_Product_SLM_License')) {
|
||||
// WooCommerce 3.0 and above use WC_Product_Simple as the base class
|
||||
if ( version_compare( WC()->version, '3.0.0', '>=' ) ) {
|
||||
class WC_Product_SLM_License extends WC_Product_Simple {
|
||||
if (version_compare(WC()->version, '3.0.0', '>=')) {
|
||||
class WC_Product_SLM_License extends WC_Product_Simple
|
||||
{
|
||||
protected $product_type = 'slm_license';
|
||||
|
||||
public function __construct( $product = 0 ) {
|
||||
parent::__construct( $product );
|
||||
public function __construct($product = 0)
|
||||
{
|
||||
parent::__construct($product);
|
||||
}
|
||||
|
||||
public function get_type() {
|
||||
public function get_type()
|
||||
{
|
||||
return 'slm_license';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Older versions use WC_Product as the base class
|
||||
class WC_Product_SLM_License extends WC_Product {
|
||||
class WC_Product_SLM_License extends WC_Product
|
||||
{
|
||||
protected $product_type = 'slm_license';
|
||||
|
||||
public function __construct( $product = 0 ) {
|
||||
parent::__construct( $product );
|
||||
public function __construct($product = 0)
|
||||
{
|
||||
parent::__construct($product);
|
||||
}
|
||||
|
||||
public function get_type() {
|
||||
public function get_type()
|
||||
{
|
||||
return 'slm_license';
|
||||
}
|
||||
}
|
||||
|
@ -38,8 +45,9 @@ function slm_register_product_type() {
|
|||
add_action('init', 'slm_register_product_type');
|
||||
|
||||
|
||||
function slm_register_product_class($classname, $product_type) {
|
||||
if ($product_type == 'slm_license') {
|
||||
function slm_register_product_class($classname, $product_type)
|
||||
{
|
||||
if ($product_type == 'slm_license') {
|
||||
$classname = 'WC_Product_SLM_License';
|
||||
}
|
||||
return $classname;
|
||||
|
@ -47,11 +55,11 @@ function slm_register_product_class($classname, $product_type) {
|
|||
add_filter('woocommerce_product_class', 'slm_register_product_class', 10, 2);
|
||||
|
||||
|
||||
function slm_add_product_type($types) {
|
||||
$types['slm_license'] = __('License product', 'slmplus');
|
||||
function slm_add_product_type($types)
|
||||
{
|
||||
$types['slm_license'] = __('License product', 'slm-plus');
|
||||
return $types;
|
||||
error_log("Saving product type for Product ID: " . $types);
|
||||
|
||||
}
|
||||
add_filter('product_type_selector', 'slm_add_product_type');
|
||||
|
||||
|
@ -59,15 +67,16 @@ add_filter('product_type_selector', 'slm_add_product_type');
|
|||
/**
|
||||
* Add 'License Manager' product option.
|
||||
*/
|
||||
function add_wc_slm_data_tab_enabled_product_option($product_type_options) {
|
||||
function add_wc_slm_data_tab_enabled_product_option($product_type_options)
|
||||
{
|
||||
// Check if the current product type is the custom license product type
|
||||
if (isset($_GET['product_type']) && $_GET['product_type'] === 'slm_license') {
|
||||
$product_type_options['wc_slm_data_tab_enabled'] = array(
|
||||
'id' => '_wc_slm_data_tab_enabled',
|
||||
'wrapper_class' => 'show_if_slm_license',
|
||||
'label' => __('License Manager', 'slmplus'),
|
||||
'label' => __('License Manager', 'slm-plus'),
|
||||
'default' => 'no',
|
||||
'description' => __('Enables the license creation API.', 'slmplus'),
|
||||
'description' => __('Enables the license creation API.', 'slm-plus'),
|
||||
'type' => 'checkbox'
|
||||
);
|
||||
}
|
||||
|
@ -79,8 +88,9 @@ add_filter('product_type_options', 'add_wc_slm_data_tab_enabled_product_option',
|
|||
/**
|
||||
* CSS To Add Custom tab Icon
|
||||
*/
|
||||
function wcpp_custom_style() {
|
||||
?>
|
||||
function wcpp_custom_style()
|
||||
{
|
||||
?>
|
||||
<style>
|
||||
#woocommerce-product-data ul.wc-tabs li.wc_slm_data_tab_options a:before {
|
||||
font-family: Dashicons;
|
||||
|
@ -108,16 +118,17 @@ function wcpp_custom_style() {
|
|||
}).trigger('change'); // Trigger change to apply initial setting on load
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
add_action('admin_head', 'wcpp_custom_style');
|
||||
|
||||
/**
|
||||
* Add Custom WooCommerce Product Data Tab
|
||||
*/
|
||||
function wc_slm_add_tab($wc_slm_data_tabs) {
|
||||
function wc_slm_add_tab($wc_slm_data_tabs)
|
||||
{
|
||||
$wc_slm_data_tabs['wc_slm_data_tab'] = array(
|
||||
'label' => __('License Info', 'slmplus'),
|
||||
'label' => __('License Info', 'slm-plus'),
|
||||
'target' => 'wc_slm_meta',
|
||||
'class' => array('show_if_slm_license', 'show_if_wc_slm_data_tab_enabled'),
|
||||
);
|
||||
|
@ -128,11 +139,12 @@ add_filter('woocommerce_product_data_tabs', 'wc_slm_add_tab');
|
|||
/**
|
||||
* Custom WooCommerce Data Panel
|
||||
*/
|
||||
function wc_slm_data_panel() {
|
||||
function wc_slm_data_panel()
|
||||
{
|
||||
global $post;
|
||||
$product_id = get_the_ID();
|
||||
$slm_options = get_option('slm_plugin_options');
|
||||
?>
|
||||
?>
|
||||
<div id='wc_slm_meta' class='panel woocommerce_options_panel'>
|
||||
<div class='options_group'>
|
||||
<?php
|
||||
|
@ -143,13 +155,13 @@ function wc_slm_data_panel() {
|
|||
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_domain_licenses',
|
||||
'label' => __('Domain Licenses', 'slmplus'),
|
||||
'label' => __('Domain Licenses', 'slm-plus'),
|
||||
'placeholder' => SLM_Helper_Class::slm_get_option('default_max_domains'),
|
||||
'desc_tip' => 'true',
|
||||
'value' => $value,
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array('step' => 'any', 'min' => 0),
|
||||
'description' => __('Enter the allowed number of domains this license can have (websites).', 'slmplus')
|
||||
'description' => __('Enter the allowed number of domains this license can have (websites).', 'slm-plus')
|
||||
));
|
||||
|
||||
// Device Licenses Input
|
||||
|
@ -158,60 +170,60 @@ function wc_slm_data_panel() {
|
|||
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_devices_licenses',
|
||||
'label' => __('Devices Licenses', 'slmplus'),
|
||||
'label' => __('Devices Licenses', 'slm-plus'),
|
||||
'placeholder' => SLM_Helper_Class::slm_get_option('default_max_devices'),
|
||||
'desc_tip' => 'true',
|
||||
'value' => $value,
|
||||
'type' => 'number',
|
||||
'custom_attributes' => array('step' => 'any', 'min' => 0),
|
||||
'description' => __('Enter the allowed number of devices this license can have (computers, mobile, etc).', 'slmplus')
|
||||
'description' => __('Enter the allowed number of devices this license can have (computers, mobile, etc).', 'slm-plus')
|
||||
));
|
||||
|
||||
// Item Reference Field (if enabled)
|
||||
if (!empty($slm_options['slm_multiple_items']) && $slm_options['slm_multiple_items'] == 1) {
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_license_item_reference',
|
||||
'label' => __('Item Reference', 'slmplus'),
|
||||
'placeholder' => __("Software's item reference"),
|
||||
'label' => __('Item Reference', 'slm-plus'),
|
||||
'placeholder' => __("Software's item reference", 'slm-plus'),
|
||||
'desc_tip' => 'true',
|
||||
'description' => __('Enter the item reference of your application, theme, or plug-in. The license will be then bound to this exact software.', 'slmplus')
|
||||
'description' => __('Enter the item reference of your application, theme, or plug-in. The license will be then bound to this exact software.', 'slm-plus')
|
||||
));
|
||||
}
|
||||
|
||||
// License Type Dropdown
|
||||
woocommerce_wp_select(array(
|
||||
'id' => '_license_type',
|
||||
'label' => __('License Type', 'slmplus'),
|
||||
'label' => __('License Type', 'slm-plus'),
|
||||
'desc_tip' => 'true',
|
||||
'description' => __('Type of license: subscription base or lifetime', 'slmplus'),
|
||||
'description' => __('Type of license: subscription base or lifetime', 'slm-plus'),
|
||||
'options' => array(
|
||||
'none' => __('Select one', 'slmplus'),
|
||||
'subscription' => __('Subscription', 'slmplus'),
|
||||
'lifetime' => __('Lifetime', 'slmplus'),
|
||||
'none' => __('Select one', 'slm-plus'),
|
||||
'subscription' => __('Subscription', 'slm-plus'),
|
||||
'lifetime' => __('Lifetime', 'slm-plus'),
|
||||
)
|
||||
));
|
||||
|
||||
// License Renewal Period Length
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_license_renewal_period_length',
|
||||
'label' => __('Renewal Period Length', 'slmplus'),
|
||||
'description' => __('XX Amount of days, months, or years.', 'slmplus'),
|
||||
'label' => __('Renewal Period Length', 'slm-plus'),
|
||||
'description' => __('XX Amount of days, months, or years.', 'slm-plus'),
|
||||
'type' => 'text',
|
||||
'value' => get_post_meta($product_id, '_license_renewal_period_length', true) ?: SLM_Helper_Class::slm_get_option('slm_billing_length'),
|
||||
));
|
||||
|
||||
|
||||
|
||||
// License Renewal Period Term Dropdown
|
||||
woocommerce_wp_select(array(
|
||||
'id' => '_license_renewal_period_term',
|
||||
'label' => __('Expiration Term', 'slmplus'),
|
||||
'label' => __('Expiration Term', 'slm-plus'),
|
||||
'placeholder' => 'select time frame',
|
||||
'description' => __('Choose between days, months, or years', 'slmplus'),
|
||||
'description' => __('Choose between days, months, or years', 'slm-plus'),
|
||||
'options' => array(
|
||||
'days' => __('Day(s)', 'slmplus'),
|
||||
'months' => __('Month(s)', 'slmplus'),
|
||||
'years' => __('Year(s)', 'slmplus'),
|
||||
'onetime' => __('One Time', 'slmplus'),
|
||||
'days' => __('Day(s)', 'slm-plus'),
|
||||
'months' => __('Month(s)', 'slm-plus'),
|
||||
'years' => __('Year(s)', 'slm-plus'),
|
||||
'onetime' => __('One Time', 'slm-plus'),
|
||||
),
|
||||
'value' => get_post_meta($product_id, '_license_renewal_period_term', true) ?: SLM_Helper_Class::slm_get_option('slm_billing_interval'), // Ensure default value is set to 'years' if empty
|
||||
));
|
||||
|
@ -221,31 +233,32 @@ function wc_slm_data_panel() {
|
|||
// Current Version Input
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_license_current_version',
|
||||
'label' => __('Current Version', 'slmplus'),
|
||||
'label' => __('Current Version', 'slm-plus'),
|
||||
'placeholder' => '0.0.0',
|
||||
'desc_tip' => 'true',
|
||||
'description' => __('Enter the current version of your application, theme, or plug-in', 'slmplus')
|
||||
'description' => __('Enter the current version of your application, theme, or plug-in', 'slm-plus')
|
||||
));
|
||||
|
||||
// Until Version Input
|
||||
woocommerce_wp_text_input(array(
|
||||
'id' => '_license_until_version',
|
||||
'label' => __('Until Version', 'slmplus'),
|
||||
'label' => __('Until Version', 'slm-plus'),
|
||||
'placeholder' => '0.0.0',
|
||||
'desc_tip' => 'true',
|
||||
'description' => __('Enter the version until support expires.', 'slmplus')
|
||||
'description' => __('Enter the version until support expires.', 'slm-plus')
|
||||
));
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
add_action('woocommerce_product_data_panels', 'wc_slm_data_panel');
|
||||
|
||||
|
||||
|
||||
/** Hook callback function to save custom fields information */
|
||||
function wc_slm_save_data($post_id) {
|
||||
function wc_slm_save_data($post_id)
|
||||
{
|
||||
// Sanitize and save domain licenses
|
||||
$_domain_licenses = isset($_POST['_domain_licenses']) ? intval($_POST['_domain_licenses']) : 0;
|
||||
update_post_meta($post_id, '_domain_licenses', $_domain_licenses);
|
||||
|
@ -267,10 +280,10 @@ function wc_slm_save_data($post_id) {
|
|||
update_post_meta($post_id, '_devices_licenses', $_devices_licenses);
|
||||
|
||||
// Handle license renewal period
|
||||
|
||||
|
||||
$_license_renewal_period_length = isset($_POST['_license_renewal_period_length']) ? sanitize_text_field($_POST['_license_renewal_period_length']) : '';
|
||||
update_post_meta($post_id, '_license_renewal_period_length', $_license_renewal_period_length);
|
||||
|
||||
|
||||
// Handle license renewal period term
|
||||
if (isset($_POST['_license_renewal_period_term'])) {
|
||||
$_license_renewal_period_term = sanitize_text_field($_POST['_license_renewal_period_term']);
|
||||
|
@ -290,7 +303,8 @@ function wc_slm_save_data($post_id) {
|
|||
}
|
||||
add_action('woocommerce_process_product_meta', 'wc_slm_save_data');
|
||||
|
||||
function slm_license_admin_custom_js() {
|
||||
function slm_license_admin_custom_js()
|
||||
{
|
||||
if ('product' !== get_post_type()) {
|
||||
return;
|
||||
}
|
||||
|
@ -298,31 +312,31 @@ function slm_license_admin_custom_js() {
|
|||
$slm_options = get_option('slm_plugin_options', array());
|
||||
$affect_downloads = isset($slm_options['slm_woo_affect_downloads']) && $slm_options['slm_woo_affect_downloads'] === '1';
|
||||
|
||||
?>
|
||||
?>
|
||||
<script type='text/javascript'>
|
||||
jQuery(document).ready(function($) {
|
||||
// Run toggleRenewalFields on page load
|
||||
toggleRenewalFields();
|
||||
|
||||
// Attach event listener to #_license_type to re-trigger toggle on change
|
||||
$("#_license_type").change(function() {
|
||||
toggleRenewalFields();
|
||||
});
|
||||
// Attach event listener to #_license_type to re-trigger toggle on change
|
||||
$("#_license_type").change(function() {
|
||||
toggleRenewalFields();
|
||||
});
|
||||
|
||||
function toggleRenewalFields() {
|
||||
var licType = $("#_license_type").val();
|
||||
if (licType === 'lifetime') {
|
||||
$('._license_renewal_period_length_field').hide(); // Corrected typo here too
|
||||
<?php if ($affect_downloads): ?>
|
||||
$('#_download_limit, #_download_expiry').val('').prop('disabled', true);
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
$('._license_renewal_period_length_field').show();
|
||||
<?php if ($affect_downloads): ?>
|
||||
$('#_download_limit, #_download_expiry').prop('disabled', false);
|
||||
<?php endif; ?>
|
||||
function toggleRenewalFields() {
|
||||
var licType = $("#_license_type").val();
|
||||
if (licType === 'lifetime') {
|
||||
$('._license_renewal_period_length_field').hide(); // Corrected typo here too
|
||||
<?php if ($affect_downloads): ?>
|
||||
$('#_download_limit, #_download_expiry').val('').prop('disabled', true);
|
||||
<?php endif; ?>
|
||||
} else {
|
||||
$('._license_renewal_period_length_field').show();
|
||||
<?php if ($affect_downloads): ?>
|
||||
$('#_download_limit, #_download_expiry').prop('disabled', false);
|
||||
<?php endif; ?>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle changes on download limit and expiry if downloads are affected
|
||||
<?php if ($affect_downloads): ?>
|
||||
|
@ -344,21 +358,22 @@ function slm_license_admin_custom_js() {
|
|||
$('.inventory_options').addClass('show_if_slm_license').show();
|
||||
$('#inventory_product_data ._manage_stock_field, #inventory_product_data ._sold_individually_field').closest('.options_group').addClass('show_if_slm_license').show();
|
||||
$('.shipping_options, .marketplace-suggestions_options').addClass('hide_if_slm_license').hide();
|
||||
|
||||
|
||||
// Trigger change event for wc_slm_data_tab_enabled to ensure fields are visible
|
||||
$('input#_wc_slm_data_tab_enabled').trigger('change');
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
add_action('admin_footer', 'slm_license_admin_custom_js');
|
||||
|
||||
|
||||
add_action('add_meta_boxes', 'add_slm_properties_meta_box');
|
||||
function add_slm_properties_meta_box() {
|
||||
function add_slm_properties_meta_box()
|
||||
{
|
||||
add_meta_box(
|
||||
'slm_properties_meta_box',
|
||||
__('SLM Properties', 'slmplus'),
|
||||
__('SLM Properties', 'slm-plus'),
|
||||
'display_slm_properties_meta_box',
|
||||
'shop_order',
|
||||
'side',
|
||||
|
@ -366,46 +381,87 @@ function add_slm_properties_meta_box() {
|
|||
);
|
||||
}
|
||||
|
||||
function display_slm_properties_meta_box($post) {
|
||||
$license_key = get_post_meta($post->ID, '_slm_lic_key', true);
|
||||
$license_type = get_post_meta($post->ID, '_slm_lic_type', true);
|
||||
|
||||
function display_slm_properties_meta_box($post)
|
||||
{
|
||||
$license_key = get_post_meta($post->ID, 'License Key', true);
|
||||
$license_type = get_post_meta($post->ID, 'License Type', true);
|
||||
$order = wc_get_order($post->ID);
|
||||
$order_status = $order->get_status();
|
||||
|
||||
// Check if the license key exists in the database
|
||||
if (empty($license_key)) {
|
||||
// Retrieve purchase_id and check if license key exists in the license table
|
||||
$purchase_id = get_post_meta($post->ID, 'purchase_id', true); // Fetch purchase_id meta
|
||||
|
||||
if (empty($purchase_id)) {
|
||||
// If no purchase_id is found, we attempt to retrieve it from the order if possible
|
||||
$purchase_id = $order->get_id(); // Use order ID if purchase_id isn't set
|
||||
}
|
||||
|
||||
if (!empty($purchase_id)) {
|
||||
global $wpdb;
|
||||
// Query the license table to find a matching license
|
||||
$license_data = $wpdb->get_row($wpdb->prepare(
|
||||
"SELECT license_key, lic_type FROM " . SLM_TBL_LICENSE_KEYS . " WHERE item_reference = %d",
|
||||
$purchase_id
|
||||
));
|
||||
|
||||
if ($license_data) {
|
||||
// Assign the license data to variables
|
||||
$license_key = $license_data->license_key;
|
||||
$license_type = $license_data->lic_type;
|
||||
|
||||
// Save the purchase_id, license_key, and license_type as metadata
|
||||
update_post_meta($post->ID, 'purchase_id', $purchase_id);
|
||||
update_post_meta($post->ID, 'License Key', $license_key);
|
||||
update_post_meta($post->ID, 'License Type', $license_type);
|
||||
|
||||
// Log success for debugging
|
||||
SLM_Helper_Class::write_log("Purchase ID $purchase_id found. License Key: $license_key, License Type: $license_type saved to order.");
|
||||
} else {
|
||||
// Log that no license was found for the given purchase_id
|
||||
SLM_Helper_Class::write_log("No license found for Purchase ID: $purchase_id.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Check if license can be created based on order status and license key existence
|
||||
$can_create_license = empty($license_key) && in_array($order_status, ['completed', 'processing']);
|
||||
|
||||
|
||||
// Display license information if a key exists
|
||||
if (!empty($license_key)) {
|
||||
echo '<p><strong>' . __('License Key:', 'slmplus') . '</strong> ' . esc_html($license_key) . '</p>';
|
||||
echo '<p><strong>' . __('License Type:', 'slmplus') . '</strong> ' . esc_html($license_type) . '</p>';
|
||||
echo '<p><em>' . __('A license key is already assigned to this order.', 'slmplus') . '</em></p>';
|
||||
echo '<p><strong>' . esc_html__('License Key:', 'slm-plus') . '</strong> ' . esc_html($license_key) . '</p>';
|
||||
echo '<p><strong>' . esc_html__('License Type:', 'slm-plus') . '</strong> ' . esc_html($license_type) . '</p>';
|
||||
echo '<p><em>' . esc_html__('A license key is already assigned to this order.', 'slm-plus') . '</em></p>';
|
||||
|
||||
$license_view_url = esc_url(admin_url('admin.php?page=slm_manage_license&edit_record=' . $license_key));
|
||||
echo '<a href="' . $license_view_url . '" class="button button-secondary" target="_blank">' . __('View License', 'slmplus') . '</a>';
|
||||
} else if ($can_create_license) {
|
||||
echo '<a href="' . esc_url($license_view_url) . '" class="button button-secondary" target="_blank">' . esc_html__('View License', 'slm-plus') . '</a>';
|
||||
} elseif ($can_create_license) {
|
||||
// Show the license creation option if no license exists and order is eligible
|
||||
echo '<label for="slm_lic_type">' . __('License Type:', 'slmplus') . '</label>';
|
||||
echo '<label for="slm_lic_type">' . esc_html__('License Type:', 'slm-plus') . '</label>';
|
||||
echo '<select id="slm_lic_type" name="slm_lic_type" class="postbox">
|
||||
<option value="subscription" ' . selected($license_type, 'subscription', false) . '>' . __('Subscription', 'slmplus') . '</option>
|
||||
<option value="lifetime" ' . selected($license_type, 'lifetime', false) . '>' . __('Lifetime', 'slmplus') . '</option>
|
||||
<option value="subscription" ' . selected($license_type, 'subscription', false) . '>' . esc_html__('Subscription', 'slm-plus') . '</option>
|
||||
<option value="lifetime" ' . selected($license_type, 'lifetime', false) . '>' . esc_html__('Lifetime', 'slm-plus') . '</option>
|
||||
</select><br><br>';
|
||||
|
||||
echo '<button type="button" class="button button-primary" id="create_license_button">' . __('Create License', 'slmplus') . '</button>';
|
||||
echo '<button type="button" class="button button-primary" id="create_license_button">' . esc_html__('Create License', 'slm-plus') . '</button>';
|
||||
} else {
|
||||
// Display informational message for new or ineligible orders
|
||||
echo '<p><em>' . __('Order must be completed or processing to create a license.', 'slmplus') . '</em></p>';
|
||||
echo '<button type="button" class="button button-primary" id="create_license_button" disabled>' . __('Create License', 'slmplus') . '</button>';
|
||||
echo '<p><em>' . esc_html__('Order must be completed or processing to create a license.', 'slm-plus') . '</em></p>';
|
||||
echo '<button type="button" class="button button-primary" id="create_license_button" disabled>' . esc_html__('Create License', 'slm-plus') . '</button>';
|
||||
}
|
||||
?>
|
||||
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
$('#create_license_button').on('click', function() {
|
||||
const licenseType = $('#slm_lic_type').val();
|
||||
const orderId = <?php echo esc_js($post->ID); ?>;
|
||||
const security = '<?php echo wp_create_nonce('slm_generate_license_nonce'); ?>';
|
||||
|
||||
const security = '<?php echo esc_js(wp_create_nonce('slm_generate_license_nonce')); ?>';
|
||||
|
||||
// Fetch user details from the server for validation
|
||||
$.post(ajaxurl, {
|
||||
action: 'check_order_user_info',
|
||||
|
@ -413,16 +469,19 @@ function display_slm_properties_meta_box($post) {
|
|||
security: security
|
||||
}, function(userInfoResponse) {
|
||||
if (userInfoResponse.success) {
|
||||
const { last_name, email } = userInfoResponse.data;
|
||||
const {
|
||||
last_name,
|
||||
email
|
||||
} = userInfoResponse.data;
|
||||
let proceed = true;
|
||||
|
||||
// Check for missing details
|
||||
if (!last_name || !email) {
|
||||
proceed = confirm('<?php echo esc_js(__('Warning: The order lacks user information like last name or email. Do you still wish to create the license?', 'slmplus')); ?>');
|
||||
proceed = confirm('<?php echo esc_js(__('Warning: The order lacks user information like last name or email. Do you still wish to create the license?', 'slm-plus')); ?>');
|
||||
}
|
||||
|
||||
if (proceed) {
|
||||
if (confirm('<?php echo esc_js(__('Are you sure you want to create a license for this order?', 'slmplus')); ?>')) {
|
||||
if (confirm('<?php echo esc_js(__('Are you sure you want to create a license for this order?', 'slm-plus')); ?>')) {
|
||||
$.post(ajaxurl, {
|
||||
action: 'slm_generate_license_for_order',
|
||||
order_id: orderId,
|
||||
|
@ -430,26 +489,27 @@ function display_slm_properties_meta_box($post) {
|
|||
security: security
|
||||
}, function(response) {
|
||||
if (response.success) {
|
||||
location.reload();
|
||||
location.reload();
|
||||
} else {
|
||||
alert('<?php echo esc_js(__('License creation failed. Please check the logs.', 'slmplus')); ?>');
|
||||
alert('<?php echo esc_js(__('License creation failed. Please check the logs.', 'slm-plus')); ?>');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
alert('<?php echo esc_js(__('Unable to verify order details. Please try again.', 'slmplus')); ?>');
|
||||
alert('<?php echo esc_js(__('Unable to verify order details. Please try again.', 'slm-plus')); ?>');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action('wp_ajax_slm_generate_license_for_order', 'slm_generate_license_for_order_callback');
|
||||
function slm_generate_license_for_order_callback() {
|
||||
function slm_generate_license_for_order_callback()
|
||||
{
|
||||
check_ajax_referer('slm_generate_license_nonce', 'security');
|
||||
|
||||
global $wpdb;
|
||||
|
@ -457,24 +517,28 @@ function slm_generate_license_for_order_callback() {
|
|||
$lic_type = isset($_POST['lic_type']) ? sanitize_text_field($_POST['lic_type']) : 'subscription';
|
||||
|
||||
if (!$order_id) {
|
||||
wp_send_json_error(['message' => __('Invalid order ID', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('Invalid order ID', 'slm-plus')]);
|
||||
}
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if (!$order || !in_array($order->get_status(), ['completed', 'processing'])) {
|
||||
wp_send_json_error(['message' => __('Order must be completed or processing to create a license', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('Order must be completed or processing to create a license', 'slm-plus')]);
|
||||
}
|
||||
|
||||
// Gather required order details
|
||||
$first_name = $order->get_billing_first_name();
|
||||
$last_name = $order->get_billing_last_name();
|
||||
$email = $order->get_billing_email();
|
||||
$purchase_id = $order->get_id();
|
||||
$purchase_id = $order;
|
||||
$txn_id = $order->get_transaction_id();
|
||||
$company_name = $order->get_billing_company();
|
||||
$date_created = $order->get_date_created()->date('Y-m-d');
|
||||
$user_id = $order->get_user_id();
|
||||
$product_ref = $order->get_items() ? $order->get_items()[0]->get_name() : ''; // Using the first item name for simplicity
|
||||
// Get the first item from the order (if available)
|
||||
$order_items = $order->get_items();
|
||||
$product_ref = !empty($order_items) ? reset($order_items)->get_name() : ''; // Using the first item name for simplicity
|
||||
|
||||
|
||||
$slm_billing_length = SLM_API_Utility::get_slm_option('slm_billing_length');
|
||||
$slm_billing_interval = SLM_API_Utility::get_slm_option('slm_billing_interval');
|
||||
|
@ -490,7 +554,7 @@ function slm_generate_license_for_order_callback() {
|
|||
'first_name' => $first_name,
|
||||
'last_name' => $last_name,
|
||||
'email' => $email,
|
||||
'purchase_id_' => $purchase_id,
|
||||
'purchase_id' => $purchase_id,
|
||||
'txn_id' => $txn_id,
|
||||
'company_name' => $company_name,
|
||||
'max_allowed_domains' => SLM_DEFAULT_MAX_DOMAINS,
|
||||
|
@ -515,34 +579,76 @@ function slm_generate_license_for_order_callback() {
|
|||
]);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
wp_send_json_error(['message' => __('API request failed', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('API request failed', 'slm-plus')]);
|
||||
}
|
||||
|
||||
$body = wp_remote_retrieve_body($response);
|
||||
$api_response = json_decode($body, true);
|
||||
|
||||
if ($api_response && isset($api_response['result']) && $api_response['result'] === 'success') {
|
||||
$license_key = sanitize_text_field($api_response['key']);
|
||||
update_post_meta($order_id, '_slm_lic_key', $license_key);
|
||||
update_post_meta($order_id, '_slm_lic_type', $lic_type); // Save the license type
|
||||
|
||||
$license_key = sanitize_text_field($api_response['key']);
|
||||
$_license_current_version = SLM_API_Utility::get_slm_option('license_current_version');
|
||||
$_license_until_version = SLM_API_Utility::get_slm_option('license_until_version');
|
||||
$amount_of_licenses_devices = SLM_DEFAULT_MAX_DEVICES;
|
||||
$sites_allowed = SLM_DEFAULT_MAX_DOMAINS;
|
||||
|
||||
// Add an order note
|
||||
$order->add_order_note(
|
||||
sprintf(__('License Key generated: %s', 'slmplus'), $license_key)
|
||||
// Translators: %s is the license key generated for the order
|
||||
sprintf(__('License Key generated: %s', 'slm-plus'), $license_key)
|
||||
);
|
||||
|
||||
wp_send_json_success(['message' => __('License created successfully', 'slmplus')]);
|
||||
// Update order item meta with the license key for each item in the order
|
||||
foreach ($order->get_items() as $item_id => $item) {
|
||||
// Sanitize the license key and license type
|
||||
$license_key = sanitize_text_field($license_key);
|
||||
$_license_current_version = sanitize_text_field($_license_current_version);
|
||||
$_license_until_version = sanitize_text_field($_license_until_version);
|
||||
$amount_of_licenses_devices = sanitize_text_field($amount_of_licenses_devices);
|
||||
$sites_allowed = sanitize_text_field($sites_allowed);
|
||||
|
||||
// Ensure the item is a valid order item
|
||||
if ($item instanceof WC_Order_Item) {
|
||||
// Set the license key and license type metadata for the item
|
||||
wc_add_order_item_meta($item, 'License Key', $license_key, true);
|
||||
wc_add_order_item_meta($item, 'License Type', 'subscription', true);
|
||||
|
||||
$item->update_meta_data('License Key', sanitize_text_field($license_key));
|
||||
$item->update_meta_data('License Type', 'subscription');
|
||||
$item->update_meta_data('Current Ver.', sanitize_text_field($_license_current_version));
|
||||
$item->update_meta_data('Until Ver.', sanitize_text_field($_license_until_version));
|
||||
$item->update_meta_data('Max Devices', sanitize_text_field($amount_of_licenses_devices));
|
||||
$item->update_meta_data('Max Domains', sanitize_text_field($sites_allowed));
|
||||
|
||||
// Save the item metadata
|
||||
$item->save(); // Save the item to persist the metadata
|
||||
}
|
||||
}
|
||||
|
||||
// Save the order after updating the items
|
||||
$order->save(); // This saves the order and ensures the changes are committed
|
||||
|
||||
|
||||
// Optionally, log the order save for debugging
|
||||
SLM_Helper_Class::write_log("Order $order_id saved with updated license information.");
|
||||
|
||||
|
||||
// Send success response
|
||||
wp_send_json_success(['message' => __('License created successfully', 'slm-plus')]);
|
||||
} else {
|
||||
wp_send_json_error(['message' => __('License creation failed', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('License creation failed', 'slm-plus')]);
|
||||
}
|
||||
}
|
||||
|
||||
add_action('wp_ajax_check_order_user_info', 'check_order_user_info_callback');
|
||||
function check_order_user_info_callback() {
|
||||
function check_order_user_info_callback()
|
||||
{
|
||||
check_ajax_referer('slm_generate_license_nonce', 'security');
|
||||
|
||||
$order_id = isset($_POST['order_id']) ? absint($_POST['order_id']) : null;
|
||||
if (!$order_id) {
|
||||
wp_send_json_error(['message' => __('Invalid order ID', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('Invalid order ID', 'slm-plus')]);
|
||||
}
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
@ -551,6 +657,6 @@ function check_order_user_info_callback() {
|
|||
$email = $order->get_billing_email();
|
||||
wp_send_json_success(['last_name' => $last_name, 'email' => $email]);
|
||||
} else {
|
||||
wp_send_json_error(['message' => __('Order not found', 'slmplus')]);
|
||||
wp_send_json_error(['message' => __('Order not found', 'slm-plus')]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
/**
|
||||
* Simple product add to cart
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce\Templates
|
||||
* @version 7.0.1
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
global $product;
|
||||
|
||||
if ( ! $product->is_purchasable() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo wc_get_stock_html( $product ); // WPCS: XSS ok.
|
||||
|
||||
if ( $product->is_in_stock() ) : ?>
|
||||
|
||||
<?php do_action( 'woocommerce_before_add_to_cart_form' ); ?>
|
||||
|
||||
<form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
|
||||
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
|
||||
|
||||
<?php
|
||||
do_action( 'woocommerce_before_add_to_cart_quantity' );
|
||||
|
||||
woocommerce_quantity_input(
|
||||
array(
|
||||
'min_value' => apply_filters( 'woocommerce_quantity_input_min', $product->get_min_purchase_quantity(), $product ),
|
||||
'max_value' => apply_filters( 'woocommerce_quantity_input_max', $product->get_max_purchase_quantity(), $product ),
|
||||
'input_value' => isset( $_POST['quantity'] ) ? wc_stock_amount( wp_unslash( $_POST['quantity'] ) ) : $product->get_min_purchase_quantity(), // WPCS: CSRF ok, input var ok.
|
||||
)
|
||||
);
|
||||
|
||||
do_action( 'woocommerce_after_add_to_cart_quantity' );
|
||||
?>
|
||||
|
||||
<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt<?php echo esc_attr( wc_wp_theme_get_element_class_name( 'button' ) ? ' ' . wc_wp_theme_get_element_class_name( 'button' ) : '' ); ?>"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
|
||||
</form>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
|
||||
|
||||
<?php endif; ?>
|
|
@ -56,7 +56,7 @@ function slm_add_my_licenses_endpoint($items) {
|
|||
unset($items['customer-logout']); // Remove "Log out" temporarily
|
||||
|
||||
// Add "My Licenses" to the array
|
||||
$items['my-licenses'] = __('My Licenses', 'slmplus');
|
||||
$items['my-licenses'] = __('My Licenses', 'slm-plus');
|
||||
|
||||
// Re-add "Log out" to the end
|
||||
$items['customer-logout'] = $logout;
|
||||
|
@ -81,7 +81,7 @@ add_action('woocommerce_account_my-licenses_endpoint', function($value) {
|
|||
slm_license_view($license_id);
|
||||
}
|
||||
else {
|
||||
echo '<p>' . __('Invalid license or access denied.', 'slmplus') . '</p>';
|
||||
echo '<p>' . esc_html__('Invalid license or access denied.', 'slm-plus') . '</p>';
|
||||
//SLM_Helper_Class::write_log('user id ' . get_current_user_id());
|
||||
}
|
||||
} else {
|
||||
|
@ -97,55 +97,69 @@ function slm_display_license_table() {
|
|||
|
||||
$user_id = get_current_user_id();
|
||||
$user_email = wp_get_current_user()->user_email;
|
||||
|
||||
|
||||
global $wpdb;
|
||||
|
||||
$licenses = $wpdb->get_results($wpdb->prepare(
|
||||
"SELECT DISTINCT license_key, purchase_id_, lic_status FROM " . SLM_TBL_LICENSE_KEYS . "
|
||||
WHERE email = %s OR subscr_id = %d",
|
||||
|
||||
// Sanitize user inputs
|
||||
$user_email = sanitize_email($user_email);
|
||||
$user_id = intval($user_id);
|
||||
|
||||
// Directly using the constant table name as it's not possible to prepare table names
|
||||
$table_name = SLM_TBL_LICENSE_KEYS; // Ensure that SLM_TBL_LICENSE_KEYS is defined as a constant
|
||||
|
||||
// Use prepare for query construction with placeholders for dynamic values
|
||||
$query = $wpdb->prepare(
|
||||
"SELECT DISTINCT license_key, purchase_id_, lic_status
|
||||
FROM $table_name
|
||||
WHERE email = %s OR subscr_id = %d",
|
||||
$user_email, $user_id
|
||||
));
|
||||
);
|
||||
|
||||
// Execute the query safely
|
||||
$licenses = $wpdb->get_results($query);
|
||||
|
||||
|
||||
if ($licenses) {
|
||||
echo '<table class="shop_table shop_table_responsive my_account_orders">';
|
||||
echo '<thead><tr>';
|
||||
echo '<th>' . __('Order ID', 'slmplus') . '</th>';
|
||||
echo '<th>' . __('License Key', 'slmplus') . '</th>';
|
||||
echo '<th>' . __('Status', 'slmplus') . '</th>';
|
||||
echo '<th>' . __('Action', 'slmplus') . '</th>';
|
||||
echo '<th>' . esc_html__('Order ID', 'slm-plus') . '</th>';
|
||||
echo '<th>' . esc_html__('License Key', 'slm-plus') . '</th>';
|
||||
echo '<th>' . esc_html__('Status', 'slm-plus') . '</th>';
|
||||
echo '<th>' . esc_html__('Action', 'slm-plus') . '</th>';
|
||||
echo '</tr></thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
|
||||
foreach ($licenses as $license) {
|
||||
$order_id = $license->purchase_id_;
|
||||
$license_key = $license->license_key;
|
||||
$status = $license->lic_status;
|
||||
$encoded_license = base64_encode($license_key);
|
||||
$encoded_license = base64_encode($license_key);
|
||||
$action_link = esc_url(add_query_arg(['my-licenses' => 'view', 'slm_lic' => $encoded_license], site_url('/my-account/my-licenses')));
|
||||
|
||||
|
||||
echo '<tr>';
|
||||
|
||||
|
||||
// Display Order ID or Custom Message
|
||||
if (!empty($order_id)) {
|
||||
echo '<td>' . esc_html($order_id) . '</td>';
|
||||
} else {
|
||||
echo '<td>' . __('Manual', 'slmplus') . '</td>';
|
||||
echo '<td>' . esc_html__('Manual', 'slm-plus') . '</td>';
|
||||
}
|
||||
|
||||
|
||||
echo '<td>' . esc_html($license_key) . '</td>';
|
||||
|
||||
|
||||
// Display the status with custom badge classes
|
||||
echo '<td><span class="slm-status-badge status-' . esc_attr(strtolower($status)) . '">' . esc_html($status) . '</span></td>';
|
||||
|
||||
echo '<td><a href="' . esc_url($action_link) . '">' . __('View', 'slmplus') . '</a></td>';
|
||||
|
||||
echo '<td><a href="' . esc_url($action_link) . '">' . esc_html__('View', 'slm-plus') . '</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
} else {
|
||||
echo '<p>No licenses found.</p>';
|
||||
echo '<p>' . esc_html__('No licenses found.', 'slm-plus') . '</p>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//SLM_Helper_Class::write_log('file loaded');
|
||||
|
@ -185,36 +199,36 @@ function slm_license_view($encoded_license_id) {
|
|||
|
||||
// Check if license was found
|
||||
if (!$license) {
|
||||
echo '<p>' . __('Invalid license or access denied.', 'slmplus') . '</p>';
|
||||
echo '<p>' . esc_html__('Invalid license or access denied.', 'slm-plus') . '</p>';
|
||||
//SLM_Helper_Class::write_log('error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Back Button with dynamic URL generation
|
||||
$back_url = wc_get_account_endpoint_url('my-licenses');
|
||||
echo '<a href="' . esc_url($back_url) . '" class="button">' . __('Back to My Licenses', 'slmplus') . '</a>';
|
||||
echo '<a href="' . esc_url($back_url) . '" class="button">' . esc_html__('Back to My Licenses', 'slm-plus') . '</a>';
|
||||
|
||||
// Define the fields and labels for dynamic generation
|
||||
$slm_license_fields = [
|
||||
'license_key' => __('License Key', 'slmplus'),
|
||||
'lic_status' => __('Status', 'slmplus'),
|
||||
'lic_type' => __('License Type', 'slmplus'),
|
||||
'purchase_id_' => __('Order ID', 'slmplus'),
|
||||
'date_created' => __('Date Created', 'slmplus'),
|
||||
'date_activated' => __('Date Activated', 'slmplus'),
|
||||
'date_renewed' => __('Date Renewed', 'slmplus'),
|
||||
'date_expiry' => __('Date Expiry', 'slmplus'),
|
||||
'product_ref' => __('Product Reference', 'slmplus'),
|
||||
'subscr_id' => __('Subscription ID', 'slmplus'),
|
||||
'max_allowed_domains' => __('Max Allowed Domains', 'slmplus'),
|
||||
'max_allowed_devices' => __('Max Allowed Devices', 'slmplus'),
|
||||
'company_name' => __('Company Name', 'slmplus'),
|
||||
'license_key' => __('License Key', 'slm-plus'),
|
||||
'lic_status' => __('Status', 'slm-plus'),
|
||||
'lic_type' => __('License Type', 'slm-plus'),
|
||||
'purchase_id_' => __('Order ID', 'slm-plus'),
|
||||
'date_created' => __('Date Created', 'slm-plus'),
|
||||
'date_activated' => __('Date Activated', 'slm-plus'),
|
||||
'date_renewed' => __('Date Renewed', 'slm-plus'),
|
||||
'date_expiry' => __('Date Expiry', 'slm-plus'),
|
||||
'product_ref' => __('Product Reference', 'slm-plus'),
|
||||
'subscr_id' => __('Subscription ID', 'slm-plus'),
|
||||
'max_allowed_domains' => __('Max Allowed Domains', 'slm-plus'),
|
||||
'max_allowed_devices' => __('Max Allowed Devices', 'slm-plus'),
|
||||
'company_name' => __('Company Name', 'slm-plus'),
|
||||
];
|
||||
|
||||
// Display license details header
|
||||
echo '<h3 class="slm_view_lic">' . __('License Details', 'slmplus') . '</h3>';
|
||||
echo '<h3 class="slm_view_lic">' . esc_html__('License Details', 'slm-plus') . '</h3>';
|
||||
echo '<table class="shop_table shop_table_responsive my_account_orders">';
|
||||
echo '<tbody>';
|
||||
echo '<tbody>';
|
||||
|
||||
// Loop through each field and output its label and value dynamically
|
||||
foreach ($slm_license_fields as $field_key => $field_label) {
|
||||
|
@ -228,7 +242,7 @@ function slm_license_view($encoded_license_id) {
|
|||
$order_link = wc_get_account_endpoint_url('view-order/' . $field_value);
|
||||
$field_value = '<a href="' . esc_url($order_link) . '">' . esc_html($field_value) . '</a>';
|
||||
} else {
|
||||
$field_value = __('No Order Information Available', 'slmplus');
|
||||
$field_value = __('No Order Information Available', 'slm-plus');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,19 +258,19 @@ function slm_license_view($encoded_license_id) {
|
|||
// Format as "#ID - ProductName"
|
||||
$field_value = '<a href="' . esc_url($product_url) . '">#' . esc_html($product_id) . ' - ' . esc_html($product_name) . '</a>';
|
||||
} else {
|
||||
$field_value = __('Product Not Found', 'slmplus');
|
||||
$field_value = __('Product Not Found', 'slm-plus');
|
||||
}
|
||||
} else {
|
||||
$field_value = __('No Product Information Available', 'slmplus');
|
||||
$field_value = __('No Product Information Available', 'slm-plus');
|
||||
}
|
||||
}
|
||||
|
||||
// Special handling for date fields with '0000-00-00' as value
|
||||
if (($field_key === 'date_activated' || $field_key === 'date_renewed') && $field_value === '0000-00-00') {
|
||||
$field_value = ($field_key === 'date_activated') ? __('Not activated yet', 'slmplus') : __('Not renewed yet', 'slmplus');
|
||||
$field_value = ($field_key === 'date_activated') ? __('Not activated yet', 'slm-plus') : __('Not renewed yet', 'slm-plus');
|
||||
}
|
||||
|
||||
echo '<tr><th>' . $field_label . '</th><td>' . $field_value . '</td></tr>';
|
||||
echo '<tr><th>' . esc_html($field_label) . '</th><td>' . esc_html($field_value) . '</td></tr>';
|
||||
}
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
|
@ -282,17 +296,17 @@ function slm_license_view($encoded_license_id) {
|
|||
$activations = array_merge($domains, $devices);
|
||||
|
||||
// Display the "Activations" section header
|
||||
echo '<h2>' . __('Activations', 'slmplus') . '</h2>';
|
||||
echo '<h2>' . esc_html__('Activations', 'slm-plus') . '</h2>';
|
||||
|
||||
// Check if there are any activations
|
||||
if (empty($activations)) {
|
||||
echo '<p>' . __('No activations found.', 'slmplus') . '</p>';
|
||||
echo '<p>' . esc_html__('No activations found.', 'slm-plus') . '</p>';
|
||||
} else {
|
||||
// Display the table header if activations exist
|
||||
echo '<table class="shop_table shop_table_responsive my_account_orders">';
|
||||
echo '<thead><tr><th>' . __('ID', 'slmplus') . '</th><th>' . __('Type', 'slmplus') . '</th><th>' . __('Origin', 'slmplus') . '</th><th>' . __('Action', 'slmplus') . '</th></tr></thead>';
|
||||
echo '<thead><tr><th>' . esc_html__('ID', 'slm-plus') . '</th><th>' . esc_html__('Type', 'slm-plus') . '</th><th>' . esc_html__('Origin', 'slm-plus') . '</th><th>' . esc_html__('Action', 'slm-plus') . '</th></tr></thead>';
|
||||
echo '<tbody>';
|
||||
|
||||
|
||||
// Loop through each activation and display in the table
|
||||
foreach ($activations as $activation) {
|
||||
echo '<tr>';
|
||||
|
@ -302,13 +316,14 @@ function slm_license_view($encoded_license_id) {
|
|||
echo '<td><form method="post" action="">';
|
||||
echo '<input type="hidden" name="activation_id" value="' . esc_attr($activation->id) . '">';
|
||||
echo '<input type="hidden" name="activation_type" value="' . esc_attr($activation->type) . '">';
|
||||
echo '<button type="submit" name="delete_activation" class="button">' . __('Delete', 'slmplus') . '</button>';
|
||||
echo '<button type="submit" name="delete_activation" class="button">' . esc_html__('Delete', 'slm-plus') . '</button>';
|
||||
echo '</form></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
|
||||
echo '</tbody>';
|
||||
echo '</table>';
|
||||
|
||||
}
|
||||
|
||||
// Handle the deletion request
|
||||
|
@ -324,9 +339,10 @@ function slm_license_view($encoded_license_id) {
|
|||
|
||||
// Display a confirmation or error message
|
||||
if ($deleted) {
|
||||
echo '<p class="slm-notice">' . __('Activation successfully deleted. Reload Page.', 'slmplus') . '</p>';
|
||||
echo '<p class="slm-notice">' . esc_html__('Activation successfully deleted. Reload Page.', 'slm-plus') . '</p>';
|
||||
} else {
|
||||
echo '<p class="slm-notice">' . __('Failed to delete activation. Please try again.', 'slmplus') . '</p>';
|
||||
echo '<p class="slm-notice">' . esc_html__('Failed to delete activation. Please try again.', 'slm-plus') . '</p>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Simple product add to cart
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/add-to-cart/simple.php.
|
||||
*
|
||||
* HOWEVER, on occasion WooCommerce will need to update template files and you
|
||||
* (the theme developer) will need to copy the new files to your theme to
|
||||
* maintain compatibility. We try to do this as little as possible, but it does
|
||||
* happen. When this occurs the version of the template file will be bumped and
|
||||
* the readme will list any important changes.
|
||||
*
|
||||
* @see https://docs.woocommerce.com/document/template-structure/
|
||||
* @package WooCommerce/Templates
|
||||
* @version 3.5.0
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
global $product;
|
||||
|
||||
if ( ! $product->is_purchasable() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo wc_get_stock_html( $product ); // WPCS: XSS ok.
|
||||
|
||||
if ( $product->is_in_stock() ) : ?>
|
||||
|
||||
<form class="cart" action="<?php echo esc_url( apply_filters( 'woocommerce_add_to_cart_form_action', $product->get_permalink() ) ); ?>" method="post" enctype='multipart/form-data'>
|
||||
<?php do_action( 'woocommerce_before_add_to_cart_button' ); ?>
|
||||
|
||||
<button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_to_cart_button' ); ?>
|
||||
</form>
|
||||
|
||||
<?php do_action( 'woocommerce_after_add_to_cart_form' ); ?>
|
||||
|
||||
<?php endif; ?>
|
Loading…
Add table
Add a link
Reference in a new issue