Skip to content

Commit

Permalink
lots of refactoring and architectural changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amin0_000 committed Sep 18, 2014
1 parent d7024d1 commit 0334b82
Show file tree
Hide file tree
Showing 16 changed files with 487 additions and 696 deletions.
File renamed without changes.
Empty file.
17 changes: 0 additions & 17 deletions license-manager/deactivation_tester.php

This file was deleted.

15 changes: 8 additions & 7 deletions license-manager/lic_manager_installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@
date_renewed datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
date_expiry datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (id)
)ENGINE=MyISAM DEFAULT CHARSET=utf8;";
)ENGINE=MyISAM DEFAULT CHARSET=utf8;";
dbDelta($lk_tbl_sql);

$ld_tbl_sql = "CREATE TABLE " .$lic_domain_table. " (
id INT NOT NULL AUTO_INCREMENT ,
lic_key_id INT NOT NULL ,
lic_key varchar(255) NOT NULL ,
registered_domain VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( id )
)ENGINE=MyISAM DEFAULT CHARSET=utf8;";
id INT NOT NULL AUTO_INCREMENT ,
lic_key_id INT NOT NULL ,
lic_key varchar(255) NOT NULL ,
registered_domain VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( id )
)ENGINE=MyISAM DEFAULT CHARSET=utf8;";
dbDelta($ld_tbl_sql);

// Add default options
update_option("wp_lic_mgr_db_version", WP_LICENSE_MANAGER_DB_VERSION);

10 changes: 0 additions & 10 deletions license-manager/menu/admin_includes1.php

This file was deleted.

324 changes: 155 additions & 169 deletions license-manager/menu/lic_add_licenses.php

Large diffs are not rendered by default.

52 changes: 22 additions & 30 deletions license-manager/menu/lic_manage_licenses.php
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
<?php

