Index: trunk/core/units/general/helpers/modules.php =================================================================== diff -u -N -r4592 -r4607 --- trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4592) +++ trunk/core/units/general/helpers/modules.php (.../modules.php) (revision 4607) @@ -103,6 +103,55 @@ } /** + * Leaves only domain part from hostname (e.g. extract "intechnic.lv" from "test.intechnic.lv") + * Used for admin login license check + * + * @param string $d + * @return string + */ + 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; + } + + /** + * When logging into admin then check only last 2 parts of host name VS domain in license + * + * @param string $user_domain + * @param string $license_domain + * @return int + */ + function _CheckDomain($user_domain, $license_domain) + { + if ($this->Application->IsAdmin()) { + $user_domain = $this->_StripDomainHost($user_domain); + return preg_match('/(.*)'.preg_quote($user_domain, '/').'$/', $license_domain); + } + else { + return preg_match('/(.*)'.preg_quote($license_domain, '/').'$/', $user_domain); + } + } + + /** * Returns modules list, that are in license * * @return Array @@ -123,7 +172,7 @@ if (!$this->_IsLocalSite($domain)) { for ($x = 0; $x < count($i_Keys); $x++) { $key = $i_Keys[$x]; - if (preg_match('/(.*)'.preg_quote($key['domain'], '/').'$/', $domain)) { + if ($this->_CheckDomain($domain, $key['domain'])) { // used hostname is subdomain or matches domain from license $modules = explode(',', $key['mod']); }