Index: branches/RC/core/units/general/helpers/modules.php =================================================================== diff -u -r8929 -r10832 --- branches/RC/core/units/general/helpers/modules.php (.../modules.php) (revision 8929) +++ branches/RC/core/units/general/helpers/modules.php (.../modules.php) (revision 10832) @@ -90,19 +90,6 @@ } /** - * Reads config.php file and parses it - * - */ - function _readConfig() - { - $vars = parse_portal_ini(FULL_PATH.'/config.php'); - - foreach ($vars as $config_key => $config_value) { - $GLOBALS['g_'.$config_key] = $config_value; - } - } - - /** * Leaves only domain part from hostname (e.g. extract "intechnic.lv" from "test.intechnic.lv") * Used for admin login license check * @@ -159,29 +146,31 @@ */ function _GetModules() { - global $i_Keys; static $modules = null; - if (isset($modules)) return $modules; + if (isset($modules)) { + return $modules; + } - $this->_readConfig(); - $license = isset($GLOBALS['g_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 ($this->_CheckDomain($domain, $key['domain'])) { - // used hostname is subdomain or matches domain from license - $modules = explode(',', $key['mod']); - } - } + $vars = parse_portal_ini(FULL_PATH . '/config.php'); + $license = array_key_exists('License', $vars) ? base64_decode($vars['License']) : false; + if ($license) { + list ( , , $i_Keys) = $this->_ParseLicense($license); + $domain = $this->_GetDomain($vars); + if (!$this->_IsLocalSite($domain)) { + for ($x = 0; $x < count($i_Keys); $x++) { + $key = $i_Keys[$x]; + if ($this->_CheckDomain($domain, $key['domain'])) { + // used hostname is subdomain or matches domain from license + $modules = explode(',', $key['mod']); + } + } + } + else { + $modules = array_keys($this->Application->ModuleInfo); + } } - else { - $modules = array_keys($this->Application->ModuleInfo); - } array_push($modules, 'Core', 'Proj-base', 'Proj-CMS', 'Custom'); return $modules; @@ -204,9 +193,9 @@ * * @return string */ - function _GetDomain() + function _GetDomain($vars) { - $config_domain = isset($GLOBALS['g_Domain']) ? $GLOBALS['g_Domain'] : ''; + $config_domain = array_key_exists('Domain', $vars) ? $vars['Domain'] : false; return $this->Application->ConfigValue('DomainDetect') ? $_SERVER['HTTP_HOST'] : $config_domain; } @@ -272,9 +261,14 @@ function _ParseLicense($txt) { - global $i_User, $i_Pswd, $i_Keys; - if (!$this->_falseIsLocalSite($txt)) $nah = false; +// global $i_User, $i_Pswd, $i_Keys; + + if (!$this->_falseIsLocalSite($txt)) { + $nah = false; + } + $data = $this->_decrypt($txt, 'beagle'); + $i_User = $i_Pswd = ''; $i_Keys = Array(); $lines = explode("\n", $data); for ($x = 0; $x < count($lines); $x++) { @@ -304,6 +298,8 @@ break; } } + + return Array ($i_User, $i_Pswd, $i_Keys); } function _GetObscureValue($i) @@ -367,6 +363,30 @@ } return FALSE; } + + function verifyLicense($license_hash) + { + $license_hash = base64_decode($license_hash); + list ($license_user, $license_password, ) = $this->_ParseLicense($license_hash); + return strlen($license_user) && strlen($license_password); + } + + function moduleInstalled($module_name) + { + static $modules = null; + + if (is_null($modules)) { + $sql = 'SELECT LOWER(Name) + FROM ' . $this->Application->getUnitOption('mod', 'TableName'); + $modules = $this->Conn->GetCol($sql); + } + + if ($module_name == 'kernel') { + $module_name = 'in-portal'; + } + + return in_array(strtolower($module_name), $modules); + } } ?> \ No newline at end of file