mirror of
https://github.com/vrana/adminer.git
synced 2025-08-16 11:34:10 +02:00
Allow specifying database in login form (bug #3499359)
This commit is contained in:
@@ -67,6 +67,7 @@ class Adminer {
|
||||
<tr><th><?php echo lang('Server'); ?><td><input name="auth[server]" value="<?php echo h(SERVER); ?>" title="hostname[:port]">
|
||||
<tr><th><?php echo lang('Username'); ?><td><input id="username" name="auth[username]" value="<?php echo h($_GET["username"]); ?>">
|
||||
<tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
|
||||
<tr><th><?php echo lang('Database'); ?><td><input name="auth[db]" value="<?php echo h($_GET["db"]); ?>">
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
var username = document.getElementById('username');
|
||||
|
@@ -28,8 +28,9 @@ if ($auth) {
|
||||
|| DRIVER != $auth["driver"]
|
||||
|| SERVER != $auth["server"]
|
||||
|| $_GET["username"] !== $auth["username"] // "0" == "00"
|
||||
|| DB != $auth["db"]
|
||||
) {
|
||||
redirect(auth_url($auth["driver"], $auth["server"], $auth["username"]));
|
||||
redirect(auth_url($auth["driver"], $auth["server"], $auth["username"], $auth["db"]));
|
||||
}
|
||||
} elseif ($_POST["logout"]) {
|
||||
if ($token && $_POST["token"] != $token) {
|
||||
|
@@ -418,15 +418,17 @@ function set_session($key, $val) {
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function auth_url($driver, $server, $username) {
|
||||
function auth_url($driver, $server, $username, $db = null) {
|
||||
global $drivers;
|
||||
preg_match('~([^?]*)\\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . session_name()), $match);
|
||||
preg_match('~([^?]*)\\??(.*)~', remove_from_uri(implode("|", array_keys($drivers)) . "|username|" . ($db !== null ? "db|" : "") . session_name()), $match);
|
||||
return "$match[1]?"
|
||||
. (sid() ? SID . "&" : "")
|
||||
. ($driver != "server" || $server != "" ? urlencode($driver) . "=" . urlencode($server) . "&" : "")
|
||||
. "username=" . urlencode($username)
|
||||
. ($db != "" ? "&db=" . urlencode($db) : "")
|
||||
. ($match[2] ? "&$match[2]" : "")
|
||||
;
|
||||
}
|
||||
|
Reference in New Issue
Block a user