adminerevo/plugins/login-servers.php

52 lines
1.7 KiB
PHP
Raw Normal View History

<?php
/** Display constant list of servers in login form
2015-09-08 16:23:25 +00:00
* @link https://www.adminer.org/plugins/#use
2017-02-27 12:43:33 +00:00
* @author Jakub Vrana, https://www.vrana.cz/
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
*/
class AdminerLoginServers {
2011-08-11 15:06:42 +00:00
/** @access protected */
var $servers, $driver;
/** Set supported servers
* @param array array($domain) or array($domain => $description) or array($category => array())
2011-06-07 13:47:11 +00:00
* @param string
*/
2015-08-15 15:04:21 +00:00
function __construct($servers, $driver = "server") {
$this->servers = $servers;
2011-06-07 13:47:11 +00:00
$this->driver = $driver;
}
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;
}
}
}
return false;
}
function loginForm() {
?>
<table cellspacing="0">
2012-05-14 07:08:32 +00:00
<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
2012-05-14 07:08:32 +00:00
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
return true;
}
}