--- latest.php.1.8.16.orig
+++ latest.php	
@@ -23,6 +23,10 @@
 require_once('include/hosts.inc.php');
 require_once('include/items.inc.php');
 
+function empty_($var) {
+	return isset($var) && is_string($var) && strlen($var) == 0;
+}
+
 $page['title'] = 'S_LATEST_DATA';
 $page['file'] = 'latest.php';
 $page['hist_arg'] = array('groupid','hostid','show','select','open','applicationid');
@@ -53,6 +57,7 @@
 		'fullscreen'=>			array(T_ZBX_INT, O_OPT,	P_SYS,	IN('0,1'),	NULL),
 // filter
 		'select'=>				array(T_ZBX_STR, O_OPT, NULL,	NULL,		NULL),
+		'select_val'=>				array(T_ZBX_STR, O_OPT, NULL,	NULL,		NULL),
 		'show_without_data'=>	array(T_ZBX_INT, O_OPT, NULL,	IN('0,1'),	NULL),
 		'filter_rst'=>			array(T_ZBX_INT, O_OPT,	P_SYS,	IN('0,1'),	NULL),
 		'filter_set'=>			array(T_ZBX_STR, O_OPT,	P_SYS,	null,		NULL),
@@ -85,19 +90,24 @@
 
 	if(isset($_REQUEST['filter_rst'])){
 		$_REQUEST['select'] = '';
+		$_REQUEST['select_val'] = '';
 		$_REQUEST['show_without_data'] = 0;
 	}
 
 	if(isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])){
 		CProfile::update('web.latest.filter.select',$_REQUEST['select'], PROFILE_TYPE_STR);
+		CProfile::update('web.latest.filter.select_val',$_REQUEST['select_val'], PROFILE_TYPE_STR);
 		CProfile::update('web.latest.filter.show_without_data',$_REQUEST['show_without_data'], PROFILE_TYPE_INT);
 	}
 	else {
 		$_REQUEST['select'] = CProfile::get('web.latest.filter.select', '');
+		$_REQUEST['select_val'] = CProfile::get('web.latest.filter.select_val', '');
 		$_REQUEST['show_without_data'] = CProfile::get('web.latest.filter.show_without_data', 0);
 	}
 // --------------
 
+	$_REQUEST['select_val'] = strval($_REQUEST['select_val']);
+
 	$latest_wdgt = new CWidget();
 
 // Header
@@ -136,6 +146,7 @@
 	$filterForm->setAttribute('id','zbx_filter');
 
 	$filterForm->addRow(S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE, new CTextBox('select',$_REQUEST['select'],20));
+	$filterForm->addRow(_('Show items with values like'), new CTextBox('select_val',$_REQUEST['select_val'],20));
 	$filterForm->addRow(S_SHOW_ITEMS_WITHOUT_DATA, new CCheckBox('show_without_data', $_REQUEST['show_without_data'], null, 1));
 
 	$reset = new CButton("filter_rst",S_RESET);
@@ -262,8 +273,8 @@
 
 		$db_app['item_cnt']++;
 
-		if(isset($showAll) && !empty($apps) && !isset($apps[$db_app['applicationid']])) continue;
-		else if(isset($hideAll) && (empty($apps) || isset($apps[$db_app['applicationid']]))) continue;
+		if(empty_($_REQUEST['select_val']) && isset($showAll) && !empty($apps) && !isset($apps[$db_app['applicationid']])) continue;
+		else if(empty_($_REQUEST['select_val']) && isset($hideAll) && (empty($apps) || isset($apps[$db_app['applicationid']]))) continue;
 
 		if(isset($db_item['lastclock']))
 			$lastclock=zbx_date2str(S_LATEST_ITEMS_TRIGGERS_DATE_FORMAT,$db_item['lastclock']);
@@ -272,6 +283,12 @@
 
 		$lastvalue = format_lastvalue($db_item);
 
+		if(!empty_($_REQUEST['select_val']) && !zbx_stristr($lastvalue, $_REQUEST['select_val']) ) 
+		{
+			$db_app['item_cnt']--;
+			continue;
+		};
+
 		if(isset($db_item['lastvalue']) && isset($db_item['prevvalue'])
 				&& in_array($db_item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64))
 				&& ($db_item['lastvalue']-$db_item['prevvalue'] != 0)){
@@ -313,6 +330,9 @@
 	foreach($db_apps as $appid => $db_app){
 		if(!isset($tab_rows[$appid])) continue;
 
+		if ($db_app['item_cnt'] == 0)
+			continue;
+
 		$app_rows = $tab_rows[$appid];
 
 		$tmp_apps = $apps;
@@ -414,8 +434,8 @@
 
 		$db_host['item_cnt']++;
 
-		if (isset($showAll) && !empty($apps) && !isset($apps[0])) continue;
-		else if (isset($hideAll) && (empty($apps) || isset($apps[0]))) continue;
+		if (empty_($_REQUEST['select_val']) && isset($showAll) && !empty($apps) && !isset($apps[0])) continue;
+		else if (empty_($_REQUEST['select_val']) && isset($hideAll) && (empty($apps) || isset($apps[0]))) continue;
 
 		// column "lastclock"
 		if (isset($db_item['lastclock']))
@@ -426,6 +446,12 @@
 		// column "lastvalue"
 		$lastvalue = format_lastvalue($db_item);
 
+                if(!empty_($_REQUEST['select_val']) && !zbx_stristr($lastvalue, $_REQUEST['select_val']) )
+                {
+                        $db_host['item_cnt']--;
+                        continue;
+                }
+
 		// column "change"
 		if (isset($db_item['lastvalue']) && isset($db_item['prevvalue'])
 				&& ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64)
@@ -472,6 +498,9 @@
 		if(!isset($tab_rows[$hostid])) continue;
 		$app_rows = $tab_rows[$hostid];
 
+                if ($db_host['item_cnt'] == 0)
+                        continue;
+
 		$tmp_apps = $apps;
 		if(isset($apps[0])){
 			unset($tmp_apps[0]);
@@ -501,7 +530,6 @@
 		$url.= url_param('groupid').url_param('hostid').url_param('fullscreen').url_param('select');
 		$link = new CLink($img,$url);
 
-
 		$col = new CCol(array(bold(S_MINUS_OTHER_MINUS),SPACE.'('.$db_host['item_cnt'].SPACE.S_ITEMS.')'));
 		$col->setColSpan(5);
 
