diff --git a/functions.inc.php b/functions.inc.php
index 28d867df..885921eb 100644
--- a/functions.inc.php
+++ b/functions.inc.php
@@ -277,6 +277,21 @@ function select($result) {
$result->free();
}
+function shorten_utf8($string, $length) {
+ for ($i=0; $i < strlen($string); $i++) {
+ if (ord($string[$i]) >= 192) {
+ while (ord($string[$i+1]) >= 128 && ord($string[$i+1]) < 192) {
+ $i++;
+ }
+ }
+ $length--;
+ if ($length == 0) {
+ return nl2br(htmlspecialchars(substr($string, 0, $i+1))) . "...";
+ }
+ }
+ return nl2br(htmlspecialchars($string));
+}
+
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST);
while (list($key, $val) = each($process)) {
diff --git a/select.inc.php b/select.inc.php
index 8866aada..c38194af 100644
--- a/select.inc.php
+++ b/select.inc.php
@@ -3,9 +3,13 @@ page_header(lang('Select') . ": " . htmlspecialchars($_GET["select"]));
$fields = fields($_GET["select"]);
$rights = array();
$columns = array();
+unset($text_length);
foreach ($fields as $key => $field) {
if (isset($field["privileges"]["select"])) {
$columns[] = $key;
+ if (preg_match('~text|blob~', $field["type"])) {
+ $text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
+ }
}
$rights += $field["privileges"];
}
@@ -107,16 +111,6 @@ function add_row(field) {
echo '
';
echo "\n";
- $select = array();
- unset($text_length);
- foreach ($columns as $column) {
- if (preg_match('~text|blob~', $fields[$column]["type"])) {
- $text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
- $select[] = (intval($text_length) ? "CONCAT(LEFT(" . idf_escape($column) . ", " . intval($text_length) . "), IF(CHAR_LENGTH(" . idf_escape($column) . ") > " . intval($text_length) . ", '...', '')) AS " : "") . idf_escape($column);
- } else {
- $select[] = idf_escape($column);
- }
- }
if (isset($text_length)) {
echo "