Permalink
Browse files

Shorten printed SQL query

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1138 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent dc135a8 commit 11982f17e36189f2de3a644c247ff531796e8c8b jakubvrana committed Sep 24, 2009
Showing with 4 additions and 4 deletions.
  1. +1 −1 adminer/include/adminer.inc.php
  2. +3 −3 adminer/include/functions.inc.php
@@ -360,7 +360,7 @@ function selectEmailProcess($where, $foreignKeys) {
function messageQuery($query) {
$id = "sql-" . count($_SESSION["messages"]);
$_SESSION["history"][$_GET["server"]][DB][] = $query;
- return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . h($query) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
+ return " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . shorten_utf8($query, 1000) . '</pre><a href="' . h(ME . 'sql=&history=' . (count($_SESSION["history"][$_GET["server"]][DB]) - 1)) . '">' . lang('Edit') . '</a></div>';
}
/** Functions displayed in edit form
@@ -307,10 +307,10 @@ function is_utf8($val) {
* @return string escaped string with appended ...
*/
function shorten_utf8($string, $length = 80, $suffix = "") {
- if (!preg_match("~^((?:.|\n){0,$length})(.|\n)?~u", $string, $match)) { // ~s causes trash in $match[2] under some PHP versions
- preg_match("(^([\t\r\n -~]{0,$length})(.?))s", $string, $match);
+ if (!preg_match("(^([\t\r\n -\x{FFFF}]{0,$length})($)?)u", $string, $match)) { // ~s causes trash in $match[2] under some PHP versions, (.|\n) is slow
+ preg_match("(^([\t\r\n -~]{0,$length})($)?)", $string, $match);
}
- return h($match[1]) . $suffix . ($match[2] ? "<em>...</em>" : "");
+ return h($match[1]) . $suffix . (isset($match[2]) ? "" : "<em>...</em>");
}
/** Generate friendly URL

0 comments on commit 11982f1

Please sign in to comment.