Skip to content

Commit

Permalink
Merge pull request #24 from MechComp/MechComp
Browse files Browse the repository at this point in the history
MechComp
  • Loading branch information
michelve committed Jun 24, 2020
2 parents 5249021 + 8e193e5 commit dc2c9e6
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 190 deletions.
94 changes: 70 additions & 24 deletions admin/includes/partials/stats.php
Original file line number Diff line number Diff line change
@@ -1,57 +1,103 @@
<ul class="slm_overview_stats">
<li class="stats total-licenses">
<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> <span>Total licenses</span></div>
<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>
<div class="description">
<span>Total licenses</span>
</div>
</li>

<li class="stats total-licenses weekly">
<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> <span>Licenses this week</span></div>
<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>
<div class="description">
<span>Licenses this week</span>
</div>
</li>

<li class="stats total-licenses monthly">
<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> <span>Licenses this month</span></div>
<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>
<div class="description">
<span>Licenses this month</span>
</div>
</li>

<li class="stats active-licenses">
<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> <span>Active licenses</span></div>
<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>
<div class="description">
<span>Active licenses</span>
</div>
</li>

<li class="stats pending-licenses">
<div class="icon"> <span class="dashicons dashicons-warning"></span> </div>
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('pending '); ?></span> </span> <span>Pending licenses</span></div>
<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>
<div class="description">
<span>Pending licenses</span>
</div>
</li>

<li class="stats blocked-licenses">
<div class="icon"> <span class="dashicons dashicons-dismiss"></span> </div>
<div class="info"> <span class="badge"><?php echo SLM_Utility::count_licenses('blocked '); ?></span> </span> <span>Blocked licenses</span></div>

<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>
<div class="description">
<span>Blocked licenses</span>
</div>
</li>

<li class="stats logs">
<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> </span> <span>Logs saved</span></div>

<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>
<div class="description">
<span>Logs saved</span>
</div>
</li>

<li class="stats reminders">
<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> </span> <span>Reminders sent</span></div>

<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>
<div class="description">
<span>Reminders sent</span>
</div>
</li>

<li class="stats expired-licenses">
<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></span> <span>Expired licenses</span></div>
<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>
<div class="description">
<span>Expired licenses</span>
</div>
</li>

<li class="stats aboutoexpire">
<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> <span>Licenses about to expire</span></div>
<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>
<div class="description">
<span>Licenses about to expire</span>
</div>
</li>

