Example integration codes with Licensing module

Integration with Licensing module is super easy. Simply use the sample codes as below

//make changes as required below
require_once __DIR__ . '/trackurlyLicenseClass.php';
define('API_URL', 'http://example.trackurly.com/licensing/api');
define('CACHE_DIR', __DIR__ . '/cache');
//or define('CACHE_DIR','/home/user/public_html/licenseserver/cache');
define('KEYFILENAME','key.txt');
define('CACHEDKEYFILENAME','cachedkey.txt');
//above 3 files and folders must be writable 777 or 666 
define('LICENSE_KEY','kjhdjkahjd-8787-mykey');





/* CONFIGURATION ENDS. No changes below required. Skip to last line to write your protected codes */
/* You can manullay force recheck of license key remotely by appending ?remote_ping_key=1 in installation url of software(works for web based accessible apps only) */





 
$license_key = LICENSE_KEY;
if (!is_writeable($fn = CACHE_DIR . '/'.KEYFILENAME))
    exit("Please chmod file [$fn] to 666");
if (!is_writeable($fn = CACHE_DIR . '/'.CACHEDKEYFILENAME))
    exit("Please chmod file [$fn] to 666");
 
function pingSaveLicenseKey($license_key){
	if($license_key=='')
	   die("NO License key entered. Please configure tha value of license key.");
	   else
	 $license_key = preg_replace('/[^A-Za-z0-9-_]/', '', trim($license_keys));   
	 $licensechecker = new Track_LicenseChecker($license_key, API_URL);
	
    if (!$licensechecker->checkLicenseKey()) // license key not confirmed by remote server
    {
         die("Invalid license");
		 
    } else { // license key verified! save it into the file
        file_put_contents(CACHE_DIR . '/'.KEYFILENAME, $license_key);
        return $license_key;
    }
	
}
 
$license_key = trim(file_get_contents(CACHE_DIR . '/'.KEYFILENAME));
if (!strlen($license_key) or isset($_GET['remote_ping_key'])) 
 
{
    $license_key = pingSaveLicenseKey($license_key);
}
 
$licensestatuscache = trim(file_get_contents(CACHE_DIR . '/'.CACHEDKEYFILENAME));
$prev_licensestatuscache = $licensestatuscache;  
$licensechecker = new Track_LicenseChecker($license_key, API_URL);
$results = empty($licensestatuscache) ?
           $licensechecker->activate($licensestatuscache) :  
           $licensechecker->checkActivation($licensestatuscache);  
 
if ($prev_licensestatuscache != $licensestatuscache)
    file_put_contents(CACHE_DIR . '/'.CACHEDKEYFILENAME, $licensestatuscache);

if (!$results)
    exit("Activation failed: (" . $licensechecker->getCode() . ') ' . $licensechecker->getMessage());
 
 










 
/* 
          SUCCESS


    If it reached here , it means everything is ok
    Write your own codes now
	Do not forget to encrypt the above codes and class file trackurlyLicenseClass.php
	Make sure you have changed the value of $_local_encryption_key = "SOMEUNIQUEKEY" 
	We recommend Ioncube loaders for encrypting.
	Dont rely on base64 encodes, NEVER EVER! 
	
*/	
// You may write your protected codes from here 
echo "I am here because I have an active license key";

A descriptive version with well commented can be downloaded from Licensing-ExampleApp

—— This feature is available in Pro Plan only ——

Leave A Comment?