Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 149 additions & 119 deletions adminer.php

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* Windows client with XAMPP: $wp_siteurl = 'C:/xampp/htdocs/wpbeta';
*/

// the path to wp-load.php
// the path to wp-load.php
7 changes: 5 additions & 2 deletions inc/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ add files:
- adminer/loader.php
- adminer/adminer.css

rename functions:
renamed functions:
- is_mail() --> is_adminer_mail()
- is_ajax() --> is_adminer_ajax()
- js_escape() --> js_adminer_escape()
- pagination() --> adminer_pagination()
- checkbox() --> adminer_checkbox()
- redirect() inkl. *redirect() --> *adminer_redirect()
- get_temp_dir() --> get_adminer_temp_dir()
- table() --> adminer_table()
- select() --> adminer_select()

currently not renamed:
- table() --> adminer_table()

Changes:
<body --> without javascript for check version, in inc/adminer/include/design.inc.php
only: <body class="<?php echo lang('ltr'); ?> nojs"<?php echo ($_POST ? "" : " onclick=\"return bodyClick(event, '" . h(js_adminer_escape(DB) . "', '" . js_adminer_escape($_GET["ns"])) . "');\""); // avoid re-post confirmation after refreshing the next page in Google Chrome ?> ">

Expand Down
4 changes: 4 additions & 0 deletions inc/adminer/adminer.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ tr:nth-child(2n) td, tr:nth-child(2n) th, .odd td, .odd th, tr.odd {
background-color: #F1F1F1;
}

.js .checkable .checked td, .js .checkable .checked th {
background: #ffebe8;
}

tbody tr:hover td, tbody tr:hover th {
background-color: #ffebe8;
}
Expand Down
4 changes: 2 additions & 2 deletions inc/adminer/create.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

