From 605b09301b403bee051b76788ef762de0ef7710f Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Thu, 6 May 2010 14:21:22 +0200 Subject: [PATCH] List authentications --- adminer/include/adminer.inc.php | 19 +++++++++++++++++-- adminer/include/auth.inc.php | 11 +++-------- adminer/include/functions.inc.php | 17 +++++++++++++++++ editor/include/adminer.inc.php | 13 ++++++++++++- 4 files changed, 49 insertions(+), 11 deletions(-) diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index e14b7eda..9bed3601 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -483,7 +483,7 @@ document.getElementById('username').focus(); * @return null */ function navigation($missing) { - global $VERSION, $connection, $token, $driver; + global $VERSION, $connection, $token, $driver, $drivers; ?>

name(); ?> @@ -491,7 +491,22 @@ document.getElementById('username').focus();

$servers) { // $driver is global variable + foreach ($servers as $server => $usernames) { + foreach ($usernames as $username => $password) { + if (isset($password)) { + if ($first) { + echo "

\n"; + $first = false; + } + echo "($drivers[$key]) " . h($username . ($server != "" ? "@$server" : "")) . "
\n"; + } + } + } + } + } else { $databases = get_databases(); ?>

diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 6bf8af10..1440f8a5 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -28,13 +28,7 @@ if (isset($_POST["server"])) { || SERVER != $_POST["server"] || $_GET["username"] !== $_POST["username"] // "0" == "00" ) { - preg_match('~([^?]*)\\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . session_name()), $match); - redirect("$match[1]?" - . (SID ? SID . "&" : "") - . ($_POST["driver"] != "server" || $_POST["server"] != "" ? urlencode($_POST["driver"]) . "=" . urlencode($_POST["server"]) . "&" : "") - . "username=" . urlencode($_POST["username"]) - . ($match[2] ? "&$match[2]" : "") - ); + redirect(auth_url($_POST["driver"], $_POST["server"], $_POST["username"])); } } elseif ($_POST["logout"]) { if ($token && $_POST["token"] != $token) { @@ -67,9 +61,10 @@ function auth_error($exception = null) { if (($_COOKIE[$session_name] || $_GET[$session_name]) && !$token) { $error = lang('Session expired, please login again.'); } else { - $password = get_session("passwords"); + $password = &get_session("passwords"); if (isset($password)) { $error = h($exception ? $exception->getMessage() : (is_string($connection) ? $connection : lang('Invalid credentials.'))); + $password = null; } } } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index f7a30a71..37a4d6be 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -285,6 +285,23 @@ function set_session($key, $val) { $_SESSION[$key][DRIVER][SERVER][$_GET["username"]] = $val; // used also in auth.inc.php } +/** Get authenticated URL +* @param string +* @param string +* @param string +* @return string +*/ +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 ? SID . "&" : "") + . ($driver != "server" || $server != "" ? urlencode($driver) . "=" . urlencode($server) . "&" : "") + . "username=" . urlencode($username) + . ($match[2] ? "&$match[2]" : "") + ; +} + /** Send Location header and exit * @param string null to only set a message * @param string diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index accf1879..3c18971c 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -447,7 +447,18 @@ ORDER BY ORDINAL_POSITION"); $password) { + if (isset($password)) { + if ($first) { + echo "

\n"; + $first = false; + } + echo "" . h($username) . "
\n"; + } + } + } else { ?>