Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No username, server or password for sqlite #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions adminer/include/adminer.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,42 @@ function css() {
*/
function loginForm() {
global $drivers;

echo "<table cellspacing='0' class='layout'>\n";
echo $this->loginFormField('driver', '<tr><th>' . lang('System') . '<td>', html_select("auth[driver]", $drivers, DRIVER, "loginDriver(this);") . "\n");
echo $this->loginFormField('server', '<tr><th>' . lang('Server') . '<td>', '<input name="auth[server]" value="' . h(SERVER) . '" title="hostname[:port]" placeholder="localhost" autocapitalize="off">' . "\n");
echo $this->loginFormField('username', '<tr><th>' . lang('Username') . '<td>', '<input name="auth[username]" id="username" value="' . h($_GET["username"]) . '" autocomplete="username" autocapitalize="off">' . script("focus(qs('#username')); qs('#username').form['auth[driver]'].onchange();"));
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input type="password" name="auth[password]" autocomplete="current-password">' . "\n");
echo $this->loginFormField('driver', '<tr><th>' . lang('System') . '<td>', html_select("auth[driver]", $drivers, DRIVER, "loginDriver(this);"));
echo $this->loginFormField('server', '<tr><th>' . lang('Server') . '<td>', '<input id="serverfield" name="auth[server]" value="' . h(SERVER) . '" title="hostname[:port]" placeholder="localhost" autocapitalize="off">' . "\n");
echo $this->loginFormField('username', '<tr><th>' . lang('Username') . '<td>', '<input id="usernamefield" name="auth[username]" id="username" value="' . h($_GET["username"]) . '" autocomplete="username" autocapitalize="off">' . script("focus(qs('#username')); qs('#username').form['auth[driver]'].onchange();"));
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input id="passwordfield" type="password" name="auth[password]" autocomplete="current-password">' . "\n");
echo $this->loginFormField('db', '<tr><th>' . lang('Database') . '<td>', '<input name="auth[db]" value="' . h($_GET["db"]) . '" autocapitalize="off">' . "\n");
echo "</table>\n";
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";

echo script("
window.addEventListener('load', (event) => {
var authDriverSelect = document.getElementById('auth_driver');
var serverFieldRow = document.getElementById('serverfield').closest('tr');
var usernameFieldRow = document.getElementById('usernamefield').closest('tr');
var passwordFieldRow = document.getElementById('passwordfield').closest('tr');

function toggleFields() {
console.debug('toggleFields')
if (authDriverSelect.value === 'sqlite' || authDriverSelect.value === 'sqlite2') {
passwordFieldRow.style.display = 'none';
serverFieldRow.style.display = 'none';
usernameFieldRow.style.display = 'none';
} else {
passwordFieldRow.style.display = '';
serverFieldRow.style.display = '';
usernameFieldRow.style.display = '';
}
}

authDriverSelect.addEventListener('change', toggleFields);

toggleFields();
});");

}

/** Get login form field
Expand Down
1 change: 1 addition & 0 deletions adminer/include/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ function optionlist($options, $selected = null, $use_keys = false) {
function html_select($name, $options, $value = "", $onchange = true, $labelled_by = "") {
if ($onchange) {
return "<select name='" . h($name) . "'"
. ($onchange === "loginDriver(this);" ? " id='auth_driver' " : "")
. ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
. ">" . optionlist($options, $value) . "</select>"
. (is_string($onchange) ? script("qsl('select').onchange = function () { $onchange };", "") : "")
Expand Down
2 changes: 1 addition & 1 deletion adminer/include/version.inc.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?php
$VERSION = "4.8.4";
$VERSION = "4.9.1";
18 changes: 18 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.