Skip to content
Browse files

Store database to permanent login

  • Loading branch information...
1 parent 741c073 commit a0d00cf7327c11338791ec33d34133569750b15e @vrana committed Sep 8, 2012
Showing with 16 additions and 8 deletions.
  1. +4 −1 adminer/include/adminer.inc.php
  2. +11 −7 adminer/include/auth.inc.php
  3. +1 −0 changes.txt
View
5 adminer/include/adminer.inc.php
@@ -801,7 +801,10 @@ function navigation($missing) {
echo "<p id='logins' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
$first = false;
}
- echo "<a href='" . h(auth_url($driver, $server, $username)) . "'>($drivers[$driver]) " . h($username . ($server != "" ? "@$server" : "")) . "</a><br>\n";
+ $dbs = $_SESSION["db"][$driver][$server][$username];
+ foreach (($dbs ? array_keys($dbs) : array("")) as $db) {
+ echo "<a href='" . h(auth_url($driver, $server, $username, $db)) . "'>($drivers[$driver]) " . h($username . ($server != "" ? "@$server" : "") . ($db != "" ? " - $db" : "")) . "</a><br>\n";
+ }
}
}
}
View
18 adminer/include/auth.inc.php
@@ -18,8 +18,9 @@
if ($auth) {
session_regenerate_id(); // defense against session fixation
$_SESSION["pwds"][$auth["driver"]][$auth["server"]][$auth["username"]] = $auth["password"];
+ $_SESSION["db"][$auth["driver"]][$auth["server"]][$auth["username"]][$auth["db"]] = true;
if ($auth["permanent"]) {
- $key = base64_encode($auth["driver"]) . "-" . base64_encode($auth["server"]) . "-" . base64_encode($auth["username"]);
+ $key = base64_encode($auth["driver"]) . "-" . base64_encode($auth["server"]) . "-" . base64_encode($auth["username"]) . "-" . base64_encode($auth["db"]);
$private = $adminer->permanentLogin();
$permanent[$key] = "$key:" . base64_encode($private ? encrypt_string($auth["password"], $private) : "");
cookie("adminer_permanent", implode(" ", $permanent));
@@ -38,7 +39,7 @@
page_footer("db");
exit;
} else {
- foreach (array("pwds", "dbs", "queries") as $key) {
+ foreach (array("pwds", "db", "dbs", "queries") as $key) {
set_session($key, null);
}
unset_permanent();
@@ -49,18 +50,21 @@
$private = $adminer->permanentLogin(); // try to decode even if not set
foreach ($permanent as $key => $val) {
list(, $cipher) = explode(":", $val);
- list($driver, $server, $username) = array_map('base64_decode', explode("-", $key));
+ list($driver, $server, $username, $db) = array_map('base64_decode', explode("-", $key));
$_SESSION["pwds"][$driver][$server][$username] = decrypt_string(base64_decode($cipher), $private);
+ $_SESSION["db"][$driver][$server][$username][$db] = true;
}
}
function unset_permanent() {
global $permanent;
- $key = base64_encode(DRIVER) . "-" . base64_encode(SERVER) . "-" . base64_encode($_GET["username"]);
- if ($permanent[$key]) {
- unset($permanent[$key]);
- cookie("adminer_permanent", implode(" ", $permanent));
+ foreach ($permanent as $key => $val) {
+ list($driver, $server, $username) = array_map('base64_decode', explode("-", $key));
+ if ($driver == DRIVER && $server == SERVER && $db == $_GET["username"]) {
+ unset($permanent[$key]);
+ }
}
+ cookie("adminer_permanent", implode(" ", $permanent));
}
function auth_error($exception = null) {
View
1 changes.txt
@@ -4,6 +4,7 @@ Edit strings with \n in textarea
Time out long running database list and select count
Use VALUES() in INSERT+UPDATE export
Style logout button as link
+Store selected database to permanent login
Ctrl+click and Shift+click on button opens form to a blank window
Switch language by POST
Compress translations

0 comments on commit a0d00cf

Please sign in to comment.
Something went wrong with that request. Please try again.