diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index 61e18ca2..9ea47fe9 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -59,7 +59,7 @@ include "../adminer/drivers/mysql.inc.php"; // must be included as last driver define("SERVER", $_GET[DRIVER]); // read from pgsql=localhost define("DB", $_GET["db"]); // for the sake of speed and size define("ME", preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) . '?' - . (SID && !$_COOKIE ? SID . '&' : '') // !$_COOKIE - don't pass SID with permanent login + . (sid() ? SID . '&' : '') . (SERVER !== null ? DRIVER . "=" . urlencode(SERVER) . '&' : '') . (isset($_GET["username"]) ? "username=" . urlencode($_GET["username"]) . '&' : '') . (DB != "" ? 'db=' . urlencode(DB) . '&' . (isset($_GET["ns"]) ? "ns=" . urlencode($_GET["ns"]) . "&" : "") : '') diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 1ec5d7dd..739a23d2 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -161,6 +161,17 @@ function ini_bool($ini) { return (eregi('^(on|true|yes)$', $val) || (int) $val); // boolean values set by php_value are strings } +/** Check if SID is neccessary +* @return bool +*/ +function sid() { + return (SID && !($_COOKIE && ini_bool("session.use_cookies"))); // $_COOKIE - don't pass SID with permanent login +} + +/** Shortcut for $connection->quote($string) +* @param string +* @return string +*/ function q($string) { global $connection; return $connection->quote($string); @@ -345,7 +356,7 @@ function auth_url($driver, $server, $username) { global $drivers; preg_match('~([^?]*)\\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . session_name()), $match); return "$match[1]?" - . (SID && !$_COOKIE ? SID . "&" : "") + . (sid() ? SID . "&" : "") . ($driver != "server" || $server != "" ? urlencode($driver) . "=" . urlencode($server) . "&" : "") . "username=" . urlencode($username) . ($match[2] ? "&$match[2]" : "") @@ -570,7 +581,7 @@ function hidden_fields($process, $ignore = array()) { * @return null */ function hidden_fields_get() { - echo (SID && !$_COOKIE ? '' : ''); + echo (sid() ? '' : ''); echo (SERVER !== null ? '' : ""); echo ''; }