X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=include%2Finit.php;h=935515219b8cac75a4f0ef31764db695fac5cb9c;hp=9610e4933c4510f69f537b94cebf2951ac07fba0;hb=918fcc1d131a60df5ba01212d61d82d753014468;hpb=5e68a08e09d4d2c3b1fe59fcce72cb15dbfcb210 diff --git a/include/init.php b/include/init.php index 9610e493..93551521 100644 --- a/include/init.php +++ b/include/init.php @@ -134,6 +134,7 @@ $color[15] = '#002266'; /* (dark blue) Unselectable folders */ $color[16] = '#ff9933'; /* (orange) Highlight color */ require(SM_PATH . 'functions/global.php'); +require(SM_PATH . 'functions/arrays.php'); /* load default configuration */ require(SM_PATH . 'config/config_default.php'); @@ -284,9 +285,34 @@ if (isset($plugins) && is_array($plugins)) { } } +/** + * Before 1.5.2 version hook was part of functions/constants.php. + * After init layout changes, hook had to be moved because include/constants.php is + * loaded before plugins are initialized. + * @since 1.2.0 + */ +do_hook('loading_constants'); switch ($sInitLocation) { - case 'style': session_write_close(); sqsetcookieflush(); break; + case 'style': + + // need to get the right template set up + sqGetGlobalVar('templatedir', $templatedir, SQ_GET); + + // sanitize just in case... + $templatedir = preg_replace('/(\.\.\/){1,}/', '', $templatedir); + + // could also conceivably make sure given templatedir is in $aTemplateSet + + // set template directory only if what was given is valid + if (is_dir(SM_PATH . 'templates/' . $templatedir . '/')) { + $sTplDir = SM_PATH . 'templates/' . $templatedir . '/'; + } + + session_write_close(); + sqsetcookieflush(); + break; + case 'redirect': /** * directory hashing functions are needed for all setups in case @@ -390,7 +416,7 @@ switch ($sInitLocation) { $prefs_cache = false; //array(); } - /* see 'redirect' switch */ + /* see 'redirect' case */ require(SM_PATH . 'functions/prefs.php'); $prefs_backend = do_hook_function('prefs_backend'); @@ -407,7 +433,6 @@ switch ($sInitLocation) { */ require(SM_PATH . 'include/load_prefs.php'); - // i do not understand the frames language cookie story /** * We'll need this to later have a noframes version @@ -491,19 +516,30 @@ switch ($sInitLocation) { * Initialize the template object */ require(SM_PATH . 'class/template/template.class.php'); + /* * $sTplDir is not initialized when a user is not logged in, so we will use - * the config file defaults here. If the neccesary variables are net set, + * the config file defaults here. If the neccesary variables are not set, * force a default value. + * + * If the user is logged in, $sTplDir will be set in load_prefs.php, so we + * shouldn't change it here. */ -$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); -$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default ); - -$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ? - SM_PATH . 'templates/default/' : - $aTemplateSet[$templateset_default]['PATH'] ); +if (!isset($sTplDir)) { + $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet ); + $templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default ); + + $sTplDir = !isset($aTemplateSet[$templateset_default]['PATH']) ? SM_PATH . 'templates/default/' : $aTemplateSet[$templateset_default]['PATH']; + $icon_theme_path = !$use_icons ? NULL : $sTplDir . 'images/'; +} $oTemplate = new Template($sTplDir); +// We want some variables to always be available to the template +$always_include = array('sTplDir', 'icon_theme_path'); +foreach ($always_include as $var) { + $oTemplate->assign($var, (isset($$var) ? $$var : NULL)); +} + /** * Initialize our custom error handler object */