1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-12 09:34:10 +02:00

Invent get_databases()

Discover nowrap class

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@497 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana
2008-09-25 20:50:08 +00:00
parent bbfe44945c
commit edd719891c
7 changed files with 34 additions and 13 deletions

View File

@@ -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; }

View File

@@ -78,11 +78,7 @@ function page_footer($missing = false) {
<p><?php if (strlen($_GET["server"])) { ?><input type="hidden" name="server" value="<?php echo htmlspecialchars($_GET["server"]); ?>" /><?php } ?>
<select name="db" onchange="this.form.submit();"><option value="">(<?php echo lang('database'); ?>)</option>
<?php
if (!isset($_SESSION["databases"][$_GET["server"]])) {
flush();
$_SESSION["databases"][$_GET["server"]] = get_vals("SHOW DATABASES");
}
echo optionlist($_SESSION["databases"][$_GET["server"]], $_GET["db"]);
echo optionlist(get_databases(), $_GET["db"]);
?>
</select>
<?php if (isset($_GET["sql"])) { ?><input type="hidden" name="sql" value="" /><?php } ?>

View File

@@ -151,10 +151,7 @@ foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) {
echo "<th onclick=\"check(this, /^databases/, '$val');\" style='cursor: pointer;'>" . ($val ? $val : lang('skip')) . "</th>";
}
echo "</tr></thead>\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 "<tr><td>" . htmlspecialchars($db) . "</td>";
foreach (array('', 'USE', 'DROP, CREATE', 'CREATE', 'CREATE, ALTER') as $val) {

View File

@@ -111,7 +111,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
<?php } ?>
<td style="white-space: nowrap;">
<td class="nowrap">
<input type="image" name="add[<?php echo $i; ?>]" src="plus.gif" title="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" />
<input type="image" name="drop_col[<?php echo $i; ?>]" src="minus.gif" title="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" />
<input type="image" name="up[<?php echo $i; ?>]" src="up.gif" title="<?php echo lang('Move up'); ?>" />

View File

@@ -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, "%_")) . "'");

View File

@@ -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]") . "<br />";
@@ -148,12 +155,23 @@ if (isset($_GET["download"])) {
} else {
echo "<form action='' method='post'>\n";
echo "<table border='1' cellspacing='0' cellpadding='2'>\n";
echo '<thead><tr><th>' . lang('Table') . '</th><td><label><input type="checkbox" onclick="var elems = this.form.elements; for (var i=0; elems.length > i; i++) if (elems[i].name == \'tables[]\') elems[i].checked = this.checked;" /> Engine</label></td><td>' . lang('Data Length') . "</td><td>" . lang('Index Length') . "</td><td>" . lang('Data Free') . "</td><td>" . lang('Collation') . "</td><td>" . lang('Auto Increment') . "</td><td>Rows</td></tr></tdead>\n";
echo '<thead><tr><td><input type="checkbox" onclick="var elems = this.form.elements; for (var i=0; elems.length > i; i++) if (elems[i].name == \'tables[]\') elems[i].checked = this.checked;" /></td><th>' . lang('Table') . '</th><td>' . lang('Engine') . '</td><td>' . lang('Collation') . '</td><td>' . lang('Data Length') . '</td><td>' . lang('Index Length') . '</td><td>' . lang('Data Free') . '</td><td>' . lang('Auto Increment') . '</td><td>' . lang('Rows') . "</td></tr></tdead>\n";
while ($row = $result->fetch_assoc()) {
echo '<tr><th><a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th>" . (isset($row["Rows"]) ? '<td><label><input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '" /> ' . $row["Engine"] . "</label></td><td>$row[Data_length]</td><td>$row[Index_length]</td><td>$row[Data_free]</td><td>$row[Collation]</td><td>$row[Auto_increment]</td><td>" . $mysql->result($mysql->query("SELECT COUNT(*) FROM " . idf_escape($row["Name"]))) : '<td colspan="7">' . lang('View')) . "</td></tr>\n";
echo '<tr class="nowrap"><td>';
if (isset($row["Rows"])) {
echo '<input type="checkbox" name="tables[]" value="' . htmlspecialchars($row["Name"]) . '"' . (in_array($row["Name"], (array) $_POST["tables"], true) ? ' checked="checked"' : '') . ' /></td><th><a href="' . htmlspecialchars($SELF) . 'create=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . "</a></th><td align='left'>$row[Engine]</td><td align='left'>$row[Collation]</td>";
$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 '<td align="right">' . (strlen($row[$val]) ? number_format($row[$val], 0, '.', lang(',')) : '') . '</td>';
}
} else {
echo '&nbsp;</td><th><a href="' . htmlspecialchars($SELF) . 'createv=' . urlencode($row["Name"]) . '">' . htmlspecialchars($row["Name"]) . '</a></th><td colspan="8">' . lang('View');
}
echo "</td></tr>\n";
}
echo "</table>\n";
echo "<p><input type='hidden' name='token' value='$token' /><input type='submit' value='" . lang('Analyze') . "' /> <input type='submit' name='optimize' value='" . lang('Optimize') . "' /> <input type='submit' name='check' value='" . lang('Check') . "' /> <input type='submit' name='repair' value='" . lang('Repair') . "' /> <input type='submit' name='truncate' value='" . lang('Truncate') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\" /> <input type='submit' name='drop' value='" . lang('Drop') . "' onclick=\"return confirm('" . lang('Are you sure?') . "');\" /></p>\n";
echo "<p>" . lang('Move to other database') . ": <select name='target'>" . optionlist(get_databases(), (isset($_POST["target"]) ? $_POST["target"] : $_GET["db"])) . "</select> <input type='submit' name='move' value='" . lang('Move') . "' /></p>\n";
echo "</form>\n";
}
$result->free();

View File

@@ -236,7 +236,7 @@ for (var i=0; <?php echo $i; ?> > i; i++) {
echo "</tr></thead>\n";
}
$unique_idf = implode('&amp;', unique_idf($row, $indexes));
echo '<tr style="white-space: nowrap;">' . (count($select) == count($group) ? '<td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
echo '<tr class="nowrap">' . (count($select) == count($group) ? '<td><input type="checkbox" name="delete[]" value="' . $unique_idf . '" /> <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&amp;' . $unique_idf . '">' . lang('edit') . '</a></td>' : '');
foreach ($row as $key => $val) {
if (!isset($val)) {
$val = "<i>NULL</i>";