diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-06 12:18:33 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-06 12:18:33 +0000 |
| commit | a5e27c0c89d5a3e89e48cbbc73efb0731799f1cc (patch) | |
| tree | 23a3a98da56c970aabb4fded87ebce4fdedeed53 /frontends/php/include | |
| parent | 4ca1f91b93ebdf892377410a0f1f64ca5db2c194 (diff) | |
- [NTT-44] The last character for last value is unreadable (Sasha)
[svn merge -r4972:4975 svn://svn.zabbix.com/branches/1.4.j]
git-svn-id: svn://svn.zabbix.com/trunk@4976 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/html.inc.php | 11 | ||||
| -rw-r--r-- | frontends/php/include/items.inc.php | 14 |
2 files changed, 18 insertions, 7 deletions
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php index 46c1d137..49204077 100644 --- a/frontends/php/include/html.inc.php +++ b/frontends/php/include/html.inc.php @@ -44,6 +44,17 @@ return str_replace(" ",SPACE,$str);; } + function utf8_strlen($s) + { + return preg_match_all('/([\x01-\x7f]|([\xc0-\xff][\x80-\xbf]{1,5}))/', $s, $tmp); + } + + function utf8_strtop($s, $len) + { + preg_match('/^([\x01-\x7f]|([\xc0-\xff][\x80-\xbf]{1,5})){0,'.$len.'}/', $s, $tmp); + return (isset($tmp[0])) ? $tmp[0] : false; + } + function form_select($var, $value, $label) { global $_REQUEST; diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 49b7dd16..fc07cca6 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -1091,19 +1091,19 @@ COpt::profiling_stop('prepare table'); { if($db_item["value_type"] == ITEM_VALUE_TYPE_LOG) { - $row=DBfetch(DBselect("select max(id) as max from history_log where itemid=".$db_item["itemid"])); - - if($row && !is_null($row['max'])) + $row=DBfetch(DBselect("select value from history_log where itemid=".$db_item["itemid"]." order by id desc", 1)); + if($row) { - $row2=DBfetch(DBselect("select value from history_log where id=".$row["max"])); - $lastvalue=nbsp(htmlspecialchars(substr($row2["value"],0,20))); - if(strlen($db_item["lastvalue"]) > 20) - $lastvalue .= " ..."; + $lastvalue=/*nbsp(htmlspecialchars(*/$row["value"]/*))*/; + if(utf8_strlen($lastvalue) > 20) + $lastvalue = utf8_strtop($lastvalue,20)." ..."; + $lastvalue = nbsp(htmlspecialchars($lastvalue)); } else { $lastvalue="-"; } + } else if(isset($db_item["lastvalue"])) { |
