mirror of
https://github.com/vrana/adminer.git
synced 2025-08-07 07:06:45 +02:00
Use namespace in callbacks
This commit is contained in:
@@ -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 .= "<b>" . h($row["Table"]) . "</b>: " . h($row["Msg_text"]) . "<br>";
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
@@ -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],
|
||||
|
@@ -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'])) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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 "<p>" . lang('Target table') . ": " . html_select("table", $referencable, $row["table"], $onchange) . "\n";
|
||||
|
@@ -392,7 +392,7 @@ class Adminer {
|
||||
print_fieldset("search", lang('Search'), $where);
|
||||
foreach ($indexes as $i => $index) {
|
||||
if ($index["type"] == "FULLTEXT") {
|
||||
echo "<div>(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
|
||||
echo "<div>(<i>" . implode("</i>, <i>", array_map('Adminer\h', $index["columns"])) . "</i>) AGAINST";
|
||||
echo " <input type='search' name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
|
||||
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]) {
|
||||
|
@@ -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');
|
||||
}
|
||||
|
@@ -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]" : "")
|
||||
;
|
||||
|
@@ -44,14 +44,14 @@ if (!is_view($table_status)) {
|
||||
echo "<thead><tr><th>" . lang('Source') . "<td>" . lang('Target') . "<td>" . lang('ON DELETE') . "<td>" . lang('ON UPDATE') . "<td></thead>\n";
|
||||
foreach ($foreign_keys as $name => $foreign_key) {
|
||||
echo "<tr title='" . h($name) . "'>";
|
||||
echo "<th><i>" . implode("</i>, <i>", array_map('h', $foreign_key["source"])) . "</i>";
|
||||
echo "<th><i>" . implode("</i>, <i>", array_map('Adminer\h', $foreign_key["source"])) . "</i>";
|
||||
echo "<td><a href='" . h($foreign_key["db"] != "" ? preg_replace('~db=[^&]*~', "db=" . urlencode($foreign_key["db"]), ME) : ($foreign_key["ns"] != "" ? preg_replace('~ns=[^&]*~', "ns=" . urlencode($foreign_key["ns"]), ME) : ME)) . "table=" . urlencode($foreign_key["table"]) . "'>"
|
||||
. ($foreign_key["db"] != "" && $foreign_key["db"] != DB ? "<b>" . h($foreign_key["db"]) . "</b>." : "")
|
||||
. ($foreign_key["ns"] != "" && $foreign_key["ns"] != $_GET["ns"] ? "<b>" . h($foreign_key["ns"]) . "</b>." : "")
|
||||
. h($foreign_key["table"])
|
||||
. "</a>"
|
||||
;
|
||||
echo "(<i>" . implode("</i>, <i>", array_map('h', $foreign_key["target"])) . "</i>)";
|
||||
echo "(<i>" . implode("</i>, <i>", array_map('Adminer\h', $foreign_key["target"])) . "</i>)";
|
||||
echo "<td>" . h($foreign_key["on_delete"]);
|
||||
echo "<td>" . h($foreign_key["on_update"]);
|
||||
echo '<td><a href="' . h(ME . 'foreign=' . urlencode($TABLE) . '&name=' . urlencode($name)) . '">' . lang('Alter') . '</a>';
|
||||
|
@@ -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) {
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user