--- mambo/branches/4.6/index.php 2006/05/20 23:17:51 530 +++ mambo/branches/4.6/index.php 2006/10/19 17:19:07 760 @@ -43,6 +43,9 @@ if (is_numeric($def)) $result = intval($result); } } + if (!get_magic_quotes_gpc()) { + $result = addslashes( $result ); + } } return $result; } else { @@ -55,71 +58,44 @@ return $sef->sefRelToAbs($string); } - -/* This is the new error handler to store errors in the database -class mosErrorHandler { -var $types = array ( -E_STRICT => 'Strict check', -E_USER_WARNING => 'User Warning', -E_USER_NOTICE => 'User Notice', -E_WARNING => 'Warning', -E_NOTICE => 'Notice', -E_CORE_WARNING => 'Core Warning', -E_COMPILE_WARNING => 'Compile Warning', -E_USER_ERROR => 'User Error', -E_ERROR => 'Error', -E_PARSE => 'Parse error', -E_CORE_ERROR => 'Core Error', -E_COMPILE_ERROR => 'Compile Error' -); - -function mosErrorHandler () { -set_error_handler(array(&$this, 'handler')); +function adminSide($val='') { + static $adminside; + if (is_null($adminside)) { + $adminside = ($val == '') ? 0 : $val; + } else { + $adminside = ($val == '') ? $adminside : $val; + } + return $adminside; } -function handler ($errno, $errstr, $errfile, $errline, $errcontext) { -if ($errno = E_STRICT) return; -$string = $this->types[$errno].': '.$errstr.' in '.$errfile.' at '.$errline; -$database =& mamboDatabase::getInstance(); -if (eregi('^(sql)$', $errstr)) { -$extra = $database->getErrorMsg(); -} -if (function_exists('debug_backtrace')) { -foreach(debug_backtrace() as $back) { -if (@$back['file']) { -$extra .= "\n".$back['file'].':'.$back['line']; -} -} -} -$database->setQuery("DELETE FROM #__errors WHERE file=$errfile AND line=$errline AND number=$errno"); -$database->query(); -$database->setQuery("INSERT INTO #__errors VALUES (0, $errno, '$errfile', $errline, '$string', '$extra')"); -$database->query(); -} +function indexType($val='') { + static $indextype; + if (is_null($indextype)) { + $indextype = ($val == '') ? 1 : $val; + } else { + $indextype = ($val == '') ? $indextype : $val; + } + return $indextype; } -*/ -if (!isset($adminside)) { - $adminside = 0; -} -if (!isset($indextype)) { - $indextype = 1; -} +if (!isset($adminside)) $adminside = 0; +if (!isset($indextype)) $indextype = 1; + +adminSide($adminside); +indexType($indextype); require_once (dirname(__FILE__).'/includes/database.php'); require_once(dirname(__FILE__).'/includes/core.classes.php'); $configuration =& mamboCore::getMamboCore(); $configuration->handleGlobals(); -//new mosErrorHandler(); - - +$adminside = adminSide(); +$indextype = indexType(); require($configuration->rootPath().'/includes/version.php'); $_VERSION =& new version(); - $version = $_VERSION->PRODUCT .' '. $_VERSION->RELEASE .'.'. $_VERSION->DEV_LEVEL .' ' . $_VERSION->DEV_STATUS .' [ '.$_VERSION->CODENAME .' ] '. $_VERSION->RELDATE .' ' @@ -127,6 +103,7 @@ if (phpversion() < '4.2.0') require_once( $configuration->rootPath() . '/includes/compat.php41x.php' ); if (phpversion() < '4.3.0') require_once( $configuration->rootPath() . '/includes/compat.php42x.php' ); +if (phpversion() < '5.0.0') require_once( $configuration->rootPath() . '/includes/compat.php5xx.php' ); $local_backup_path = $configuration->rootPath().'/administrator/backups'; $media_path = $configuration->rootPath().'/media/'; @@ -137,13 +114,6 @@ $database =& mamboDatabase::getInstance(); $database->debug(mamboCore::get('mosConfig_debug')); -// -$gettext =& phpgettext(); -$gettext->bindtextdomain('common', $configuration->rootPath().'/language'); -$gettext->textdomain('common'); -//dump($gettext->textdomain(substr($option, 3))); -//$gettext->bindtextdomain('frontend', $lang_path); -//$gettext->textdomain('frontend'); if (!$adminside) { $sefcode = $configuration->rootPath().'/components/com_sef/sef.php'; @@ -173,6 +143,17 @@ ini_set('session.use_only_cookies', 1); +/* initialize i18n */ +$lang = $configuration->current_language->name; +$charset = $configuration->current_language->charset; +$gettext =& phpgettext(); +$gettext->debug = $configuration->mosConfig_locale_debug; +$gettext->has_gettext = $configuration->mosConfig_locale_use_gettext; +$gettext->setlocale($lang); +$gettext->bindtextdomain($lang, $configuration->rootPath().'/language'); +$gettext->textdomain($lang); +#$gettext =& phpgettext(); dump($gettext); + if ($adminside) { // Start ACL require_once($configuration->rootPath().'/includes/gacl.class.php' ); @@ -182,21 +163,17 @@ $option = strtolower(mosGetParam($_REQUEST,'option','com_admin')); $domain = substr($option, 4); - $gettext->bindtextdomain('administrator', $lang_path); - $gettext->bindtextdomain($domain, $lang_path); - $admindomain = $gettext->textdomain(); - $gettext->textdomain('administrator'); session_name(md5(mamboCore::get('mosConfig_live_site'))); session_start(); - // restore some session variables - $my = new mosUser(); - $my->getSession(); - if (mosSession::validate($my)) { - mosSession::purge(); - } else { - mosSession::purge(); - $my = null; - } + // restore some session variables + $my = new mosUser(); + $my->getSession(); + if (mosSession::validate($my)) { + mosSession::purge(); + } else { + mosSession::purge(); + $my = null; + } if (!$my AND $option == 'login') { require_once($configuration->rootPath().'/includes/authenticator.php'); $authenticator =& mamboAuthenticator::getInstance(); @@ -259,16 +236,8 @@ // Finished admin side; the rest is user side code: else { $option = $configuration->determineOptionAndItemid(); - $configuration->handleGlobals(); $Itemid = $configuration->get('Itemid'); - // load frontend language file - $gettext->bindtextdomain(substr($option, 4), $configuration->rootPath().'/language'); - $gettext->bindtextdomain('frontend', $configuration->rootPath().'/language'); - $frontdomain = $gettext->textdomain(); - $gettext->textdomain('frontend'); - - $mainframe =& new mosMainFrame($database, $option, '.'); if ($option == 'login') $configuration->handleLogin(); elseif ($option == 'logout') $configuration->handleLogout(); @@ -313,9 +282,7 @@ $ret = $menuhandler->menuCheck($Itemid, $option, $task, $gid); $menuhandler->setPathway($Itemid); if ($ret) { - $gettext->textdomain(substr($option, 4)); // get the component lang file require ($path); - $gettext->textdomain($frontdomain); } else mosNotAuth(); }