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