From 868db8058391862a1b7d2ef207af73906b45f572 Mon Sep 17 00:00:00 2001 From: mattpass Date: Wed, 3 Mar 2021 13:23:48 +0000 Subject: [PATCH] Adminer 4.8.0 working in frame --- lib/adminer-plugins/frames.php | 28 + lib/adminer-plugins/plugin.php | 406 +++++++ lib/database-adminer-480-en.php | 1786 ++++++++++++++++++++++++++++++ lib/database.php | 1797 +------------------------------ 4 files changed, 2233 insertions(+), 1784 deletions(-) create mode 100644 lib/adminer-plugins/frames.php create mode 100644 lib/adminer-plugins/plugin.php create mode 100644 lib/database-adminer-480-en.php diff --git a/lib/adminer-plugins/frames.php b/lib/adminer-plugins/frames.php new file mode 100644 index 0000000..eb80098 --- /dev/null +++ b/lib/adminer-plugins/frames.php @@ -0,0 +1,28 @@ +sameOrigin = $sameOrigin; + } + + function headers() { + if ($this->sameOrigin) { + header("X-Frame-Options: SameOrigin"); + } elseif (function_exists('header_remove')) { + header_remove("X-Frame-Options"); + } + } + +} diff --git a/lib/adminer-plugins/plugin.php b/lib/adminer-plugins/plugin.php new file mode 100644 index 0000000..265f8fe --- /dev/null +++ b/lib/adminer-plugins/plugin.php @@ -0,0 +1,406 @@ +_findRootClass($class), 'Adminer')) { //! can use interface + $plugins[$class] = new $class; + } + } + } + $this->plugins = $plugins; + //! it is possible to use ReflectionObject to find out which plugins defines which methods at once + } + + function _callParent($function, $args) { + return call_user_func_array(array('parent', $function), $args); + } + + function _applyPlugin($function, $args) { + foreach ($this->plugins as $plugin) { + if (method_exists($plugin, $function)) { + switch (count($args)) { // call_user_func_array() doesn't work well with references + case 0: $return = $plugin->$function(); break; + case 1: $return = $plugin->$function($args[0]); break; + case 2: $return = $plugin->$function($args[0], $args[1]); break; + case 3: $return = $plugin->$function($args[0], $args[1], $args[2]); break; + case 4: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3]); break; + case 5: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4]); break; + case 6: $return = $plugin->$function($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); break; + default: trigger_error('Too many parameters.', E_USER_WARNING); + } + if ($return !== null) { + return $return; + } + } + } + return $this->_callParent($function, $args); + } + + function _appendPlugin($function, $args) { + $return = $this->_callParent($function, $args); + foreach ($this->plugins as $plugin) { + if (method_exists($plugin, $function)) { + $value = call_user_func_array(array($plugin, $function), $args); + if ($value) { + $return += $value; + } + } + } + return $return; + } + + // appendPlugin + + function dumpFormat() { + $args = func_get_args(); + return $this->_appendPlugin(__FUNCTION__, $args); + } + + function dumpOutput() { + $args = func_get_args(); + return $this->_appendPlugin(__FUNCTION__, $args); + } + + function editRowPrint($table, $fields, $row, $update) { + } + + function editFunctions($field) { + $args = func_get_args(); + return $this->_appendPlugin(__FUNCTION__, $args); + } + + // applyPlugin + + function name() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function credentials() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function connectSsl() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function permanentLogin($create = false) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function bruteForceKey() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function serverName($server) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function database() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function schemas() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function databases($flush = true) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function queryTimeout() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function headers() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function csp() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function head() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function css() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function loginForm() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function loginFormField($name, $heading, $value) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function login($login, $password) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function tableName($tableStatus) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function fieldName($field, $order = 0) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLinks($tableStatus, $set = "") { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function foreignKeys($table) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function backwardKeys($table, $tableName) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function backwardKeysPrint($backwardKeys, $row) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectQuery($query, $start, $failed = false) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function sqlCommandQuery($query) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function rowDescription($table) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function rowDescriptions($rows, $foreignKeys) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLink($val, $field) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectVal($val, $link, $field, $original) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function editVal($val, $field) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function tableStructurePrint($fields) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function tableIndexesPrint($indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectColumnsPrint($select, $columns) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectSearchPrint($where, $columns, $indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectOrderPrint($order, $columns, $indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLimitPrint($limit) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLengthPrint($text_length) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectActionPrint($indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectCommandPrint() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectImportPrint() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectEmailPrint($emailFields, $columns) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectColumnsProcess($columns, $indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectSearchProcess($fields, $indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectOrderProcess($fields, $indexes) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLimitProcess() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectLengthProcess() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectEmailProcess($where, $foreignKeys) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function selectQueryBuild($select, $where, $group, $order, $limit, $page) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function messageQuery($query, $time, $failed = false) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function editInput($table, $field, $attrs, $value) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function editHint($table, $field, $value) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function processInput($field, $value, $function = "") { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function dumpDatabase($db) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function dumpTable($table, $style, $is_view = 0) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function dumpData($table, $style, $query) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function dumpFilename($identifier) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function dumpHeaders($identifier, $multi_table = false) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function importServerPath() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function homepage() { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function navigation($missing) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function databasesPrint($missing) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + + function tablesPrint($tables) { + $args = func_get_args(); + return $this->_applyPlugin(__FUNCTION__, $args); + } + +} diff --git a/lib/database-adminer-480-en.php b/lib/database-adminer-480-en.php new file mode 100644 index 0000000..ce3bc76 --- /dev/null +++ b/lib/database-adminer-480-en.php @@ -0,0 +1,1786 @@ +$W){unset($pg[$z][$ee]);if(is_array($W)){$pg[$z][stripslashes($ee)]=$W;$pg[]=&$pg[$z][stripslashes($ee)];}else$pg[$z][stripslashes($ee)]=($Xc?$W:stripslashes($W));}}}}function +bracket_escape($v,$Ma=false){static$qi=array(':'=>':1',']'=>':2','['=>':3','"'=>':4');return +strtr($v,($Ma?array_flip($qi):$qi));}function +min_version($Vi,$_e="",$g=null){global$f;if(!$g)$g=$f;$jh=$g->server_info;if($_e&&preg_match('~([\d.]+)-MariaDB~',$jh,$C)){$jh=$C[1];$Vi=$_e;}return(version_compare($jh,$Vi)>=0);}function +charset($f){return(min_version("5.5.3",0,$f)?"utf8mb4":"utf8");}function +script($uh,$pi="\n"){return"$uh$pi";}function +script_src($Ji){return"\n";}function +nonce(){return' nonce="'.get_nonce().'"';}function +target_blank(){return' target="_blank" rel="noreferrer noopener"';}function +h($P){return +str_replace("\0","�",htmlspecialchars($P,ENT_QUOTES,'utf-8'));}function +nl_br($P){return +str_replace("\n","
",$P);}function +checkbox($D,$Y,$cb,$je="",$qf="",$gb="",$ke=""){$I="".($qf?script("qsl('input').onclick = function () { $qf };",""):"");return($je!=""||$gb?"$I".h($je)."":$I);}function +optionlist($wf,$ch=null,$Ni=false){$I="";foreach($wf +as$ee=>$W){$xf=array($ee=>$W);if(is_array($W)){$I.='';$xf=$W;}foreach($xf +as$z=>$X)$I.=''.h($X);if(is_array($W))$I.='';}return$I;}function +html_select($D,$wf,$Y="",$pf=true,$ke=""){if($pf)return"".(is_string($pf)?script("qsl('select').onchange = function () { $pf };",""):"");$I="";foreach($wf +as$z=>$X)$I.="";return$I;}function +select_input($Ha,$wf,$Y="",$pf="",$bg=""){$Uh=($wf?"select":"input");return"<$Uh$Ha".($wf?">