From e1e085f3125df7396c6fc940ee6c65d0ee3de696 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Wed, 5 Mar 2025 12:28:01 +0100 Subject: [PATCH] Use namespace in callbacks --- adminer/db.inc.php | 2 +- adminer/drivers/mssql.inc.php | 6 +++--- adminer/drivers/mysql.inc.php | 10 +++++----- adminer/drivers/pgsql.inc.php | 8 ++++---- adminer/drivers/sqlite.inc.php | 4 ++-- adminer/foreign.inc.php | 2 +- adminer/include/adminer.inc.php | 6 +++--- adminer/include/coverage.inc.php | 2 +- adminer/include/editing.inc.php | 4 ++-- adminer/table.inc.php | 4 ++-- editor/include/adminer.inc.php | 4 ++-- plugins/drivers/simpledb.php | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/adminer/db.inc.php b/adminer/db.inc.php index e7dd04bd..bb4464db 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -43,7 +43,7 @@ if ($tables_views && !$error && !$_POST["search"]) { $message = lang('Tables have been optimized.'); } elseif (!$_POST["tables"]) { $message = lang('No tables.'); - } elseif ($result = queries(($_POST["optimize"] ? "OPTIMIZE" : ($_POST["check"] ? "CHECK" : ($_POST["repair"] ? "REPAIR" : "ANALYZE"))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) { + } elseif ($result = queries(($_POST["optimize"] ? "OPTIMIZE" : ($_POST["check"] ? "CHECK" : ($_POST["repair"] ? "REPAIR" : "ANALYZE"))) . " TABLE " . implode(", ", array_map('Adminer\idf_escape', $_POST["tables"])))) { while ($row = $result->fetch_assoc()) { $message .= "" . h($row["Table"]) . ": " . h($row["Msg_text"]) . "
"; } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index 7df3232c..cdb18c66 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -406,7 +406,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) { } function drop_databases($databases) { - return queries("DROP DATABASE " . implode(", ", array_map('idf_escape', $databases))); + return queries("DROP DATABASE " . implode(", ", array_map('Adminer\idf_escape', $databases))); } function rename_database($name, $collation) { @@ -536,11 +536,11 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table), $connection2) as $row) { } function drop_views($views) { - return queries("DROP VIEW " . implode(", ", array_map('table', $views))); + return queries("DROP VIEW " . implode(", ", array_map('Adminer\table', $views))); } function drop_tables($tables) { - return queries("DROP TABLE " . implode(", ", array_map('table', $tables))); + return queries("DROP TABLE " . implode(", ", array_map('Adminer\table', $tables))); } function move_tables($tables, $views, $target) { diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index a44cad35..c07a76d2 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -621,8 +621,8 @@ if (!defined("DRIVER")) { $return[idf_unescape($match[1])] = array( "db" => idf_unescape($match[4] != "" ? $match[3] : $match[4]), "table" => idf_unescape($match[4] != "" ? $match[4] : $match[3]), - "source" => array_map('idf_unescape', $source[0]), - "target" => array_map('idf_unescape', $target[0]), + "source" => array_map('Adminer\idf_unescape', $source[0]), + "target" => array_map('Adminer\idf_unescape', $target[0]), "on_delete" => ($match[6] ? $match[6] : "RESTRICT"), "on_update" => ($match[7] ? $match[7] : "RESTRICT"), ); @@ -805,7 +805,7 @@ if (!defined("DRIVER")) { * @return bool */ function drop_views($views) { - return queries("DROP VIEW " . implode(", ", array_map('table', $views))); + return queries("DROP VIEW " . implode(", ", array_map('Adminer\table', $views))); } /** Drop tables @@ -813,7 +813,7 @@ if (!defined("DRIVER")) { * @return bool */ function drop_tables($tables) { - return queries("DROP TABLE " . implode(", ", array_map('table', $tables))); + return queries("DROP TABLE " . implode(", ", array_map('Adminer\table', $tables))); } /** Move tables to other schema @@ -934,7 +934,7 @@ if (!defined("DRIVER")) { $fields[] = array( "field" => str_replace("``", "`", $param[2]) . $param[3], "type" => strtolower($param[5]), - "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[6]), + "length" => preg_replace_callback("~$enum_length~s", 'Adminer\normalize_enum', $param[6]), "unsigned" => strtolower(preg_replace('~\s+~', ' ', trim("$param[8] $param[7]"))), "null" => 1, "full_type" => $param[4], diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 9436bd41..adb60b3f 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -455,12 +455,12 @@ WHERE conrelid = (SELECT pc.oid FROM pg_class AS pc INNER JOIN pg_namespace AS p AND contype = 'f'::char ORDER BY conkey, conname") as $row) { if (preg_match('~FOREIGN KEY\s*\((.+)\)\s*REFERENCES (.+)\((.+)\)(.*)$~iA', $row['definition'], $match)) { - $row['source'] = array_map('idf_unescape', array_map('trim', explode(',', $match[1]))); + $row['source'] = array_map('Adminer\idf_unescape', array_map('trim', explode(',', $match[1]))); if (preg_match('~^(("([^"]|"")+"|[^"]+)\.)?"?("([^"]|"")+"|[^"]+)$~', $match[2], $match2)) { $row['ns'] = idf_unescape($match2[2]); $row['table'] = idf_unescape($match2[4]); } - $row['target'] = array_map('idf_unescape', array_map('trim', explode(',', $match[3]))); + $row['target'] = array_map('Adminer\idf_unescape', array_map('trim', explode(',', $match[3]))); $row['on_delete'] = (preg_match("~ON DELETE ($on_actions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION'); $row['on_update'] = (preg_match("~ON UPDATE ($on_actions)~", $match[4], $match2) ? $match2[1] : 'NO ACTION'); $return[$row['conname']] = $row; @@ -610,7 +610,7 @@ ORDER BY conkey, conname") as $row) { } function truncate_tables($tables) { - return queries("TRUNCATE " . implode(", ", array_map('table', $tables))); + return queries("TRUNCATE " . implode(", ", array_map('Adminer\table', $tables))); return true; } @@ -834,7 +834,7 @@ AND typelem = 0" foreach (indexes($table) as $index_name => $index) { if ($index['type'] == 'PRIMARY') { $primary = $index_name; - $return_parts[] = "CONSTRAINT " . idf_escape($index_name) . " PRIMARY KEY (" . implode(', ', array_map('idf_escape', $index['columns'])) . ")"; + $return_parts[] = "CONSTRAINT " . idf_escape($index_name) . " PRIMARY KEY (" . implode(', ', array_map('Adminer\idf_escape', $index['columns'])) . ")"; } } diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 2a1e1d41..883ead9f 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -529,7 +529,7 @@ if (isset($_GET["sqlite"])) { return false; } if ($table != "") { - if ($originals && !queries("INSERT INTO " . table($temp_name) . " (" . implode(", ", $originals) . ") SELECT " . implode(", ", array_map('idf_escape', array_keys($originals))) . " FROM " . table($table))) { + if ($originals && !queries("INSERT INTO " . table($temp_name) . " (" . implode(", ", $originals) . ") SELECT " . implode(", ", array_map('Adminer\idf_escape', array_keys($originals))) . " FROM " . table($table))) { return false; } $triggers = array(); @@ -665,7 +665,7 @@ if (isset($_GET["sqlite"])) { if ($name == '') { continue; } - $return .= ";\n\n" . index_sql($table, $index['type'], $name, "(" . implode(", ", array_map('idf_escape', $index['columns'])) . ")"); + $return .= ";\n\n" . index_sql($table, $index['type'], $name, "(" . implode(", ", array_map('Adminer\idf_escape', $index['columns'])) . ")"); } return $return; } diff --git a/adminer/foreign.inc.php b/adminer/foreign.inc.php index 78791613..f48291ea 100644 --- a/adminer/foreign.inc.php +++ b/adminer/foreign.inc.php @@ -61,7 +61,7 @@ if ($row["ns"] != "") { $orig_schema = get_schema(); set_schema($row["ns"]); } -$referencable = array_keys(array_filter(table_status('', true), 'fk_support')); +$referencable = array_keys(array_filter(table_status('', true), 'Adminer\fk_support')); $target = array_keys(fields(in_array($row["table"], $referencable) ? $row["table"] : reset($referencable))); $onchange = "this.form['change-js'].value = '1'; this.form.submit();"; echo "

" . lang('Target table') . ": " . html_select("table", $referencable, $row["table"], $onchange) . "\n"; diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index 7cd1f006..80bcf6ce 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -392,7 +392,7 @@ class Adminer { print_fieldset("search", lang('Search'), $where); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT") { - echo "

(" . implode(", ", array_map('h', $index["columns"])) . ") AGAINST"; + echo "
(" . implode(", ", array_map('Adminer\h', $index["columns"])) . ") AGAINST"; echo " "; echo script("qsl('input').oninput = selectFieldChange;", ""); echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL"); @@ -541,7 +541,7 @@ class Adminer { $return = array(); foreach ($indexes as $i => $index) { if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") { - $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . q($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")"; + $return[] = "MATCH (" . implode(", ", array_map('Adminer\idf_escape', $index["columns"])) . ") AGAINST (" . q($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")"; } } foreach ((array) $_GET["where"] as $key => $val) { @@ -876,7 +876,7 @@ class Adminer { dump_csv($row); } else { if (!$insert) { - $insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', $keys)) . ") VALUES"; + $insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('Adminer\idf_escape', $keys)) . ") VALUES"; } foreach ($row as $key => $val) { if ($generated[$key]) { diff --git a/adminer/include/coverage.inc.php b/adminer/include/coverage.inc.php index f2e80bf3..77069920 100644 --- a/adminer/include/coverage.inc.php +++ b/adminer/include/coverage.inc.php @@ -16,5 +16,5 @@ if (extension_loaded("xdebug") && file_exists(sys_get_temp_dir() . "/adminer_cov } } xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); - register_shutdown_function('save_coverage'); + register_shutdown_function('Adminer\save_coverage'); } diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php index 5b5a773d..590e90d4 100644 --- a/adminer/include/editing.inc.php +++ b/adminer/include/editing.inc.php @@ -554,11 +554,11 @@ function format_foreign_key($foreign_key) { global $on_actions; $db = $foreign_key["db"]; $ns = $foreign_key["ns"]; - return " FOREIGN KEY (" . implode(", ", array_map('idf_escape', $foreign_key["source"])) . ") REFERENCES " + return " FOREIGN KEY (" . implode(", ", array_map('Adminer\idf_escape', $foreign_key["source"])) . ") REFERENCES " . ($db != "" && $db != $_GET["db"] ? idf_escape($db) . "." : "") . ($ns != "" && $ns != $_GET["ns"] ? idf_escape($ns) . "." : "") . idf_escape($foreign_key["table"]) - . " (" . implode(", ", array_map('idf_escape', $foreign_key["target"])) . ")" //! reuse $name - check in older MySQL versions + . " (" . implode(", ", array_map('Adminer\idf_escape', $foreign_key["target"])) . ")" //! reuse $name - check in older MySQL versions . (preg_match("~^($on_actions)\$~", $foreign_key["on_delete"]) ? " ON DELETE $foreign_key[on_delete]" : "") . (preg_match("~^($on_actions)\$~", $foreign_key["on_update"]) ? " ON UPDATE $foreign_key[on_update]" : "") ; diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 6263518e..2709b72d 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -44,14 +44,14 @@ if (!is_view($table_status)) { echo "" . lang('Source') . "" . lang('Target') . "" . lang('ON DELETE') . "" . lang('ON UPDATE') . "\n"; foreach ($foreign_keys as $name => $foreign_key) { echo ""; - echo "" . implode(", ", array_map('h', $foreign_key["source"])) . ""; + echo "" . implode(", ", array_map('Adminer\h', $foreign_key["source"])) . ""; echo "" . ($foreign_key["db"] != "" && $foreign_key["db"] != DB ? "" . h($foreign_key["db"]) . "." : "") . ($foreign_key["ns"] != "" && $foreign_key["ns"] != $_GET["ns"] ? "" . h($foreign_key["ns"]) . "." : "") . h($foreign_key["table"]) . "" ; - echo "(" . implode(", ", array_map('h', $foreign_key["target"])) . ")"; + echo "(" . implode(", ", array_map('Adminer\h', $foreign_key["target"])) . ")"; echo "" . h($foreign_key["on_delete"]); echo "" . h($foreign_key["on_update"]); echo '' . lang('Alter') . ''; diff --git a/editor/include/adminer.inc.php b/editor/include/adminer.inc.php index a3562ee8..2deab4a8 100644 --- a/editor/include/adminer.inc.php +++ b/editor/include/adminer.inc.php @@ -423,10 +423,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5 $subject = $_POST["email_subject"]; $message = $_POST["email_message"]; preg_match_all('~\{\$([a-z0-9_]+)\}~i', "$subject.$message", $matches); // allows {$name} in subject or message - $rows = get_rows("SELECT DISTINCT $field" . ($matches[1] ? ", " . implode(", ", array_map('idf_escape', array_unique($matches[1]))) : "") . " FROM " . table($_GET["select"]) + $rows = get_rows("SELECT DISTINCT $field" . ($matches[1] ? ", " . implode(", ", array_map('Adminer\idf_escape', array_unique($matches[1]))) : "") . " FROM " . table($_GET["select"]) . " WHERE $field IS NOT NULL AND $field != ''" . ($where ? " AND " . implode(" AND ", $where) : "") - . ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . "))") + . ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('Adminer\where_check', (array) $_POST["check"])) . "))") ); $fields = fields($_GET["select"]); foreach ($this->rowDescriptions($rows, $foreignKeys) as $row) { diff --git a/plugins/drivers/simpledb.php b/plugins/drivers/simpledb.php index 2d6f6ec3..d78d4cb2 100644 --- a/plugins/drivers/simpledb.php +++ b/plugins/drivers/simpledb.php @@ -143,7 +143,7 @@ if (isset($_GET["simpledb"])) { function _extractIds($table, $queryWhere, $limit) { $return = array(); if (preg_match_all("~itemName\(\) = (('[^']*+')+)~", $queryWhere, $matches)) { - $return = array_map('idf_unescape', $matches[1]); + $return = array_map('Adminer\idf_unescape', $matches[1]); } else { foreach (sdb_request_all('Select', 'Item', array('SelectExpression' => 'SELECT itemName() FROM ' . table($table) . $queryWhere . ($limit ? " LIMIT 1" : ""))) as $item) { $return[] = $item->Name; -- 2.39.5