Index: trunk/admin/install.php
===================================================================
diff -u -N -r4566 -r4590
--- trunk/admin/install.php (.../install.php) (revision 4566)
+++ trunk/admin/install.php (.../install.php) (revision 4590)
@@ -705,7 +705,7 @@
$objThemes->CreateMissingThemes(false);
- $css_hash = $application->DB->GetCol('SELECT LOWER(Name) AS Name, StylesheetId FROM '.TABLE_PREFIX.'Stylesheets', 'StylesheetId');
+ $css_hash = $application->Conn->GetCol('SELECT LOWER(Name) AS Name, StylesheetId FROM '.TABLE_PREFIX.'Stylesheets', 'StylesheetId');
$application->setUnitOption('css', 'AutoLoad', false);
$css_table = $application->getUnitOption('css','TableName');
@@ -720,7 +720,7 @@
$css_item =& $application->recallObject('css');
$css_item->Load($stylesheet_id);
$css_item->Compile();
- $application->DB->Query( sprintf($theme_update_sql, $stylesheet_id, $application->DB->qstr( getArrayValue($css_hash,$stylesheet_id) ) ) );
+ $application->Conn->Query( sprintf($theme_update_sql, $stylesheet_id, $application->Conn->qstr( getArrayValue($css_hash,$stylesheet_id) ) ) );
}
// do redirect, because upgrade scripts can eat a lot or memory used for language pack upgrade operation
Index: trunk/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php
===================================================================
diff -u -N -r3585 -r4590
--- trunk/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php (.../commands.php) (revision 3585)
+++ trunk/admin/editor/cmseditor/editor/filemanager/browser/default/connectors/php/commands.php (.../commands.php) (revision 4590)
@@ -88,7 +88,7 @@
$application->Init();
$query = 'SELECT Path, Title FROM '.TABLE_PREFIX.'Pages ORDER By Title';
- $pages = $application->DB->Query($query);
+ $pages = $application->Conn->Query($query);
$res = '';
foreach ($pages as $page) {
Index: trunk/kernel/units/general/helpers/modules.php
===================================================================
diff -u -N -r4490 -r4590
--- trunk/kernel/units/general/helpers/modules.php (.../modules.php) (revision 4490)
+++ trunk/kernel/units/general/helpers/modules.php (.../modules.php) (revision 4590)
@@ -4,7 +4,7 @@
function checkLogin()
{
- return $this->_ValidateModules();
+ return $this->_GetModules();
}
function _EnableCookieSID()
@@ -29,28 +29,6 @@
return in_array($UserAgent, $robots);
}
- function _StripDomainHost($d)
- {
- $dotcount = substr_count($d, '.');
- if ($dotcount == 3) {
- $IsIp = TRUE;
- for ($x = 0; $x < strlen($d); $x++) {
- if (!is_numeric(substr($d, $x, 1)) && substr($d, $x, 1) != '.') {
- $IsIp = FALSE;
- break;
- }
- }
- }
- if ($dotcount > 1 && !$IsIp) {
- $p = explode('.', $d);
- $ret = $p[count($p)-2].'.'.$p[count($p)-1];
- }
- else {
- $ret = $d;
- }
- return $ret;
- }
-
function _MatchIp($ip1, $ip2)
{
$matched = TRUE;
@@ -94,205 +72,169 @@
return $Result;
}
- function _ValidateModules()
- {
- global $i_Keys, $g_License;
-
- $this->_readConfig();
-
- $lic = base64_decode($g_License);
- $this->_ParseLicense($lic);
-
- $modules = array();
- //echo "License: ".$lic."
";
- $domain = $this->_GetDomain();
- //echo "Domain: ".$domain."
";
- if(!$this->_IsLocalSite($domain))
- {
- $domain = $this->_StripDomainHost($domain);
- //echo "New domain: $domain
";
- // echo "
"; print_r($i_Keys); echo "
";
- for($x=0;$x0)
- {
- return TRUE;
- }
- }
- else
- return TRUE;
- return FALSE;
- }
-
+ /**
+ * Reads config.php file and parses it
+ *
+ */
function _readConfig()
{
- static $config_read = false;
- if (!$config_read) {
- $vars = parse_portal_ini(FULL_PATH.'/config.php');
-
- foreach ($vars as $config_key => $config_value) {
- $GLOBALS['g_'.$config_key] = $config_value;
- }
- $config_read = true;
+ $vars = parse_portal_ini(FULL_PATH.'/config.php');
+
+ foreach ($vars as $config_key => $config_value) {
+ $GLOBALS['g_'.$config_key] = $config_value;
}
}
- function _ModuleLicensed($name)
+ /**
+ * Returns modules list, that are in license
+ *
+ * @return Array
+ */
+ function _GetModules()
{
- global $i_Keys;
-
- $this->_readConfig();
+ global $i_Keys;
+ static $modules = null;
- $lic = base64_decode($GLOBALS['g_License']);
-
- $this->_ParseLicense($lic);
- $modules = array();
- if(!$this->_IsLocalSite($this->_GetDomain()))
- {
- for($x=0;$x_readConfig();
+ $license = base64_decode($GLOBALS['g_License']);
+ $this->_ParseLicense($license);
+
+ $modules = Array();
+ $domain = $this->_GetDomain();
+ if (!$this->_IsLocalSite($domain)) {
+ for ($x = 0; $x < count($i_Keys); $x++) {
$key = $i_Keys[$x];
- if(strlen(stristr($this->_GetDomain(),$key["domain"])))
- {
- //echo "ok
";
- $modules = explode(",",$key["mod"]);
+ if (preg_match('/(.*)'.preg_quote($key['domain'], '/').'$/', $domain)) {
+ // used hostname is subdomain or matches domain from license
+ $modules = explode(',', $key['mod']);
}
}
- //print_pre($modules);
- if(in_array($name,$modules)) {
- //echo "ok
";
- return TRUE;
- }
}
else {
- return TRUE;
+ $modules = array_keys($this->Application->ModuleInfo);
}
- return FALSE;
+ return $modules;
}
- function _GetDomain()
+ /**
+ * Allows to determine if module is licensed
+ *
+ * @param string $name
+ * @return bool
+ */
+ function _ModuleLicensed($name)
{
- global $g_Domain;
+ $modules = $this->_GetModules();
+ return in_array($name, $modules);
+ }
- if ($this->Application->ConfigValue('DomainDetect')) {
- $d = $_SERVER['HTTP_HOST'];
- }
- else {
- $d = $g_Domain;
- }
- return $d;
+ /**
+ * Returns domain from licences (and direct in case of install script)
+ *
+ * @return string
+ */
+ function _GetDomain()
+ {
+ return $this->Application->ConfigValue('DomainDetect') ? $_SERVER['HTTP_HOST'] : $GLOBALS['g_Domain'];
}
- function _keyED($txt,$encrypt_key)
+ function _keyED($txt, $encrypt_key)
{
- $encrypt_key = md5($encrypt_key);
- $ctr=0;
- $tmp = "";
- for ($i=0;$i_keyED($txt,$key);
- $tmp = "";
- for ($i=0;$i_keyED($txt,$key);
+ $tmp = '';
+ for ($i = 0; $i < strlen($txt); $i++) {
+ $md5 = substr($txt, $i, 1);
+ $i++;
+ $tmp .= (substr($txt, $i, 1) ^ $md5);
+ }
+ return $tmp;
}
function LoadFromRemote()
{
- return "";
+ return '';
}
function DLid()
{
- global $lid;
- echo $lid."\n";
- die();
+ die($GLOBALS['lid']."\n");
}
- function _LoadLicense($LoadRemote=FALSE)
+ function _LoadLicense($LoadRemote = false)
{
$f = FULL_PATH.'/intechnic.php';
if ($this->_falseIsLocalSite($f)) $ret = true;
- if(file_exists($f))
- {
+ if (file_exists($f)) {
$contents = file($f);
$data = base64_decode($contents[1]);
}
- else
- if($LoadRemote)
- return $LoadFromRemote;
+ else {
+ if ($LoadRemote) return $LoadFromRemote;
+ }
return $data;
}
- function _VerifyKey($domain,$k)
+ function _VerifyKey($domain, $k)
{
$key = md5($domain);
- $lkey = substr($key,0,strlen($key)/2);
- $rkey = substr($key,strlen($key)/2);
+ $lkey = substr($key, 0, strlen($key) / 2);
+ $rkey = substr($key, strlen($key) / 2);
$r = $rkey.$lkey;
- if($k==$r)
- return TRUE;
- return FALSE;
+ if ($k == $r) return true;
+ return false;
}
function _ParseLicense($txt)
{
- global $i_User, $i_Pswd, $i_Keys;
+ global $i_User, $i_Pswd, $i_Keys;
if (!$this->_falseIsLocalSite($txt)) $nah = false;
- $data = $this->_decrypt($txt,"beagle");
- $i_Keys = array();
- $lines = explode("\n",$data);
- for($x=0;$x_VerifyKey($parts[0],$parts[1]))
- {
- unset($K);
- $k["domain"]=$parts[0];
- $k["key"]=$parts[1];
- $k["desc"]=$parts[2];
- $k["mod"]=$parts[3];
- $i_Keys[] = $k;
- }
- }
- break;
- }
- }
+ $data = $this->_decrypt($txt, 'beagle');
+ $i_Keys = Array();
+ $lines = explode("\n", $data);
+ for ($x = 0; $x < count($lines); $x++) {
+ $l = $lines[$x];
+ $p = explode('=', $l, 2);
+ switch($p[0]) {
+ case 'Username':
+ $i_User = $p[1];
+ break;
+
+ case 'UserPass':
+ $i_Pswd = $p[1];
+ break;
+
+ default:
+ if (substr($p[0], 0, 3) == 'key') {
+ $parts = explode('|', $p[1]);
+ if ($this->_VerifyKey($parts[0], $parts[1])) {
+ unset($K);
+ $k['domain'] = $parts[0];
+ $k['key'] = $parts[1];
+ $k['desc'] = $parts[2];
+ $k['mod'] = $parts[3];
+ $i_Keys[] = $k;
+ }
+ }
+ break;
+ }
+ }
}
function _GetObscureValue($i)
Index: trunk/core/kernel/application.php
===================================================================
diff -u -N -r4576 -r4590
--- trunk/core/kernel/application.php (.../application.php) (revision 4576)
+++ trunk/core/kernel/application.php (.../application.php) (revision 4590)
@@ -85,13 +85,20 @@
var $ModuleInfo = Array();
/**
- * Holds DBConnection
+ * Holds DBConnection (depricated, use Conn instead)
*
* @var kDBConnection
*/
var $DB;
/**
+ * Holds DBConnection
+ *
+ * @var kDBConnection
+ */
+ var $Conn = null;
+
+ /**
* Maintains list of user-defined error handlers
*
* @var Array
@@ -187,22 +194,24 @@
if($error_handler) $this->errorHandlers[] = $error_handler;
}
- $this->DB = new kDBConnection(SQL_TYPE, Array(&$this,'handleSQLError') );
- $this->DB->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB);
- $this->DB->debugMode = $this->isDebugMode();
+ $this->Conn = new kDBConnection(SQL_TYPE, Array(&$this, 'handleSQLError') );
+ $this->Conn->Connect(SQL_SERVER, SQL_USER, SQL_PASS, SQL_DB);
+ $this->Conn->debugMode = $this->isDebugMode();
- $this->refreshModuleInfo();
- $this->ConfigHash = $this->DB->GetCol('SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'ConfigurationValues', 'VariableName');
+// $this->DB =& $this->Conn; // for backwards compatibility
+
+ $this->ConfigHash = $this->Conn->GetCol('SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'ConfigurationValues', 'VariableName');
$rewrite_on = $this->ConfigValue('UseModRewrite');
$admin_on = getArrayValue($_REQUEST, 'admin') || $this->IsAdmin();
define('MOD_REWRITE', $rewrite_on && !$admin_on ? 1 : 0);
$this->Factory = new kFactory();
-
+
$this->registerDefaultClasses();
+ $this->refreshModuleInfo();
$this->SetDefaultConstants();
-
+
// 1. to read configs before doing any recallObject (called from "SetDefaultConstants" anyway)
$config_reader =& $this->recallObject('kUnitConfigReader');
@@ -242,7 +251,27 @@
function refreshModuleInfo()
{
- $this->ModuleInfo = $this->DB->Query('SELECT * FROM '.TABLE_PREFIX.'Modules ORDER BY LoadOrder', 'Name');
+ $where_clause = Array('Loaded = 1');
+
+ // admin only: filter licensed modules
+ if ($this->IsAdmin()) {
+ $modules_helper =& $this->recallObject('ModulesHelper');
+ $modules = $modules_helper->checkLogin();
+ if ($modules) {
+ foreach ($modules as $module_index => $module) {
+ $modules[$module_index] = $this->Conn->qstr($module);
+ }
+ $where_clause[] = 'Name IN ('.implode(',', $modules).')';
+ }
+ }
+
+ // front and admin: filter enabled modules
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'Modules
+ WHERE '.implode(' AND ', $where_clause).'
+ ORDER BY LoadOrder';
+
+ $this->ModuleInfo = $this->Conn->Query($sql, 'Name');
}
/**
@@ -258,7 +287,7 @@
$sql = 'SELECT '.$id_field.'
FROM '.$table.'
WHERE Enabled = 1';
- $language_ids = $this->DB->GetCol($sql);
+ $language_ids = $this->Conn->GetCol($sql);
}
if (!$language_id || !in_array($language_id, $language_ids)) {
@@ -280,7 +309,7 @@
$sql = 'SELECT '.$id_field.'
FROM '.$table.'
WHERE Enabled = 1';
- $theme_ids = $this->DB->GetCol($sql);
+ $theme_ids = $this->Conn->GetCol($sql);
}
if (!$theme_id || !in_array($theme_id, $theme_ids)) {
@@ -300,7 +329,7 @@
$sql = 'SELECT '.$id_field.'
FROM '.$table.'
WHERE (PrimaryLang = 1) AND (Enabled = 1)';
- $language_id = $this->DB->GetOne($sql);
+ $language_id = $this->Conn->GetOne($sql);
return $language_id;
}
@@ -320,7 +349,7 @@
$sql = 'SELECT '.$id_field.'
FROM '.$table.'
WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
- $theme_id = $this->DB->GetOne($sql);
+ $theme_id = $this->Conn->GetOne($sql);
}
return $theme_id;
}
@@ -329,7 +358,7 @@
{
if ($this->isModuleEnabled('In-Commerce')) {
$table = $this->getUnitOption('curr', 'TableName');
- return $this->DB->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
+ return $this->Conn->GetOne('SELECT ISO FROM '.$table.' WHERE IsPrimary = 1');
}
else {
return 'USD';
@@ -423,17 +452,17 @@
// this allows to save 2 sql queries for each category
$sql = 'SELECT NamedParentPath, CachedCategoryTemplate, CachedItemTemplate
FROM '.$table.'
- WHERE '.$id_field.' = '.$this->DB->qstr($id);
- $category_data = $this->DB->GetRow($sql);
+ WHERE '.$id_field.' = '.$this->Conn->qstr($id);
+ $category_data = $this->Conn->GetRow($sql);
$filename = $category_data['NamedParentPath'];
$this->setCache('category_templates', $id, $category_data['CachedCategoryTemplate']);
$this->setCache('item_templates', $id, $category_data['CachedItemTemplate']);
}
else {
$sql = 'SELECT Filename
FROM '.$table.'
- WHERE '.$id_field.' = '.$this->DB->qstr($id);
- $filename = $this->DB->GetOne($sql);
+ WHERE '.$id_field.' = '.$this->Conn->qstr($id);
+ $filename = $this->Conn->GetOne($sql);
}
$this->setCache('filenames', $prefix.'_'.$id, $filename);
}
@@ -611,7 +640,7 @@
/*if (constOn('EXPERIMENTAL_PRE_PARSE')) {
$data = serialize($this->PreParsedCache);
- $this->DB->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->DB->qstr($data).', '.adodb_mktime().')');
+ $this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("blocks_cache", '.$this->Conn->qstr($data).', '.adodb_mktime().')');
}*/
}
@@ -819,7 +848,7 @@
*/
function &GetADODBConnection()
{
- return $this->DB;
+ return $this->Conn;
}
function ParseBlock($params,$pass_params=0,$as_template=false)
@@ -1319,7 +1348,6 @@
function ConfigValue($name)
{
return getArrayValue($this->ConfigHash, $name);
-// return $this->DB->GetOne('SELECT VariableValue FROM '.TABLE_PREFIX.'ConfigurationValues WHERE VariableName = '.$this->DB->qstr($name) );
}
/**
@@ -1684,15 +1712,15 @@
{
$table_name = TABLE_PREFIX.'IdGenerator';
- $this->DB->Query('LOCK TABLES '.$table_name.' WRITE');
- $this->DB->Query('UPDATE '.$table_name.' SET lastid = lastid + 1');
- $id = $this->DB->GetOne('SELECT lastid FROM '.$table_name);
+ $this->Conn->Query('LOCK TABLES '.$table_name.' WRITE');
+ $this->Conn->Query('UPDATE '.$table_name.' SET lastid = lastid + 1');
+ $id = $this->Conn->GetOne('SELECT lastid FROM '.$table_name);
if($id === false)
{
- $this->DB->Query('INSERT INTO '.$table_name.' (lastid) VALUES (2)');
+ $this->Conn->Query('INSERT INTO '.$table_name.' (lastid) VALUES (2)');
$id = 2;
}
- $this->DB->Query('UNLOCK TABLES');
+ $this->Conn->Query('UNLOCK TABLES');
return $id - 1;
}
@@ -1764,7 +1792,7 @@
}
else {
$sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id;
- $cat_hierarchy = $this->DB->GetOne($sql);
+ $cat_hierarchy = $this->Conn->GetOne($sql);
$cat_hierarchy = explode('|', $cat_hierarchy);
array_shift($cat_hierarchy);
array_pop($cat_hierarchy);
@@ -1779,7 +1807,7 @@
WHERE Permission = "'.$name.'"
AND CatId = '.$category_id.'
AND GroupId IN ('.$groups.')';
- $res = $this->DB->GetOne($sql);
+ $res = $this->Conn->GetOne($sql);
if ($res !== false) {
return $res;
}
@@ -1819,7 +1847,7 @@
*/
function isModuleEnabled($module_name)
{
- return $this->findModule('Name', $module_name, 'Loaded');
+ return $this->findModule('Name', $module_name);
}
Index: trunk/core/units/general/helpers/modules.php
===================================================================
diff -u -N -r4490 -r4590
--- trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4490)
+++ trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4590)
@@ -4,7 +4,7 @@
function checkLogin()
{
- return $this->_ValidateModules();
+ return $this->_GetModules();
}
function _EnableCookieSID()
@@ -29,28 +29,6 @@
return in_array($UserAgent, $robots);
}
- function _StripDomainHost($d)
- {
- $dotcount = substr_count($d, '.');
- if ($dotcount == 3) {
- $IsIp = TRUE;
- for ($x = 0; $x < strlen($d); $x++) {
- if (!is_numeric(substr($d, $x, 1)) && substr($d, $x, 1) != '.') {
- $IsIp = FALSE;
- break;
- }
- }
- }
- if ($dotcount > 1 && !$IsIp) {
- $p = explode('.', $d);
- $ret = $p[count($p)-2].'.'.$p[count($p)-1];
- }
- else {
- $ret = $d;
- }
- return $ret;
- }
-
function _MatchIp($ip1, $ip2)
{
$matched = TRUE;
@@ -94,205 +72,169 @@
return $Result;
}
- function _ValidateModules()
- {
- global $i_Keys, $g_License;
-
- $this->_readConfig();
-
- $lic = base64_decode($g_License);
- $this->_ParseLicense($lic);
-
- $modules = array();
- //echo "License: ".$lic."
";
- $domain = $this->_GetDomain();
- //echo "Domain: ".$domain."
";
- if(!$this->_IsLocalSite($domain))
- {
- $domain = $this->_StripDomainHost($domain);
- //echo "New domain: $domain
";
- // echo ""; print_r($i_Keys); echo "
";
- for($x=0;$x0)
- {
- return TRUE;
- }
- }
- else
- return TRUE;
- return FALSE;
- }
-
+ /**
+ * Reads config.php file and parses it
+ *
+ */
function _readConfig()
{
- static $config_read = false;
- if (!$config_read) {
- $vars = parse_portal_ini(FULL_PATH.'/config.php');
-
- foreach ($vars as $config_key => $config_value) {
- $GLOBALS['g_'.$config_key] = $config_value;
- }
- $config_read = true;
+ $vars = parse_portal_ini(FULL_PATH.'/config.php');
+
+ foreach ($vars as $config_key => $config_value) {
+ $GLOBALS['g_'.$config_key] = $config_value;
}
}
- function _ModuleLicensed($name)
+ /**
+ * Returns modules list, that are in license
+ *
+ * @return Array
+ */
+ function _GetModules()
{
- global $i_Keys;
-
- $this->_readConfig();
+ global $i_Keys;
+ static $modules = null;
- $lic = base64_decode($GLOBALS['g_License']);
-
- $this->_ParseLicense($lic);
- $modules = array();
- if(!$this->_IsLocalSite($this->_GetDomain()))
- {
- for($x=0;$x_readConfig();
+ $license = base64_decode($GLOBALS['g_License']);
+ $this->_ParseLicense($license);
+
+ $modules = Array();
+ $domain = $this->_GetDomain();
+ if (!$this->_IsLocalSite($domain)) {
+ for ($x = 0; $x < count($i_Keys); $x++) {
$key = $i_Keys[$x];
- if(strlen(stristr($this->_GetDomain(),$key["domain"])))
- {
- //echo "ok
";
- $modules = explode(",",$key["mod"]);
+ if (preg_match('/(.*)'.preg_quote($key['domain'], '/').'$/', $domain)) {
+ // used hostname is subdomain or matches domain from license
+ $modules = explode(',', $key['mod']);
}
}
- //print_pre($modules);
- if(in_array($name,$modules)) {
- //echo "ok
";
- return TRUE;
- }
}
else {
- return TRUE;
+ $modules = array_keys($this->Application->ModuleInfo);
}
- return FALSE;
+ return $modules;
}
- function _GetDomain()
+ /**
+ * Allows to determine if module is licensed
+ *
+ * @param string $name
+ * @return bool
+ */
+ function _ModuleLicensed($name)
{
- global $g_Domain;
+ $modules = $this->_GetModules();
+ return in_array($name, $modules);
+ }
- if ($this->Application->ConfigValue('DomainDetect')) {
- $d = $_SERVER['HTTP_HOST'];
- }
- else {
- $d = $g_Domain;
- }
- return $d;
+ /**
+ * Returns domain from licences (and direct in case of install script)
+ *
+ * @return string
+ */
+ function _GetDomain()
+ {
+ return $this->Application->ConfigValue('DomainDetect') ? $_SERVER['HTTP_HOST'] : $GLOBALS['g_Domain'];
}
- function _keyED($txt,$encrypt_key)
+ function _keyED($txt, $encrypt_key)
{
- $encrypt_key = md5($encrypt_key);
- $ctr=0;
- $tmp = "";
- for ($i=0;$i_keyED($txt,$key);
- $tmp = "";
- for ($i=0;$i_keyED($txt,$key);
+ $tmp = '';
+ for ($i = 0; $i < strlen($txt); $i++) {
+ $md5 = substr($txt, $i, 1);
+ $i++;
+ $tmp .= (substr($txt, $i, 1) ^ $md5);
+ }
+ return $tmp;
}
function LoadFromRemote()
{
- return "";
+ return '';
}
function DLid()
{
- global $lid;
- echo $lid."\n";
- die();
+ die($GLOBALS['lid']."\n");
}
- function _LoadLicense($LoadRemote=FALSE)
+ function _LoadLicense($LoadRemote = false)
{
$f = FULL_PATH.'/intechnic.php';
if ($this->_falseIsLocalSite($f)) $ret = true;
- if(file_exists($f))
- {
+ if (file_exists($f)) {
$contents = file($f);
$data = base64_decode($contents[1]);
}
- else
- if($LoadRemote)
- return $LoadFromRemote;
+ else {
+ if ($LoadRemote) return $LoadFromRemote;
+ }
return $data;
}
- function _VerifyKey($domain,$k)
+ function _VerifyKey($domain, $k)
{
$key = md5($domain);
- $lkey = substr($key,0,strlen($key)/2);
- $rkey = substr($key,strlen($key)/2);
+ $lkey = substr($key, 0, strlen($key) / 2);
+ $rkey = substr($key, strlen($key) / 2);
$r = $rkey.$lkey;
- if($k==$r)
- return TRUE;
- return FALSE;
+ if ($k == $r) return true;
+ return false;
}
function _ParseLicense($txt)
{
- global $i_User, $i_Pswd, $i_Keys;
+ global $i_User, $i_Pswd, $i_Keys;
if (!$this->_falseIsLocalSite($txt)) $nah = false;
- $data = $this->_decrypt($txt,"beagle");
- $i_Keys = array();
- $lines = explode("\n",$data);
- for($x=0;$x_VerifyKey($parts[0],$parts[1]))
- {
- unset($K);
- $k["domain"]=$parts[0];
- $k["key"]=$parts[1];
- $k["desc"]=$parts[2];
- $k["mod"]=$parts[3];
- $i_Keys[] = $k;
- }
- }
- break;
- }
- }
+ $data = $this->_decrypt($txt, 'beagle');
+ $i_Keys = Array();
+ $lines = explode("\n", $data);
+ for ($x = 0; $x < count($lines); $x++) {
+ $l = $lines[$x];
+ $p = explode('=', $l, 2);
+ switch($p[0]) {
+ case 'Username':
+ $i_User = $p[1];
+ break;
+
+ case 'UserPass':
+ $i_Pswd = $p[1];
+ break;
+
+ default:
+ if (substr($p[0], 0, 3) == 'key') {
+ $parts = explode('|', $p[1]);
+ if ($this->_VerifyKey($parts[0], $parts[1])) {
+ unset($K);
+ $k['domain'] = $parts[0];
+ $k['key'] = $parts[1];
+ $k['desc'] = $parts[2];
+ $k['mod'] = $parts[3];
+ $i_Keys[] = $k;
+ }
+ }
+ break;
+ }
+ }
}
function _GetObscureValue($i)
Index: trunk/kernel/parser.php
===================================================================
diff -u -N -r3983 -r4590
--- trunk/kernel/parser.php (.../parser.php) (revision 3983)
+++ trunk/kernel/parser.php (.../parser.php) (revision 4590)
@@ -601,7 +601,7 @@
$item_type = $application->getUnitOption($attribs['_prefix'], 'ItemType');
$sql = 'SELECT ValueList FROM '.GetTablePrefix().'CustomField WHERE FieldName = %s AND Type = %s';
- $values = $application->DB->GetOne( sprintf($sql, $application->DB->qstr($field), $item_type ) );
+ $values = $application->Conn->GetOne( sprintf($sql, $application->DB->qstr($field), $item_type ) );
if(!$values) return '';
if( GetVar($field) )
Index: trunk/kernel/admin/include/summary/root.php
===================================================================
diff -u -N -r4524 -r4590
--- trunk/kernel/admin/include/summary/root.php (.../root.php) (revision 4524)
+++ trunk/kernel/admin/include/summary/root.php (.../root.php) (revision 4590)
@@ -146,7 +146,7 @@
$pending_status = $prefix == 'ord' ? ORDER_STATUS_PENDING : 2;
$sql = 'SELECT COUNT(*) FROM %s WHERE Status = '.$pending_status;
- $pending_count = $application->DB->GetOne( sprintf($sql, $table) );
+ $pending_count = $application->Conn->GetOne( sprintf($sql, $table) );
}
else
{
Index: trunk/core/units/general/my_application.php
===================================================================
diff -u -N -r4490 -r4590
--- trunk/core/units/general/my_application.php (.../my_application.php) (revision 4490)
+++ trunk/core/units/general/my_application.php (.../my_application.php) (revision 4590)
@@ -43,7 +43,7 @@
break;
default:
$sql = 'SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId = '.$user_id;
- $res = $this->DB->GetCol($sql);
+ $res = $this->Conn->GetCol($sql);
$user_groups = Array( $this->ConfigValue('User_LoggedInGroup') );
if(is_array($res))
{
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -N -r4584 -r4590
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4584)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4590)
@@ -39,7 +39,8 @@
{
$module_path = '/'.$module_info['Path'];
if (substr($config_path, 0, strlen($module_path)) == $module_path) {
- $module_found = $module_info['Loaded'] ? true : false;
+ // config file path starts with module folder path
+ $module_found = true;
break;
}
}
Index: trunk/kernel/units/modules/modules_tag_processor.php
===================================================================
diff -u -N -r2060 -r4590
--- trunk/kernel/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 2060)
+++ trunk/kernel/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 4590)
@@ -4,10 +4,7 @@
function ModuleInstalled($params)
{
- $module = $this->SelectParam($params, 'name,module');
- $sql = 'SELECT Loaded FROM '.$this->Application->getUnitOption('mod', 'TableName').'
- WHERE Name = "'.$module.'"';
- return $this->Conn->GetOne($sql) ? 1 : 0;
+ return $this->Application->isModuleEnabled($module);
}
}
Index: trunk/kernel/units/general/my_application.php
===================================================================
diff -u -N -r4490 -r4590
--- trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4490)
+++ trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4590)
@@ -43,7 +43,7 @@
break;
default:
$sql = 'SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup WHERE PortalUserId = '.$user_id;
- $res = $this->DB->GetCol($sql);
+ $res = $this->Conn->GetCol($sql);
$user_groups = Array( $this->ConfigValue('User_LoggedInGroup') );
if(is_array($res))
{
Index: trunk/core/units/modules/modules_tag_processor.php
===================================================================
diff -u -N -r2060 -r4590
--- trunk/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 2060)
+++ trunk/core/units/modules/modules_tag_processor.php (.../modules_tag_processor.php) (revision 4590)
@@ -4,10 +4,7 @@
function ModuleInstalled($params)
{
- $module = $this->SelectParam($params, 'name,module');
- $sql = 'SELECT Loaded FROM '.$this->Application->getUnitOption('mod', 'TableName').'
- WHERE Name = "'.$module.'"';
- return $this->Conn->GetOne($sql) ? 1 : 0;
+ return $this->Application->isModuleEnabled($module);
}
}
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -N -r4490 -r4590
--- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4490)
+++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4590)
@@ -523,7 +523,6 @@
$block_params = Array('is_silent' => 2); // don't make fatal errors in case if template is missing
$current_template = $this->Application->GetVar('t');
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
- if (!$module_data['Loaded']) continue;
$module_key = strtolower($module_name);
if ($module_name == 'In-Portal') {
@@ -742,7 +741,7 @@
$group = $this->SelectParam($params, 'group');
$group_access = true;
if ($group) {
- $conn =& $this->Application->DB;
+ $conn =& $this->Application->GetADODBConnection();
$group_id = $conn->GetOne('SELECT GroupId FROM '.TABLE_PREFIX.'PortalGroup WHERE Name = '.$conn->qstr($group));
if ($group_id) {
$groups = explode(',', $this->Application->RecallVar('UserGroups'));