if ($_POST && !process_fields($row["fields"]) && !$error) {
if ($_POST["drop"]) {
queries_adminer_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
queries_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
} else {
$fields = array();
$all_fields = array();
Expand Down Expand Up @@ -102,7 +102,7 @@
}
$name = trim($row["name"]);

queries_adminer_redirect(ME . (support("table") ? "table=" : "select=") . urlencode($name), $message, alter_table(
queries_redirect(ME . (support("table") ? "table=" : "select=") . urlencode($name), $message, alter_table(
$TABLE,
$name,
($jush == "sqlite" && ($use_all_fields || $foreign) ? $all_fields : $fields),
Expand Down
8 changes: 4 additions & 4 deletions inc/adminer/database.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
$name = trim($row["name"]);
if ($_POST["drop"]) {
$_GET["db"] = ""; // to save in global history
queries_adminer_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
} elseif (DB !== $name) {
// create or rename database
if (DB != "") {
$_GET["db"] = $name;
queries_adminer_redirect(preg_replace('~\bdb=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
queries_redirect(preg_replace('~\bdb=[^&]*&~', '', ME) . "db=" . urlencode($name), lang('Database has been renamed.'), rename_database($name, $row["collation"]));
} else {
$databases = explode("\n", str_replace("\r", "", $name));
$success = true;
Expand All @@ -25,14 +25,14 @@
}
restart_session();
set_session("dbs", null);
queries_adminer_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
queries_redirect(ME . "db=" . urlencode($last), lang('Database has been created.'), $success);
}
} else {
// alter database
if (!$row["collation"]) {
adminer_redirect(substr(ME, 0, -1));
}
query_adminer_redirect("ALTER DATABASE " . idf_escape($name) . (preg_match('~^[a-z0-9_]+$~i', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
query_redirect("ALTER DATABASE " . idf_escape($name) . (preg_match('~^[a-z0-9_]+$~i', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
}
}

Expand Down
2 changes: 1 addition & 1 deletion inc/adminer/db.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
}

queries_adminer_redirect(substr(ME, 0, -1), $message, $result);
queries_redirect(substr(ME, 0, -1), $message, $result);
}

page_header(($_GET["ns"] == "" ? lang('Database') . ": " . h(DB) : lang('Schema') . ": " . h($_GET["ns"])), $error, true);
Expand Down
4 changes: 2 additions & 2 deletions inc/adminer/drivers/elastic.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function quote($string) {
class Min_Result {
var $num_rows, $_rows;

function Min_Result($rows) {
function __construct($rows) {
$this->num_rows = count($this->_rows);
$this->_rows = $rows;
reset($this->_rows);
Expand Down Expand Up @@ -313,7 +313,7 @@ function foreign_keys($table) {
return array();
}

function adminer_table($idf) {
function table($idf) {
return $idf;
}

Expand Down
4 changes: 2 additions & 2 deletions inc/adminer/drivers/firebird.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function result($query, $field = 0) {
class Min_Result {
var $num_rows, $_result, $_offset = 0;

function Min_Result($result) {
function __construct($result) {
$this->_result = $result;
// $this->num_rows = ibase_num_rows($result);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ function idf_escape($idf) {
return '"' . str_replace('"', '""', $idf) . '"';
}

function adminer_table($idf) {
function table($idf) {
return idf_escape($idf);
}

Expand Down
4 changes: 2 additions & 2 deletions inc/adminer/drivers/mongo.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function quote($string) {
class Min_Result {
var $num_rows, $_rows = array(), $_offset = 0, $_charset = array();

function Min_Result($result) {
function __construct($result) {
foreach ($result as $item) {
$row = array();
foreach ($item as $key => $val) {
Expand Down Expand Up @@ -337,7 +337,7 @@ function last_id() {
return $connection->last_id;
}

function adminer_table($idf) {
function table($idf) {
return $idf;
}

Expand Down
22 changes: 11 additions & 11 deletions inc/adminer/drivers/mssql.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function result($query, $field = 0) {
class Min_Result {
var $_result, $_offset = 0, $_fields, $num_rows;

function Min_Result($result) {
function __construct($result) {
$this->_result = $result;
// $this->num_rows = sqlsrv_num_rows($result); // available only in scrollable results
}
Expand Down Expand Up @@ -201,7 +201,7 @@ function result($query, $field = 0) {
class Min_Result {
var $_result, $_offset = 0, $_fields, $num_rows;

function Min_Result($result) {
function __construct($result) {
$this->_result = $result;
$this->num_rows = mssql_num_rows($result);
}
Expand Down Expand Up @@ -251,7 +251,7 @@ function insertUpdate($table, $rows, $primary) {
}
}
//! can use only one query for all rows
if (!queries("MERGE " . adminer_table($table) . " USING (VALUES(" . implode(", ", $set) . ")) AS source (c" . implode(", c", range(1, count($set))) . ") ON " . implode(" AND ", $where) //! source, c1 - possible conflict
if (!queries("MERGE " . table($table) . " USING (VALUES(" . implode(", ", $set) . ")) AS source (c" . implode(", c", range(1, count($set))) . ") ON " . implode(" AND ", $where) //! source, c1 - possible conflict
. " WHEN MATCHED THEN UPDATE SET " . implode(", ", $update)
. " WHEN NOT MATCHED THEN INSERT (" . implode(", ", array_keys($set)) . ") VALUES (" . implode(", ", $set) . ");" // ; is mandatory
)) {
Expand All @@ -273,7 +273,7 @@ function idf_escape($idf) {
return "[" . str_replace("]", "]]", $idf) . "]";
}

function adminer_table($idf) {
function table($idf) {
return ($_GET["ns"] != "" ? idf_escape($_GET["ns"]) . "." : "") . idf_escape($idf);
}

Expand Down Expand Up @@ -447,17 +447,17 @@ function alter_table($table, $name, $fields, $foreign, $comment, $engine, $colla
} else {
unset($val[6]); //! identity can't be removed
if ($column != $val[0]) {
queries("EXEC sp_rename " . q(adminer_table($table) . ".$column") . ", " . q(idf_unescape($val[0])) . ", 'COLUMN'");
queries("EXEC sp_rename " . q(table($table) . ".$column") . ", " . q(idf_unescape($val[0])) . ", 'COLUMN'");
}
$alter["ALTER COLUMN " . implode("", $val)][] = "";
}
}
}
if ($table == "") {
return queries("CREATE TABLE " . adminer_table($name) . " (" . implode(",", (array) $alter["ADD"]) . "\n)");
return queries("CREATE TABLE " . table($name) . " (" . implode(",", (array) $alter["ADD"]) . "\n)");
}
if ($table != $name) {
queries("EXEC sp_rename " . q(adminer_table($table)) . ", " . q($name));
queries("EXEC sp_rename " . q(table($table)) . ", " . q($name));
}
if ($foreign) {
$alter[""] = $foreign;
Expand All @@ -478,17 +478,17 @@ function alter_indexes($table, $alter) {
if ($val[0] == "PRIMARY") { //! sometimes used also for UNIQUE
$drop[] = idf_escape($val[1]);
} else {
$index[] = idf_escape($val[1]) . " ON " . adminer_table($table);
$index[] = idf_escape($val[1]) . " ON " . table($table);
}
} elseif (!queries(($val[0] != "PRIMARY"
? "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . adminer_table($table)
: "ALTER TABLE " . adminer_table($table) . " ADD PRIMARY KEY"
? "CREATE $val[0] " . ($val[0] != "INDEX" ? "INDEX " : "") . idf_escape($val[1] != "" ? $val[1] : uniqid($table . "_")) . " ON " . table($table)
: "ALTER TABLE " . table($table) . " ADD PRIMARY KEY"
) . " (" . implode(", ", $val[2]) . ")")) {
return false;
}
}
return (!$index || queries("DROP INDEX " . implode(", ", $index)))
&& (!$drop || queries("ALTER TABLE " . adminer_table($table) . " DROP " . implode(", ", $drop)))
&& (!$drop || queries("ALTER TABLE " . table($table) . " DROP " . implode(", ", $drop)))
;
}

Expand Down
Loading