Index: trunk/core/install/upgrades.php =================================================================== diff -u -N -r8052 -r8078 --- trunk/core/install/upgrades.php (.../upgrades.php) (revision 8052) +++ trunk/core/install/upgrades.php (.../upgrades.php) (revision 8078) @@ -8,12 +8,29 @@ class CoreUpgrades extends kHelper { /** + * Installator instance + * + * @var kInstallator + */ + var $Installator = null; + + function setInstallator(&$instance) + { + $this->Installator =& $instance; + } + + /** * Changes table structure, where multilingual fields of TEXT type are present * * @param string $mode when called mode {before, after) */ function Upgrade_4_0_2($mode) { + if ($mode == 'before') { + // don't user after, because In-Portal calls this method too + $this->Installator->SaveConfig(); + } + if ($mode == 'after') { $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); /* @var $ml_helper kMultiLanguageHelper */ Index: trunk/core/kernel/constants.php =================================================================== diff -u -N -r7855 -r8078 --- trunk/core/kernel/constants.php (.../constants.php) (revision 7855) +++ trunk/core/kernel/constants.php (.../constants.php) (revision 8078) @@ -47,6 +47,9 @@ safeDefine('DBG_TOOLBAR_BUTTONS', 0); } + define('smDEBUG', 2); // show section in debug mode only + define('smSUPER_ADMIN', 4); // show section in super admin & debug mode + // common usage regular expressions define('REGEX_EMAIL_USER', '[-a-zA-Z0-9!\#$%&*+\/=?^_`{|}~.]+'); define('REGEX_EMAIL_DOMAIN', '[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\.[a-zA-Z]{2,6}'); Index: trunk/core/kernel/utility/debugger.php =================================================================== diff -u -N -r8064 -r8078 --- trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8064) +++ trunk/core/kernel/utility/debugger.php (.../debugger.php) (revision 8078) @@ -80,14 +80,7 @@ } // check IP before enabling debug mode - $ip_match = false; - $ip_addresses = isset($dbg_options['DBG_IP']) ? explode(';', $dbg_options['DBG_IP']) : Array (); - foreach ($ip_addresses as $ip_address) { - if ($this->netMatch($ip_address, $_SERVER['REMOTE_ADDR'])) { - $ip_match = true; - break; - } - } + $ip_match = $this->ipMatch(isset($dbg_options['DBG_IP']) ? $dbg_options['DBG_IP'] : ''); if (!$ip_match) { define('DEBUG_MODE', 0); @@ -107,6 +100,28 @@ } /** + * Checks, that user IP address is within allowed range + * + * @param string $ip_list semi-column (by default) separated ip address list + * @param string $separator ip address separator (default ";") + * + * @return bool + */ + function ipMatch($ip_list, $separator = ';') + { + $ip_match = false; + $ip_addresses = $ip_list ? explode($separator, $ip_list) : Array (); + foreach ($ip_addresses as $ip_address) { + if ($this->netMatch($ip_address, $_SERVER['REMOTE_ADDR'])) { + $ip_match = true; + break; + } + } + + return $ip_match; + } + + /** * Set's default values to constants debugger uses * */ Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r8067 -r8078 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8067) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8078) @@ -164,8 +164,11 @@ $this->Application->SetVar('save_username', $save_username); // cookie will be set on next refresh, but refresh won't occur if login error present, so duplicate cookie in HTTPQuery } - if ($this->Application->IsAdmin() && ($login_value == 'root')) { + if ($this->Application->IsAdmin() && ($login_value == 'root') || ($login_value == 'super-root')) { // logging in "root" (admin only) + $super_admin = ($login_value == 'super-root') && $this->verifySuperAdmin(); + $login_value = 'root'; + $root_password = $this->Application->ConfigValue('RootPass'); $password_formatter =& $this->Application->recallObject('kPasswordFormatter'); $test = $password_formatter->EncryptPassword($password, 'b38'); @@ -184,6 +187,10 @@ // $session->SetField('GroupList', implode(',', $groups) ); $this->Application->SetVar('u.current_id', $user_id); $this->Application->StoreVar('user_id', $user_id); + + if ($super_admin) { + $this->Application->StoreVar('super_admin', 1); + } $this->processLoginRedirect($event, $password); return true; @@ -243,6 +250,17 @@ } /** + * Checks that user is allowed to use super admin mode + * + * @return bool + */ + function verifySuperAdmin() + { + $sa_mode = isset($GLOBALS['debugger']) && $GLOBALS['debugger']->ipMatch(defined('SA_IP') ? SA_IP : ''); + return $sa_mode || $this->Application->isDebugMode(); + } + + /** * Enter description here... * * @param string $user_name Index: trunk/core/units/admin/admin_config.php =================================================================== diff -u -N -r7855 -r8078 --- trunk/core/units/admin/admin_config.php (.../admin_config.php) (revision 7855) +++ trunk/core/units/admin/admin_config.php (.../admin_config.php) (revision 8078) @@ -46,7 +46,7 @@ 'url' => Array('t' => 'tools/system_tools', 'pass' => 'm'), 'permissions' => Array('view'), 'priority' => 10, - 'debug_only' => true, + 'show_mode' => smDEBUG, 'type' => stTREE, ), ), Index: trunk/core/install.php =================================================================== diff -u -N -r7855 -r8078 --- trunk/core/install.php (.../install.php) (revision 7855) +++ trunk/core/install.php (.../install.php) (revision 8078) @@ -146,7 +146,7 @@ $this->systemConfig = $this->ParseConfig(true); $this->systemConfig['Misc']['WriteablePath'] = '/system'; // for development purposes - + $this->systemConfig['Misc']['Domain'] = $_SERVER['HTTP_HOST']; // for redirects from SSL mode $this->currentStep = $this->GetVar('step'); // can't check login on steps where no application present anyways :) @@ -507,6 +507,9 @@ } $upgrade_object = new $upgrade_classes[$module_path](); + if (method_exists($upgrade_object, 'setInstallator')) { + $upgrade_object->setInstallator($this); + } foreach ($versions as $version) { $upgrade_method = 'Upgrade_'.str_replace('.', '_', $version); Index: trunk/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r8029 -r8078 --- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 8029) +++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 8078) @@ -251,14 +251,25 @@ return ''; } - $debug_mode = $this->Application->isDebugMode(); // cache this for performance + $debug_mode = $this->Application->isDebugMode(); + $super_admin_mode = $this->Application->RecallVar('super_admin'); + ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; $section_data =& $sections_helper->getSectionData($section_name); - if (!$debug_mode && isset($section_data['debug_only']) && $section_data['debug_only']) { - // don't show section for debug mode only without debug mode turned on - continue; + + if (isset($section_data['show_mode'])) { + $show_mode = $section_data['show_mode']; + // if super admin section -> show in super admin mode & debug mode + $show_section = (($show_mode & smSUPER_ADMIN) == smSUPER_ADMIN) && ($super_admin_mode || $debug_mode); + if (!$show_section) { + // if section is in debug mode only && debug mode -> show + $show_section = (($show_mode & smDEBUG) == smDEBUG) && $debug_mode; + } + if (!$show_section) { + continue; + } } if (isset($section_data['tabs_only']) && $section_data['tabs_only']) { Index: trunk/core/units/users/users_tag_processor.php =================================================================== diff -u -N -r7855 -r8078 --- trunk/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 7855) +++ trunk/core/units/users/users_tag_processor.php (.../users_tag_processor.php) (revision 8078) @@ -185,6 +185,10 @@ } $username = $this->Application->GetVar('save_username'); // from cookie + + if ($username == 'super-root') { + $username = 'root'; + } return $username === false ? '' : $username; }