]> git.joonet.de Git - adminer.git/commitdiff
Add SQLite auto-login plugin
authorJakub Vrana <jakub@vrana.cz>
Mon, 28 Nov 2016 18:09:51 +0000 (10:09 -0800)
committerJakub Vrana <jakub@vrana.cz>
Mon, 28 Nov 2016 18:09:51 +0000 (10:09 -0800)
plugins/login-sqlite.php [new file with mode: 0644]

diff --git a/plugins/login-sqlite.php b/plugins/login-sqlite.php
new file mode 100644 (file)
index 0000000..d598fdb
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+/** Enable auto-login for SQLite
+* @link https://www.adminer.org/plugins/#use
+* @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 AdminerLoginSqlite {
+
+       function login($login, $password) {
+               return true;
+       }
+
+       function loginForm() {
+               ?>
+<script type="text/javascript">
+addEventListener('load', function () {
+       var driver = document.getElementsByName('auth[driver]')[0];
+       if (isTag(driver, 'select')) {
+               driver.onchange = function () {
+                       var trs = parentTag(driver, 'table').rows;
+                       for (var i=1; i < trs.length - 1; i++) {
+                               var disabled = /sqlite/.test(driver.value);
+                               alterClass(trs[i], 'hidden', disabled);
+                               trs[i].getElementsByTagName('input')[0].disabled = disabled;
+                       }
+               };
+       }
+       driver.onchange();
+});
+</script>
+<?php
+       }
+
+}