Allow connecting to different drivers in login-servers
This commit is contained in:
parent
cd503f6a0d
commit
3410836c12
|
@ -119,11 +119,11 @@ class Adminer {
|
|||
function loginForm() {
|
||||
global $drivers;
|
||||
echo "<table cellspacing='0'>\n";
|
||||
echo $this->loginFormField('driver', '<tr><th>' . lang('System') . '<td>' . html_select("auth[driver]", $drivers, DRIVER) . "\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"]) . '" autocapitalize="off">' . script("focus(qs('#username'));"));
|
||||
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td><input type="password" name="auth[password]">' . "\n");
|
||||
echo $this->loginFormField('db', '<tr><th>' . lang('Database') . '<td><input name="auth[db]" value="' . h($_GET["db"]) . '" autocapitalize="off">' . "\n");
|
||||
echo $this->loginFormField('driver', '<tr><th>' . lang('System') . '<td>', html_select("auth[driver]", $drivers, DRIVER) . "\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"]) . '" autocapitalize="off">' . script("focus(qs('#username'));"));
|
||||
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input type="password" name="auth[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";
|
||||
|
@ -132,10 +132,11 @@ class Adminer {
|
|||
/** Get login form field
|
||||
* @param string
|
||||
* @param string HTML
|
||||
* @param string HTML
|
||||
* @return string
|
||||
*/
|
||||
function loginFormField($name, $default) {
|
||||
return $default;
|
||||
function loginFormField($name, $heading, $value) {
|
||||
return $heading . $value;
|
||||
}
|
||||
|
||||
/** Authorize the user
|
||||
|
|
|
@ -72,15 +72,15 @@ class Adminer {
|
|||
|
||||
function loginForm() {
|
||||
echo "<table cellspacing='0'>\n";
|
||||
echo $this->loginFormField('username', '<tr><th>' . lang('Username') . '<td><input type="hidden" name="auth[driver]" value="server"><input name="auth[username]" id="username" value="' . h($_GET["username"]) . '" autocapitalize="off">' . script("focus(qs('#username'));"));
|
||||
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td><input type="password" name="auth[password]">' . "\n");
|
||||
echo $this->loginFormField('username', '<tr><th>' . lang('Username') . '<td>', '<input type="hidden" name="auth[driver]" value="server"><input name="auth[username]" id="username" value="' . h($_GET["username"]) . '" autocapitalize="off">' . script("focus(qs('#username'));"));
|
||||
echo $this->loginFormField('password', '<tr><th>' . lang('Password') . '<td>', '<input type="password" name="auth[password]">' . "\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";
|
||||
}
|
||||
|
||||
function loginFormField($name, $default) {
|
||||
return $default;
|
||||
function loginFormField($name, $heading, $value) {
|
||||
return $heading . $value;
|
||||
}
|
||||
|
||||
function login($login, $password) {
|
||||
|
|
|
@ -21,9 +21,9 @@ class AdminerLoginOtp {
|
|||
}
|
||||
}
|
||||
|
||||
function loginFormField($name, $default) {
|
||||
function loginFormField($name, $heading, $value) {
|
||||
if ($name == 'password') {
|
||||
return $default
|
||||
return $heading . $value
|
||||
. "<tr><th><acronym title='One Time Password' lang='en'>OTP</acronym>"
|
||||
. "<td><input type='number' name='auth[otp]' value='" . h($_SESSION["otp"]) . "' size='6' autocomplete='off'>\n"
|
||||
;
|
||||
|
|
|
@ -8,48 +8,35 @@
|
|||
*/
|
||||
class AdminerLoginServers {
|
||||
/** @access protected */
|
||||
var $servers, $driver;
|
||||
var $servers;
|
||||
|
||||
/** Set supported servers
|
||||
* @param array array($domain) or array($domain => $description) or array($category => array())
|
||||
* @param string
|
||||
* @param array array($description => array("server" => , "driver" => "server|pgsql|sqlite|..."))
|
||||
*/
|
||||
function __construct($servers, $driver = "server") {
|
||||
function __construct($servers) {
|
||||
$this->servers = $servers;
|
||||
$this->driver = $driver;
|
||||
if ($_POST["auth"]) {
|
||||
$key = $_POST["auth"]["server"];
|
||||
$_POST["auth"]["driver"] = $this->servers[$key]["driver"];
|
||||
}
|
||||
}
|
||||
|
||||
function serverName($server) {
|
||||
return h($this->servers[$server]);
|
||||
function credentials() {
|
||||
return array($this->servers[SERVER]["server"], $_GET["username"], get_password());
|
||||
}
|
||||
|
||||
function login($login, $password) {
|
||||
// check if server is allowed
|
||||
foreach ($this->servers as $key => $val) {
|
||||
$servers = $val;
|
||||
if (!is_array($val)) {
|
||||
$servers = array($key => $val);
|
||||
}
|
||||
foreach ($servers as $k => $v) {
|
||||
if ((is_string($k) ? $k : $v) == SERVER) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!$this->servers[SERVER]) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function loginForm() {
|
||||
?>
|
||||
<table cellspacing="0">
|
||||
<tr><th><?php echo lang('Server'); ?><td><input type="hidden" name="auth[driver]" value="<?php echo $this->driver; ?>"><select name="auth[server]"><?php echo optionlist($this->servers, SERVER); ?></select>
|
||||
<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]">
|
||||
</table>
|
||||
<p><input type="submit" value="<?php echo lang('Login'); ?>">
|
||||
<?php
|
||||
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
|
||||
return true;
|
||||
function loginFormField($name, $heading, $value) {
|
||||
if ($name == 'driver') {
|
||||
return '';
|
||||
} elseif ($name == 'server') {
|
||||
return $heading . "<select name='auth[server]'>" . optionlist(array_keys($this->servers), SERVER) . "</select>\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ class AdminerPlugin extends Adminer {
|
|||
return $this->_applyPlugin(__FUNCTION__, $args);
|
||||
}
|
||||
|
||||
function loginFormField($name, $default) {
|
||||
function loginFormField($name, $heading, $value) {
|
||||
$args = func_get_args();
|
||||
return $this->_applyPlugin(__FUNCTION__, $args);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue