2011-03-21 10:16:01 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/** Display constant list of servers in login form
|
2015-09-08 09:23:25 -07:00
|
|
|
* @link https://www.adminer.org/plugins/#use
|
2017-02-27 13:43:33 +01:00
|
|
|
* @author Jakub Vrana, https://www.vrana.cz/
|
2018-01-14 11:03:54 +01:00
|
|
|
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
|
|
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
2011-03-21 10:16:01 +01:00
|
|
|
*/
|
|
|
|
|
class AdminerLoginServers {
|
2011-08-11 17:06:42 +02:00
|
|
|
/** @access protected */
|
2018-02-22 12:38:22 +01:00
|
|
|
var $servers;
|
2025-02-21 13:53:18 +01:00
|
|
|
|
2011-03-21 10:16:01 +01:00
|
|
|
/** Set supported servers
|
2025-03-02 03:17:14 +01:00
|
|
|
* @param array [$description => ["server" => , "driver" => "server|pgsql|sqlite|..."]]
|
2011-03-21 10:16:01 +01:00
|
|
|
*/
|
2018-02-22 12:38:22 +01:00
|
|
|
function __construct($servers) {
|
2011-03-21 10:16:01 +01:00
|
|
|
$this->servers = $servers;
|
2018-02-22 12:38:22 +01:00
|
|
|
if ($_POST["auth"]) {
|
|
|
|
|
$key = $_POST["auth"]["server"];
|
|
|
|
|
$_POST["auth"]["driver"] = $this->servers[$key]["driver"];
|
|
|
|
|
}
|
2011-03-21 10:16:01 +01:00
|
|
|
}
|
2025-02-21 13:53:18 +01:00
|
|
|
|
2018-02-22 12:38:22 +01:00
|
|
|
function credentials() {
|
2025-03-06 17:34:21 +01:00
|
|
|
return array($this->servers[Adminer\SERVER]["server"], $_GET["username"], Adminer\get_password());
|
2018-02-08 14:27:44 +01:00
|
|
|
}
|
2025-02-21 13:53:18 +01:00
|
|
|
|
2011-03-21 10:16:01 +01:00
|
|
|
function login($login, $password) {
|
2025-03-06 17:34:21 +01:00
|
|
|
if (!$this->servers[Adminer\SERVER]) {
|
2018-02-22 12:38:22 +01:00
|
|
|
return false;
|
2011-03-21 10:16:01 +01:00
|
|
|
}
|
|
|
|
|
}
|
2025-02-21 13:53:18 +01:00
|
|
|
|
2018-02-22 12:38:22 +01:00
|
|
|
function loginFormField($name, $heading, $value) {
|
|
|
|
|
if ($name == 'driver') {
|
|
|
|
|
return '';
|
|
|
|
|
} elseif ($name == 'server') {
|
2025-03-08 19:57:36 +01:00
|
|
|
return $heading . Adminer\html_select("auth[server]", array_keys($this->servers), Adminer\SERVER) . "\n";
|
2018-02-22 12:38:22 +01:00
|
|
|
}
|
2011-03-21 10:16:01 +01:00
|
|
|
}
|
|
|
|
|
}
|