]> git.joonet.de Git - adminer.git/commitdiff
New plugin: Display constant list of servers in login form
authorJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 09:16:01 +0000 (10:16 +0100)
committerJakub Vrana <jakub@vrana.cz>
Mon, 21 Mar 2011 09:16:01 +0000 (10:16 +0100)
plugins/login-servers.php [new file with mode: 0644]

diff --git a/plugins/login-servers.php b/plugins/login-servers.php
new file mode 100644 (file)
index 0000000..691b730
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+/** Display constant list of servers in login form
+* @author Jakub Vrana, http://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 {
+       var $servers;
+       
+       /** Set supported servers
+       * @param array array($domain) or array($domain => $description) or array($category => array())
+       */
+       function AdminerLoginServers($servers) {
+               $this->servers = $servers;
+       }
+       
+       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">
+<tr><th><?php echo lang('Server'); ?><td><input type="hidden" name="driver" value="server"><select name="server"><?php echo optionlist($this->servers, SERVER); ?></select>
+<tr><th><?php echo lang('Username'); ?><td><input id="username" name="username" value="<?php echo h($_GET["username"]);  ?>">
+<tr><th><?php echo lang('Password'); ?><td><input type="password" name="password">
+</table>
+<p><input type="submit" value="<?php echo lang('Login'); ?>">
+<?php
+               echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
+               return true;
+       }
+       
+}