From ee3544d3d11105b1cfb3c00d59667f7280c28f30 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 11 Sep 2013 12:18:40 +0000 Subject: [PATCH] fixed language selection got lost --- setup/inc/class.setup.inc.php | 44 ++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/setup/inc/class.setup.inc.php b/setup/inc/class.setup.inc.php index 1004bea425..5a63d55c66 100644 --- a/setup/inc/class.setup.inc.php +++ b/setup/inc/class.setup.inc.php @@ -196,18 +196,27 @@ class setup } /** - * Get configuration language from $_POST or $_COOKIE and validate it + * Get configuration language from $_POST or $_SESSION and validate it * * @return string */ static function get_lang() { - $ConfigLang = get_var('ConfigLang', array('POST','COOKIE')); - if (preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) + if (isset($_POST['ConfigLang'])) { - return $ConfigLang; + $ConfigLang = $_POST['ConfigLang']; } - return null; // not returning 'en', as it suppresses the language selection in check_install and manageheader + else + { + if (!isset($_SESSION)) self::session_start(); + $ConfigLang = $_SESSION['ConfigLang']; + } + if (!preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$ConfigLang)) + { + $ConfigLang = null; // not returning 'en', as it suppresses the language selection in check_install and manageheader + } + //error_log(__METHOD__."() \$_POST['ConfigLang']=".array2string($_POST['ConfigLang']).", \$_SESSION['ConfigLang']=".array2string($_SESSION['ConfigLang'])." returning ".array2string($ConfigLang)); + return $ConfigLang; } /** @@ -220,6 +229,21 @@ class setup */ const TIMEOUT = 1200; + /** + * Start session + */ + private static function session_start() + { + // make sure we have session extension available, otherwise fail with exception that we need it + check_load_extension('session', true); + + ini_set('session.use_cookie', true); + session_name(self::SESSIONID); + if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); + + return @session_start(); // suppress notice if session already started or warning in CLI + } + /** * authenticate the setup user * @@ -236,14 +260,7 @@ class setup return false; } - // make sure we have session extension available, otherwise fail with exception that we need it - check_load_extension('session', true); - - ini_set('session.use_cookie', true); - session_name(self::SESSIONID); - if (isset($_COOKIE[self::SESSIONID])) session_id($_COOKIE[self::SESSIONID]); - - if (!session_start() || isset($_REQUEST['FormLogout']) || + if (!self::session_start() || isset($_REQUEST['FormLogout']) || empty($_SESSION['egw_setup_auth_type']) || $_SESSION['egw_setup_auth_type'] != $auth_type) { //error_log(__METHOD__."('$auth_type') \$_COOKIE['".self::SESSIONID."'] = ".array2string($_COOKIE[self::SESSIONID]).", \$_SESSION=".array2string($_SESSION).", \$_POST=".array2string($_POST)); @@ -294,6 +311,7 @@ class setup break; } $_SESSION['egw_setup_auth_type'] = $auth_type; + $_SESSION['ConfigLang'] = self::get_lang(); $_SESSION['egw_last_action_time'] = time(); session_regenerate_id(true); $this->set_cookie(self::SESSIONID, session_id(), 0);