public function __construct($flagActivatePlugins = true) { G::LoadClass('serverConfiguration'); $oServerConf =& serverConf::getSingleton(); $oServerConf->setProperty('LOGIN_NO_WS', true); //to do: this files probably needs to be in core, since they are GPL2 //include_once (PATH_PLUGINS . 'enterprise' . PATH_SEP . 'classes' . PATH_SEP . 'class.license.lib.php'); //include_once (PATH_PLUGINS . 'enterprise' . PATH_SEP . 'classes' . PATH_SEP . 'class.license.app.php'); require_once PATH_CORE . 'classes' . PATH_SEP . 'class.license.lib.php'; require_once PATH_CORE . 'classes' . PATH_SEP . 'class.license.app.php'; //searching .dat files in workspace folder $server_array = $_SERVER; $licfile = glob(PATH_DATA_SITE . "*.dat"); if (count($licfile) > 0 && is_file($licfile[0])) { $oServerConf->setProperty('ACTIVE_LICENSE', array(SYS_SYS => "")); } $activeLicenseSetting = $oServerConf->getProperty('ACTIVE_LICENSE'); if (isset($activeLicenseSetting[SYS_SYS]) && file_exists($activeLicenseSetting[SYS_SYS])) { $licenseFile = $activeLicenseSetting[SYS_SYS]; } else { $activeLicense = $this->getActiveLicense(); $oServerConf->setProperty('ACTIVE_LICENSE', array(SYS_SYS => $activeLicense['LICENSE_PATH'])); $licenseFile = $activeLicense['LICENSE_PATH']; } $application = new license_application($licenseFile, false, true, false, true); $application->set_server_vars($server_array); $application->DATE_STRING = 'Y-m-d H:i:s'; $results = $application->validate(); $validStatus = array('OK', 'EXPIRED', 'TMINUS'); $this->result = $results['RESULT']; $this->features = array(); $this->licensedfeatures = array(); $this->licensedfeaturesList = array(); if (in_array($this->result, $validStatus)) { $this->serial = "3ptta7Xko2prrptrZnSd356aqmPXvMrayNPFj6CLdaR1pWtrW6qPw9jV0OHjxrDGu8LVxtmSm9nP5kR23HRpdZWccpeui+bKkK°DoqCt2Kqgpq6Vg37s"; $info['FIRST_NAME'] = $results['DATA']['FIRST_NAME']; $info['LAST_NAME'] = $results['DATA']['LAST_NAME']; $info['DOMAIN_WORKSPACE'] = $results['DATA']['DOMAIN_WORKSPACE']; $this->date = $results['DATE']; $this->info = $info; $this->type = $results['DATA']['TYPE']; $this->plan = isset($results['DATA']['PLAN']) ? $results['DATA']['PLAN'] : ""; $this->id = $results['ID']; $this->expireIn = $this->getExpireIn(); $this->features = $this->result != 'TMINUS' ? isset($results['DATA']['CUSTOMER_PLUGIN']) ? $results['DATA']['CUSTOMER_PLUGIN'] : $this->getActiveFeatures() : array(); $this->licensedfeatures = $this->result != 'TMINUS' ? isset($results['DATA']['CUSTOMER_LICENSED_FEATURES']) ? $results['DATA']['CUSTOMER_LICENSED_FEATURES'] : array() : array(); $this->licensedfeaturesList = isset($results['DATA']['LICENSED_FEATURES_LIST']) ? $results['DATA']['LICENSED_FEATURES_LIST'] : null; $this->status = $this->getCurrentLicenseStatus(); if (isset($results['LIC'])) { $resultsRegister = $results['LIC']; $this->server = $results['LIC']['SRV']; $this->file = $results['LIC']['FILE']; $this->workspace = isset($results['LIC']['WORKSPACE']) ? $results['LIC']['WORKSPACE'] : 'pmLicenseSrv'; $this->licenseSerial = isset($results['LIC']['SERIAL']) ? $results['LIC']['SERIAL'] : ''; $this->supportStartDate = isset($results['DATA']['SUPPORT_START_DATE']) ? $results['DATA']['SUPPORT_START_DATE'] : ''; $this->supportEndDate = isset($results['DATA']['SUPPORT_END_DATE']) ? $results['DATA']['SUPPORT_END_DATE'] : ''; $this->supportStartDate = date("Y-m-d H:i:s", strtotime($this->supportStartDate)); $this->supportEndDate = date("Y-m-d H:i:s", strtotime($this->supportEndDate)); G::LoadClass("configuration"); $conf = new Configurations(); if (defined('SYS_SYS') && $conf->exists("ENVIRONMENT_SETTINGS")) { $this->supportStartDate = $conf->getSystemDate($this->supportStartDate); $this->supportEndDate = $conf->getSystemDate($this->supportEndDate); } else { $this->supportStartDate = G::getformatedDate($this->supportStartDate, 'M d, yyyy', SYS_LANG); $this->supportEndDate = G::getformatedDate($this->supportEndDate, 'M d, yyyy', SYS_LANG); } } else { $resultsRegister = array(); $resultsRegister['ID'] = $results['DATA']['DOMAIN_WORKSPACE']; $this->server = null; $this->file = null; } $resultsRegister['date'] = $results['DATE']; $resultsRegister['info'] = $info; $resultsRegister['type'] = $results['DATA']['TYPE']; if ($oServerConf->getProperty('LICENSE_INFO')) { $licInfoA = $oServerConf->getProperty('LICENSE_INFO'); } else { $licInfoA = array(); } $licInfoA[SYS_SYS] = $resultsRegister; $oServerConf->setProperty('LICENSE_INFO', $licInfoA); } if ($flagActivatePlugins) { $this->activateFeatures(); } }
echo '</span>' . "\r\n"; # import the classes include_once '../shared/class.license.lib.php'; include_once 'class.license.app.php'; # initialise the class # note for this demonstration script we will turn off mcrypt usage # as some systems do not have it installed in their setup. # the initial argument usually defaults to true (use mcrypt) $application = new license_application('license.supplied.dat', false, true, true, true); # set the server vars # note this doesn't have to be set, however if not all of your app files are encoded # then there would be a possibility that the end user could modify the server vars # to fit the key thus making it possible to use your app on any domain # you should copy your server vars in the first line of your active script so you can # use the unmodified copy of the vars $application->set_server_vars($server_array); # the set key is the key validated for my server, when run on your box it will be illegal $set_data = $application->validate(); echo '<b>########################################################################</b><br />' . "\r\n"; echo '<b>Set License Key Validation Example</b><br />' . "\r\n"; echo 'The <a href="license.supplied.dat" target="_blank" class="bodylink">license.supplied.dat</a> file is evaluated. If it is unwriteable the license returns with an error. It has also<br />' . "\r\n"; echo 'been validated for my server so when run on your box it will be return as illegal<br />' . "\r\n"; echo '<span style="font-size: 10;">' . "\r\n"; echo 'You should also note that even though the key is contains date restrictions the date binding<br />' . "\r\n"; echo 'was turned off when the class was inited.<br />' . "\r\n"; echo '</span>' . "\r\n"; echo '<b>########################################################################</b><br /><br />' . "\r\n"; echo '<span style="color: #F00"><b>Supplied License is : ' . $set_data['RESULT'] . '</b><br />'; if ($set_data['RESULT'] == 'OK') { echo '<span style="font-size: 10;">' . "\r\n"; echo 'Key is valid untill : ' . $set_data['DATE']['HUMAN']['END'];