</ul>
<div class="h-spacer"></div>
<div class="clear clearfix"></div>
7 changes: 5 additions & 2 deletions admin/slm-add-licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,17 +613,20 @@ function slm_add_licenses_menu(){
<div class="form-group col-md-12">
<label for="item_reference">Item reference</label>
<select name="item_reference" class="form-control">
<option value="select one" selected> Select one ...</option>
<?php
$was_selected = false;
foreach ($values_item_refs as $item_reference) {
$sel_val = esc_attr(trim($item_reference->meta_value));
$is_selected = $lic_item_ref==$sel_val;
//remember is it was selected during the process
$was_selected = $was_selected==false ? $is_selected : $was_selected;
// filter out empty values
if (!empty($sel_val)) {
echo '<option value="'. $sel_val .'">'.$sel_val .'</option>';
echo '<option value="'. $sel_val .'"'.($is_selected==true ? ' selected' : '').'>'.$sel_val .'</option>';
}
}
?>
<option value="select one"<?php echo ($was_selected==false ? ' selected' : '') ?>> Select one ...</option>
</select>
<small class="form-text text-muted"><?php _e('Item reference of your software');?></small>
</div>
Expand Down
2 changes: 1 addition & 1 deletion admin/slm-dashboard-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function add_toolbar_items($admin_bar){
$admin_bar->add_menu(array(
'id' => 'slm-menu',
'title' => '<span class="ab-icon"></span>' . __('SLM', 'softwarelicensemanager'),
'href' => '#',
'href' => admin_url('admin.php?page=slm_overview'),
'meta' => array(
'title' => __('SLM'),
),
Expand Down
18 changes: 18 additions & 0 deletions admin/slm-lic-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ function slm_general_settings(){
'enable_debug' => isset($_POST['enable_debug']) ? '1' : '',
'slm_woo' => isset($_POST['slm_woo']) ? '1' : '',
'slm_woo_downloads' => isset($_POST['slm_woo_downloads']) ? '1' : '',
'slm_woo_affect_downloads' => isset($_POST['slm_woo_affect_downloads']) ? '1' : '',
'slm_stats' => isset($_POST['slm_stats']) ? '1' : '',
'slm_adminbar' => isset($_POST['slm_adminbar']) ? '1' : '',
'slm_conflictmode' => isset($_POST['slm_conflictmode']) ? '1' : '',
'slm_wpestores' => isset($_POST['slm_wpestores']) ? '1' : '',
'slm_dl_manager' => isset($_POST['slm_dl_manager']) ? '1' : '',
'slm_multiple_items' => isset($_POST['slm_multiple_items']) ? '1' : '',
'allow_user_activation_removal' => isset($_POST['allow_user_activation_removal']) ? '1' : '',
'expiration_reminder_text' => sanitize_text_field($_POST['expiration_reminder_text'])
);
update_option('slm_plugin_options', $options);
Expand Down Expand Up @@ -182,6 +184,15 @@ function slm_general_settings(){
</td>
</tr>

<tr>
<th scope="row"><?php _e('User permissions', 'softwarelicensemanager'); ?></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.', 'softwarelicensemanager'); ?>
<p class="description"><?php _e("When enabled, users will be able to remove registered domains or devices in their account.", 'softwarelicensemanager'); ?></p>
</td>
</tr>

<tr>
<th scope="row">Bootstrap library</th>
<td>
Expand Down Expand Up @@ -209,6 +220,13 @@ function slm_general_settings(){
<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.', 'softwarelicensemanager'); ?></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('Expire WooCommerce downloads. Downloads will expire together with corresponding license.', 'softwarelicensemanager'); ?>
</td>
</tr>
<!-- <tr valign="top">
<th scope="row"> <?php _e('Download Manager Support', 'softwarelicensemanager'); ?></th>
<td>
Expand Down
4 changes: 3 additions & 1 deletion admin/slm-list-licenses-class.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function get_columns()
'id' => 'ID',
'lic_status' => 'Status',
'license_key' => 'Key',
'item_reference' => 'Item reference',
'lic_type' => 'License type',
'email' => 'Email',
'max_allowed_domains' => 'Domains',
Expand Down Expand Up @@ -184,7 +185,8 @@ function get_sortable_columns()
'lic_type' => array('lic_type', true),
'until' => array('until', true),
'current_ver' => array('current_ver', true),
'lic_status' => array('lic_status', true)
'lic_status' => array('lic_status', true),
'item_reference' => array('item_reference', true),
);

return $sortable_columns;
Expand Down
4 changes: 3 additions & 1 deletion includes/class-slm-installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,16 @@
'lic_verification_secret' => SLM_Utility::create_secret_keys(),
'enable_debug' => '',
'slm_woo' => '1',
'slm_wpestores' => '',
'slm_woo_downloads' => '',
'slm_woo_affect_downloads'=> '1',
'slm_wpestores' => '',
'slm_stats' => '1',
'slm_adminbar' => '1',
'slm_multiple_items' => '',
'slm_conflictmode' => '1',
'enable_auto_key_expiration' => '1',
'slm_dl_manager' => '',
'allow_user_activation_removal' => '1',
'expiration_reminder_text' => 'Your account has reverted to Basic with limited functionality. Renew today to keep using it on all of your devices and enjoy the valuable features. It’s a smart investment');

//Bugfix - Prevention of overwriting existing settings
Expand Down
10 changes: 8 additions & 2 deletions includes/slm-api-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,14 @@ function activation_api_listener() {

$key = $fields['lic_key'];

$sql_prep1 = $wpdb->prepare("SELECT * FROM $tbl_name WHERE license_key = %s", $key);
$retLic = $wpdb->get_row($sql_prep1, OBJECT);
//Enable item_reference verification during activation
if ($options['slm_multiple_items']==1){
$sql_prep1 = $wpdb->prepare("SELECT * FROM $tbl_name WHERE license_key = %s AND item_reference = %s", $key, $item_reference);
$retLic = $wpdb->get_row($sql_prep1, OBJECT);
}else{
$sql_prep1 = $wpdb->prepare("SELECT * FROM $tbl_name WHERE license_key = %s", $key);
$retLic = $wpdb->get_row($sql_prep1, OBJECT);
}

$sql_prep2 = $wpdb->prepare("SELECT * FROM $reg_table WHERE lic_key = %s", $key);
$reg_domains = $wpdb->get_results($sql_prep2, OBJECT);
Expand Down
6 changes: 4 additions & 2 deletions includes/slm-utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ static function slm_wp_dashboards_stats($amount){
global $wpdb;
$slm_log_table = SLM_TBL_LICENSE_KEYS;

$result = $wpdb->get_results(" SELECT * FROM $slm_log_table LIMIT $amount");
$result = $wpdb->get_results(" SELECT * FROM $slm_log_table ORDER BY id DESC LIMIT $amount");

foreach ($result as $license) {
echo '<tr>
Expand Down Expand Up @@ -515,7 +515,7 @@ static function get_lic_activity($license_key){
</div>';
}

static function get_license_activation($license_key, $tablename, $item_name) {
static function get_license_activation($license_key, $tablename, $item_name, $allow_removal = true) {
?>
<div class="table">
<h5> <?php echo $item_name; ?> </h5>
Expand All @@ -540,9 +540,11 @@ static function get_license_activation($license_key, $tablename, $item_name) {
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>';
}
?>
<?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-id="<?php echo $activation->id; ?>"> Remove</button>
</div>
<?php endif; ?>
</div>

<?php $count++; ?>
Expand Down
3 changes: 3 additions & 0 deletions public/assets/css/slm.css
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,6 @@ span.days-left {
.show_if_slm_license.slm-display, .slm-display {
display: block !important
}
.stats .description{
padding: 10px 15px 0px 15px;
}
7 changes: 4 additions & 3 deletions software-license-manager.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php
/*
Plugin Name: Software License Manager
Version: 5.5.3
Version: 5.5.4
Plugin URI: https://github.com/michelve/software-license-manager/
Author: Michel Velis
Author URI: https://www.epikly.com/
Description: Software license management solution for your web applications (WordPress plugins, Themes, Applications, PHP based membership script etc.). Supports WooCommerce.
Author2: <a href="https://www.tipsandtricks-hq.com/">Tips and Tricks HQ</a>
Text Domain: softwarelicensemanager
Domain Path: /i18n/languages/
WC tested up to: 4.2.1
*/

// If this file is called directly, abort.
Expand All @@ -18,8 +19,8 @@
global $wpdb, $slm_debug_logger;

//Short name/slug "SLM" or "slm"
define('SLM_VERSION', '5.5.3');
define('SLM_DB_VERSION', '4.2.6');
define('SLM_VERSION', '5.5.4');
define('SLM_DB_VERSION', '4.2.7');
define('SLM_REWRITE_VERSION', '2.3.8');
define('SLM_FOLDER', dirname(plugin_basename(__FILE__)));
define('SLM_URL', plugins_url('' ,__FILE__));
Expand Down
Loading

0 comments on commit dc2c9e6

Please sign in to comment.