Shorten printed SQL query

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1138 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2009-09-24 10:07:06 +00:00
parent dc135a8946
commit 11982f17e3
2 changed files with 4 additions and 4 deletions

View file

@ -360,7 +360,7 @@ class Adminer {
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

View file

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