/***********************************************************************/
/* */
/* This file is created by de-ionCube */
/* */
/* de-ionCube (Decoder for ionCube encoder): */
/* Version: 0.9.5.2 */
/* Author: qinvent.com */
/* Release on: 2006.6.22 */
/* */
/***********************************************************************/
class licensereader
{
var $crypt = NULL;
var $license_data = array ();
var $description = array ();
var $product = '';
var $crypt_key = '';
function licensereader ($props)
{
$this->crypt_key = $props['license_key'];
$this->product = $props['license_product'];
}
function is_valid ()
{
if ($this->_read_license () == false)
{
// echo 'Giay dang ky ko dung';
return fn_get_lang_var ('error_license_invalid');
}
if (!empty ($this->license_data['expiry']))
{
if ($this->license_data['expiry'] < time ())
{
return fn_get_lang_var ('error_license_expired');
}
}
if ($this->license_data['product'] != $this->product)
{
// echo '
License Product:'.$this->license_data['product'];
// echo '
The product:'.$this->product;
return fn_get_lang_var ('error_license_for_another_product');
}
if (strpos ($this->license_data['domains'], ',') !== false)
{
$domains = explode (',', $this->license_data['domains']);
}
else
{
$domains = array ($this->license_data['domains']);
}
$license_valid = false;
foreach ($domains as $domain)
{
$d = $this-> _get_hostname ($domain);
// echo '
'.$d;
if (strpos ($_SERVER['HTTP_HOST'], $d) !== false)
{
$license_valid = true;
continue;
}
}
if ($license_valid == false)
{
return fn_get_lang_var ('error_license_for_another_domain');
}
return true;
}
function get_field ($field)
{
return (isset ($this->license_data[$field]) ? $this->license_data[$field] : false);
}
function _read_license ()
{
global $kjccart_dir;
if (file_exists ($kjccart_dir . DS . 'LICENSE'))
{
$fd = fopen ($kjccart_dir . DS . 'LICENSE', 'r');
if ($fd)
{
$code_started = false;
$license_code = '';
while (!feof ($fd))
{
$line = fgets ($fd);
if (preg_match ('/\\[(\\w*)\\] (.*)/i', $line, $matches))
{
$this->description[$matches[1]] = $matches[2];
}
if (trim ($line) == '------ LICENSE FILE DATA -------')
{
$code_started = true;
continue;
}
if (trim ($line) == '--------------------------------')
{
$code_started = false;
continue;
}
if ($code_started == true)
{
$license_code .= $line;
continue;
}
}
// echo '
Hien thi License code:
'.$license_code;//hien thi License code.
if (!empty ($license_code))
{
return $this->_parse_license_code ($license_code);
}
fclose ($fd);
}
}
return false;
}
function _init_crypt ()
{
global $classes_dir;
if (!class_exists ('Crypt_Blowfish'))
{
if (!include $classes_dir . 'crypt' . DS . 'Blowfish.php')
{
return false;
}
}
$this->crypt = new Crypt_Blowfish ($this->crypt_key);
// echo '
OK';
$encrypted = $this->crypt->encrypt('product=KJC-Cart+Encoded&license=KJCCART-SOQ9-8260-M691-V287&domains=vitinhtrongtin.com,+localhost');
// echo '$encrypted of :'.$encrypted;
$truelicense = base64_encode($encrypted);
// echo '
$truelicense of :'.$truelicense.'
';
return true;
}
function _parse_license_code ($license_code)
{
if (!is_object ($this->crypt))
{
$this->_init_crypt ();
}
// echo '
base64:'.base64_decode ($license_code);
$decrypted = $this->crypt->decrypt (base64_decode ($license_code));
// echo '
Decrypted:'.$decrypted;
$this->crypt = NULL;
if (!empty ($decrypted))
{
// echo 'Again $decrypted: '.$decrypted;
parse_str ($decrypted, $this->license_data);
// echo '
Check parse_str to $this->license_data: ';
// var_dump ($this->license_data);
if (!empty ($this->license_data['product']))
{
return true;
}
}
return false;
}
function _get_hostname ($host)
{
$arr = explode ('.', trim ($host));
// echo '
host name';
// var_dump ($arr);
if ($arr[0] == 'www')
{
unset ($arr[0]);
}
$arr = array_reverse ($arr);
foreach ($arr as $k => $v)
{
if ((strlen ($v) <= 3 AND 2 <= count ($arr)))
{
unset ($arr[$k]);
continue;
}
}
return array_shift ($arr);
}
}
function fn_check_license ($props)
{
static $checked = false;
if (empty ($props))
{
exit ('Unknown file');
}
if (($props['license_type'] == 'COMMERCIAL' AND $checked == false))
{
$checked = true;
$lic = new LicenseReader ($props);
$result = $lic->is_valid ();
unset ($lic);
if ($result !== true)
{
if (AREA == 'A')
{
fn_set_notification ('W', fn_get_lang_var ('warning'), $result, false, true);
return null;
}
exit ($result);
}
}
}
if (!defined ('IN_KJCCART'))
{
exit ('Access denied');
}
?>