Skip to content
Browse files

Print current time next to executed SQL queries

  • Loading branch information...
1 parent b254503 commit 24c51fe11f07ace1b38278cf13cd34f13015f829 @vrana committed Mar 10, 2012
Showing with 11 additions and 10 deletions.
  1. +3 −3 adminer/include/adminer.inc.php
  2. +1 −1 adminer/include/editing.inc.php
  3. +5 −5 adminer/sql.inc.php
  4. +1 −0 changes.txt
  5. +1 −1 editor/include/adminer.inc.php
View
6 adminer/include/adminer.inc.php
@@ -438,11 +438,11 @@ function messageQuery($query) {
restart_session();
$id = "sql-" . ($count++);
$history = &get_session("queries");
- if (strlen($query) > 1e6) { // not DB - reset in drop database
+ if (strlen($query) > 1e6) {
$query = ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
}
- $history[$_GET["db"]][] = $query; // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
- return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></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>';
+ $history[$_GET["db"]][] = array($query, time()); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
+ return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></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>'; // @ - time zone may be not set
}
/** Functions displayed in edit form
View
2 adminer/include/editing.inc.php
@@ -114,7 +114,7 @@ function textarea($name, $value, $rows = 10, $cols = 80) {
echo "<textarea name='$name' rows='$rows' cols='$cols' class='sqlarea' spellcheck='false' wrap='off' onkeydown='return textareaKeydown(this, event);'>"; // spellcheck, wrap - not valid before HTML5
if (is_array($value)) {
foreach ($value as $val) { // not implode() to save memory
- echo h($val) . "\n\n\n";
+ echo h($val[0]) . "\n\n\n"; // $val == array($query, $time)
}
} else {
echo h($value);
View
10 adminer/sql.inc.php
@@ -34,8 +34,8 @@
}
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
$q = $query . (ereg(";[ \t\r\n]*\$", $query) ? "" : ";"); //! doesn't work with DELIMITER |
- if (!$history || end($history) != $q) { // no repeated queries
- $history[] = $q;
+ if (!$history || reset(end($history)) != $q) { // no repeated queries
+ $history[] = array($q, time());
}
}
$space = "(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";
@@ -171,7 +171,7 @@
} elseif ($_GET["history"] == "all") {
$q = $history;
} elseif ($_GET["history"] != "") {
- $q = $history[$_GET["history"]];
+ $q = $history[$_GET["history"]][0];
}
textarea("query", $q, 20);
echo ($_POST ? "" : "<script type='text/javascript'>document.getElementsByTagName('textarea')[0].focus();</script>\n");
@@ -202,8 +202,8 @@
if ($history) {
print_fieldset("history", lang('History'), $_GET["history"] != "");
foreach ($history as $key => $val) {
- //! save and display timestamp
- echo '<a href="' . h(ME . "sql=&history=$key") . '">' . lang('Edit') . "</a> <code class='jush-$jush'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $val)))), 80, "</code>") . "<br>\n";
+ list($q, $time) = $val;
+ echo '<a href="' . h(ME . "sql=&history=$key") . '">' . lang('Edit') . "</a> <span class='time'>" . @date("H:i:s", $time) . "</span> <code class='jush-$jush'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $q)))), 80, "</code>") . "<br>\n"; // @ - time zone may be not set
}
echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n";
echo "<a href='" . h(ME . "sql=&history=all") . "'>" . lang('Edit all') . "</a>\n";
View
1 changes.txt
@@ -1,4 +1,5 @@
Adminer 3.4.0-dev:
+Print current time next to executed SQL queries
Replace JSMin by better JavaScript minifier
Ukrainian translation
View
2 editor/include/adminer.inc.php
@@ -408,7 +408,7 @@ function selectEmailProcess($where, $foreignKeys) {
}
function messageQuery($query) {
- return "<!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->";
+ return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->";
}
function editFunctions($field) {

0 comments on commit 24c51fe

Please sign in to comment.
Something went wrong with that request. Please try again.