_ValidateModules(); } function _EnableCookieSID() { $session =& $this->Application->recallObject('Session'); return $session->CookiesEnabled; } function _IsSpider($UserAgent) { global $robots; $lines = file(FULL_PATH.'/robots_list.txt'); if (!is_array($robots)) { $robots = Array(); for($i = 0; $i < count($lines); $i++) { $l = $lines[$i]; $p = explode("\t", $l, 3); $robots[] = $p[2]; } } 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; $ip = explode('.', $ip1); $MatchIp = explode('.', $ip2); for ($i = 0; $i < count($ip); $i++) { if($i == count($MatchIp)) break; if (trim($ip[$i]) != trim($MatchIp[$i]) || trim($ip[$i]) == '*') { $matched = FALSE; break; } } return $matched; } function _IpAccess($IpAddress, $AllowList, $DenyList) { $allowed = explode(',', $AllowList); $denied = explode(',', $DenyList); $MatchAllowed = FALSE; for ($x = 0; $x < count($allowed); $x++) { $ip = explode('.', $allowed[$x]); $MatchAllowed = $this->_MatchIp($IpAddress, $allowed[$x]); if ($MatchAllowed) break; } $MatchDenied = FALSE; for ($x = 0; $x < count($denied); $x++) { $ip = explode('.', $denied[$x]); $MatchDenied = $this->_MatchIp($IpAddress, $denied[$x]); if ($MatchDenied) break; } $Result = (($MatchAllowed && !$MatchDenied) || (!$MatchAllowed && !$MatchDenied) || ($MatchAllowed && $MatchDenied)); 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; } 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; } } function _ModuleLicensed($name) { global $i_Keys; $this->_readConfig(); $lic = base64_decode($GLOBALS['g_License']); $this->_ParseLicense($lic); $modules = array(); if(!$this->_IsLocalSite($this->_GetDomain())) { for($x=0;$x_GetDomain(),$key["domain"]))) { //echo "ok
"; $modules = explode(",",$key["mod"]); } } //print_pre($modules); if(in_array($name,$modules)) { //echo "ok
"; return TRUE; } } else { return TRUE; } return FALSE; } function _GetDomain() { global $g_Domain; if ($this->Application->ConfigValue('DomainDetect')) { $d = $_SERVER['HTTP_HOST']; } else { $d = $g_Domain; } return $d; } 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_falseIsLocalSite($f)) $ret = true; if(file_exists($f)) { $contents = file($f); $data = base64_decode($contents[1]); } else if($LoadRemote) return $LoadFromRemote; return $data; } function _VerifyKey($domain,$k) { $key = md5($domain); $lkey = substr($key,0,strlen($key)/2); $rkey = substr($key,strlen($key)/2); $r = $rkey.$lkey; if($k==$r) return TRUE; return FALSE; } function _ParseLicense($txt) { 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; } } } function _GetObscureValue($i) { if ($i == 'x') return 0254; $z = ''; if ($i == 'z') return 0x7F.'.'; if ($i == 'c') return '--code--'; if ($i >= 5 && $i < 7) return $this->_GetObscureValue($z)*$this->_GetObscureValue('e'); if ($i > 30) return Array(0x6c,0x6f,0x63,0x61,0x6c,0x68,0x6f,0x73,0x74); if ($i > 20) return 99; if ($i > 10) return '.'.($this->_GetObscureValue(6.5)+1); if ($i == 'a') return 0xa; } function _Chr($val) { $x = $this->_GetObscureValue(25); $f = chr($x).chr($x+5).chr($x+15); return $f($val); } function _IsLocalSite($domain) { $ee = $this->_GetObscureValue(35); $yy = ''; foreach ($ee as $e) $yy .= $this->_Chr($e); $localb = FALSE; if(substr($domain,0,3)==$this->_GetObscureValue('x')) { $b = substr($domain,0,6); $p = explode(".",$domain); $subnet = $p[1]; if($p[1]>15 && $p[1]<32) $localb=TRUE; } $zz = $this->_GetObscureValue('z').$this->_GetObscureValue(5).'.'.(int)$this->_GetObscureValue(7).$this->_GetObscureValue(12); $ff = $this->_GetObscureValue('z')+65; $hh = $ff-0x18; if($domain==$yy || $domain==$zz || substr($domain,0,7)==$ff.$this->_Chr(46).$hh || substr($domain,0,3)==$this->_GetObscureValue('a').$this->_Chr(46) || $localb || strpos($domain,".")==0) { return TRUE; } return FALSE; } function _falseIsLocalSite($domain) { $localb = FALSE; if(substr($domain,0,3)=="172") { $b = substr($domain,0,6); $p = explode(".",$domain); $subnet = $p[1]; if($p[1]>15 && $p[1]<32) $localb=TRUE; } if($domain=="localhost" || $domain=="127.0.0.1" || substr($domain,0,7)=="192.168" || substr($domain,0,3)=="10." || $localb || strpos($domain,".")==0) { return TRUE; } return FALSE; } } ?>