Permalink
Browse files

Save database drop to global history

  • Loading branch information...
1 parent 29e7f04 commit 2bd9b391d26ce521dab555836ee67f855c625192 @vrana committed May 12, 2010
Showing with 7 additions and 2 deletions.
  1. +2 −0 adminer/database.inc.php
  2. +5 −2 adminer/include/adminer.inc.php
@@ -2,10 +2,12 @@
if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP changes add.x to add_x
restart_session();
if ($_POST["drop"]) {
+ $_GET["db"] = ""; // to save in global history
queries_redirect(remove_from_uri("db|database"), lang('Database has been dropped.'), drop_databases(array(DB)));
} elseif (DB !== $_POST["name"]) {
// create or rename database
if (DB != "") {
+ $_GET["db"] = $_POST["name"];
queries_redirect(preg_replace('~db=[^&]*&~', '', ME) . "db=" . urlencode($_POST["name"]), lang('Database has been renamed.'), rename_database($_POST["name"], $_POST["collation"]));
} else {
$dbs = explode("\n", str_replace("\r", "", $_POST["name"]));
@@ -387,8 +387,11 @@ function messageQuery($query) {
restart_session();
$id = "sql-" . count($_SESSION["messages"]);
$history = &get_session("history");
- $history[DB][] = (strlen($query) > 1e6 ? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." : $query); // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
- return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-$jush'>" . shorten_utf8($query, 1000) . '</pre><p><a href="' . h(ME . 'sql=&history=' . (count($history[DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
+ $history[$_GET["db"]][] = (strlen($query) > 1e6 // not DB - reset in drop database
+ ? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
+ : $query
+ ); //! respect $_GET["ns"]
+ return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-$jush'>" . shorten_utf8($query, 1000) . '</pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>';
}
/** Functions displayed in edit form

0 comments on commit 2bd9b39

Please sign in to comment.