]> git.joonet.de Git - adminer.git/commitdiff
Work without session.use_cookies (bug #3138640)
authorJakub Vrana <jakub@vrana.cz>
Mon, 20 Dec 2010 17:09:13 +0000 (18:09 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 20 Dec 2010 17:09:13 +0000 (18:09 +0100)
adminer/include/bootstrap.inc.php
adminer/include/functions.inc.php

index 61e18ca2842fe5e1d9215557b4625a6e49e41fcd..9ea47fe95cc0cf205e017279b0d7e75853a526ae 100644 (file)
@@ -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"]) . "&" : "") : '')
index 1ec5d7dde139dac981dd4b6774e8ee06c2769cac..739a23d2c043953d9aa21abc0d25560c14769d33 100644 (file)
@@ -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 ? '<input type="hidden" name="' . session_name() . '" value="' . h(session_id()) . '">' : '');
+       echo (sid() ? '<input type="hidden" name="' . session_name() . '" value="' . h(session_id()) . '">' : '');
        echo (SERVER !== null ? '<input type="hidden" name="' . DRIVER . '" value="' . h(SERVER) . '">' : "");
        echo '<input type="hidden" name="username" value="' . h($_GET["username"]) . '">';
 }