Index: trunk/core/units/general/xml_helper.php =================================================================== diff -u --- trunk/core/units/general/xml_helper.php (revision 0) +++ trunk/core/units/general/xml_helper.php (revision 3866) @@ -0,0 +1,136 @@ +RootElement; + } + + function startElement(&$Parser, &$Elem, $Attrs) + { + $parent =& $this->CurrentElement; + $this->CurrentElement =& new kXMLNode($Elem, $Attrs); + if (is_null($this->RootElement)) { + $this->RootElement =& $this->CurrentElement; + } + if (!is_null($parent)) { + $parent->AddChild($this->CurrentElement); + } + } + + function characterData($Parser, $Line) + { + $this->CurrentElement->AppendData($Line); + } + + function endElement($Parser, $Elem) + { + if ($this->CurrentElement->Parent != null) { + $this->CurrentElement =& $this->CurrentElement->Parent; + } + } + + function Clear() + { + $this->RootElement = null; + $this->CurrentElement = null; + } +} + +class kXMLNode { + var $Name = null; + var $Attributes = array(); + var $Children = array(); + var $Data = null; + var $Parent = null; + + function kXMLNode($name, $attrs = array()) + { + $this->Name = $name; + $this->Attributes = $attrs; + } + + function SetParent(&$elem) + { + $this->Parent =& $elem; + } + + function AddChild(&$a_child) + { + $this->Children[$a_child->Name] =& $a_child; + $a_child->SetParent($this); + } + + function AppendData($data) + { + $this->Data .= $data; + } + + function &GetChild($path) + { + $entries = explode('/', strtoupper($path)); + $cur = array_shift($entries); + if ($cur == $this->Name) $cur = array_shift($entries); + if (!$cur) return $this; + if (!isset($this->Children[$cur])) return false; + $left = implode('/', $entries); + if (!$left) return $this->Children[$cur]; + return $this->Children[$cur]->GetChild($left); + } + + function GetChildValue($path) + { + $child =& $this->GetChild($path); + if ($child !== false) { + return $child->Data; + } + } + + function &FindChild($name) + { + $name = strtoupper($name); + if ($this->Name == $name) return $this; + if (isset($this->Children[$name])) return $this->Children[$name]; + $children_names = array_keys($this->Children); + foreach ($children_names as $a_name) + { + $child =& $this->Children[$a_name]->FindChild($name); + if ($child !== false) + { + return $child; + } + } + return false; + } + + function FindChildValue($name, $attr=null) + { + $child =& $this->FindChild($name); + if ($child !== false) { + if (isset($attr)) { + return $child->Attributes[strtoupper($attr)]; + } + return $child->Data; + } + } +} + +?> \ No newline at end of file Index: trunk/kernel/units/general/xml_helper.php =================================================================== diff -u --- trunk/kernel/units/general/xml_helper.php (revision 0) +++ trunk/kernel/units/general/xml_helper.php (revision 3866) @@ -0,0 +1,136 @@ +RootElement; + } + + function startElement(&$Parser, &$Elem, $Attrs) + { + $parent =& $this->CurrentElement; + $this->CurrentElement =& new kXMLNode($Elem, $Attrs); + if (is_null($this->RootElement)) { + $this->RootElement =& $this->CurrentElement; + } + if (!is_null($parent)) { + $parent->AddChild($this->CurrentElement); + } + } + + function characterData($Parser, $Line) + { + $this->CurrentElement->AppendData($Line); + } + + function endElement($Parser, $Elem) + { + if ($this->CurrentElement->Parent != null) { + $this->CurrentElement =& $this->CurrentElement->Parent; + } + } + + function Clear() + { + $this->RootElement = null; + $this->CurrentElement = null; + } +} + +class kXMLNode { + var $Name = null; + var $Attributes = array(); + var $Children = array(); + var $Data = null; + var $Parent = null; + + function kXMLNode($name, $attrs = array()) + { + $this->Name = $name; + $this->Attributes = $attrs; + } + + function SetParent(&$elem) + { + $this->Parent =& $elem; + } + + function AddChild(&$a_child) + { + $this->Children[$a_child->Name] =& $a_child; + $a_child->SetParent($this); + } + + function AppendData($data) + { + $this->Data .= $data; + } + + function &GetChild($path) + { + $entries = explode('/', strtoupper($path)); + $cur = array_shift($entries); + if ($cur == $this->Name) $cur = array_shift($entries); + if (!$cur) return $this; + if (!isset($this->Children[$cur])) return false; + $left = implode('/', $entries); + if (!$left) return $this->Children[$cur]; + return $this->Children[$cur]->GetChild($left); + } + + function GetChildValue($path) + { + $child =& $this->GetChild($path); + if ($child !== false) { + return $child->Data; + } + } + + function &FindChild($name) + { + $name = strtoupper($name); + if ($this->Name == $name) return $this; + if (isset($this->Children[$name])) return $this->Children[$name]; + $children_names = array_keys($this->Children); + foreach ($children_names as $a_name) + { + $child =& $this->Children[$a_name]->FindChild($name); + if ($child !== false) + { + return $child; + } + } + return false; + } + + function FindChildValue($name, $attr=null) + { + $child =& $this->FindChild($name); + if ($child !== false) { + if (isset($attr)) { + return $child->Attributes[strtoupper($attr)]; + } + return $child->Data; + } + } +} + +?> \ No newline at end of file Index: trunk/globals.php =================================================================== diff -u -r3850 -r3866 --- trunk/globals.php (.../globals.php) (revision 3850) +++ trunk/globals.php (.../globals.php) (revision 3866) @@ -3,7 +3,7 @@ if (!function_exists('parse_portal_ini')) { function parse_portal_ini($file, $parse_section = false) { - if (!file_exists($file)) return; + if (!file_exists($file)) return false; if(file_exists($file) && !is_readable($file)) die('Could Not Open Ini File'); @@ -56,16 +56,14 @@ } } -$vars = parse_portal_ini(FULL_PATH.'/config.php'); + $vars = parse_portal_ini(FULL_PATH.'/config.php'); + if ($vars) { + foreach ($vars as $config_key => $config_value) { + $GLOBALS['g_'.$config_key] = $config_value; + } + unset($config_key, $config_value); + } -while($key = key($vars)) -{ - $key = "g_".$key; - global $$key; - $$key = current($vars); //variable variables - next($vars); -} - /*list the tables which contain item data */ $ItemTables = array(); @@ -1713,9 +1711,8 @@ */ function IsDebugMode($check_debugger = true) { - $debug_mode = defined('DEBUG_MODE') && DEBUG_MODE; - if($check_debugger) $debug_mode = $debug_mode && isset($GLOBALS['debugger']); - return $debug_mode; + $application =& kApplication::Instance(); + return $application->isDebugMode($check_debugger); } /** @@ -1725,7 +1722,8 @@ */ function IsAdmin() { - return defined('ADMIN') && constant('ADMIN') == 1 ? 1 : 0; + $application =& kApplication::Instance(); + return $application->IsAdmin(); } /** Index: trunk/admin/index.php =================================================================== diff -u -r3282 -r3866 --- trunk/admin/index.php (.../index.php) (revision 3282) +++ trunk/admin/index.php (.../index.php) (revision 3866) @@ -12,106 +12,31 @@ ## result in revocation of the license and support ## ## privileges along maximum prosecution allowed by law. ## ############################################################## -$pathtoroot = ""; -if( !(isset($pathtoroot) && $pathtoroot) ) -{ - $path=dirname(realpath(__FILE__)); - if(strlen($path)) - { - /* determine the OS type for path parsing */ - $pos = strpos($path,":"); - if ($pos === false) - { - $gOS_TYPE="unix"; - $pathchar = "/"; - } - else - { - $gOS_TYPE="win"; - $pathchar="\\"; - } - $p = $path.$pathchar; - /*Start looking for the root flag file */ - if( !isset($pathtoroot) ) $pathtoroot = ''; - while(!strlen($pathtoroot) && strlen($p)) - { - $sub = substr($p,strlen($pathchar)*-1); - if($sub==$pathchar) - { - $filename = $p."root.flg"; - } - else - $filename = $p.$pathchar."root.flg"; - if(file_exists($filename)) - { - $pathtoroot = $p; - } - else - { - $parent = realpath($p.$pathchar."..".$pathchar); - if($parent!=$p) - { - $p = $parent; - } - else - $p = ""; - } - } - if( !(isset($pathtoroot) && $pathtoroot) ) - $pathtoroot = ".".$pathchar; - } - else - { - $pathtoroot = ".".$pathchar; - } -} -if (!file_exists($pathtoroot."/config.php")) { - echo "In-Portal is probably not installed, or configuration file is missing.
"; - echo "Please use the installation script to fix the problem.

"; - echo "Go to installation script

"; - flush(); - die(); -} + // new startup: begin + define('REL_PATH', 'admin'); + $relation_level = count( explode('/', REL_PATH) ); + define('FULL_PATH', realpath(dirname(__FILE__) . str_repeat('/..', $relation_level) ) ); + require_once FULL_PATH.'/kernel/startup.php'; + // new startup: end -$sub = substr($pathtoroot,strlen($pathchar)*-1); -if($sub!=$pathchar) -{ - $pathtoroot = $pathtoroot.$pathchar; -} + $objConfig->Set('AdminDirectory', $admin, 0, true); + $objConfig->Save(); -//echo "
"; print_r($_POST); echo "
"; -require_once($pathtoroot."/kernel/startup.php"); + if (!admin_login() || GetVar('logout') || GetVar('expired') ) { + if (!headers_sent()) { + set_cookie(SESSION_COOKIE_NAME, '', adodb_mktime() - 3600); + } + $objSession->Logout(); + require_once FULL_PATH.'/admin/login.php'; + } -$rootURL="http://".ThisDomain().$objConfig->Get("Site_Path"); -$admin = substr($path,strlen($pathtoroot)); -$objConfig->Set("AdminDirectory",$admin,0,TRUE); -$objConfig->Save(); + $envar = 'env='.BuildEnv(); -//echo "Setting admin to $admin
\n"; -$localURL=$rootURL."kernel/"; -$adminURL = $rootURL.$admin; -$imagesURL = $adminURL."/images"; -$browseURL = $adminURL."/browse"; -$cssURL = $adminURL."/include"; + require_once FULL_PATH.'/admin/include/elements.php'; + require_once FULL_PATH.'/kernel/admin/include/navmenu.php'; - -// !admin_login() - admin, but not logged in - -if (!admin_login() || GetVar('logout') || GetVar('expired') ) -{ - if( !headers_sent() ) set_cookie(SESSION_COOKIE_NAME, '', adodb_mktime() - 3600); - $objSession->Logout(); - require_once($pathtoroot.$admin.'/login.php'); -} - -$envar = "env=" . BuildEnv(); - -require_once ($pathtoroot.$admin."/include/elements.php"); -require_once ($pathtoroot."kernel/admin/include/navmenu.php"); - -$pathtolocal = $pathtoroot; -$charset = GetRegionalOption('Charset'); + $charset = GetRegionalOption('Charset'); ?> @@ -139,9 +64,8 @@ document.write(""); } - - - + + " name="main" marginwidth="0" marginheight="0" frameborder="NO" noresize scrolling="auto">