--- hostprofiles.php.orig	2012-09-27 13:19:56.937525415 +0400
+++ hostprofiles.php	2012-09-27 13:54:48.392202447 +0400
@@ -35,6 +35,16 @@
 		'groupid'=>		array(T_ZBX_INT, O_OPT,	P_SYS,	DB_ID,	NULL),
 		'hostid'=>		array(T_ZBX_INT, O_OPT,	P_SYS,	DB_ID,	NULL),
 		'prof_type'=>	array(T_ZBX_INT, O_OPT,	P_SYS,	NULL,	NULL),
+// Filter
+		'filter_set' =>		array(T_ZBX_STR, O_OPT, P_ACT,  null,   null),
+		'filter_host'=>		array(T_ZBX_STR, O_OPT,  null,  null,   null),
+		'filter_os'=>		array(T_ZBX_STR, O_OPT,  null,  null,   null),
+		'filter_name'=>		array(T_ZBX_STR, O_OPT,  null,  null,   null),
+
+//ajax
+                'favobj'=>              array(T_ZBX_STR, O_OPT, P_ACT,  NULL,                   NULL),
+                'favref'=>              array(T_ZBX_STR, O_OPT, P_ACT,  NOT_EMPTY,              'isset({favobj})'),
+                'state'=>               array(T_ZBX_INT, O_OPT, P_ACT,  NOT_EMPTY,              'isset({favobj}) && ("filter"=={favobj})')
 	);
 
 	check_fields($fields);
@@ -42,6 +52,18 @@
 ?>
 <?php
 
+/* AJAX */
+	if(isset($_REQUEST['favobj'])){
+		if('filter' == $_REQUEST['favobj']){
+			CProfile::update('web.inventory.filter.state', $_REQUEST['state'], PROFILE_TYPE_INT);
+		}
+	}
+
+	if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){
+		include_once('include/page_footer.php');
+		exit();
+	}
+
 	$options = array(
 		'groups' => array(
 			'real_hosts' => 1,
@@ -60,10 +82,54 @@
 	}
 
 
+/* FILTER */
+	if(isset($_REQUEST['filter_set'])){
+		$_REQUEST['filter_host'] = get_request('filter_host');
+		$_REQUEST['filter_os'] = get_request('filter_os');
+		$_REQUEST['filter_name'] = get_request('filter_name');
+
+		CProfile::update('web.inventory.filter_host', $_REQUEST['filter_host'], PROFILE_TYPE_STR);
+		CProfile::update('web.inventory.filter_os', $_REQUEST['filter_os'], PROFILE_TYPE_STR);
+		CProfile::update('web.inventory.filter_name', $_REQUEST['filter_name'], PROFILE_TYPE_STR);
+	}
+	else{
+		$_REQUEST['filter_host'] = CProfile::get('web.inventory.filter_host');
+		$_REQUEST['filter_os'] = CProfile::get('web.inventory.filter_os');
+		$_REQUEST['filter_name'] = CProfile::get('web.inventory.filter_name');
+	}
+
 	$_REQUEST['prof_type'] = get_request('prof_type', 0);
 
 	$hostprof_wdgt = new CWidget();
 
+// HOSTS FILTER {{{
+	$filter_table = new CTable('', 'filter_config');
+	$filter_table->addRow(array(
+		array(array(bold(S_HOST), SPACE.S_LIKE_SMALL.': '), new CTextBox('filter_host', $_REQUEST['filter_host'], 20)),
+		array(array(bold(S_OS), SPACE.S_LIKE_SMALL.': '), new CTextBox('filter_os', $_REQUEST['filter_os'], 20)),
+		array(array(bold(S_NAME), SPACE.S_LIKE_SMALL.': '), new CTextBox('filter_name', $_REQUEST['filter_name'], 20)),
+		));
+
+	$reset = new CSpan( S_RESET,'biglink');
+	$reset->onClick("javascript: clearAllForm('zbx_filter'); create_var('zbx_filter', 'filter_set', '0', true); ");
+	$filter = new CSpan(S_FILTER,'biglink');
+	$filter->onClick("javascript: create_var('zbx_filter', 'filter_set', '1', true);");
+
+	$footer_col = new CCol(array($filter, SPACE, SPACE, SPACE, $reset), 'center');
+	$footer_col->setColSpan(4);
+
+	$filter_table->addRow($footer_col);
+
+	$filter_form = new CForm(null, 'get');
+	$filter_form->setAttribute('name','zbx_filter');
+	$filter_form->setAttribute('id','zbx_filter');
+	$filter_form->addItem($filter_table);
+// }}} HOSTS FILTER
+        if (get_request('prof_type', 0) == 0)
+		$hostprof_wdgt->addFlicker($filter_form, CProfile::get('web.inventory.filter.state', 0));
+
+	$_REQUEST['prof_type'] = get_request('prof_type', 0);
+
 	$profile_form = new CForm(null, 'get');
 	$cmbProf = new CComboBox('prof_type', $_REQUEST['prof_type'], 'javascript: submit();');
 	$cmbProf->additem(0, S_NORMAL);
@@ -90,7 +156,10 @@
 			'sortorder' => $sortorder,
 			'select_profile' => 1,
 			'select_groups' => 1,
-			'limit' => ($config['search_limit']+1)
+			'limit' => ($config['search_limit']+1),
+			'search' => array(
+				'host' => (empty($_REQUEST['filter_host']) ? null : $_REQUEST['filter_host'])
+				)
 		);
 		if($pageFilter->groupsSelected){
 			if($pageFilter->groupid > 0)
@@ -106,13 +175,16 @@
 		$pr = ($_REQUEST['prof_type'] == 0) ? 'profile' : 'profile_ext';
 		$profile = array();
 		foreach($hosts as $num => $host){
-			if(empty($host[$pr])){
+			if(empty($host[$pr])
+				|| !empty($_REQUEST['filter_os']) && stripos($host['profile']['os'], $_REQUEST['filter_os']) === FALSE
+				|| !empty($_REQUEST['filter_name']) && stripos($host['profile']['name'], $_REQUEST['filter_name']) === FALSE ) {
 				unset($hosts[$num]);
 			}
 			else{
 				if($_REQUEST['prof_type'] == 0){
 					$hosts[$num]['pr_name'] = $host['profile']['name'];
 					$hosts[$num]['pr_os'] = $host['profile']['os'];
+					$hosts[$num]['pr_name'] = $host['profile']['name'];
 					$hosts[$num]['pr_serialno'] = $host['profile']['serialno'];
 					$hosts[$num]['pr_tag'] = $host['profile']['tag'];
 					$hosts[$num]['pr_macaddress'] = $host['profile']['macaddress'];
