From edd719891c72084dc5fdded965082c25daac47bd Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 25 Sep 2008 20:50:08 +0000 Subject: [PATCH] Invent get_databases() Discover nowrap class git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@497 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- default.css | 1 + design.inc.php | 6 +----- dump.inc.php | 5 +---- editing.inc.php | 2 +- functions.inc.php | 9 +++++++++ index.php | 22 ++++++++++++++++++++-- select.inc.php | 2 +- 7 files changed, 34 insertions(+), 13 deletions(-) diff --git a/default.css b/default.css index 01c8e6df..6c5a2fda 100644 --- a/default.css +++ b/default.css @@ -14,6 +14,7 @@ p { margin: 0 20px 1em 0; } img { vertical-align: middle; } code { background-color: #eee; } .js .hidden { display: none; } +.nowrap { white-space: nowrap; } .error { color: red; background: #fee; padding: .5em .8em; } .message { color: green; background: #efe; padding: .5em .8em; } .char { color: #007F00; } diff --git a/design.inc.php b/design.inc.php index b73784fc..433d36a5 100644 --- a/design.inc.php +++ b/design.inc.php @@ -78,11 +78,7 @@ function page_footer($missing = false) {

" /> diff --git a/dump.inc.php b/dump.inc.php index ff4e4e00..bad01177 100644 --- a/dump.inc.php +++ b/dump.inc.php @@ -151,10 +151,7 @@ foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) { echo "" . ($val ? $val : lang('skip')) . ""; } echo "\n"; -if (!strlen($_GET["db"]) && !isset($_SESSION["databases"][$_GET["server"]])) { - $_SESSION["databases"][$_GET["server"]] = get_vals("SHOW DATABASES"); -} -foreach ((strlen($_GET["db"]) ? array($_GET["db"]) : $_SESSION["databases"][$_GET["server"]]) as $db) { +foreach ((strlen($_GET["db"]) ? array($_GET["db"]) : get_databases()) as $db) { if ($db != "information_schema" || $mysql->server_info < 5) { echo "" . htmlspecialchars($db) . ""; foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) { diff --git a/editing.inc.php b/editing.inc.php index 34693169..265e64b6 100644 --- a/editing.inc.php +++ b/editing.inc.php @@ -111,7 +111,7 @@ function edit_fields($fields, $collations, $type = "TABLE") { checked="checked" /> " maxlength="255" /> - + diff --git a/functions.inc.php b/functions.inc.php index de714cd8..a30a7546 100644 --- a/functions.inc.php +++ b/functions.inc.php @@ -40,6 +40,15 @@ function get_vals($query) { return $return; } +function get_databases() { + $return = &$_SESSION["databases"][$_GET["server"]]; + if (!isset($return)) { + flush(); + $return = get_vals("SHOW DATABASES"); + } + return $return; +} + function table_status($table) { global $mysql; $result = $mysql->query("SHOW TABLE STATUS LIKE '" . $mysql->escape_string(addcslashes($table, "%_")) . "'"); diff --git a/index.php b/index.php index 84cbb379..d957900a 100644 --- a/index.php +++ b/index.php @@ -129,6 +129,13 @@ if (isset($_GET["download"])) { } } $message = lang('Tables have been truncated.'); + } elseif (isset($_POST["move"])) { + $rename = array(); + foreach ($_POST["tables"] as $table) { + $rename[] = idf_escape($table) . " TO " . idf_escape($_POST["target"]) . "." . idf_escape($table); + } + $result = queries("RENAME TABLE " . implode(", ", $rename)); + $message = lang('Tables have been moved.'); } elseif ($result = queries((isset($_POST["optimize"]) ? "OPTIMIZE" : (isset($_POST["check"]) ? "CHECK" : (isset($_POST["repair"]) ? "REPAIR" : (isset($_POST["drop"]) ? "DROP" : "ANALYZE")))) . " TABLE " . implode(", ", array_map('idf_escape', $_POST["tables"])))) { while ($row = $result->fetch_assoc()) { $message .= htmlspecialchars("$row[Table]: $row[Msg_text]") . "
"; @@ -148,12 +155,23 @@ if (isset($_GET["download"])) { } else { echo "

\n"; echo "\n"; - echo '\n"; + echo '\n"; while ($row = $result->fetch_assoc()) { - echo '" . (isset($row["Rows"]) ? '\n"; + echo '"; + $row["count"] = $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))); + foreach (array("Data_length", "Index_length", "Data_free", "Auto_increment", "count") as $val) { + echo ''; + } + } else { + echo ' \n"; } echo "
' . lang('Table') . '' . lang('Data Length') . "" . lang('Index Length') . "" . lang('Data Free') . "" . lang('Collation') . "" . lang('Auto Increment') . "Rows
' . lang('Table') . '' . lang('Engine') . '' . lang('Collation') . '' . lang('Data Length') . '' . lang('Index Length') . '' . lang('Data Free') . '' . lang('Auto Increment') . '' . lang('Rows') . "
' . htmlspecialchars($row["Name"]) . "$row[Data_length]$row[Index_length]$row[Data_free]$row[Collation]$row[Auto_increment]" . $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))) : '' . lang('View')) . "
'; + if (isset($row["Rows"])) { + echo '' . htmlspecialchars($row["Name"]) . "$row[Engine]$row[Collation]' . (strlen($row[$val]) ? number_format($row[$val], 0, '.', lang(',')) : '') . '' . htmlspecialchars($row["Name"]) . '' . lang('View'); + } + echo "
\n"; echo "

\n"; + echo "

" . lang('Move to other database') . ":

\n"; echo "
\n"; } $result->free(); diff --git a/select.inc.php b/select.inc.php index bfa41304..c38a46d4 100644 --- a/select.inc.php +++ b/select.inc.php @@ -236,7 +236,7 @@ for (var i=0; > i; i++) { echo "\n"; } $unique_idf = implode('&', unique_idf($row, $indexes)); - echo '' . (count($select) == count($group) ? ' ' . lang('edit') . '' : ''); + echo '' . (count($select) == count($group) ? ' ' . lang('edit') . '' : ''); foreach ($row as $key => $val) { if (!isset($val)) { $val = "NULL";