Skip to content

Commit

Permalink
Allow specifying database in login form (bug #3499359)
Browse files Browse the repository at this point in the history
  • Loading branch information
vrana committed May 14, 2012
1 parent f595f93 commit 8be29af
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions adminer/include/adminer.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function loginForm() {
<tr><th><?php echo lang('Server'); ?><td><input name="auth[server]" value="<?php echo h(SERVER); ?>" title="hostname[:port]"> <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('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('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> </table>
<script type="text/javascript"> <script type="text/javascript">
var username = document.getElementById('username'); var username = document.getElementById('username');
Expand Down
3 changes: 2 additions & 1 deletion adminer/include/auth.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
|| DRIVER != $auth["driver"] || DRIVER != $auth["driver"]
|| SERVER != $auth["server"] || SERVER != $auth["server"]
|| $_GET["username"] !== $auth["username"] // "0" == "00" || $_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"]) { } elseif ($_POST["logout"]) {
if ($token && $_POST["token"] != $token) { if ($token && $_POST["token"] != $token) {
Expand Down
6 changes: 4 additions & 2 deletions adminer/include/functions.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -418,15 +418,17 @@ function set_session($key, $val) {
* @param string * @param string
* @param string * @param string
* @param string * @param string
* @param string
* @return string * @return string
*/ */
function auth_url($driver, $server, $username) { function auth_url($driver, $server, $username, $db = null) {
global $drivers; 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]?" return "$match[1]?"
. (sid() ? SID . "&" : "") . (sid() ? SID . "&" : "")
. ($driver != "server" || $server != "" ? urlencode($driver) . "=" . urlencode($server) . "&" : "") . ($driver != "server" || $server != "" ? urlencode($driver) . "=" . urlencode($server) . "&" : "")
. "username=" . urlencode($username) . "username=" . urlencode($username)
. ($db != "" ? "&db=" . urlencode($db) : "")
. ($match[2] ? "&$match[2]" : "") . ($match[2] ? "&$match[2]" : "")
; ;
} }
Expand Down
2 changes: 1 addition & 1 deletion adminer/static/editing.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function typePassword(el, disable) {


function loginDriver(driver) { function loginDriver(driver) {
var trs = driver.parentNode.parentNode.parentNode.rows; var trs = driver.parentNode.parentNode.parentNode.rows;
for (var i=1; i < trs.length; i++) { for (var i=1; i < trs.length - 1; i++) {
trs[i].className = (/sqlite/.test(driver.value) ? 'hidden' : ''); trs[i].className = (/sqlite/.test(driver.value) ? 'hidden' : '');
} }
} }
Expand Down
1 change: 1 addition & 0 deletions changes.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Adminer 3.4.0-dev:
Print current time next to executed SQL queries Print current time next to executed SQL queries
Highlight code in SQL command by CodeMirror Highlight code in SQL command by CodeMirror
Link to descending order Link to descending order
Allow specifying database in login form
Link to original table in EXPLAIN of SELECT * FROM table t Link to original table in EXPLAIN of SELECT * FROM table t
MySQL: inform about disabled event_scheduler MySQL: inform about disabled event_scheduler
SQLite: support binary data SQLite: support binary data
Expand Down

0 comments on commit 8be29af

Please sign in to comment.