diff --git a/plugins/import-from-dir.php b/plugins/import-from-dir.php new file mode 100644 index 00000000..7d65d301 --- /dev/null +++ b/plugins/import-from-dir.php @@ -0,0 +1,85 @@ +dir = $dir; + } + + protected function _readFiles($gz = false) { + $mapped = array(); + $glob = "$this->dir*.[Ss][Qq][Ll]"; + if ($gz) { + $suffix = '.gz'; # lowercase only because of core + $glob .= $suffix; + $suffix_cut = -3; + } + if ($files = glob($glob)) { + $from = strlen($this->dir); + foreach ($files as $file) { + if ($from) { + $file = substr($file, $from); # do not expose server paths in output + } + if ($gz) { + $mapped[substr($file, 0, $suffix_cut)] = $file; + } + else { + $mapped[$file] = $file; + } + } + } + return $mapped; + } + + function importServerPath() { + static $posted = null; + + $files = $this->_readFiles(); + if (extension_loaded('zlib')) { + $files += $this->_readFiles(true); # core prioritises files without .gz + } + if (count($files) > 1) { + ksort($files); + } + + if ($posted !== null || !isset($_POST['webfile'])) { + # use existing translation strings + echo "
" . lang('From server') . "
"; + echo lang('Webserver file %s', ''); + echo ' '; + echo "
\n"; + $posted = null; + return false; # skip core UI + } + + if ( + empty($_POST['webfilename']) + || !is_string($_POST['webfilename']) + || !array_key_exists($_POST['webfilename'], $files) + ) { + $posted = ''; + return 'SELECTED_FILE_DOES_NOT_EXIST'; # can't return empty string because of core file_exists() check + } + + $posted = $_POST['webfilename']; + return $this->dir . $posted; + } +} diff --git a/plugins/login-external.php b/plugins/login-external.php new file mode 100644 index 00000000..20926bb5 --- /dev/null +++ b/plugins/login-external.php @@ -0,0 +1,138 @@ +driver)) { + $externals->driver = 'server'; + } + if (isset($_POST['auth'])) { + $_POST['auth']['driver'] = $externals->driver; + $_POST['auth']['server'] = $_POST['auth']['username'] = $_POST['auth']['password'] = ''; + } + $this->externals = $externals; + } + + function name() { + return empty($this->externals->app_name) ? null : $this->externals->app_name; + } + + function credentials() { + if (empty($this->externals->authenticated)) { + # always check external stat rather than relying on adminer's session login + auth_error( + empty($this->externals->expired_html) ? + 'External authentication expired.' : + $this->externals->expired_html + ); + return false; + } + return [ + $this->externals->server, + $this->externals->username, + $this->externals->password, + ]; + } + + function database() { + return empty($this->externals->database) ? null : $this->externals->database; + } + + function loginForm() { + if (empty($this->externals->authenticated)) { + if (empty($this->externals->failure_html)) { + echo '

You must first log in to the system that grants access to this tool.

'; + } + else { + echo $this->externals->failure_html; + } + return false; + } + + if (empty($this->externals->manual_login)) { + echo script( + <<database()); + return << + +EOHTML; + case 'driver': + if (function_exists('get_driver')) { + $value = h($this->externals->driver); + $driver = h(get_driver($this->externals->driver)) ?: 'Unknown'; + return <<$driver + +EOHTML; + } + $value = ' value="' . h($this->externals->driver) . '"'; + # don't break + case 'server': + case 'username': + case 'password': + return << + +EOHTML; + } + } + + function login($login, $password) { + return !empty($this->externals->authenticated); + } +} diff --git a/plugins/tables-filter.php b/plugins/tables-filter.php index ab716531..68b9b809 100644 --- a/plugins/tables-filter.php +++ b/plugins/tables-filter.php @@ -54,16 +54,39 @@ function tablesFilterInput() { } sessionStorage && document.addEventListener('DOMContentLoaded', function () { - var db = qs('#dbs').querySelector('select'); - db = db.options[db.selectedIndex].text; - if (db == sessionStorage.getItem('adminer_tables_filter_db') && sessionStorage.getItem('adminer_tables_filter')){ - qs('#filter-field').value = sessionStorage.getItem('adminer_tables_filter'); - tablesFilter(); + if (qs('#dbs') != null) { + var db = qs('#dbs').querySelector('select'); + db = db.options[db.selectedIndex].text; + if (db == sessionStorage.getItem('adminer_tables_filter_db') && sessionStorage.getItem('adminer_tables_filter')){ + qs('#filter-field').value = sessionStorage.getItem('adminer_tables_filter'); + tablesFilter(); + } + sessionStorage.setItem('adminer_tables_filter_db', db); } - sessionStorage.setItem('adminer_tables_filter_db', db); + document.addEventListener('keyup', function(event) { + if (event.ctrlKey && event.shiftKey && event.key == 'F') { + qs('#filter-field').focus(); + return; + } + }); + qs('#filter-field').addEventListener('keydown', function(event) { + if (event.key == 'Enter' || event.keyCode == 13 || event.which == 13) { + event.preventDefault(); + return false; + } + }); }); -

+ +

+ +
+ + + +
+
+