function wp_lic_mgr_manage_licenses_menu()
{
if(!wp_lic_mgr_is_license_valid())
{
return; //Do not display the page if licese key is invalid
}

function wp_lic_mgr_manage_licenses_menu() {
echo '<div class="wrap">';
echo '<h2>Manage Licenses</h2>';
echo '<div id="poststuff"><div id="post-body">';

?>
<br />
<div class="postbox">
<h3><label for="title">Existing Licenses</label></h3>
<div class="inside">
<?php
include_once 'wp-lic-mgr-list-licenses.php'; //For rendering the license List Table
$license_list = new WPLM_List_Licenses();
if(isset($_REQUEST['action'])) //Do list table form row action tasks
{
if(isset($_REQUEST['task']) && $_REQUEST['task'] == 'delete'){ //Delete link was clicked for a row in list table
$license_list->delete_licnses(strip_tags($_REQUEST['id']));
}
<h3><label for="title">Existing Licenses</label></h3>
<div class="inside">
<?php
include_once( 'wp-lic-mgr-list-licenses.php' ); //For rendering the license List Table
$license_list = new WPLM_List_Licenses();
if (isset($_REQUEST['action'])) { //Do list table form row action tasks
if (isset($_REQUEST['task']) && $_REQUEST['task'] == 'delete') { //Delete link was clicked for a row in list table
$license_list->delete_licnses(strip_tags($_REQUEST['id']));
}
//Fetch, prepare, sort, and filter our data...
$license_list->prepare_items();
//echo "put table of locked entries here";
?>
<form id="tables-filter" method="get" onSubmit="return confirm('Are you sure you want to perform this bulk operation on the selected entries?');">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
<!-- Now we can render the completed list table -->
<?php $license_list->display(); ?>
</form>

</div></div>
}
//Fetch, prepare, sort, and filter our data...
$license_list->prepare_items();
//echo "put table of locked entries here";
?>
<form id="tables-filter" method="get" onSubmit="return confirm('Are you sure you want to perform this bulk operation on the selected entries?');">
<!-- For plugins, we also need to ensure that the form posts back to our current page -->
<input type="hidden" name="page" value="<?php echo $_REQUEST['page']; ?>" />
<!-- Now we can render the completed list table -->
<?php $license_list->display(); ?>
</form>

</div></div>

<?php
echo '</div></div>';
Expand Down
227 changes: 112 additions & 115 deletions license-manager/menu/lic_mgr_integration_help_page.php
Original file line number Diff line number Diff line change
@@ -1,125 +1,122 @@
<?php
include_once('admin_includes1.php');

function lic_mgr_integration_help_menu()
{
if(!wp_lic_mgr_is_license_valid())
{
return; //Do not display the page if licese key is invalid
}
function lic_mgr_integration_help_menu() {
?>
<style type="text/css">
.lic_mgr_code{border:1px solid #C2D7EF; background-color:#E2EDFF; margin:10px 0; padding:10px; width:800px; font-family:"Consolas","Bitstream Vera Sans Mono","Courier New",Courier,monospace !important; font-size:13px;}
</style>
<?php
echo '<div class="wrap">';
echo '<div id="poststuff"><div id="post-body">';
lic_mgr_admin_general_css();
echo '<h2>WP License Manager Integration Help v'.WP_LICENSE_MANAGER_VERSION.'</h2>';

$LicenseCreationPostURL = WP_LICENSE_MANAGER_URL.'/api/create.php';
echo "<strong>The License Creation POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">'.$LicenseCreationPostURL.'</div>';
echo '<h2>WP License Manager Integration Help v' . WP_LICENSE_MANAGER_VERSION . '</h2>';

$LicenseVerificationPostURL = WP_LICENSE_MANAGER_URL.'/api/verify.php';
echo "<strong>The License Verification POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">'.$LicenseVerificationPostURL.'</div>';

$LicenseDeactivationPostURL = WP_LICENSE_MANAGER_URL.'/api/deactivate.php';
echo "<strong>The License Deactivation POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">'.$LicenseDeactivationPostURL.'</div>';
?>
<h2>3rd Party Integration</h2>
$LicenseCreationPostURL = WP_LICENSE_MANAGER_URL . '/api/create.php';
echo "<strong>The License Creation POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">' . $LicenseCreationPostURL . '</div>';

Integrating a 3rd party payment system or shopping cart with WP License Manager is possible.
<br /><br />
The integration process can be accomplished in three steps, namely:
<br />
<br />1. Generate POST data
<br />2. Send POST data to the POST URL
<br />3. Process the returned data
<br /><br />
<strong>POST Values</strong>
<br />
WP License Manager expects a certain set of variables to be sent to it via HTTP POST. These variables are:
<br /><br />
Mandatory Variables
<br />
----------------
<br />a. Secret Key: A Secret API key (you can find this value in the settings menu of this plugin)
<br /><br />
Optional Variables
<br />
---------------
<br />b. Customer First Name: The first name of the customer
<br />c. Customer Last Name: The last name of the customer
<br />d. Customer Email: The email address of the customer
<br />e. Company Name: The customer's company name
<br />f. Maximum Domains Allowed: The number of domains this license key can be used on
<br />g. Transaction ID: A unique transaction ID to reference the transaction
<br /><br />
<strong>Return Value</strong>
<br />
Upon successful processing, WP License Manager will return a plain text message that will have two or three lines similar to the following:
<br />
<div class="lic_mgr_code">
Success
<br />License key
<br />WPLICMGR4bc29fd61e471
</div>
or
<div class="lic_mgr_code">
Error
<br />Secret key is invalid
</div>
$LicenseVerificationPostURL = WP_LICENSE_MANAGER_URL . '/api/verify.php';
echo "<strong>The License Verification POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">' . $LicenseVerificationPostURL . '</div>';

1. The first line is an indication of success or error
<br />2. The second line is the result.
<br />3. The third line is additional message that resulted from the request.
<br /><br />
<strong>Sample PHP Code</strong>
<br />
Below is a sample PHP code that shows how easy it is to integrate with WP License Manager
<br />
$LicenseDeactivationPostURL = WP_LICENSE_MANAGER_URL . '/api/deactivate.php';
echo "<strong>The License Deactivation POST URL For Your Installation</strong>";
echo '<div class="lic_mgr_code">' . $LicenseDeactivationPostURL . '</div>';
?>
<h2>3rd Party Integration</h2>

<div class="lic_mgr_code">
/*** Mandatory data ***/
<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 />
<br />/*** Optional Data ***/
<br />$firstname = "John";
<br />$lastname = "Doe";
<br />$email = "john.doe@gmail.com";
<br />
<br />// prepare the data
<br />$data = array ();
<br />$data['secret_key'] = $secretKey;
<br />$data['source_file'] = $fileURL;
<br />$data['first_name'] = $firstname;
<br />$data['last_name'] = $lastname;
<br />$data['email'] = $email;
<br />
<br />// send data to post URL
<br />$ch = curl_init ($postURL);
<br />curl_setopt ($ch, CURLOPT_POST, true);
<br />curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
<br />curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
<br />$returnValue = curl_exec ($ch);
<br />
<br />// Process the return values
<br />list ($status, $msg, $additionalMsg) = explode ("\n", $returnValue);
<br />if(strpos($status,"Success") !== false)
<br />{
<br /> $license_key = trim($additionalMsg);
<br /> echo "The generated license key is: ".$license_key;
<br />}
<br />else
<br />{
<br /> echo "An error occured while trying to create license! Error details: ".$msg;
<br />}
</div>

<?php
Integrating a 3rd party payment system or shopping cart with WP License Manager is possible.
<br /><br />
The integration process can be accomplished in three steps, namely:
<br />
<br />1. Generate POST data
<br />2. Send POST data to the POST URL
<br />3. Process the returned data
<br /><br />
<strong>POST Values</strong>
<br />
WP License Manager expects a certain set of variables to be sent to it via HTTP POST. These variables are:
<br /><br />
Mandatory Variables
<br />
----------------
<br />a. Secret Key: A Secret API key (you can find this value in the settings menu of this plugin)
<br /><br />
Optional Variables
<br />
---------------
<br />b. Customer First Name: The first name of the customer
<br />c. Customer Last Name: The last name of the customer
<br />d. Customer Email: The email address of the customer
<br />e. Company Name: The customer's company name
<br />f. Maximum Domains Allowed: The number of domains this license key can be used on
<br />g. Transaction ID: A unique transaction ID to reference the transaction
<br /><br />
<strong>Return Value</strong>
<br />
Upon successful processing, WP License Manager will return a plain text message that will have two or three lines similar to the following:
<br />
<div class="lic_mgr_code">
Success
<br />License key
<br />WPLICMGR4bc29fd61e471
</div>
or
<div class="lic_mgr_code">
Error
<br />Secret key is invalid
</div>

1. The first line is an indication of success or error
<br />2. The second line is the result.
<br />3. The third line is additional message that resulted from the request.
<br /><br />
<strong>Sample PHP Code</strong>
<br />
Below is a sample PHP code that shows how easy it is to integrate with WP License Manager
<br />

<div class="lic_mgr_code">
/*** Mandatory data ***/
<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 />
<br />/*** Optional Data ***/
<br />$firstname = "John";
<br />$lastname = "Doe";
<br />$email = "john.doe@gmail.com";
<br />
<br />// prepare the data
<br />$data = array ();
<br />$data['secret_key'] = $secretKey;
<br />$data['source_file'] = $fileURL;
<br />$data['first_name'] = $firstname;
<br />$data['last_name'] = $lastname;
<br />$data['email'] = $email;
<br />
<br />// send data to post URL
<br />$ch = curl_init ($postURL);
<br />curl_setopt ($ch, CURLOPT_POST, true);
<br />curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
<br />curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
<br />$returnValue = curl_exec ($ch);
<br />
<br />// Process the return values
<br />list ($status, $msg, $additionalMsg) = explode ("\n", $returnValue);
<br />if(strpos($status,"Success") !== false)
<br />{
<br /> $license_key = trim($additionalMsg);
<br /> echo "The generated license key is: ".$license_key;
<br />}
<br />else
<br />{
<br /> echo "An error occured while trying to create license! Error details: ".$msg;
<br />}
</div>

<?php
echo '</div></div>';
echo '</div>';
echo '</div>';
}
?>
Loading

0 comments on commit 0334b82

Please sign in to comment.