Skip to content

Commit

Permalink
changed the settings/options savings to an ARRAY structure
Browse files Browse the repository at this point in the history
  • Loading branch information
amin0_000 committed Sep 22, 2014
1 parent 085071e commit 8b2c03f
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 33 deletions.
7 changes: 4 additions & 3 deletions license-manager/api/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
include_once('../../../../wp-load.php');
include_once(WP_LICENSE_MANAGER_PATH . 'includes/slm_db_access.php');

$right_secret_key = get_option('wp_lic_mgr_reg_secret_key');
$lic_key_prefix = get_option('wp_lic_mgr_key_prefix');
$options = get_option('slm_plugin_options');
$right_secret_key = $options['lic_creation_secret'];
$lic_key_prefix = $options['lic_prefix'];

$received_secret_key = $_REQUEST['secret_key'];
if ($received_secret_key != $right_secret_key) {
Expand All @@ -22,7 +23,7 @@
$fields['company_name'] = $_REQUEST['company_name'];
$fields['txn_id'] = $_REQUEST['txn_id'];
if (empty($_REQUEST['max_allowed_domains'])) {
$fields['max_allowed_domains'] = get_option('wp_lic_mgr_max_num_domain');
$fields['max_allowed_domains'] = $options['default_max_domains'];
}

$updateDb = LicMgrDbAccess::insert(WP_LICENSE_MANAGER_LICENSE_TABLE_NAME, $fields);
Expand Down
3 changes: 2 additions & 1 deletion license-manager/api/deactivate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
include_once('../../../../wp-load.php');
include_once(WP_LICENSE_MANAGER_PATH . 'includes/slm_db_access.php');

$right_secret_key = get_option('wp_lic_mgr_verification_secret_key');
$slm_options = get_option('slm_plugin_options');
$right_secret_key = $slm_options['lic_verification_secret'];

$received_secret_key = $_REQUEST['secret_key'];
if ($received_secret_key != $right_secret_key) {
Expand Down
3 changes: 2 additions & 1 deletion license-manager/api/verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
include_once('../../../../wp-load.php');
include_once(WP_LICENSE_MANAGER_PATH . 'includes/slm_db_access.php');

$right_secret_key = get_option('wp_lic_mgr_verification_secret_key');
$slm_options = get_option('slm_plugin_options');
$right_secret_key = $slm_options['lic_verification_secret'];

$received_secret_key = $_REQUEST['secret_key'];
if ($received_secret_key != $right_secret_key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


// This is the secret key for API authentication. You configured it in the settings menu of the license manager plugin.
define('YOUR_SPECIAL_SECRET_KEY', '541fbfb9d49ba6.45466831'); //Rename this constant name so it is specific to your plugin or theme.
define('YOUR_SPECIAL_SECRET_KEY', '541fc9967d4bb4.41297561'); //Rename this constant name so it is specific to your plugin or theme.

// This is the URL where API query request will be sent to. This should be the URL of the site where you have installed the main license manager plugin. Get this value from the integration help page.
define('YOUR_LICENSE_SERVER_URL', 'http://localhost:81/wp/wp7'); //Rename this constant name so it is specific to your plugin or theme.
Expand Down
7 changes: 4 additions & 3 deletions license-manager/includes/slm-api-listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ function activation_api_listener()
{
if(isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_activate'){
//Handle the license activation API query
$right_secret_key = get_option('wp_lic_mgr_verification_secret_key');
$slm_options = get_option('slm_plugin_options');
$right_secret_key = $slm_options['lic_verification_secret'];
$received_secret_key = $_REQUEST['secret_key'];
if ($received_secret_key != $right_secret_key) {
echo "Error\n";
Expand Down Expand Up @@ -103,8 +104,8 @@ function deactivation_api_listener()
if(isset($_REQUEST['slm_action']) && trim($_REQUEST['slm_action']) == 'slm_deactivate'){
//Handle the license deactivation API query
if (isset($_REQUEST['secret_key'])) {
$right_secret_key = get_option('wp_lic_mgr_verification_secret_key');

$slm_options = get_option('slm_plugin_options');
$right_secret_key = $slm_options['lic_verification_secret'];
$received_secret_key = $_REQUEST['secret_key'];
if ($received_secret_key != $right_secret_key) {
echo "Error\n";
Expand Down
3 changes: 2 additions & 1 deletion license-manager/menu/lic_add_licenses.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function wp_lic_mgr_add_licenses_menu() {
$renewed_date = '';
$expiry_date = '';

$slm_options = get_option('slm_plugin_options');

echo '<div class="wrap">';
echo '<h2>Add/Edit Licenses</h2>';
Expand Down Expand Up @@ -126,7 +127,7 @@ function wp_lic_mgr_add_licenses_menu() {
$editing_record = new stdClass();
}
//Auto generate unique key
$lic_key_prefix = get_option('wp_lic_mgr_key_prefix');
$lic_key_prefix = $slm_options['lic_prefix'];
if (!empty($lic_key_prefix)) {
$license_key = uniqid($lic_key_prefix);
} else {
Expand Down
5 changes: 4 additions & 1 deletion license-manager/menu/lic_mgr_integration_help_page.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ function lic_mgr_integration_help_menu() {
</style>
<?php

$options = get_option('slm_plugin_options');
$creation_secret_key = $options['lic_creation_secret'];

echo '<div class="wrap">';
echo '<div id="poststuff"><div id="post-body">';
echo '<h2>WP License Manager Integration Help v' . WP_LICENSE_MANAGER_VERSION . '</h2>';
Expand Down Expand Up @@ -81,7 +84,7 @@ function lic_mgr_integration_help_menu() {
<br />// Post URL
<br />$postURL = "<?php echo $LicenseCreationPostURL; ?>";
<br />// The Secret key
<br />$secretKey = "<?php echo get_option('wp_lic_mgr_reg_secret_key'); ?>";
<br />$secretKey = "<?php echo $creation_secret_key; ?>";
<br />
<br />/*** Optional Data ***/
<br />$firstname = "John";
Expand Down
50 changes: 29 additions & 21 deletions license-manager/menu/lic_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,34 @@ function wp_lic_mgr_settings_menu() {
}

function wp_lic_mgr_general_settings() {

if (isset($_POST['info_update'])) {

update_option('wp_lic_mgr_reg_secret_key', (string) $_POST["wp_lic_mgr_reg_secret_key"]);
update_option('wp_lic_mgr_key_prefix', (string) $_POST["wp_lic_mgr_key_prefix"]);
if (is_numeric($_POST["wp_lic_mgr_max_num_domain"])) {
update_option('wp_lic_mgr_max_num_domain', (string) $_POST["wp_lic_mgr_max_num_domain"]);

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"] = '1';
}
update_option('wp_lic_mgr_verification_secret_key', (string) $_POST["wp_lic_mgr_verification_secret_key"]);
//update_option('eStore_enable_wishlist_int', ($_POST['eStore_enable_wishlist_int']=='1') ? '1':'' );

$options = array(
'lic_creation_secret' => trim($_POST["lic_creation_secret"]),
'lic_prefix' => trim($_POST["lic_prefix"]),
'default_max_domains' => trim($_POST["default_max_domains"]),
'lic_verification_secret' => trim($_POST["lic_verification_secret"]),
);
update_option('slm_plugin_options', $options);
}
$secret_key = get_option('wp_lic_mgr_reg_secret_key');

$options = get_option('slm_plugin_options');

$secret_key = $options['lic_creation_secret'];
if (empty($secret_key)) {
$secret_key = uniqid('', true);
}
$secret_verification_key = get_option('wp_lic_mgr_verification_secret_key');
$secret_verification_key = $options['lic_verification_secret'];
if (empty($secret_verification_key)) {
$secret_verification_key = uniqid('', true);
}
?>
<p>For information, updates and detailed documentation, please visit the <a href="http://www.tipsandtricks-hq.com" target="_blank">License Manager Documentation</a> page.</p>
<p>For information, updates and detailed documentation, please visit the <a href="https://www.tipsandtricks-hq.com" target="_blank">License Manager Documentation</a> page.</p>

<div class="postbox">
<h3><label for="title">Quick Usage Guide</label></h3>
Expand All @@ -53,32 +60,33 @@ function wp_lic_mgr_general_settings() {

<tr valign="top">
<th scope="row">Secret Key for License Creation</th>
<td><input type="text" name="wp_lic_mgr_reg_secret_key" value="<?php echo $secret_key; ?>" size="40" />
<td><input type="text" name="lic_creation_secret" value="<?php echo $secret_key; ?>" size="40" />
<br />This secret key will be used to authenticate any license creation request. You can change it with something random.</td>
</tr>

<tr valign="top">
<th scope="row">License Key Prefix</th>
<td><input type="text" name="wp_lic_mgr_key_prefix" value="<?php echo get_option('wp_lic_mgr_key_prefix'); ?>" size="440" />
<br />You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.</td>
<th scope="row">Secret Key for License Verification Requests</th>
<td><input type="text" name="lic_verification_secret" value="<?php echo $secret_verification_key; ?>" size="40" />
<br />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)!</td>
</tr>

<tr valign="top">
<th scope="row">Secret Key for License Verification Requests</th>
<td><input type="text" name="wp_lic_mgr_verification_secret_key" value="<?php echo $secret_verification_key; ?>" size="40" />
<br />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)!</td>
<th scope="row">License Key Prefix</th>
<td><input type="text" name="lic_prefix" value="<?php echo $options['lic_prefix']; ?>" size="40" />
<br />You can optionaly specify a prefix for the license keys. This prefix will be added to the uniquely generated license keys.</td>
</tr>

<tr valign="top">
<th scope="row">Maximum Allowed Domains</th>
<td><input type="text" name="wp_lic_mgr_max_num_domain" value="<?php echo get_option('wp_lic_mgr_max_num_domain'); ?>" size="6" />
<td><input type="text" name="default_max_domains" value="<?php echo $options['default_max_domains']; ?>" size="6" />
<br />Maximum number of domains which each license is valid for (default value).</td>
</tr>

</table>
</div></div>

<div class="submit">
<input type="submit" class="button-primary" name="info_update" value="Update Options" />
<input type="submit" class="button-primary" name="slm_save_settings" value=" <?php _e('Update Options', 'slm'); ?>" />
</div>
</form>
<?php
Expand Down
4 changes: 3 additions & 1 deletion license-manager/menu/wp_lic_mgr_admin_fnc.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ function wp_lic_mgr_admin_fnc_menu() {
echo '<h2>License Manager Admin Functions</h2>';
echo '<div id="poststuff"><div id="post-body">';

$slm_options = get_option('slm_plugin_options');

if (isset($_POST['send_deactivation_request'])) {
$postURL = $_POST['lic_mgr_deactivation_req_url'];
$secretKeyForVerification = get_option('wp_lic_mgr_verification_secret_key');
$secretKeyForVerification = $slm_options['lic_verification_secret'];
$data = array();
$data['secret_key'] = $secretKeyForVerification;

Expand Down

0 comments on commit 8b2c03f

Please sign in to comment.