diff --git a/admin/slm-lic-settings.php b/admin/slm-lic-settings.php index 693f243..63a53ff 100755 --- a/admin/slm-lic-settings.php +++ b/admin/slm-lic-settings.php @@ -4,79 +4,82 @@ die; } -function slm_settings_menu(){ +function slm_settings_menu() +{ slm_general_settings(); } -function slm_general_settings(){ - ?> +function slm_general_settings() +{ +?> reset_log_file("log.txt"); - $slm_debug_logger->reset_log_file("log-cron-job.txt"); - echo '

- '.__( 'Debug log files have been reset!', 'softwarelicensemanager' ) .' + if (isset($_REQUEST['slm_reset_log'])) { + $slm_logger = new SLM_Debug_Logger(); + global $slm_debug_logger; + $slm_debug_logger->reset_log_file("log.txt"); + $slm_debug_logger->reset_log_file("log-cron-job.txt"); + echo '

+ ' . __('Debug log files have been reset!', 'softwarelicensemanager') . '

'; - } - - if (isset($_POST['slm_save_settings'])) { + } - if (!is_numeric($_POST["default_max_domains"])) { - //Set it to one by default if incorrect value is entered - $_POST["default_max_domains"] = '2'; - } - if (!is_numeric($_POST["default_max_devices"])) { - //Set it to one by default if incorrect value is entered - $_POST["default_max_devices"] = '2'; - } + if (isset($_POST['slm_save_settings'])) { - $options = array( - 'lic_creation_secret' => trim($_POST["lic_creation_secret"]), - 'lic_prefix' => trim($_POST["lic_prefix"]), - 'default_max_domains' => trim($_POST["default_max_domains"]), - 'default_max_devices' => trim($_POST["default_max_devices"]), - 'lic_verification_secret' => trim($_POST["lic_verification_secret"]), - 'enable_auto_key_expiration' => isset($_POST['enable_auto_key_expiration']) ? '1' : '', - '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); - - echo '

'.__( 'Options updated!', 'softwarelicensemanager' ).'

'; + if (!is_numeric($_POST["default_max_domains"])) { + //Set it to one by default if incorrect value is entered + $_POST["default_max_domains"] = '2'; + } + if (!is_numeric($_POST["default_max_devices"])) { + //Set it to one by default if incorrect value is entered + $_POST["default_max_devices"] = '2'; } - $options = get_option('slm_plugin_options'); - $secret_key = $options['lic_creation_secret']; + $options = array( + 'lic_creation_secret' => trim($_POST["lic_creation_secret"]), + 'lic_prefix' => trim($_POST["lic_prefix"]), + 'default_max_domains' => trim($_POST["default_max_domains"]), + 'default_max_devices' => trim($_POST["default_max_devices"]), + 'lic_verification_secret' => trim($_POST["lic_verification_secret"]), + 'enable_auto_key_expiration' => isset($_POST['enable_auto_key_expiration']) ? '1' : '', + '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_front_conflictmode' => isset($_POST['slm_front_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); + + echo '

' . __('Options updated!', 'softwarelicensemanager') . '

'; + } - if (empty($secret_key)) { - //$secret_key = md5(uniqid('', true)); - $secret_key = SLM_Utility::create_secret_keys(); - } + $options = get_option('slm_plugin_options'); + $secret_key = $options['lic_creation_secret']; - $secret_verification_key = $options['lic_verification_secret']; - if (empty($secret_verification_key)) { - //$secret_verification_key = md5(uniqid('', true)); - $secret_verification_key = SLM_Utility::create_secret_keys(); - } - $tab = ""; //Initialization value; - if (isset($_REQUEST['tab'])) { - $tab = $_REQUEST['tab']; - } else { - $tab = 'general_settings'; - } + if (empty($secret_key)) { + //$secret_key = md5(uniqid('', true)); + $secret_key = SLM_Utility::create_secret_keys(); + } + + $secret_verification_key = $options['lic_verification_secret']; + if (empty($secret_verification_key)) { + //$secret_verification_key = md5(uniqid('', true)); + $secret_verification_key = SLM_Utility::create_secret_keys(); + } + $tab = ""; //Initialization value; + if (isset($_REQUEST['tab'])) { + $tab = $_REQUEST['tab']; + } else { + $tab = 'general_settings'; + } ?>
@@ -199,6 +202,12 @@ function slm_general_settings(){ value="1" /> + + + + value="1" /> + +
@@ -279,4 +288,4 @@ function slm_general_settings(){
charset)){ - $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; -} -else{ - $charset_collate = "DEFAULT CHARSET=utf8"; +if (!empty($wpdb->charset)) { + $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset"; +} else { + $charset_collate = "DEFAULT CHARSET=utf8"; } -if (!empty($wpdb->collate)){ - $charset_collate .= " COLLATE $wpdb->collate"; +if (!empty($wpdb->collate)) { + $charset_collate .= " COLLATE $wpdb->collate"; } $lk_tbl_sql = "CREATE TABLE " . $lic_key_table . " ( @@ -80,12 +80,12 @@ foreach ($item_result as $reference_item) { $item_id = $reference_item->id; // update and set default value - $update_reference = "UPDATE $lic_key_table SET item_reference='default' WHERE id='".$item_id."';"; + $update_reference = "UPDATE $lic_key_table SET item_reference='default' WHERE id='" . $item_id . "';"; dbDelta($update_reference); } } -$ld_tbl_sql = "CREATE TABLE " .$lic_domain_table. " ( +$ld_tbl_sql = "CREATE TABLE " . $lic_domain_table . " ( id INT NOT NULL AUTO_INCREMENT , lic_key_id INT NOT NULL , lic_key varchar(255) NOT NULL , @@ -120,7 +120,7 @@ )" . $charset_collate . ";"; dbDelta($log_tbl_sql); -$ldv_tbl_sql = "CREATE TABLE " .$lic_devices_table. " ( +$ldv_tbl_sql = "CREATE TABLE " . $lic_devices_table . " ( id INT NOT NULL AUTO_INCREMENT , lic_key_id INT NOT NULL , lic_key varchar(255) NOT NULL , @@ -133,31 +133,33 @@ // Add default options $options = array( - 'lic_creation_secret' => SLM_Utility::create_secret_keys(), - 'lic_prefix' => 'SLM-', - 'default_max_domains' => '2', - 'default_max_devices' => '2', - 'lic_verification_secret' => SLM_Utility::create_secret_keys(), - 'enable_debug' => '', - 'slm_woo' => '1', - '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'); + 'lic_creation_secret' => SLM_Utility::create_secret_keys(), + 'lic_prefix' => 'SLM-', + 'default_max_domains' => '2', + 'default_max_devices' => '2', + 'lic_verification_secret' => SLM_Utility::create_secret_keys(), + 'enable_debug' => '', + 'slm_woo' => '1', + 'slm_woo_downloads' => '', + 'slm_woo_affect_downloads' => '1', + 'slm_wpestores' => '', + 'slm_stats' => '1', + 'slm_adminbar' => '1', + 'slm_multiple_items' => '', + 'slm_conflictmode' => '1', + 'slm_front_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 // thanks to @MechComp $old_options = get_option('slm_plugin_options'); -if($old_options != false){ - $options = array_merge($options,$old_options); +if ($old_options != false) { + $options = array_merge($options, $old_options); } update_option('slm_plugin_options', $options); -update_option("slm_db_version", SLM_DB_VERSION); \ No newline at end of file +update_option("slm_db_version", SLM_DB_VERSION); diff --git a/includes/slm-scripts.php b/includes/slm-scripts.php index ff99f41..958dd10 100644 --- a/includes/slm-scripts.php +++ b/includes/slm-scripts.php @@ -1,38 +1,39 @@ + + + + +
>