[core] Remove config data from session as it brings chicken-egg problem.

Configuration data stores PmaAbsoluteUri, which should be accessible
before initiating session. Otherwise there is no way to make
PmaAbsoluteUri work. PmaAbsoluteUri is needed at least for reverse
proxy setups, for example http webserver running behind https proxy.
This commit is contained in:
Michal Čihař
2010-01-21 11:18:18 +00:00
parent f7dda75cd7
commit 94c2f864ae
34 changed files with 223 additions and 222 deletions

View File

@@ -206,7 +206,7 @@ function PMA_securePath($path)
* @uses $GLOBALS['strError']
* @uses $GLOBALS['available_languages']
* @uses $GLOBALS['lang']
* @uses PMA_removeCookie()
* @uses $GLOBALS['PMA_Config']->removeCookie()
* @uses select_lang.lib.php
* @uses $_COOKIE
* @uses substr()
@@ -273,7 +273,7 @@ function PMA_fatalError($error_message, $message_args = null)
// on fatal errors it cannot hurt to always delete the current session
if (isset($GLOBALS['session_name']) && isset($_COOKIE[$GLOBALS['session_name']])) {
PMA_removeCookie($GLOBALS['session_name']);
$GLOBALS['PMA_Config']->removeCookie($GLOBALS['session_name']);
}
exit;
@@ -302,13 +302,13 @@ function PMA_getTableCount($db)
// for use in determining if a table here is a blobstreaming table - rajk
// load PMA configuration
$PMA_Config = $_SESSION['PMA_Config'];
$PMA_Config = $GLOBALS['PMA_Config'];
// if PMA configuration exists
if (!empty($PMA_Config))
{
// load BS tables
$session_bs_tables = $_SESSION['PMA_Config']->get('BLOBSTREAMING_TABLES');
$session_bs_tables = $GLOBALS['PMA_Config']->get('BLOBSTREAMING_TABLES');
// if BS tables exist
if (isset ($session_bs_tables))
@@ -526,69 +526,4 @@ function PMA_getenv($var_name) {
return '';
}
/**
* removes cookie
*
* @uses PMA_Config::isHttps()
* @uses PMA_Config::getCookiePath()
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @return boolean result of setcookie()
*/
function PMA_removeCookie($cookie)
{
return setcookie($cookie, '', time() - 3600,
PMA_Config::getCookiePath(), '', PMA_Config::isHttps());
}
/**
* sets cookie if value is different from current cokkie value,
* or removes if value is equal to default
*
* @uses PMA_Config::isHttps()
* @uses PMA_Config::getCookiePath()
* @uses $_COOKIE
* @uses PMA_removeCookie()
* @uses setcookie()
* @uses time()
* @param string $cookie name of cookie to remove
* @param mixed $value new cookie value
* @param string $default default value
* @param int $validity validity of cookie in seconds (default is one month)
* @param bool $httponlt whether cookie is only for HTTP (and not for scripts)
* @return boolean result of setcookie()
*/
function PMA_setCookie($cookie, $value, $default = null, $validity = null, $httponly = true)
{
if ($validity == null) {
$validity = 2592000;
}
if (strlen($value) && null !== $default && $value === $default
&& isset($_COOKIE[$cookie])) {
// remove cookie, default value is used
return PMA_removeCookie($cookie);
}
if (! strlen($value) && isset($_COOKIE[$cookie])) {
// remove cookie, value is empty
return PMA_removeCookie($cookie);
}
if (! isset($_COOKIE[$cookie]) || $_COOKIE[$cookie] !== $value) {
// set cookie with new value
/* Calculate cookie validity */
if ($validity == 0) {
$v = 0;
} else {
$v = time() + $validity;
}
return setcookie($cookie, $value, $v,
PMA_Config::getCookiePath(), '', PMA_Config::isHttps(), $httponly);
}
// cookie has already $value as value
return true;
}
?>