From 5c3768ceaa3080321c3bf6481640fcdd380d0025 Mon Sep 17 00:00:00 2001 From: artem Date: Wed, 23 Jul 2008 09:37:47 +0000 Subject: - [DEV-192] added filter to Status of triggers (Artem) - [DEV-191] monitoring screens inline update preparation (Artem) - [DEV-192] added severity filter in status of triggers (Artem) - [DEV-137] sql fixes for oracle (Artem) - [ZBX-396] fixed error maps message (Artem) - [ZBX-394] fixed showing hosts without group in status of triggers (Artem) - [DEV-137] small fixes (Artem) git-svn-id: svn://svn.zabbix.com/trunk@5841 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/chart.php | 11 +- frontends/php/chart2.php | 7 +- frontends/php/chart4.php | 27 +- frontends/php/chart6.php | 4 +- frontends/php/charts.php | 10 +- frontends/php/dashboard.php | 26 +- frontends/php/discovery.php | 49 +++- frontends/php/events.php | 49 ++-- frontends/php/exp_imp.php | 18 +- frontends/php/graphs.php | 1 + frontends/php/history.php | 4 +- frontends/php/hostprofiles.php | 15 +- frontends/php/hosts.php | 59 +--- frontends/php/httpconf.php | 10 +- frontends/php/httpdetails.php | 9 +- frontends/php/httpmon.php | 111 +++++--- frontends/php/include/actions.inc.php | 16 +- frontends/php/include/classes/chart.inc.php | 389 +++++++++++++------------ frontends/php/include/classes/cimg.inc.php | 41 ++- frontends/php/include/db.inc.php | 15 +- frontends/php/include/forms.inc.php | 51 ++-- frontends/php/include/graphs.inc.php | 8 +- frontends/php/include/hosts.inc.php | 114 ++++++-- frontends/php/include/items.inc.php | 11 +- frontends/php/include/locales/en_gb.inc.php | 1 + frontends/php/include/page_header.php | 6 +- frontends/php/include/reports.inc.php | 10 +- frontends/php/include/screens.inc.php | 11 +- frontends/php/include/triggers.inc.php | 42 ++- frontends/php/items.php | 1 - frontends/php/latest.php | 81 ++++-- frontends/php/maps.php | 36 ++- frontends/php/overview.php | 75 +++-- frontends/php/popup.php | 39 +-- frontends/php/popup_trexpr.php | 7 +- frontends/php/queue.php | 32 +-- frontends/php/report2.php | 10 +- frontends/php/report5.php | 6 +- frontends/php/screens.php | 6 +- frontends/php/scripts_exec.php | 4 +- frontends/php/services_form.php | 4 +- frontends/php/srv_status.php | 2 +- frontends/php/sysmap.php | 28 +- frontends/php/tr_events.php | 27 +- frontends/php/tr_status.php | 421 +++++++++++++++------------- frontends/php/triggers.php | 109 ++++--- 46 files changed, 1088 insertions(+), 925 deletions(-) diff --git a/frontends/php/chart.php b/frontends/php/chart.php index 9d9813e7..35b8b0a9 100644 --- a/frontends/php/chart.php +++ b/frontends/php/chart.php @@ -44,15 +44,16 @@ include_once "include/page_header.php"; check_fields($fields); ?> AddItem( $db_data['itemid'], $db_data['yaxisside'], diff --git a/frontends/php/chart4.php b/frontends/php/chart4.php index c279d7ea..a7b6f27b 100644 --- a/frontends/php/chart4.php +++ b/frontends/php/chart4.php @@ -38,7 +38,7 @@ include_once "include/page_header.php"; check_fields($fields); ?> $maxY) - { + if($tmp>$maxY){ $maxY=$tmp; } $minY=0; @@ -154,13 +150,10 @@ include_once "include/page_header.php"; $maxX=900; $minX=0; - for($i=0;$i<52;$i++) - { - + for($i=0;$i<52;$i++){ $x1=(900/52)*$sizeX*($i-$minX)/($maxX-$minX); - ImageFilledRectangle($im,$x1+$shiftX,$shiftYup,$x1+$shiftX+8,$sizeY+$shiftYup,ImageColorAllocate($im,200,200,120)) -; + ImageFilledRectangle($im,$x1+$shiftX,$shiftYup,$x1+$shiftX+8,$sizeY+$shiftYup,ImageColorAllocate($im,200,200,120)); $y1=$sizeY*$true[$i]/100; ImageFilledRectangle($im,$x1+$shiftX,$shiftYup,$x1+$shiftX+8,$y1+$shiftYup,ImageColorAllocate($im,200,120,120)); diff --git a/frontends/php/chart6.php b/frontends/php/chart6.php index fcf94a32..56a93bcf 100644 --- a/frontends/php/chart6.php +++ b/frontends/php/chart6.php @@ -51,7 +51,7 @@ include_once "include/page_header.php"; show_error_message(S_NO_GRAPH_DEFINED); } - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); if(!graph_accessible($_REQUEST['graphid'])){ access_deny(); @@ -63,7 +63,7 @@ include_once "include/page_header.php"; ' LEFT JOIN items i ON gi.itemid=i.itemid '. ' LEFT JOIN hosts h ON i.hostid=h.hostid '. ' WHERE g.graphid='.$_REQUEST['graphid']. - ' AND h.hostid IN ('.$available_hosts.') '; + ' AND '.DBcondition('h.hostid',$available_hosts); $db_data = DBfetch(DBselect($sql)); diff --git a/frontends/php/charts.php b/frontends/php/charts.php index b6bd8b20..5b4a03a3 100644 --- a/frontends/php/charts.php +++ b/frontends/php/charts.php @@ -128,7 +128,7 @@ include_once 'include/page_header.php'; $h1 = array(S_GRAPHS_BIG.SPACE.'/'.SPACE); $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY); $available_graphs = get_accessible_graphs(PERM_READ_LIST, PERM_RES_IDS_ARRAY, get_current_nodeid()); @@ -185,7 +185,7 @@ include_once 'include/page_header.php'; ' AND hg.hostid=h.hostid '. ($_REQUEST['groupid']?' AND hg.groupid='.$_REQUEST['groupid']:''). ' AND '.DBcondition('gi.graphid',$available_graphs); -// ' AND h.hostid IN ('.$available_hosts.') '; +// ' AND '.DBcondition('h.hostid',$available_hosts); if($cnt_row = DBfetch(DBselect($sql))){ @@ -209,7 +209,7 @@ include_once 'include/page_header.php'; ' AND h.status='.HOST_STATUS_MONITORED. ' AND '.DBin_node('g.graphid'). ' AND '.DBcondition('g.graphid',$available_graphs); -// ' AND h.hostid IN ('.$available_hosts.') '; +// ' AND '.DBcondition('h.hostid',$available_hosts); if($cnt_row = DBfetch(DBselect($sql))){ if($cnt_row['grphcount'] == 1){ @@ -250,7 +250,7 @@ include_once 'include/page_header.php'; ' AND hg.hostid=h.hostid '. ($_REQUEST['groupid']?' AND hg.groupid='.$_REQUEST['groupid']:''). ' AND '.DBcondition('gi.graphid',$available_graphs). -// ' AND h.hostid IN ('.$available_hosts.') '. +// ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; $result=DBselect($sql); @@ -274,7 +274,7 @@ include_once 'include/page_header.php'; ($_REQUEST['hostid']?' AND h.hostid='.$_REQUEST['hostid']:''). ' AND '.DBin_node('g.graphid'). ' AND '.DBcondition('g.graphid',$available_graphs). -// ' AND h.hostid IN ('.$available_hosts.') '; +// ' AND '.DBcondition('h.hostid',$available_hosts); ' ORDER BY g.name'; $result = DBselect($sql); diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php index 4cb276c0..d6807c7d 100644 --- a/frontends/php/dashboard.php +++ b/frontends/php/dashboard.php @@ -190,21 +190,14 @@ include_once "include/page_header.php"; // $time = new CSpan(date("[H:i:s]",time())); // $time->AddOption('id','refreshed'); + $p_elements = array(); // Header - $text = array(S_DASHBOARD_BIG); - + $url = '?fullscreen='.($_REQUEST['fullscreen']?'0':'1'); $fs_icon = new CDiv(SPACE,'fullscreen'); $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,SPACE,$text)); - - $text = $icon_tab; - - show_table_header($text,SPACE); //------------- $left_tab = new CTable(); @@ -387,7 +380,7 @@ include_once "include/page_header.php"; $outer_table->SetCellSpacing(1); $outer_table->AddRow(array($td_l,$td_r)); - $outer_table->Show(); + $p_elements[] = $outer_table; $fav_form = new CForm(); $fav_form->AddOption('name','fav_form'); @@ -396,7 +389,18 @@ include_once "include/page_header.php"; $fav_form->AddVar('favobj',''); $fav_form->AddVar('favid',''); $fav_form->AddVar('source',''); - $fav_form->Show(); + + $p_elements[] = $fav_form; + + $dashboard_hat = create_hat( + S_DASHBOARD_BIG, + $p_elements, + array($fs_icon), + 'hat_dashboard', + get_profile('web.dashboard.hats.hat_dashboard.state',1) + ); + + $dashboard_hat->Show(); $jsmenu = new CPUMenu(null,170); $jsmenu->InsertJavaScript(); diff --git a/frontends/php/discovery.php b/frontends/php/discovery.php index 68a38cdd..4e7ea1f5 100644 --- a/frontends/php/discovery.php +++ b/frontends/php/discovery.php @@ -32,11 +32,30 @@ include_once "include/page_header.php"; $fields=array( "druleid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), +//ajax + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), + 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), ); check_fields($fields); + +/* AJAX */ + if(isset($_REQUEST['favobj'])){ + if('hat' == $_REQUEST['favobj']){ + update_profile('web.discovery.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } + } + + if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ + exit(); + } +//-------- + validate_sort_and_sortorder('ip',ZBX_SORT_UP); + $p_elements = array(); + $r_form = new CForm(); $r_form->SetMethod('get'); @@ -53,7 +72,7 @@ include_once "include/page_header.php"; $r_form->AddItem(array(S_DISCOVERY_RULE.SPACE,$cmbDRules)); // Header - $text = array(S_STATUS_OF_DISCOVERY_BIG); + $text = array(SPACE); $url = '?fullscreen='.($_REQUEST['fullscreen']?'0':'1'); @@ -61,12 +80,7 @@ include_once "include/page_header.php"; $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,SPACE,$text)); - - $text = $icon_tab; - - show_table_header($text, $r_form); + $p_elements[] = get_table_header($text, $r_form); //------------- @@ -149,19 +163,16 @@ include_once "include/page_header.php"; $table->AddRow(array(get_node_name_by_elid($drule['druleid']),$col)); } - foreach($discovery_info as $ip => $h_data) - { + foreach($discovery_info as $ip => $h_data){ $table_row = array( get_node_name_by_elid($h_data['druleid']), new CSpan($ip, $h_data['class']), new CSpan(($h_data['time'] == 0 ? '' : convert_units(time() - $h_data['time'], 'uptime')), $h_data['class']) ); - foreach($services as $name => $foo) - { + foreach($services as $name => $foo){ $class = null; $time = SPACE; - if(isset($h_data['services'][$name])) - { + if(isset($h_data['services'][$name])){ $class = $h_data['services'][$name]['class']; $time = $h_data['services'][$name]['time']; } @@ -171,7 +182,17 @@ include_once "include/page_header.php"; } } - $table->Show(); + $p_elements[] = $table; + + $latest_hat = create_hat( + S_STATUS_OF_DISCOVERY_BIG, + $p_elements, + array($fs_icon), + 'hat_discovery', + get_profile('web.discovery.hats.hat_discovery.state',1) + ); + + $latest_hat->Show(); ?> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'prev'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL), 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), + // filter 'filter_rst'=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL), 'filter_set'=> array(T_ZBX_STR, O_OPT, P_SYS, null, NULL), @@ -143,7 +144,7 @@ include_once "include/page_header.php"; if(EVENT_SOURCE_TRIGGERS == $source){ $available_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_DATA_ARRAY, get_current_nodeid()); @@ -156,12 +157,14 @@ include_once "include/page_header.php"; ' AND f.triggerid='.$_REQUEST['triggerid']; if($host = DBfetch(DBselect($sql,1))){ - $_REQUEST['hostid'] = $host['hostid']; - if($group = DBfetch(DBselect('SELECT DISTINCT hg.groupid '. - ' FROM hosts_groups hg'. - ' WHERE hg.hostid='.$_REQUEST['hostid']. - ' AND hg.hostid in ('.$available_hosts.') '))) - { + $_REQUEST['hostid'] = $host['hostid']; + + $sql = 'SELECT DISTINCT hg.groupid '. + ' FROM hosts_groups hg '. + ' WHERE hg.hostid='.$_REQUEST['hostid']. + ' AND '.DBcondition('hg.hostid',$available_hosts); + + if($group = DBfetch(DBselect($sql))){ $_REQUEST['groupid'] = $group['groupid']; } } @@ -204,7 +207,7 @@ include_once "include/page_header.php"; ' AND h.hostid=i.hostid '. ($_REQUEST['groupid']?' AND hg.groupid='.$_REQUEST['groupid']:''). ' AND hg.hostid=h.hostid '. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; $result=DBselect($sql); @@ -226,6 +229,8 @@ include_once "include/page_header.php"; } // Header + $p_elements = array(); + $text = array(S_HISTORY_OF_EVENTS_BIG,SPACE,date('[H:i:s]',time())); $url = '?fullscreen='.($_REQUEST['fullscreen']?'0':'1'); @@ -234,12 +239,8 @@ include_once "include/page_header.php"; $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,SPACE,$text)); + $p_elements[] = get_table_header(S_EVENTS,$r_form); - $text = $icon_tab; - - show_table_header($text,$r_form); //------------- @@ -256,11 +257,11 @@ include_once "include/page_header.php"; } else if($_REQUEST['groupid'] > 0){ $sql_from = ', hosts_groups hg '; - $sql_cond = ' and h.hostid=hg.hostid and hg.groupid='.$_REQUEST['groupid']; + $sql_cond = ' AND h.hostid=hg.hostid and hg.groupid='.$_REQUEST['groupid']; } else{ $sql_from = ''; - $sql_cond = ' and h.hostid in ('.$available_hosts.') '; + $sql_cond = ' AND '.DBcondition('h.hostid',$available_hosts); } $sql_cond.=(isset($_REQUEST['triggerid']) && ($_REQUEST['triggerid']>0))?(' AND t.triggerid='.$_REQUEST['triggerid'].' '):''; @@ -485,17 +486,25 @@ include_once "include/page_header.php"; $filterForm->AddItemToBottomRow(new CButton("filter_set",S_FILTER)); $filterForm->AddItemToBottomRow($reset); - $filter = create_filter(S_FILTER,$navigation,$filterForm,'tr_filter',get_profile('web.events.filter.state',0)); - $filter->Show(); + $p_elements[] = create_filter(S_FILTER,$navigation,$filterForm,'tr_filter',get_profile('web.events.filter.state',0)); } else{ - show_thin_table_header(SPACE,$navigation); + $p_elements[] = get_thin_table_header(SPACE,$navigation); } //------- - $table->Show(); + $p_elements[] = $table; + $p_elements[] = get_thin_table_header(SPACE,$navigation); - show_thin_table_header(SPACE,$navigation); + $events_hat = create_hat( + $text, + $p_elements, + $fs_icon, + 'hat_events', + get_profile('web.events.hats.hat_events.state',1) + ); + + $events_hat->Show(); ?> SetHeader(array(S_HOST, S_ELEMENTS)); $table->ShowStart(); - $db_hosts = DBselect('select * from hosts where hostid in ('.implode(',',array_keys($hosts)).')'); + $db_hosts = DBselect('SELECT * FROM hosts WHERE '.DBcondition('hostid',array_keys($hosts)); while($host = DBfetch($db_hosts)){ $el_table = new CTableInfo(S_ONLY_HOST_INFO); $sqls = array( @@ -260,12 +258,12 @@ include_once "include/page_header.php"; $cmbGroups = new CComboBox("groupid",get_request("groupid",0),"submit()"); $cmbGroups->AddItem(0,S_ALL_SMALL); - $result=DBselect('select distinct g.groupid,g.name '. - ' from groups g,hosts_groups hg,hosts h'. - ' where h.hostid in ('.$available_hosts.') '. - ' and g.groupid=hg.groupid '. - ' and h.hostid=hg.hostid '. - ' order by g.name'); + $result=DBselect('SELECT DISTINCT g.groupid,g.name '. + ' FROM groups g,hosts_groups hg,hosts h '. + ' WHERE '.DBcondition('h.hostid',$available_hosts). + ' AND g.groupid=hg.groupid '. + ' AND h.hostid=hg.hostid '. + ' ORDER BY g.name'); while($row=DBfetch($result)){ $cmbGroups->AddItem($row["groupid"],$row["name"]); if((bccomp($row["groupid"] , $_REQUEST["groupid"])==0)) $correct_host = 1; @@ -313,7 +311,7 @@ include_once "include/page_header.php"; else $sql .= ' hosts h '. ' WHERE'; - $sql .= ' h.hostid in ('.$available_hosts.') '. + $sql .= DBcondition('h.hostid',$available_hosts). order_by('h.host,h.dns,h.ip,h.port,h.status'); $result=DBselect($sql); diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php index 73147bfd..885493a1 100644 --- a/frontends/php/graphs.php +++ b/frontends/php/graphs.php @@ -248,6 +248,7 @@ include_once "include/page_header.php"; break; } } + if(!isset($already_exist)){ array_push($_REQUEST['items'], $new_gitem); } diff --git a/frontends/php/history.php b/frontends/php/history.php index 13a8d8aa..ce58bf04 100644 --- a/frontends/php/history.php +++ b/frontends/php/history.php @@ -130,13 +130,13 @@ include_once "include/page_header.php"; } } - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if(DBfetch(DBselect('SELECT h.host,i.hostid,i.description,i.key_ '. ' FROM items i,hosts h '. ' WHERE i.itemid IN ('.(is_array($_REQUEST["itemid"]) ? implode(',', $_REQUEST["itemid"]) : $_REQUEST["itemid"]).') '. ' AND h.hostid=i.hostid '. - ' AND h.hostid NOT IN ('.$available_hosts.')'))) + ' AND '.DBcondition('h.hostid',$available_host, true)))) { access_deny(); } diff --git a/frontends/php/hostprofiles.php b/frontends/php/hostprofiles.php index d42db41f..0254f6a9 100644 --- a/frontends/php/hostprofiles.php +++ b/frontends/php/hostprofiles.php @@ -50,11 +50,11 @@ include_once "include/page_header.php"; $cmbGroup->AddItem(0,S_ALL_SMALL); - $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY); $result=DBselect('SELECT DISTINCT g.groupid,g.name '. ' FROM groups g, hosts_groups hg, hosts h, items i '. - ' WHERE h.hostid IN ('.$availiable_hosts.') '. + ' WHERE '.DBcondition('h.hostid',$available_hosts). ' AND hg.groupid=g.groupid '. ' AND h.status='.HOST_STATUS_MONITORED. ' AND h.hostid=i.hostid '. @@ -88,28 +88,25 @@ include_once "include/page_header.php"; make_sorting_link(S_MACADDRESS,'p.macaddress')) ); - if($_REQUEST["groupid"] > 0) - { + if($_REQUEST["groupid"] > 0){ $sql='SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress'. ' FROM hosts h,hosts_profiles p,hosts_groups hg '. ' WHERE h.hostid=p.hostid'. ' and h.hostid=hg.hostid '. ' and hg.groupid='.$_REQUEST['groupid']. - ' and h.hostid in ('.$availiable_hosts.') '. + ' and '.DBcondition('h.hostid',$available_hosts). order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress'); } else{ - $sql='SELECT h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress'. ' FROM hosts h,hosts_profiles p '. ' WHERE h.hostid=p.hostid'. - ' AND h.hostid in ('.$availiable_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). order_by('h.host,h.hostid,p.name,p.os,p.serialno,p.tag,p.macaddress'); } $result=DBselect($sql); - while($row=DBfetch($result)) - { + while($row=DBfetch($result)){ $table->AddRow(array( get_node_name_by_elid($row['hostid']), new CLink($row["host"],"?hostid=".$row["hostid"].url_param("groupid"),"action"), diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php index b7b2bca9..ecf3821f 100644 --- a/frontends/php/hosts.php +++ b/frontends/php/hosts.php @@ -325,7 +325,7 @@ include_once 'include/page_header.php'; /* SAVE HOST */ else if(($_REQUEST['config']==0 || $_REQUEST['config']==3) && isset($_REQUEST['save'])){ $useip = get_request('useip',0); - $groups=get_request('groups',array()); + $groups= get_request('groups',array()); if(count($groups) > 0){ $accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); @@ -602,7 +602,7 @@ include_once 'include/page_header.php'; } show_messages($result, $msg_ok, $msg_fail); if($result){ - add_audit($action,AUDIT_RESOURCE_HOST_GROUP,S_HOST_GROUP." [".$_REQUEST["gname"]." ] [".$groupid."]"); + add_audit($action,AUDIT_RESOURCE_HOST_GROUP,S_HOST_GROUP.' ['.$_REQUEST['gname'].'] ['.$groupid.']'); unset($_REQUEST["form"]); } unset($_REQUEST["save"]); @@ -1024,9 +1024,6 @@ include_once 'include/page_header.php'; array_push($description, new CLink($row["host"], "hosts.php?form=update&hostid=".$row["hostid"].url_param("groupid").url_param("config"), 'action')); - $add_to = array(); - $delete_from = array(); - $templates = get_templates_by_hostid($row["hostid"]); $host=new CCol(array( @@ -1088,62 +1085,20 @@ include_once 'include/page_header.php'; } - $popup_menu_actions = array( - array(S_SHOW, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))), - array(S_ITEMS, 'items.php?hostid='.$row['hostid'], array('tw'=>'_blank')), - array(S_TRIGGERS, 'triggers.php?hostid='.$row['hostid'], array('tw'=>'_blank')), - array(S_GRAPHS, 'graphs.php?hostid='.$row['hostid'], array('tw'=>'_blank')), - ); - - $db_groups = DBselect('SELECT g.groupid, g.name '. - ' FROM groups g '. - ' LEFT JOIN hosts_groups hg on g.groupid=hg.groupid and hg.hostid='.$row['hostid']. - ' WHERE hostid is NULL '. - ' ORDER BY g.name,g.groupid'); - while($group_data = DBfetch($db_groups)) - { - $add_to[] = array($group_data['name'], '?'. - url_param($group_data['groupid'], false, 'add_to_group'). - url_param($row['hostid'], false, 'hostid') - ); - } - $db_groups = DBselect('select g.groupid, g.name from groups g, hosts_groups hg '. - ' where g.groupid=hg.groupid and hg.hostid='.$row['hostid']. - ' order by g.name,g.groupid'); - - while($group_data = DBfetch($db_groups)){ - $delete_from[] = array($group_data['name'], '?'. - url_param($group_data['groupid'], false, 'delete_from_group'). - url_param($row['hostid'], false, 'hostid') - ); - } + $show = host_js_menu($row["hostid"]); - if(count($add_to) > 0 || count($delete_from) > 0){ - $popup_menu_actions[] = array(S_GROUPS, null, null, - array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))); + $templates_linked = array(); + foreach($templates as $templateid => $temp){ + $templates_linked[$templateid] = array(empty($templates_linked)?'':', ',host_js_menu($templateid, $templates[$templateid])); } - - if(count($add_to) > 0){ - $popup_menu_actions[] = array_merge(array(S_ADD_TO_GROUP, null, null, - array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $add_to); - } - - if(count($delete_from) > 0){ - $popup_menu_actions[] = array_merge(array(S_DELETE_FROM_GROUP, null, null, - array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $delete_from); - } - - $mnuActions = new CPUMenu($popup_menu_actions); - - $show = new CLink(S_SELECT, '#', 'action', $mnuActions->GetOnActionJS()); $table->addRow(array( $host, $dns, $ip, $port, - empty($templates)?'-':implode(', ',$templates), + empty($templates)?'-':$templates_linked, $status, $available, $error, diff --git a/frontends/php/httpconf.php b/frontends/php/httpconf.php index a880741f..d9c4d2b2 100644 --- a/frontends/php/httpconf.php +++ b/frontends/php/httpconf.php @@ -80,9 +80,9 @@ include_once "include/page_header.php"; $showdisabled = get_request("showdisabled", 0); - $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); - if(isset($_REQUEST['hostid']) && !uint_in_array($_REQUEST['hostid'], explode(',',$accessible_hosts))){ + if(isset($_REQUEST['hostid']) && !uint_in_array($_REQUEST['hostid'], $available_hosts)){ unset($_REQUEST['hostid']); } @@ -329,7 +329,7 @@ include_once "include/page_header.php"; $result=DBselect('select distinct g.groupid,g.name '. ' from groups g,hosts_groups hg '. ' where g.groupid=hg.groupid '. - ' and hg.hostid in ('.$accessible_hosts.') '. + ' and '.DBcondition('hg.hostid',$available_hosts). ' order by name'); while($row=DBfetch($result)){ $cmbGroup->AddItem($row["groupid"],$row["name"]); @@ -343,7 +343,7 @@ include_once "include/page_header.php"; ' where hg.groupid='.$_REQUEST["groupid"]. ' and hg.hostid=h.hostid '. ' and h.status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.') '. - ' and h.hostid in ('.$accessible_hosts.') '. + ' and '.DBcondition('h.hostid',$available_hosts). ' group by h.hostid,h.host '. ' order by h.host'; } @@ -351,7 +351,7 @@ include_once "include/page_header.php"; $sql='select distinct h.hostid,h.host '. ' from hosts h '. ' where h.status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.') '. - ' and h.hostid in ('.$accessible_hosts.') '. + ' and '.DBcondition('h.hostid',$available_hosts). ' group by h.hostid,h.host '. ' order by h.host'; } diff --git a/frontends/php/httpdetails.php b/frontends/php/httpdetails.php index f7016ae5..70d48b42 100644 --- a/frontends/php/httpdetails.php +++ b/frontends/php/httpdetails.php @@ -50,15 +50,20 @@ include_once "include/page_header.php"; "hostid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), +//ajax + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), + 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), + ); check_fields($fields); - $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $sql = 'select ht.* '. ' from httptest ht, applications a '. - ' where a.hostid in ('.$accessible_hosts.') '. + ' where '.DBcondition('a.hostid',$available_hosts). ' and a.applicationid=ht.applicationid '. ' and ht.httptestid='.$_REQUEST['httptestid']; diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php index 2a27a607..875e801a 100644 --- a/frontends/php/httpmon.php +++ b/frontends/php/httpmon.php @@ -43,10 +43,28 @@ include_once "include/page_header.php"; "open"=> array(T_ZBX_INT, O_OPT, null, IN("1"), null), "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null) + "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), +//ajax + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), + 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), + ); check_fields($fields); + +/* AJAX */ + if(isset($_REQUEST['favobj'])){ + if('hat' == $_REQUEST['favobj']){ + update_profile('web.httpmon.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } + } + + if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ + exit(); + } +//-------- + validate_sort_and_sortorder('wt.name',ZBX_SORT_DOWN); $options = array('allow_all_hosts','monitored_hosts');//,'always_select_first_host' @@ -86,6 +104,9 @@ include_once "include/page_header.php"; update_profile("web.httpmon.applications",$_REQUEST["applications"],PROFILE_TYPE_ARRAY_ID); ?> SetMethod('get'); @@ -93,12 +114,13 @@ include_once "include/page_header.php"; $cmbGroup = new CComboBox("groupid",null,"submit();"); $cmbGroup->AddItem(0,S_ALL_SMALL); - $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST); - $accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST); - + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY); + $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST); +//\ ([hg]{1,2}\.hostid)\ [inIN]+\ \(.\.\$[a-z_]+\..\)\ +// '.DBcondition('$1',$available_hosts) $result=DBselect('SELECT DISTINCT g.groupid,g.name '. ' FROM groups g, hosts_groups hg, hosts h, applications a, httptest ht '. - ' WHERE g.groupid in ('.$accessible_groups.') '. + ' WHERE g.groupid in ('.$available_groups.') '. ' AND hg.groupid=g.groupid '. ' AND h.status='.HOST_STATUS_MONITORED. ' AND h.hostid=a.hostid '. @@ -134,7 +156,7 @@ include_once "include/page_header.php"; ' AND h.hostid=a.hostid '. ' AND hg.hostid=h.hostid '. ' AND hg.groupid='.$_REQUEST["groupid"]. - ' AND h.hostid in ('.$accessible_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND a.applicationid=ht.applicationid '. ' AND ht.status='.HTTPTEST_STATUS_ACTIVE. ' GROUP BY h.hostid,h.host'. @@ -147,14 +169,13 @@ include_once "include/page_header.php"; ' AND h.hostid=a.hostid '. ' AND ht.status='.HTTPTEST_STATUS_ACTIVE. ' AND ht.applicationid=a.applicationid '. - ' AND h.hostid in ('.$accessible_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' GROUP BY h.hostid,h.host '. ' ORDER BY h.host'; } $result=DBselect($sql); - while($row=DBfetch($result)) - { + while($row=DBfetch($result)){ $cmbHosts->AddItem( $row['hostid'], get_node_name_by_elid($row['hostid']).$row['host'] @@ -164,7 +185,7 @@ include_once "include/page_header.php"; $form->AddItem(SPACE.S_HOST.SPACE); $form->AddItem($cmbHosts); - show_table_header(S_STATUS_OF_WEB_MONITORING_BIG, $form); + $p_elements[] = get_table_header(SPACE, $form); // TABLE $form = new CForm(); @@ -195,27 +216,31 @@ include_once "include/page_header.php"; $any_app_exist = false; if($_REQUEST["hostid"] > 0) - $compare_host = " AND h.hostid=".$_REQUEST["hostid"]; + $compare_host = ' AND h.hostid='.$_REQUEST["hostid"]; else - $compare_host = " AND h.hostid in (".$accessible_hosts.") "; - - $db_applications = DBselect('SELECT DISTINCT h.host,h.hostid,a.* '. - ' FROM applications a,hosts h '. - ' WHERE a.hostid=h.hostid '.$compare_host. - order_by('a.applicationid,h.host,h.hostid','a.name') - ); - while($db_app = DBfetch($db_applications)) - { - $db_httptests = DBselect('select wt.*,a.name as application,h.host,h.hostid from httptest wt '. - ' left join applications a on wt.applicationid=a.applicationid '. - ' left join hosts h on h.hostid=a.hostid'. - ' where a.applicationid='.$db_app["applicationid"].' AND wt.status <> 1'. - order_by('wt.name','h.host')); - + $compare_host = ' AND '.DBcondition('h.hostid',$available_hosts); + + $sql = 'SELECT DISTINCT h.host,h.hostid,a.* '. + ' FROM applications a,hosts h '. + ' WHERE a.hostid=h.hostid '. + $compare_host. + order_by('a.applicationid,h.host,h.hostid','a.name'); + $db_applications = DBselect($sql); + while($db_app = DBfetch($db_applications)){ + $app_rows = array(); $httptest_cnt = 0; - while($httptest_data = DBfetch($db_httptests)) - { + + $sql = 'SELECT wt.*,a.name as application,h.host,h.hostid '. + ' FROM httptest wt '. + ' LEFT JOIN applications a on wt.applicationid=a.applicationid '. + ' LEFT JOIN hosts h on h.hostid=a.hostid'. + ' WHERE a.applicationid='.$db_app["applicationid"]. + ' AND wt.status <> 1'. + order_by('wt.name','h.host'); + + $db_httptests = DBselect($sql); + while($httptest_data = DBfetch($db_httptests)){ ++$httptest_cnt; if(!uint_in_array($db_app["applicationid"],$_REQUEST["applications"]) && !isset($show_all_apps)) continue; @@ -231,34 +256,29 @@ include_once "include/page_header.php"; else $lastcheck = new CCol('-', 'center'); - if( HTTPTEST_STATE_BUSY == $httptest_data['curstate'] ) - { + if( HTTPTEST_STATE_BUSY == $httptest_data['curstate'] ){ $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['curstep']); $state = S_IN_CHECK.' "'.$step_data['name'].'" ['.$httptest_data['curstep'].' '.S_OF_SMALL.' '.$step_cout.']'; $status['msg'] = S_IN_PROGRESS; $status['style'] = 'unknown'; } - else if( HTTPTEST_STATE_IDLE == $httptest_data['curstate'] ) - { + else if( HTTPTEST_STATE_IDLE == $httptest_data['curstate'] ){ $state = S_IDLE_TILL." ".date(S_DATE_FORMAT_YMDHMS,$httptest_data['nextcheck']); - if($httptest_data['lastfailedstep'] > 0) - { + if($httptest_data['lastfailedstep'] > 0){ $step_data = get_httpstep_by_no($httptest_data['httptestid'], $httptest_data['lastfailedstep']); $status['msg'] = S_FAILED_ON.' "'.$step_data['name'].'" '. '['.$httptest_data['lastfailedstep'].' '.S_OF_SMALL.' '.$step_cout.'] '. ' '.S_ERROR.': '.$httptest_data['error']; $status['style'] = 'disabled'; } - else - { + else{ $status['msg'] = S_OK_BIG; $status['style'] = 'enabled'; } } - else - { + else{ $state = S_IDLE_TILL." ".date(S_DATE_FORMAT_YMDHMS,$httptest_data['nextcheck']); $status['msg'] = S_UNKNOWN; $status['style'] = 'unknown'; @@ -274,8 +294,7 @@ include_once "include/page_header.php"; new CSpan($status['msg'], $status['style']) ))); } - if($httptest_cnt > 0) - { + if($httptest_cnt > 0){ if(uint_in_array($db_app["applicationid"],$_REQUEST["applications"]) || isset($show_all_apps)) $link = new CLink(new CImg("images/general/opened.gif"), "?close=1&applicationid=".$db_app["applicationid"]. @@ -306,7 +325,17 @@ include_once "include/page_header.php"; } $form->AddItem($table); - $form->Show(); + + $p_elements[] = $form; + + $latest_hat = create_hat( + S_STATUS_OF_WEB_MONITORING_BIG, + $p_elements, + null, + 'hat_httpmon', + get_profile('web.httpmon.hats.hat_httpmon.state',1) + ); + $latest_hat->Show(); include_once "include/page_footer.php" ?> \ No newline at end of file diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php index e7616d29..401f68d5 100644 --- a/frontends/php/include/actions.inc.php +++ b/frontends/php/include/actions.inc.php @@ -30,7 +30,7 @@ function action_accessible($actionid,$perm){ if (DBselect('select actionid from actions where actionid='.$actionid.' and '.DBin_node('actionid'))){ $result = true; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); $db_result = DBselect('SELECT * FROM conditions WHERE actionid='.$actionid); @@ -39,13 +39,13 @@ function action_accessible($actionid,$perm){ switch($ac_data['conditiontype']){ case CONDITION_TYPE_HOST_GROUP: - if(!uint_in_array($ac_data['value'],explode(',',$available_groups))){ + if(!uint_in_array($ac_data['value'],$available_groups)){ $result = false; } break; case CONDITION_TYPE_HOST: case CONDITION_TYPE_HOST_TEMPLATE: - if(!uint_in_array($ac_data['value'],explode(',',$available_hosts))){ + if(!uint_in_array($ac_data['value'],$available_hosts)){ $result = false; } break; @@ -55,7 +55,7 @@ function action_accessible($actionid,$perm){ ' WHERE t.triggerid='.$ac_data['value']. ' AND f.triggerid=t.triggerid'. ' AND i.itemid=f.itemid '. - ' AND i.hostid NOT IN ('.$available_hosts.')'; + ' AND '.DBcondition('i.hostid',$available_hosts, true); if(DBfetch(DBselect($sql,1))){ $result = false; @@ -72,7 +72,7 @@ function check_permission_for_action_conditions($conditions){ $result = true; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); foreach($conditions as $ac_data){ @@ -80,14 +80,14 @@ function check_permission_for_action_conditions($conditions){ switch($ac_data['type']){ case CONDITION_TYPE_HOST_GROUP: - if(!uint_in_array($ac_data['value'],explode(',',$available_groups))){ + if(!uint_in_array($ac_data['value'],$available_groups)){ error(S_INCORRECT_GROUP); $result = false; } break; case CONDITION_TYPE_HOST: case CONDITION_TYPE_HOST_TEMPLATE: - if(!uint_in_array($ac_data['value'],explode(',',$available_hosts))){ + if(!uint_in_array($ac_data['value'],$available_hosts)){ error(S_INCORRECT_HOST); $result = false; } @@ -98,7 +98,7 @@ function check_permission_for_action_conditions($conditions){ ' WHERE t.triggerid='.$ac_data['value']. ' AND f.triggerid=t.triggerid'. ' AND i.itemid=f.itemid '. - ' AND i.hostid NOT IN ('.$available_hosts.')'; + ' AND '.DBcondition('i.hostid',$available_hosts, true); // ' AND e.eventid='.$ac_data['value']. // ' AND t.triggerid=e.objectid'; diff --git a/frontends/php/include/classes/chart.inc.php b/frontends/php/include/classes/chart.inc.php index d1d69b88..50f076c6 100644 --- a/frontends/php/include/classes/chart.inc.php +++ b/frontends/php/include/classes/chart.inc.php @@ -40,41 +40,36 @@ class Chart extends Graph{ $this->zero = array(); $this->graphorientation = ''; + + $this->gridPixels = 40; } - function updateShifts() - { - if( ($this->yaxisleft == 1) && ($this->yaxisright == 1)) - { + function updateShifts(){ + if( ($this->yaxisleft == 1) && ($this->yaxisright == 1)){ $this->shiftXleft = 60; $this->shiftXright = 60; } - else if($this->yaxisleft == 1) - { + else if($this->yaxisleft == 1){ $this->shiftXleft = 60; $this->shiftXright = 20; } - else if($this->yaxisright == 1) - { + else if($this->yaxisright == 1){ $this->shiftXleft = 10; $this->shiftXright = 60; } // $this->sizeX = $this->sizeX - $this->shiftXleft-$this->shiftXright; } - function ShowWorkPeriod($value) - { - $this->m_showWorkPeriod = $value == 1 ? 1 : 0; + function ShowWorkPeriod($value){ + $this->m_showWorkPeriod = ($value==1)?1:0; } - function ShowTriggers($value) - { - $this->m_showTriggers = $value == 1 ? 1 : 0; + function ShowTriggers($value){ + $this->m_showTriggers = ($value==1)?1:0; } function AddItem($itemid, $axis=GRAPH_YAXIS_SIDE_RIGHT, $calc_fnc=CALC_FNC_AVG, - $color=null, $drawtype=null, $type=null, $periods_cnt=null) - { + $color=null, $drawtype=null, $type=null, $periods_cnt=null){ if($this->type == GRAPH_TYPE_STACKED /* stacked graph */) $drawtype = GRAPH_ITEM_DRAWTYPE_FILLED_REGION; @@ -106,7 +101,7 @@ class Chart extends Graph{ if(($this->graphorientation == '+') && ($value<0)){ // Error(); } - elseif(($this->graphorientation == '-') && ($value>0)){ + else if(($this->graphorientation == '-') && ($value>0)){ // Error(); } } @@ -114,61 +109,78 @@ class Chart extends Graph{ if($value < 0){ $this->graphorientation = '-'; } - elseif($value > 0){ + else if($value > 0){ $this->graphorientation = '+'; } } } - function setYAxisMin($yaxismin) - { + function setYAxisMin($yaxismin){ $this->yaxismin=$yaxismin; } - function setYAxisMax($yaxismax) - { + function setYAxisMax($yaxismax){ $this->yaxismax=$yaxismax; } - function setYAxisType($yaxistype) - { + function setYAxisType($yaxistype){ $this->yaxistype=$yaxistype; } - function drawGrid() - { + function drawGrid(){ $this->drawSmallRectangle(); - for($i=1;$i<=5;$i++) - { - DashedLine($this->im,$this->shiftXleft,$i*($this->sizeY/6)+$this->shiftY,$this->sizeX+$this->shiftXleft,$i*($this->sizeY/6)+$this->shiftY,$this->GetColor("Gray")); + $hline_count = round($this->sizeY / $this->gridPixels); + for($i=1;$i<=$hline_count;$i++){ + DashedLine($this->im, + $this->shiftXleft, + $i*($this->sizeY/($hline_count+1))+$this->shiftY, + $this->sizeX+$this->shiftXleft, + $i*($this->sizeY/($hline_count+1))+$this->shiftY, + $this->GetColor("Gray") + ); } - for($i=1;$i<=23;$i++) - { - DashedLine($this->im,$i*($this->sizeX/24)+$this->shiftXleft,$this->shiftY,$i*($this->sizeX/24)+$this->shiftXleft,$this->sizeY+$this->shiftY,$this->GetColor("Gray")); + $vline_count = round($this->sizeX / $this->gridPixels); + for($i=1;$i<=$vline_count;$i++){ + DashedLine($this->im, + $i*($this->sizeX/($vline_count+1))+$this->shiftXleft, + $this->shiftY, + $i*($this->sizeX/($vline_count+1))+$this->shiftXleft, + $this->sizeY+$this->shiftY, + $this->GetColor("Gray") + ); } $old_day=-1; - for($i=0;$i<=24;$i++) - { - ImageStringUp($this->im, 1,$i*($this->sizeX/24)+$this->shiftXleft-3, $this->sizeY+$this->shiftY+57, date(" H:i",$this->from_time+$i*($this->period/24)) , $this->GetColor("Black No Alpha")); - - $new_day=date("d",$this->from_time+$i*($this->period/24)); - if( ($old_day != $new_day) ||($i==24)) - { + for($i=0;$i<=($vline_count+1);$i++){ + ImageStringUp($this->im, + 1, + $i*($this->sizeX/($vline_count+1))+$this->shiftXleft-3, + $this->sizeY+$this->shiftY+57, + date(" H:i",$this->from_time+$i*($this->period/($vline_count+1))), + $this->GetColor("Black No Alpha") + ); + + $new_day=date("d",$this->from_time+$i*($this->period/($vline_count+1))); + if(($old_day != $new_day) || ($i==($vline_count+1))){ $old_day=$new_day; - ImageStringUp($this->im, 1,$i*($this->sizeX/24)+$this->shiftXleft-3, $this->sizeY+$this->shiftY+57, date("m.d H:i",$this->from_time+$i*($this->period/24)) , $this->GetColor("Dark Red No Alpha")); + ImageStringUp($this->im, + 1, + $i*($this->sizeX/($vline_count+1))+$this->shiftXleft-3, + $this->sizeY+$this->shiftY+57, + date("m.d H:i",$this->from_time+$i*($this->period/($vline_count+1))), + $this->GetColor("Dark Red No Alpha") + ); } } } - function drawWorkPeriod() - { + function drawWorkPeriod(){ if($this->m_showWorkPeriod != 1) return; if($this->period > 2678400) return; // > 31*24*3600 (month) - $db_work_period = DBselect("SELECT work_period FROM config"); + $db_work_period = DBselect('SELECT work_period FROM config'); $work_period = DBfetch($db_work_period); if(!$work_period) return; @@ -185,13 +197,11 @@ class Chart extends Graph{ $this->GetColor("Not Work Period")); $now = time(); - if(isset($this->stime)) - { + if(isset($this->stime)){ $this->from_time=$this->stime; $this->to_time=$this->stime+$this->period; } - else - { + else{ $this->to_time=$now-3600*$this->from; $this->from_time=$this->to_time-$this->period; } @@ -200,8 +210,7 @@ class Chart extends Graph{ $start = find_period_start($periods,$from); $end = -1; - while($start < $max_time && $start > 0) - { + while($start < $max_time && $start > 0){ $end = find_period_end($periods,$start,$max_time); $x1 = round((($start-$from)*$this->sizeX)/$this->period) + $this->shiftXleft; @@ -220,8 +229,7 @@ class Chart extends Graph{ } } - function calcTriggers() - { + function calcTriggers(){ $this->triggers = array(); if($this->m_showTriggers != 1) return; if($this->num != 1) return; // skip multiple graphs @@ -238,8 +246,7 @@ class Chart extends Graph{ ' AND f.itemid='.$this->items[0]["itemid"]. ' ORDER BY tr.priority'); - while(($trigger = DBfetch($db_triggers)) && ($cnt < $max)) - { + while(($trigger = DBfetch($db_triggers)) && ($cnt < $max)){ $db_fnc_cnt = DBselect('SELECT count(*) as cnt FROM functions f WHERE f.triggerid='.$trigger['triggerid']); $fnc_cnt = DBfetch($db_fnc_cnt); if($fnc_cnt['cnt'] != 1) continue; @@ -271,13 +278,11 @@ class Chart extends Graph{ } } - function drawTriggers() - { + function drawTriggers(){ if($this->m_showTriggers != 1) return; if($this->num != 1) return; // skip multiple graphs - foreach($this->triggers as $trigger) - { + foreach($this->triggers as $trigger){ DashedLine( $this->im, $this->shiftXleft, @@ -290,28 +295,22 @@ class Chart extends Graph{ } - function drawLegend() - { + function drawLegend(){ $max_host_len=0; $max_desc_len=0; - for($i=0;$i<$this->num;$i++) - { + for($i=0;$i<$this->num;$i++){ if(strlen($this->items[$i]["host"])>$max_host_len) $max_host_len=strlen($this->items[$i]["host"]); if(strlen($this->items[$i]["description"])>$max_desc_len) $max_desc_len=strlen($this->items[$i]["description"]); } - for($i=0;$i<$this->num;$i++) - { - if($this->items[$i]["calc_type"] == GRAPH_ITEM_AGGREGATED) - { + for($i=0;$i<$this->num;$i++){ + if($this->items[$i]["calc_type"] == GRAPH_ITEM_AGGREGATED){ $fnc_name = "agr(".$this->items[$i]["periods_cnt"].")"; $color = $this->GetColor("HistoryMinMax"); } - else - { + else{ $color = $this->GetColor($this->items[$i]["color"]); - switch($this->items[$i]["calc_fnc"]) - { + switch($this->items[$i]["calc_fnc"]){ case CALC_FNC_MIN: $fnc_name = "min"; break; case CALC_FNC_MAX: $fnc_name = "max"; break; case CALC_FNC_ALL: $fnc_name = "all"; break; @@ -321,8 +320,7 @@ class Chart extends Graph{ } $data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["calc_type"]]; - if(isset($data)&&isset($data->min)) - { + if(isset($data)&&isset($data->min)){ $str=sprintf("%s: %s [%s] [min:%s max:%s last:%s]", str_pad($this->items[$i]["host"],$max_host_len," "), str_pad($this->items[$i]["description"],$max_desc_len," "), @@ -331,27 +329,39 @@ class Chart extends Graph{ convert_units(max($data->max),$this->items[$i]["units"]), convert_units($this->getLastValue($i),$this->items[$i]["units"])); } - else - { + else{ $str=sprintf("%s: %s [ no data ]", str_pad($this->items[$i]["host"],$max_host_len," "), str_pad($this->items[$i]["description"],$max_desc_len," ")); } - ImageFilledRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$color); - ImageRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$this->GetColor("Black No Alpha")); + ImageFilledRectangle($this->im, + $this->shiftXleft, + $this->sizeY+$this->shiftY+62+12*$i, + $this->shiftXleft+5 + ,$this->sizeY+$this->shiftY+5+62+12*$i, + $color + ); + ImageRectangle($this->im, + $this->shiftXleft, + $this->sizeY+$this->shiftY+62+12*$i, + $this->shiftXleft+5, + $this->sizeY+$this->shiftY+5+62+12*$i, + $this->GetColor("Black No Alpha") + ); - ImageString($this->im, 2, - $this->shiftXleft+9, - $this->sizeY+$this->shiftY+(62-5)+12*$i, - $str, - $this->GetColor("Black No Alpha")); + ImageString($this->im, + 2, + $this->shiftXleft+9, + $this->sizeY+$this->shiftY+(62-5)+12*$i, + $str, + $this->GetColor("Black No Alpha") + ); } if($this->sizeY < 120) return; - foreach($this->triggers as $trigger) - { + foreach($this->triggers as $trigger){ ImageFilledEllipse($this->im, $this->shiftXleft + 2, $this->sizeY+$this->shiftY+2+62+12*$i, @@ -383,14 +393,13 @@ class Chart extends Graph{ $drawtype, $max_color, $avg_color, $min_color, $minmax_color, $calc_fnc, $axisside - ) - { + ){ if(!isset($data->max[$from]) || !isset($data->max[$to])) return; $oxy = $this->oxy[$axisside]; $zero = $this->zero[$axisside]; $unit2px = $this->unit2px[$axisside]; - +//SDI($oxy); $shift_min_from = $shift_min_to = 0; $shift_max_from = $shift_max_to = 0; $shift_avg_from = $shift_avg_to = 0; @@ -416,10 +425,10 @@ class Chart extends Graph{ $x1 = $from + $this->shiftXleft - 1; $x2 = $to + $this->shiftXleft; - + $y1min = $zero - ($min_from-$oxy)/$unit2px; $y2min = $zero - ($min_to-$oxy)/$unit2px; - +//SDI(array($y1min,$zero,$min_from,$oxy,$unit2px)); $y1max = $zero - ($max_from-$oxy)/$unit2px; $y2max = $zero - ($max_to-$oxy)/$unit2px; @@ -468,12 +477,12 @@ class Chart extends Graph{ $y2_shift = $zero - $shift_to/$unit2px;//*/ /* draw main line */ - switch($drawtype) - { + switch($drawtype){ case GRAPH_ITEM_DRAWTYPE_BOLD_LINE: ImageLine($this->im,$x1,$y1+1,$x2,$y2+1,$avg_color); // break; /* don't use break, must be drawed line also */ case GRAPH_ITEM_DRAWTYPE_LINE: +//SDI(array($this->im,$x1,$y1,$x2,$y2,$avg_color)); ImageLine($this->im,$x1,$y1,$x2,$y2,$avg_color); break; case GRAPH_ITEM_DRAWTYPE_FILLED_REGION: @@ -509,9 +518,11 @@ class Chart extends Graph{ function calculateMinY($side){ if($this->yaxistype==GRAPH_YAXIS_TYPE_FIXED){ return $this->yaxismin; - } else if ($this->yaxistype==GRAPH_YAXIS_TYPE_CALCULATED_0_MIN) { + } + else if($this->yaxistype==GRAPH_YAXIS_TYPE_CALCULATED_0_MIN) { return 0; - } else{ + } + else{ unset($minY); for($i=0;$i<$this->num;$i++){ @@ -534,10 +545,18 @@ class Chart extends Graph{ switch($calc_fnc){ case CALC_FNC_ALL: /* use min */ - case CALC_FNC_MIN: $val = $data->min; $shift_val = $data->shift_min; break; - case CALC_FNC_MAX: $val = $data->max; $shift_val = $data->shift_max; break; + case CALC_FNC_MIN: + $val = $data->min; + $shift_val = $data->shift_min; + break; + case CALC_FNC_MAX: + $val = $data->max; + $shift_val = $data->shift_max; + break; case CALC_FNC_AVG: - default: $val = $data->avg; $shift_val = $data->shift_avg; + default: + $val = $data->avg; + $shift_val = $data->shift_avg; } if(!isset($val)) continue; @@ -566,7 +585,7 @@ class Chart extends Graph{ if(isset($minY)&&($minY>0)){ $minY = $minY - ($minY * 0.2) - 0.05; } - elseif(isset($minY)&&($minY<0)){ + else if(isset($minY)&&($minY<0)){ $minY = $minY + ($minY * 0.2) - 0.05; } else { @@ -579,23 +598,18 @@ class Chart extends Graph{ } // Calculation of maximum Y of a side (left/right) - function calculateMaxY($side) - { - if($this->yaxistype==GRAPH_YAXIS_TYPE_FIXED) - { + function calculateMaxY($side){ + if($this->yaxistype==GRAPH_YAXIS_TYPE_FIXED){ return $this->yaxismax; } - else - { + else{ unset($maxY); - for($i=0;$i<$this->num;$i++) - { + for($i=0;$i<$this->num;$i++){ if($this->items[$i]["axisside"] != $side) continue; - foreach(array(GRAPH_ITEM_SIMPLE, GRAPH_ITEM_AGGREGATED) as $type) - { + foreach(array(GRAPH_ITEM_SIMPLE, GRAPH_ITEM_AGGREGATED) as $type){ if(!isset($this->data[$this->items[$i]["itemid"]][$type])) continue; @@ -608,28 +622,32 @@ class Chart extends Graph{ else $calc_fnc = $this->items[$i]["calc_fnc"]; - switch($calc_fnc) - { + switch($calc_fnc){ case CALC_FNC_ALL: /* use max */ - case CALC_FNC_MAX: $val = $data->max; $shift_val = $data->shift_max; break; - case CALC_FNC_MIN: $val = $data->min; $shift_val = $data->shift_min; break; + case CALC_FNC_MAX: + $val = $data->max; + $shift_val = $data->shift_max; + break; + case CALC_FNC_MIN: + $val = $data->min; + $shift_val = $data->shift_min; + break; case CALC_FNC_AVG: - default: $val = $data->avg; $shift_val = $data->shift_avg; + default: + $val = $data->avg; + $shift_val = $data->shift_avg; } if(!isset($val)) continue; for($ci=0; $ci < min(count($val),count($shift_val)); $ci++) $val[$ci] += $shift_val[$ci]; - if(!isset($maxY)) - { - if(isset($val) && count($val) > 0) - { + if(!isset($maxY)){ + if(isset($val) && count($val) > 0){ $maxY = max($val); } } - else - { + else{ $maxY = max($maxY, max($val)); } @@ -638,15 +656,17 @@ class Chart extends Graph{ if(isset($maxY)&&($maxY>0)){ -/* $exp = round(log10($maxY)); +/* + $exp = round(log10($maxY)); $mant = $maxY/pow(10,$exp); $mant=((round(($mant*11)/6)-1)*6)/10; - $maxY = $mant*pow(10,$exp);//*/ + $maxY = $mant*pow(10,$exp); +//*/ $maxY = round($maxY,1) + round($maxY,1)*0.2 + 0.05; } - elseif(isset($maxY)&&($maxY<0)){ + else if(isset($maxY)&&($maxY<0)){ $maxY = round($maxY,1) - round($maxY,1)*0.2 + 0.05; } else { @@ -672,8 +692,8 @@ class Chart extends Graph{ } $p = $this->to_time - $this->from_time; // graph size in time - $z = $p - $this->from_time % $p; // graphsize - mod(from_time,p) for Oracle... - $x = $this->sizeX; // graph size in px + $z = $p - $this->from_time % $p; // graphsize - mod(from_time,p) for Oracle... + $x = $this->sizeX; // graph size in px for($i=0; $i < $this->num; $i++){ @@ -691,6 +711,7 @@ class Chart extends Graph{ } $calc_field = 'round('.$x.'*(mod('.zbx_dbcast_2bigint('clock').'+'.$z.','.$p.'))/('.$p.'),0)'; /* required for 'group by' support of Oracle */ + $sql_arr = array(); if((($real_item['history']*86400) > (time()-($from_time+$this->period/2))) && // should pick data from history or trends @@ -745,13 +766,13 @@ class Chart extends Graph{ while($row=DBfetch($result)){ $idx=$row["i"]-1; if($idx<0) continue; - /* -------------------------------------------------- - We are taking graph on 1px more than we need, - and here we are skiping first px, because of MOD (in SELECT), - it combines prelast point (it would be last point if not that 1px in begining) - and first point, but we still losing prelast point :( - but now we've got the first point. - --------------------------------------------------*/ +/* -------------------------------------------------- + We are taking graph on 1px more than we need, + and here we are skiping first px, because of MOD (in SELECT), + it combines prelast point (it would be last point if not that 1px in begining) + and first point, but we still losing prelast point :( + but now we've got the first point. +--------------------------------------------------*/ $curr_data->count[$idx] = $row["count"]; $curr_data->min[$idx] = $row["min"]; @@ -777,18 +798,15 @@ class Chart extends Graph{ dx - offset to first value (count to last existed point) //*/ - for($ci = 0, $cj=0; $ci < $this->sizeX; $ci++) - { - if(!isset($curr_data->count[$ci]) || $curr_data->count[$ci] == 0) - { + for($ci = 0, $cj=0; $ci < $this->sizeX; $ci++){ + if(!isset($curr_data->count[$ci]) || $curr_data->count[$ci] == 0){ $curr_data->count[$ci] = 0; $curr_data->shift_min[$ci] = 0; $curr_data->shift_max[$ci] = 0; $curr_data->shift_avg[$ci] = 0; $cj++; } - else if($cj > 0) - { + else if($cj > 0){ $dx = $cj + 1; $first_idx = $ci - $dx; @@ -827,14 +845,13 @@ class Chart extends Graph{ for(;$cj > 0; $cj--){ -// if($dx < ($this->sizeX/20)) //($this->type == GRAPH_TYPE_STACKED) -// $curr_data->count[$first_idx + ($dx - $cj)] = 1; +// if($dx < ($this->sizeX/20)) //($this->type == GRAPH_TYPE_STACKED) +// $curr_data->count[$first_idx + ($dx - $cj)] = 1; foreach(array('clock','min','max','avg') as $var_name){ $var = &$curr_data->$var_name; - if( $var_name == 'clock') - { + if( $var_name == 'clock'){ $var[$first_idx + ($dx - $cj)] = $var[$first_idx] + (($p / $this->sizeX) * ($dx - $cj)); continue; } @@ -847,26 +864,21 @@ class Chart extends Graph{ /* calculte shift for stacked graphs */ - if($this->type == GRAPH_TYPE_STACKED) - { - for($i=1; $i<$this->num; $i++) - { + if($this->type == GRAPH_TYPE_STACKED){ + for($i=1; $i<$this->num; $i++){ $curr_data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["calc_type"]]; if(!isset($curr_data)) continue; - for($j = $i-1; $j >= 0; $j--) - { + for($j = $i-1; $j >= 0; $j--){ if($this->items[$j]["axisside"] != $this->items[$i]["axisside"]) continue; $prev_data = &$this->data[$this->items[$j]["itemid"]][$this->items[$j]["calc_type"]]; if(!isset($prev_data)) continue; - for($ci = 0; $ci < $this->sizeX; $ci++) - { - foreach(array('min','max','avg') as $var_name) - { + for($ci = 0; $ci < $this->sizeX; $ci++){ + foreach(array('min','max','avg') as $var_name){ $shift_var_name = 'shift_'.$var_name; $curr_shift = &$curr_data->$shift_var_name; $curr_var = &$curr_data->$var_name; @@ -882,28 +894,33 @@ class Chart extends Graph{ /* end calculation of stacked graphs */ } - function DrawLeftSide() - { - if($this->yaxisleft == 1) - { + function DrawLeftSide(){ + if($this->yaxisleft == 1){ $minY = $this->m_minY[GRAPH_YAXIS_SIDE_LEFT]; $maxY = $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]; - for($item=0;$item<$this->num;$item++) - { - if($this->items[$item]["axisside"] == GRAPH_YAXIS_SIDE_LEFT) - { + for($item=0;$item<$this->num;$item++){ + if($this->items[$item]["axisside"] == GRAPH_YAXIS_SIDE_LEFT){ $units=$this->items[$item]["units"]; break; } } - for($i=0;$i<=6;$i++) - { - $str = str_pad(convert_units($this->sizeY*$i/6*($maxY-$minY)/$this->sizeY+$minY,$units),10," ", STR_PAD_LEFT); - ImageString($this->im, 1, 5, $this->sizeY-$this->sizeY*$i/6-4+$this->shiftY, $str, $this->GetColor("Dark Red No Alpha")); + + $hstr_count = round($this->sizeY / $this->gridPixels) + 1; + for($i=0;$i<=$hstr_count;$i++){ + $str = str_pad(convert_units($this->sizeY*$i/$hstr_count*($maxY-$minY)/$this->sizeY+$minY,$units),10," ", STR_PAD_LEFT); + ImageString($this->im, + 1, + 5, + $this->sizeY-$this->sizeY*$i/$hstr_count-4+$this->shiftY, + $str, + $this->GetColor("Dark Red No Alpha") + ); } + if(($this->zero[GRAPH_YAXIS_SIDE_LEFT] != $this->sizeY+$this->shiftY) && - ($this->zero[GRAPH_YAXIS_SIDE_LEFT] != $this->shiftY)){ + ($this->zero[GRAPH_YAXIS_SIDE_LEFT] != $this->shiftY)) + { imageline($this->im, $this->shiftXleft, $this->zero[GRAPH_YAXIS_SIDE_LEFT], @@ -915,10 +932,8 @@ class Chart extends Graph{ } } - function DrawRightSide() - { - if($this->yaxisright == 1) - { + function DrawRightSide(){ + if($this->yaxisright == 1){ $minY = $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT]; $maxY = $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]; @@ -928,13 +943,20 @@ class Chart extends Graph{ break; } } - for($i=0;$i<=6;$i++){ - $str = str_pad(convert_units($this->sizeY*$i/6*($maxY-$minY)/$this->sizeY+$minY,$units),10," "); - ImageString($this->im, 1, $this->sizeX+$this->shiftXleft+2, $this->sizeY-$this->sizeY*$i/6-4+$this->shiftY, $str, $this->GetColor("Dark Red No Alpha")); + $hstr_count = round($this->sizeY / $this->gridPixels) + 1; + for($i=0;$i<=$hstr_count;$i++){ + $str = str_pad(convert_units($this->sizeY*$i/$hstr_count*($maxY-$minY)/$this->sizeY+$minY,$units),10," "); + ImageString($this->im, + 1, + $this->sizeX+$this->shiftXleft+2, + $this->sizeY-$this->sizeY*$i/$hstr_count-4+$this->shiftY, + $str, + $this->GetColor("Dark Red No Alpha")); } if(($this->zero[GRAPH_YAXIS_SIDE_RIGHT] != $this->sizeY+$this->shiftY) && - ($this->zero[GRAPH_YAXIS_SIDE_RIGHT] != $this->shiftY)){ + ($this->zero[GRAPH_YAXIS_SIDE_RIGHT] != $this->shiftY)) + { imageline($this->im, $this->shiftXleft, $this->zero[GRAPH_YAXIS_SIDE_RIGHT], @@ -949,17 +971,17 @@ class Chart extends Graph{ function CalcZero(){ $left = GRAPH_YAXIS_SIDE_LEFT; $right = GRAPH_YAXIS_SIDE_RIGHT; - + $this->unit2px[$right] = ($this->m_maxY[$right] - $this->m_minY[$right])/$this->sizeY; $this->unit2px[$left] = ($this->m_maxY[$left] - $this->m_minY[$left])/$this->sizeY; if($this->m_minY[$right]>0){ $this->zero[$right] = $this->sizeY+$this->shiftY; - $this->oxy[$right] = min(abs($this->m_minY[$right]),abs($this->m_maxY[$right])); + $this->oxy[$right] = min($this->m_minY[$right],$this->m_maxY[$right]); } - elseif($this->m_maxY[$right]<0) { + else if($this->m_maxY[$right]<0) { $this->zero[$right] = $this->shiftY; - $this->oxy[$right] = min(abs($this->m_minY[$right]),abs($this->m_maxY[$right])); + $this->oxy[$right] = max($this->m_minY[$right],$this->m_maxY[$right]); } else{ $this->zero[$right] = $this->sizeY+$this->shiftY - (int)abs($this->m_minY[$right]/$this->unit2px[$right]); @@ -968,11 +990,11 @@ class Chart extends Graph{ if($this->m_minY[$left]>0){ $this->zero[$left] = $this->sizeY+$this->shiftY; - $this->oxy[$left] = min(abs($this->m_minY[$left]),abs($this->m_maxY[$left])); + $this->oxy[$left] = min($this->m_minY[$left],$this->m_maxY[$left]); } - elseif($this->m_maxY[$left]<0){ + else if($this->m_maxY[$left]<0){ $this->zero[$left] = $this->shiftY; - $this->oxy[$left] = min(abs($this->m_minY[$left]),abs($this->m_maxY[$left])); + $this->oxy[$left] = max($this->m_minY[$left],$this->m_maxY[$left]); } else{ $this->zero[$left] = $this->sizeY+$this->shiftY - (int)abs($this->m_minY[$left]/$this->unit2px[$left]); @@ -980,8 +1002,7 @@ class Chart extends Graph{ } } - function Draw() - { + function Draw(){ $start_time=getmicrotime(); set_image_header(); @@ -1012,8 +1033,7 @@ class Chart extends Graph{ $this->drawRectangle(); $this->drawHeader(); - if($this->num==0) - { + if($this->num==0){ // $this->noDataFound(); } @@ -1023,8 +1043,7 @@ class Chart extends Graph{ $maxX = $this->sizeX; // For each metric - for($item = 0; $item < $this->num; $item++) - { + for($item = 0; $item < $this->num; $item++){ $minY = $this->m_minY[$this->items[$item]["axisside"]]; $maxY = $this->m_maxY[$this->items[$item]["axisside"]]; @@ -1042,7 +1061,7 @@ class Chart extends Graph{ $calc_fnc = CALC_FNC_ALL; } - elseif($this->type == GRAPH_TYPE_STACKED){ + else if($this->type == GRAPH_TYPE_STACKED){ $drawtype = $this->items[$item]["drawtype"]; $max_color = $this->GetColor("ValueMax",GRAPH_STACKED_ALFA); @@ -1063,8 +1082,8 @@ class Chart extends Graph{ $calc_fnc = $this->items[$item]["calc_fnc"]; } // For each X - for($i = 1, $j = 0; $i < $maxX; $i++) // new point - { + for($i = 1, $j = 0; $i < $maxX; $i++){ // new point + if(($data->count[$i] == 0) && ($i != ($maxX-1))) continue; $diff = abs($data->clock[$i] - $data->clock[$j]); diff --git a/frontends/php/include/classes/cimg.inc.php b/frontends/php/include/classes/cimg.inc.php index 488c7b91..d26adf3f 100644 --- a/frontends/php/include/classes/cimg.inc.php +++ b/frontends/php/include/classes/cimg.inc.php @@ -19,11 +19,9 @@ **/ ?> tag_start= ""; @@ -43,47 +41,46 @@ $this->SetHeight($height); $this->SetClass($class); } - function SetSrc($value) - { - if(!is_string($value)) - { + + function SetSrc($value){ + if(!is_string($value)){ return $this->error("Incorrect value for SetSrc [$value]"); } - return $this->AddOption("src",$value); + return $this->AddOption("src",$value); } - function SetAltText($value=NULL) - { - if(!is_string($value)) - { + + function SetAltText($value=NULL){ + if(!is_string($value)){ return $this->error("Incorrect value for SetText [$value]"); } - return $this->AddOption("alt",$value); + return $this->AddOption("alt",$value); } - function SetMap($value=NULL) - { + + function SetMap($value=NULL){ if(is_null($value)) - $this->DeleteOption("usemup"); + $this->DeleteOption("usemap"); - if(!is_string($value)) - { + if(!is_string($value)){ return $this->error("Incorrect value for SetMap [$value]"); } $value = '#'.ltrim($value,'#'); - return $this->AddOption("usemap",$value); + return $this->AddOption("usemap",$value); } + function SetWidth($value=NULL){ if(is_null($value)) return $this->DelOption("width"); - elseif(is_numeric($value)||is_int($value)) + else if(is_numeric($value)||is_int($value)) return $this->AddOption("width",$value); else return $this->error("Incorrect value for SetWidth [$value]"); } + function SetHeight($value=NULL){ if(is_null($value)) return $this->DelOption("height"); - elseif(is_numeric($value)||is_int($value)) + else if(is_numeric($value)||is_int($value)) return $this->AddOption("height",$value); else return $this->error("Incorrect value for SetHeight [$value]"); diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index fb4c46f1..f46ffb93 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -571,12 +571,10 @@ else { } } - function zbx_dbconcat($params) - { + function zbx_dbconcat($params){ global $DB; - switch($DB['TYPE']) - { + switch($DB['TYPE']){ case "SQLITE3": return implode(' || ',$params); default: @@ -587,8 +585,7 @@ else { function zbx_sql_mod($x,$y){ global $DB; - switch($DB['TYPE']) - { + switch($DB['TYPE']){ case "SQLITE3": return ' ('.$x.' %% '.$y.')'; default: @@ -596,12 +593,10 @@ else { } } - function DBid2nodeid($id_name) - { + function DBid2nodeid($id_name){ global $DB; - switch($DB['TYPE']) - { + switch($DB['TYPE']){ case "MYSQL": $result = '('.$id_name.' div 100000000000000)'; break; diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 3be5b593..7a018757 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -2316,7 +2316,6 @@ function insert_graph_form(){ - $frmGraph = new CFormTable(S_GRAPH,null,'post'); $frmGraph->SetName('frm_graph'); $frmGraph->SetHelp("web.graphs.graph.php"); @@ -2346,8 +2345,7 @@ $graph3d = $row['show_3d']; $db_items = DBselect('SELECT * FROM graphs_items WHERE graphid='.$_REQUEST['graphid']); - while($item = DBfetch($db_items)) - { + while($item = DBfetch($db_items)){ array_push($items, array( 'itemid' => $item['itemid'], @@ -2360,7 +2358,8 @@ 'periods_cnt' => $item['periods_cnt'] )); } - } else { + } + else { $name = get_request('name' ,''); $graphtype = get_request("graphtype" ,GRAPH_TYPE_NORMAL); @@ -2376,8 +2375,8 @@ $yaxistype = get_request("yaxistype" ,GRAPH_YAXIS_TYPE_CALCULATED); $yaxismin = get_request("yaxismin" ,0.00); $yaxismax = get_request("yaxismax" ,100.00); - $showworkperiod = get_request("showworkperiod" ,1); - $showtriggers = get_request("showtriggers" ,1); + $showworkperiod = get_request("showworkperiod" ,0); + $showtriggers = get_request("showtriggers" ,0); $legend = get_request("legend" ,0); $graph3d = get_request("graph3d" ,0); } @@ -2410,8 +2409,14 @@ $group_gid = get_request('group_gid', array()); $frmGraph->AddRow(S_NAME,new CTextBox("name",$name,32)); - $frmGraph->AddRow(S_WIDTH,new CNumericBox("width",$width,5)); - $frmGraph->AddRow(S_HEIGHT,new CNumericBox("height",$height,5)); + + $g_width = new CNumericBox("width",$width,5); + $g_width->Addoption('onblur','javascript: submit();'); + $frmGraph->AddRow(S_WIDTH,$g_width); + + $g_height = new CNumericBox("height",$height,5); + $g_height->Addoption('onblur','javascript: submit();'); + $frmGraph->AddRow(S_HEIGHT,$g_height); $cmbGType = new CComboBox("graphtype",$graphtype,'graphs.submit(this)'); $cmbGType->AddItem(GRAPH_TYPE_NORMAL,S_NORMAL); @@ -4509,6 +4514,7 @@ # Insert form for Host Groups function insert_hostgroups_form(){ global $USER_DETAILS; + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $hosts = get_request("hosts",array()); $frm_title = S_HOST_GROUP; @@ -4521,10 +4527,10 @@ $name=$group["name"]; $db_hosts=DBselect('SELECT DISTINCT h.hostid,host '. ' FROM hosts h, hosts_groups hg '. - ' WHERE h.status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.')'. + ' WHERE h.status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.')'. ' AND h.hostid=hg.hostid '. ' AND hg.groupid='.$_REQUEST['groupid']. - ' order by host'); + ' ORDER BY host'); while($db_host=DBfetch($db_hosts)){ if(uint_in_array($db_host["hostid"],$hosts)) continue; array_push($hosts, $db_host["hostid"]); @@ -4548,8 +4554,8 @@ $db_hosts=DBselect('SELECT DISTINCT hostid,host '. ' FROM hosts '. ' WHERE status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.','.HOST_STATUS_TEMPLATE.')'. - ' AND hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).')'. - ' order by host'); + ' AND '.DBcondition('hostid',$available_hosts). + ' ORDER BY host'); while($db_host=DBfetch($db_hosts)){ $cmbHosts->AddItem( @@ -4578,7 +4584,8 @@ # Insert form for Proxies function insert_proxies_form(){ global $USER_DETAILS; - + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); + $hosts = array(); $frm_title = S_PROXY; @@ -4612,11 +4619,11 @@ $frmHostG->AddRow(S_PROXY_NAME,new CTextBox("host",$name,30)); $cmbHosts = new CTweenBox($frmHostG,'hosts',$hosts); - $db_hosts=DBselect('select hostid,proxy_hostid,host '. - ' from hosts '. - ' where status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.') '. - ' and hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).') '. - ' order by host'); + $db_hosts=DBselect('SELECT hostid,proxy_hostid,host '. + ' FROM hosts '. + ' WHERE status IN ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.') '. + ' AND '.DBcondition('hostid',$available_hosts). + ' ORDER BY host'); while($db_host=DBfetch($db_hosts)){ $cmbHosts->AddItem($db_host["hostid"], get_node_name_by_elid($db_host["hostid"]).$db_host["host"], @@ -4647,7 +4654,7 @@ $frmHostP = new CFormTable(S_HOST_PROFILE); $frmHostP->SetHelp("web.host_profile.php"); - $result=DBselect("SELECT * FROM hosts_profiles WHERE hostid=".$_REQUEST["hostid"]); + $result=DBselect('SELECT * FROM hosts_profiles WHERE hostid='.$_REQUEST["hostid"]); $row=DBfetch($result); if($row){ @@ -4751,7 +4758,7 @@ if(isset($_REQUEST["applicationid"])){ $result=DBselect("SELECT * FROM applications WHERE applicationid=".$_REQUEST["applicationid"]); $row=DBfetch($result); - $frm_title = "Application: \"".$row["name"]."\""; + $frm_title = 'Application: "'.$row['name'].'"'; } if(isset($_REQUEST["applicationid"]) && !isset($_REQUEST["form_refresh"])){ @@ -5254,8 +5261,7 @@ $frmCnct->Show(); } - function insert_command_result_form($scriptid,$hostid) - { + function insert_command_result_form($scriptid,$hostid){ $result = execute_script($scriptid,$hostid); $script_info = DBfetch(DBselect("SELECT name FROM scripts WHERE scriptid=$scriptid")); @@ -5266,6 +5272,7 @@ error($message); $message = ""; } + $frmResult->AddRow(S_RESULT,new CTextArea("message",$message,100,25,'yes')); $frmResult->AddItemToBottomRow(new CButton('close',S_CLOSE,'window.close();')); diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index 7159d424..84bfa6c6 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -165,14 +165,14 @@ */ function graph_accessible($graphid){ global $USER_DETAILS; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $sql = 'SELECT g.graphid '. ' FROM graphs g, graphs_items gi, items i '. ' WHERE g.graphid='.$graphid. ' AND g.graphid=gi.graphid '. ' AND i.itemid=gi.itemid '. - ' AND i.hostid NOT IN ('.$available_hosts.')'; + ' AND '.DBcondition('i.hostid',$available_hosts,true); if(DBfetch(DBselect($sql,1))){ return false; @@ -197,7 +197,7 @@ if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, null, $nodeid); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, $perm, PERM_RES_IDS_ARRAY, $nodeid); $denied_graphs = array(); $result = array(); @@ -207,7 +207,7 @@ ' WHERE g.graphid=gi.graphid '. (!empty($hostid)?' AND i.hostid='.$hostid:''). ' AND i.itemid=gi.itemid '. - ' AND i.hostid NOT IN ('.$available_hosts.')'; + ' AND '.DBcondition('i.hostid',$available_hosts, true); $db_graphs = DBselect($sql); while($graph = DBfetch($db_graphs)){ diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index 57a675ea..a57f0032 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -25,7 +25,7 @@ require_once "include/items.inc.php"; require_once "include/httptest.inc.php"; /* HOST GROUP functions */ - function add_host_to_group($hostid, $groupid){ + function add_host_to_group($hostid, $groupid){ if(!is_numeric($hostid) || !is_numeric($groupid)){ error("incorrect parameters for 'add_host_to_group' [hostid:".$hostid."][groupid:".$groupid."]"); return false; @@ -37,7 +37,7 @@ require_once "include/httptest.inc.php"; return $hostgroupid; } - function delete_host_from_group($hostid, $groupid){ + function delete_host_from_group($hostid, $groupid){ if(!is_numeric($hostid) || !is_numeric($groupid)){ error("incorrect parameters for 'add_host_to_group' [hostid:".$hostid."][groupid:".$groupid."]"); return false; @@ -57,7 +57,7 @@ require_once "include/httptest.inc.php"; * Comments: * */ - function db_save_group($name,$groupid=null){ + function db_save_group($name,$groupid=null){ if(!is_string($name)){ error("incorrect parameters for 'db_save_group'"); return false; @@ -85,8 +85,8 @@ require_once "include/httptest.inc.php"; return DBexecute("update groups set name=".zbx_dbstr($name)." where groupid=$groupid"); } - function add_group_to_host($hostid,$newgroup=""){ - if(empty($newgroup)) + function add_group_to_host($hostid,$newgroup=''){ + if(zbx_empty($newgroup)) return true; $groupid = db_save_group($newgroup); @@ -96,7 +96,7 @@ require_once "include/httptest.inc.php"; return add_host_to_group($hostid, $groupid); } - function update_host_groups_by_groupid($groupid,$hosts=array()){ + function update_host_groups_by_groupid($groupid,$hosts=array()){ DBexecute("delete from hosts_groups where groupid=$groupid"); foreach($hosts as $hostid) @@ -105,7 +105,7 @@ require_once "include/httptest.inc.php"; } } - function update_host_groups($hostid,$groups=array()){ + function update_host_groups($hostid,$groups=array()){ DBexecute("delete from hosts_groups where hostid=$hostid"); foreach($groups as $groupid) @@ -114,7 +114,7 @@ require_once "include/httptest.inc.php"; } } - function add_host_group($name,$hosts=array()){ + function add_host_group($name,$hosts=array()){ $groupid = db_save_group($name); if(!$groupid) return $groupid; @@ -124,7 +124,7 @@ require_once "include/httptest.inc.php"; return $groupid; } - function update_host_group($groupid,$name,$hosts){ + function update_host_group($groupid,$name,$hosts){ $result = db_save_group($name,$groupid); if(!$result) return $result; @@ -148,7 +148,7 @@ require_once "include/httptest.inc.php"; * NOTE: templates = array(id => name, id2 => name2, ...) * */ - function check_circle_host_link($hostid, $templates){ + function check_circle_host_link($hostid, $templates){ if(count($templates) == 0) return false; if(isset($templates[$hostid])) return true; foreach($templates as $id => $name) @@ -312,7 +312,7 @@ require_once "include/httptest.inc.php"; * Comments: !!! Don't forget sync code with C !!! * */ - function unlink_template($hostid, $templateid, $unlink_mode = true){ + function unlink_template($hostid, $templateid, $unlink_mode = true){ if(!is_numeric($templateid)) fatal_error('Not supported type for [templateid] in [unlink_template] - ['.$templateid.']'); @@ -333,7 +333,7 @@ require_once "include/httptest.inc.php"; * Comments: !!! Don't forget sync code with C !!! * */ - function delete_template_elements($hostid, $templateid = null, $unlink_mode = false){ + function delete_template_elements($hostid, $templateid = null, $unlink_mode = false){ delete_template_graphs($hostid, $templateid, $unlink_mode); delete_template_triggers($hostid, $templateid, $unlink_mode); delete_template_items($hostid, $templateid, $unlink_mode); @@ -353,7 +353,7 @@ require_once "include/httptest.inc.php"; * Comments: !!! Don't forget sync code with C !!! * */ - function copy_template_elements($hostid, $templateid = null, $copy_mode = false){ + function copy_template_elements($hostid, $templateid = null, $copy_mode = false){ copy_template_applications($hostid, $templateid, $copy_mode); copy_template_items($hostid, $templateid, $copy_mode); copy_template_triggers($hostid, $templateid, $copy_mode); @@ -372,12 +372,12 @@ require_once "include/httptest.inc.php"; * Comments: !!! Don't forget sync code with C !!! * */ - function sync_host_with_templates($hostid, $templateid = null){ + function sync_host_with_templates($hostid, $templateid = null){ delete_template_elements($hostid, $templateid); copy_template_elements($hostid, $templateid); } - function delete_groups_by_hostid($hostid){ + function delete_groups_by_hostid($hostid){ $sql="select groupid from hosts_groups where hostid=$hostid"; $result=DBselect($sql); while($row=DBfetch($result)) @@ -406,7 +406,7 @@ require_once "include/httptest.inc.php"; * Comments: !!! Don't forget sync code with C !!! * */ - function delete_host($hostid, $unlink_mode = false){ + function delete_host($hostid, $unlink_mode = false){ $ret = false; // unlink child hosts @@ -455,7 +455,7 @@ require_once "include/httptest.inc.php"; return DBexecute("delete from hosts where hostid=$hostid"); } - function delete_host_group($groupid){ + function delete_host_group($groupid){ if(!delete_sysmaps_elements_with_groupid($groupid)) return false; @@ -619,7 +619,7 @@ require_once "include/httptest.inc.php"; * Comments: * */ - function get_templates_by_hostid($hostid){ + function get_templates_by_hostid($hostid){ $result = array(); $db_templates = DBselect('SELECT DISTINCT h.hostid,h.host '. ' FROM hosts_templates ht '. @@ -646,7 +646,7 @@ require_once "include/httptest.inc.php"; * Comments: * */ - function validate_group_with_templates($perm, $options = array(),$group_var=null,$host_var=null){ + function validate_group_with_templates($perm, $options = array(),$group_var=null,$host_var=null){ if(is_null($group_var)) $group_var = "web.latest.groupid"; if(is_null($host_var)) $host_var = "web.latest.hostid"; @@ -723,7 +723,7 @@ require_once "include/httptest.inc.php"; $with_node = ''; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm,null,get_current_nodeid(!$only_current_node)); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm,PERM_RES_IDS_ARRAY,get_current_nodeid(!$only_current_node)); if(is_null($a_groupid)){ $groupid = 0; @@ -738,7 +738,7 @@ require_once "include/httptest.inc.php"; ' FROM groups g, hosts_groups hg, hosts h'.$item_table. ' WHERE hg.groupid=g.groupid '. ' AND h.hostid=hg.hostid '. - ' AND h.hostid IN ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). $with_host_status. $with_items. $with_node. @@ -755,7 +755,7 @@ require_once "include/httptest.inc.php"; ' FROM groups g, hosts_groups hg, hosts h'.$item_table. ' WHERE hg.groupid=g.groupid '. ' AND h.hostid=hg.hostid '. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND g.groupid='.$groupid.$with_host_status.$with_items.$with_node))) { $groupid = 0; @@ -790,7 +790,7 @@ require_once "include/httptest.inc.php"; if($db_host = DBfetch(DBselect('SELECT DISTINCT h.hostid,h.host FROM hosts h '. $item_table. $group_table. - ' WHERE h.hostid IN ('.$available_hosts.') '. + ' WHERE '.DBcondition('h.hostid',$available_hosts). $with_host_status. $with_items. $witth_group. @@ -806,7 +806,7 @@ require_once "include/httptest.inc.php"; if(!DBfetch(DBselect('SELECT DISTINCT h.hostid '. ' FROM hosts h '.$item_table. ' WHERE h.hostid='.$hostid. - ' AND h.hostid IN ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). $with_host_status. $with_items. $with_node))) @@ -1217,14 +1217,15 @@ require_once "include/httptest.inc.php"; $result = true; $db_cnt = DBfetch(DBselect('select key_,type,count(*) as cnt from items '. - ' where hostid in ('.implode(',',$templateid_list).') '. + ' WHERE '.DBcondition('hostid',$templateid_list). ' group by key_,type order by cnt desc' )); $result &= $db_cnt['cnt'] > 1 ? false : true; - $db_cnt = DBfetch(DBselect('select name,count(*) as cnt from applications '. - ' where hostid in ('.implode(',',$templateid_list).') '. + $db_cnt = DBfetch(DBselect('SELECT name,count(*) as cnt '. + ' FROM applications '. + ' WHERE '.DBcondition('hostid',$templateid_list). ' group by name order by cnt desc' )); @@ -1282,4 +1283,63 @@ require_once "include/httptest.inc.php"; return $result; } + + + function host_js_menu($hostid, $link_text = S_SELECT){ + $add_to = array(); + $delete_from = array(); + + $popup_menu_actions = array( + array(S_SHOW, null, null, array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))), + array(S_ITEMS, 'items.php?hostid='.$hostid, array('tw'=>'')), + array(S_TRIGGERS, 'triggers.php?hostid='.$hostid, array('tw'=>'')), + array(S_GRAPHS, 'graphs.php?hostid='.$hostid, array('tw'=>'')), + ); + + $db_groups = DBselect('SELECT g.groupid, g.name '. + ' FROM groups g '. + ' LEFT JOIN hosts_groups hg on g.groupid=hg.groupid and hg.hostid='.$hostid. + ' WHERE hostid is NULL '. + ' ORDER BY g.name,g.groupid'); + while($group_data = DBfetch($db_groups)){ + $add_to[] = array($group_data['name'], '?'. + url_param($group_data['groupid'], false, 'add_to_group'). + url_param($hostid, false, 'hostid') + ); + } + + $db_groups = DBselect('SELECT g.groupid, g.name '. + ' FROM groups g, hosts_groups hg '. + ' WHERE g.groupid=hg.groupid '. + ' AND hg.hostid='.$hostid. + ' ORDER BY g.name,g.groupid'); + + while($group_data = DBfetch($db_groups)){ + $delete_from[] = array($group_data['name'], '?'. + url_param($group_data['groupid'], false, 'delete_from_group'). + url_param($hostid, false, 'hostid') + ); + } + + if(count($add_to) > 0 || count($delete_from) > 0){ + $popup_menu_actions[] = array(S_GROUPS, null, null, + array('outer'=> array('pum_oheader'), 'inner'=>array('pum_iheader'))); + } + + if(count($add_to) > 0){ + $popup_menu_actions[] = array_merge(array(S_ADD_TO_GROUP, null, null, + array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $add_to); + } + + if(count($delete_from) > 0){ + $popup_menu_actions[] = array_merge(array(S_DELETE_FROM_GROUP, null, null, + array('outer' => 'pum_o_submenu', 'inner'=>array('pum_i_submenu'))), $delete_from); + } + + $mnuActions = new CPUMenu($popup_menu_actions); + + $show = new CLink($link_text, '#', 'action', $mnuActions->GetOnActionJS()); + + return $show; + } ?> diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 5552f4a5..8a022791 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -834,17 +834,19 @@ */ function get_items_data_overview($groupid,$view_style=null){ global $USER_DETAILS; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if(is_null($view_style)) $view_style = get_profile('web.overview.view.style',STYLE_TOP); $table = new CTableInfo(S_NO_ITEMS_DEFINED); if($groupid > 0){ - $group_where = ",hosts_groups hg where hg.groupid=$groupid and hg.hostid=h.hostid and"; + $group_where = ',hosts_groups hg '. + ' WHERE hg.groupid='.$groupid. + ' AND hg.hostid=h.hostid AND '; } else { - $group_where = " where"; + $group_where = ' WHERE '; } COpt::profiling_start('prepare data'); @@ -853,7 +855,8 @@ COpt::profiling_start('prepare data'); ' from hosts h,items i '. ' left join functions f on f.itemid=i.itemid '. ' left join triggers t on t.triggerid=f.triggerid '. - $group_where.' h.hostid in ('.$available_hosts.') '. + $group_where. + DBcondition('h.hostid',$available_hosts). ' and h.status='.HOST_STATUS_MONITORED. ' and h.hostid=i.hostid '. ' and i.status='.ITEM_STATUS_ACTIVE. diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 39a07f5f..5171ae56 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -1327,6 +1327,7 @@ 'S_TRIGGER_ADDED'=> 'Trigger added', 'S_CANNOT_ADD_TRIGGER'=> 'Cannot add trigger', 'S_SEVERITY'=> 'Severity', + 'S_MIN_SEVERITY'=> 'Min severity', 'S_EXPRESSION'=> 'Expression', 'S_DISABLED'=> 'Disabled', 'S_ENABLED'=> 'Enabled', diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 636d28fd..d952a2bb 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -209,15 +209,15 @@ COpt::profiling_start("page"); 'sub_pages'=>array('popup_trexpr.php') ), array('url'=>'actionconf.php' ,'label'=>S_ACTIONS), - array('url'=>'sysmaps.php' ,'label'=>S_MAPS, - 'sub_pages'=>array('sysmap.php','popup_link_tr.php') - ), array('url'=>'graphs.php' ,'label'=>S_GRAPHS, 'sub_pages'=>array('popup_gitem.php') ), array('url'=>'screenconf.php' ,'label'=>S_SCREENS, 'sub_pages'=>array('screenedit.php') ), + array('url'=>'sysmaps.php' ,'label'=>S_MAPS, + 'sub_pages'=>array('sysmap.php','popup_link_tr.php') + ), array('url'=>'services.php' ,'label'=>S_IT_SERVICES, 'sub_pages'=>array('services_form.php') ), diff --git a/frontends/php/include/reports.inc.php b/frontends/php/include/reports.inc.php index 0cdb6422..3f04d9fc 100644 --- a/frontends/php/include/reports.inc.php +++ b/frontends/php/include/reports.inc.php @@ -37,7 +37,7 @@ function show_report2_header($config,$available_hosts){ $status_filter=($config==1)?' AND h.status='.HOST_STATUS_TEMPLATE:' AND h.status='.HOST_STATUS_MONITORED; $sql = 'SELECT DISTINCT g.groupid,g.name '. ' FROM groups g,hosts_groups hg,hosts h'. - ' WHERE h.hostid in ('.$available_hosts.') '. + ' WHERE '.DBcondition('h.hostid',$available_hosts). ' AND g.groupid=hg.groupid '. ' AND h.hostid=hg.hostid'. $status_filter. @@ -71,7 +71,7 @@ function show_report2_header($config,$available_hosts){ ' WHERE h.hostid=i.hostid '. ' AND hg.groupid='.$_REQUEST['groupid']. ' AND hg.hostid=h.hostid'. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). $sql_cond. ' GROUP BY h.hostid,h.host '. ' ORDER BY h.host'; @@ -80,7 +80,7 @@ function show_report2_header($config,$available_hosts){ $sql='SELECT h.hostid,h.host '. ' FROM hosts h,items i '. ' WHERE h.hostid=i.hostid '. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). $sql_cond. ' GROUP BY h.hostid,h.host '. ' ORDER BY h.host'; @@ -124,7 +124,7 @@ function show_report2_header($config,$available_hosts){ ' AND h.hostid=i.hostid '. ' AND hg.hostid=h.hostid'. ' AND g.groupid=hg.groupid '. - ' AND h.hostid in ('.$available_hosts.')'. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND t.status='.TRIGGER_STATUS_ENABLED. ' AND t.triggerid=f.triggerid '. ' AND '.DBin_node('t.triggerid'). @@ -140,7 +140,7 @@ function show_report2_header($config,$available_hosts){ ); } - $sql_cond=($_REQUEST['hostid'] > 0)?' AND h.hostid='.$_REQUEST['hostid']:' AND h.hostid in ('.$available_hosts.')'; + $sql_cond=($_REQUEST['hostid'] > 0)?' AND h.hostid='.$_REQUEST['hostid']:' AND '.DBcondition('h.hostid',$available_hosts); $sql = 'SELECT DISTINCT t.triggerid,t.description '. ' FROM triggers t,hosts h,items i,functions f '. ' WHERE f.itemid=i.itemid '. diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php index e6c0acd7..292af0d2 100644 --- a/frontends/php/include/screens.inc.php +++ b/frontends/php/include/screens.inc.php @@ -29,7 +29,7 @@ if(DBfetch(DBselect('SELECT screenid FROM screens WHERE screenid='.$screenid.' AND '.DBin_node('screenid', get_current_nodeid($perm))))){ $result = true; - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $db_result = DBselect('SELECT * FROM screens_items WHERE screenid='.$screenid); while(($ac_data = DBfetch($db_result)) && $result){ @@ -54,7 +54,7 @@ if(DBfetch(DBselect('SELECT itemid '. ' FROM items '. ' WHERE itemid IN ('.implode(',',$itemid).') '. - ' AND hostid NOT IN ('.$available_hosts.')'))) + ' AND '.DBcondition('hostid',$available_hosts,true)))) { $result = false; } @@ -394,7 +394,8 @@ function get_screen_item_form(){ global $USER_DETAILS; - + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); + $form = new CFormTable(S_SCREEN_CELL_CONFIGURATION,'screenedit.php#form'); $form->SetHelp('web.screenedit.cell.php'); @@ -505,7 +506,7 @@ ' WHERE h.hostid=i.hostid '. ' AND h.status='.HOST_STATUS_MONITORED. ' AND i.status='.ITEM_STATUS_ACTIVE. - ' AND i.hostid IN ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).')'. + ' AND '.DBcondition('i.hostid',$available_hosts). ' AND i.itemid='.$resourceid); while($row=DBfetch($result)){ @@ -566,7 +567,7 @@ ' WHERE h.hostid=i.hostid '. ' AND h.status='.HOST_STATUS_MONITORED. ' AND i.status='.ITEM_STATUS_ACTIVE. - ' AND i.hostid IN ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).')'. + ' AND '.DBcondition('i.hostid',$available_hosts). ' AND i.itemid='.$resourceid); while($row=DBfetch($result)){ diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 575278cd..33aba8f2 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -1655,32 +1655,25 @@ while($trigger = DBfetch($triggers)){ if($trigger["templateid"]==0) continue; - if($templateid != null) - { - if( !is_array($templateid)) - $templateid = array($templateid); - - $db_tmp_hosts = get_hosts_by_triggerid($trigger["templateid"]); + if($templateid != null){ + if( !is_array($templateid)) $templateid = array($templateid); + + $db_tmp_hosts = get_hosts_by_triggerid($trigger["templateid"]); $tmp_host = DBfetch($db_tmp_hosts); - if( !uint_in_array($tmp_host["hostid"], $templateid) ) - continue; - } - - if($unlink_mode) - { - if(DBexecute("update triggers set templateid=0 where triggerid=".$trigger["triggerid"])) - { - info("Trigger '".$trigger["description"]."' unlinked"); - } - } - else - { + if(!uint_in_array($tmp_host["hostid"], $templateid)) continue; + } + + if($unlink_mode){ + if(DBexecute("update triggers set templateid=0 where triggerid=".$trigger["triggerid"])){ + info("Trigger '".$trigger["description"]."' unlinked"); + } + } + else{ delete_trigger($trigger["triggerid"]); } } - - return TRUE; + return TRUE; } /* @@ -1765,7 +1758,9 @@ */ function get_triggers_overview($groupid,$view_style=null){ global $USER_DETAILS; - + + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); + if(is_null($view_style)) $view_style = get_profile('web.overview.view.style',STYLE_TOP); $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); @@ -1776,13 +1771,14 @@ $group_where = ' where'; } + $result=DBselect('SELECT DISTINCT t.triggerid,t.description,t.expression,t.value,t.priority,t.lastchange,h.hostid,h.host'. ' FROM hosts h,items i,triggers t, functions f '. $group_where.' h.status='.HOST_STATUS_MONITORED. ' AND h.hostid=i.hostid '. ' AND i.itemid=f.itemid '. ' AND f.triggerid=t.triggerid'. - ' AND h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND t.status='.TRIGGER_STATUS_ENABLED. ' AND i.status='.ITEM_STATUS_ACTIVE. ' ORDER BY t.description'); diff --git a/frontends/php/items.php b/frontends/php/items.php index ae6f79a9..799dca2c 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -967,7 +967,6 @@ include_once "include/page_header.php"; ($_REQUEST["form"]=="mass_update" && isset($_REQUEST['group_itemid'])))) { // FORM - echo SBR; insert_item_form(); } ?> diff --git a/frontends/php/latest.php b/frontends/php/latest.php index ac44a107..deaa49ed 100644 --- a/frontends/php/latest.php +++ b/frontends/php/latest.php @@ -45,9 +45,27 @@ include_once "include/page_header.php"; "show"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), + +//ajax + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), + 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), ); check_fields($fields); + +/* AJAX */ + if(isset($_REQUEST['favobj'])){ + if('hat' == $_REQUEST['favobj']){ + update_profile('web.latest.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } + } + + if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ + exit(); + } +//-------- + validate_sort_and_sortorder('i.description',ZBX_SORT_UP); $options = array('allow_all_hosts','monitored_hosts','with_monitored_items'); @@ -103,6 +121,10 @@ include_once "include/page_header.php"; update_profile('web.latest.applications',$_REQUEST['applications'],PROFILE_TYPE_ARRAY_ID); ?> SetMethod('get'); @@ -115,7 +137,7 @@ include_once "include/page_header.php"; $cmbHosts->AddItem(0,S_ALL_SMALL); $available_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY); $result=DBselect('SELECT DISTINCT g.groupid,g.name '. ' FROM groups g, hosts_groups hg, hosts h, items i '. @@ -142,7 +164,7 @@ include_once "include/page_header.php"; ' AND hg.groupid='.$_REQUEST['groupid']. ' AND hg.hostid=h.hostid'. ' AND i.status='.ITEM_STATUS_ACTIVE. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; } else{ @@ -151,7 +173,7 @@ include_once "include/page_header.php"; ' WHERE h.status='.HOST_STATUS_MONITORED. ' AND i.status='.ITEM_STATUS_ACTIVE. ' AND h.hostid=i.hostid'. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; } @@ -165,34 +187,24 @@ include_once "include/page_header.php"; $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts)); -// Header - $text = array(S_LATEST_DATA_BIG); - $url = '?fullscreen='.($_REQUEST['fullscreen']?'0':'1').url_param('select'); $fs_icon = new CDiv(SPACE,'fullscreen'); $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,SPACE,$text)); - - $text = $icon_tab; - - show_table_header($text,$r_form); -//------------- + $l_form = new CForm(); + $l_form->SetMethod('get'); + $l_form->AddVar("hostid",$_REQUEST["hostid"]); + $l_form->AddVar("groupid",$_REQUEST["groupid"]); - $r_form = new CForm(); - $r_form->SetMethod('get'); - - $r_form->AddVar("hostid",$_REQUEST["hostid"]); - $r_form->AddVar("groupid",$_REQUEST["groupid"]); + $l_form->AddItem(array(S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE, new CTextBox("select",$_REQUEST["select"],20))); + $l_form->AddItem(array(SPACE, new CButton("show",S_SHOW))); - $r_form->AddItem(array(S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE, new CTextBox("select",$_REQUEST["select"],20))); - $r_form->AddItem(array(SPACE, new CButton("show",S_SHOW))); + $p_elements[] = get_table_header($l_form,$r_form); +//------------- - show_table_header(NULL, $r_form); ?> ShowStart(); + +// $table->ShowStart(); $compare_host = $_REQUEST['hostid']?' AND h.hostid='.$_REQUEST['hostid']:''; $compare_host.= $_REQUEST['groupid']?' AND hg.hostid=h.hostid AND hg.groupid ='.$_REQUEST['groupid']:''; @@ -226,7 +239,7 @@ include_once "include/page_header.php"; ' FROM applications a, hosts h'.($_REQUEST['groupid']?', hosts_groups hg ':''). ' WHERE a.hostid=h.hostid'. $compare_host. - ' AND h.hostid IN ('.$available_hosts.')'. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND h.status='.HOST_STATUS_MONITORED. order_by('h.host,h.hostid','a.name,a.applicationid')); @@ -310,13 +323,13 @@ include_once "include/page_header.php"; $col = new CCol(array($link,SPACE,bold($db_app["name"]),SPACE.'('.$item_cnt.SPACE.S_ITEMS.')')); $col->SetColSpan(5); - $table->ShowRow(array( + $table->AddRow(array( get_node_name_by_elid($db_app['hostid']), $_REQUEST["hostid"] > 0 ? NULL : $db_app["host"], $col )); - foreach($app_rows as $row) $table->ShowRow($row); + foreach($app_rows as $row) $table->AddRow($row); } } @@ -329,7 +342,7 @@ include_once "include/page_header.php"; ' AND h.hostid=i.hostid '. ' AND h.status='.HOST_STATUS_MONITORED. ' AND i.status='.ITEM_STATUS_ACTIVE. - ' AND h.hostid in ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; $db_appitems = DBselect($sql); @@ -421,17 +434,27 @@ include_once "include/page_header.php"; $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS),SPACE.'('.$item_cnt.SPACE.S_ITEMS.')')); $col->SetColSpan(5); - $table->ShowRow(array( + $table->AddRow(array( get_node_name_by_elid($db_appitem['hostid']), $_REQUEST["hostid"] > 0 ? NULL : $db_appitem["host"], $col )); - foreach($app_rows as $row) $table->ShowRow($row); + foreach($app_rows as $row) $table->AddRow($row); } } - $table->ShowEnd(); + $p_elements[] = $table; + + $latest_hat = create_hat( + S_LATEST_DATA_BIG, + $p_elements, + array($fs_icon), + 'hat_latest', + get_profile('web.latest.hats.hat_latest.state',1) + ); + + $latest_hat->Show(); ?> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), 'favid'=> 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})'), 'action'=> array(T_ZBX_STR, O_OPT, P_ACT, IN("'add','remove'"),NULL) ); @@ -53,7 +54,12 @@ include_once "include/page_header.php"; ?> AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); - $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,$icon,SPACE,$text)); - - $text = $icon_tab; - + $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); } $form = new CForm(); @@ -162,7 +163,7 @@ include_once "include/page_header.php"; $form->AddItem($cmbMaps); } - show_table_header($text,$form); + $p_elements[] = get_table_header($text,$form); ?> SetMap($action_map->GetName()); $table->AddRow($imgMap); } - $table->Show(); + + $p_elements[] = $table; + + $latest_hat = create_hat( + S_NETWORK_MAPS_BIG, + $p_elements, + array($icon,$fs_icon), + 'hat_maps', + get_profile('web.maps.hats.hat_maps.state',1) + ); + + $latest_hat->Show(); ?> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL), 'view_style'=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), 'type'=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), - 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL) + 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL), + +//ajax + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), + 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), ); check_fields($fields); +/* AJAX */ + if(isset($_REQUEST['favobj'])){ + if('hat' == $_REQUEST['favobj']){ + update_profile('web.overview.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } + } + + if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ + exit(); + } +//-------- + $_REQUEST['view_style'] = get_request('view_style',get_profile('web.overview.view.style',STYLE_TOP)); update_profile('web.overview.view.style',$_REQUEST['view_style'],PROFILE_TYPE_INT); @@ -96,14 +114,14 @@ if(isset($_REQUEST["select"])&&($_REQUEST["select"]!="")){ ); } - $form->AddItem(array(S_GROUP.SPACE,$cmbGroup)); + $form->AddItem(array(S_GROUP.SPACE,$cmbGroup,SPACE)); $cmbType = new CComboBox("type",$_REQUEST["type"],"submit()"); $cmbType->AddItem(SHOW_TRIGGERS,S_TRIGGERS); $cmbType->AddItem(SHOW_DATA, S_DATA); $form->AddItem(array(S_TYPE.SPACE,$cmbType)); - $help = new CHelp('web.view.php','left'); + $help = new CHelp('web.view.php','right'); $help_table = new CTableInfo(); $help_table->AddOption('style', 'width: 200px'); @@ -132,6 +150,7 @@ if(isset($_REQUEST["select"])&&($_REQUEST["select"]!="")){ } $help->SetHint($help_table); + // Header $text = array(S_OVERVIEW_BIG); @@ -141,27 +160,19 @@ if(isset($_REQUEST["select"])&&($_REQUEST["select"]!="")){ $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,$help,$text)); - - $text = $icon_tab; - - show_table_header($text,$form); - unset($help, $help_table, $form, $col); - -//------------- - - - $form = new CForm(); - $form->SetMethod('get'); + $form_l = new CForm(); + $form_l->SetMethod('get'); $cmbStyle = new CComboBox("view_style",$_REQUEST["view_style"],"submit()"); $cmbStyle->AddItem(STYLE_TOP,S_TOP); $cmbStyle->AddItem(STYLE_LEFT,S_LEFT); - $form->Additem(array(S_HOSTS_LOCATION.SPACE,$cmbStyle)); + $form_l->Additem(array(S_HOSTS_LOCATION.SPACE,$cmbStyle)); + + $p_elements[] = get_table_header($form_l,$form); + +//------------- - show_table_header($form, NULL); ?> Show(); - unset($table); } else if($_REQUEST["type"]==SHOW_TRIGGERS){ COpt::profiling_start("get_triggers_overview"); $table = get_triggers_overview($_REQUEST["groupid"],$_REQUEST['view_style']); COpt::profiling_stop("get_triggers_overview"); - $table->Show(); - unset($table); } + $p_elements[] = $table; + + $overview_hat = create_hat( + $text, + $p_elements, + array($help,$fs_icon), + 'hat_overview', + get_profile('web.overview.hats.hat_overview.state',1) + ); + + $overview_hat->Show(); +// $table->Show(); +// unset($table); + include_once "include/page_footer.php"; ?> diff --git a/frontends/php/popup.php b/frontends/php/popup.php index 74d0d161..d74aa148 100644 --- a/frontends/php/popup.php +++ b/frontends/php/popup.php @@ -29,8 +29,7 @@ $srctbl = get_request("srctbl", ''); // source table name - switch($srctbl) - { + switch($srctbl){ case 'host_templates': case 'templates': $page["title"] = "S_TEMPLATES_BIG"; @@ -127,8 +126,7 @@ include_once "include/page_header.php"; - if(isset($error)) - { + if(isset($error)){ invalid_url(); } @@ -520,8 +518,7 @@ include_once "include/page_header.php"; $form->AddItem($table); $form->Show(); } - else if(str_in_array($srctbl,array("host_group"))) - { + else if(str_in_array($srctbl,array("host_group"))){ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null,$nodeid); $table = new CTableInfo(S_NO_GROUPS_DEFINED); @@ -531,8 +528,7 @@ include_once "include/page_header.php"; ' where '.DBin_node('groupid', $nodeid). " AND groupid in (".$available_groups.") ". " order by name"); - while($row = DBfetch($db_groups)) - { + while($row = DBfetch($db_groups)){ $name = new CLink($row["name"],"#","action"); if(isset($_REQUEST['reference']) && ($_REQUEST['reference'] =='dashboard')){ $action = get_window_opener($dstfrm, $dstfld1, $srcfld2). @@ -550,8 +546,7 @@ include_once "include/page_header.php"; } $table->Show(); } - else if(str_in_array($srctbl,array('host_templates'))) - { + else if(str_in_array($srctbl,array('host_templates'))){ $table = new CTableInfo(S_NO_TEMPLATES_DEFINED); $table->SetHeader(array(S_NAME)); @@ -567,8 +562,7 @@ include_once "include/page_header.php"; ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host,h.hostid'; $db_hosts = DBselect($sql); - while($row = DBfetch($db_hosts)) - { + while($row = DBfetch($db_hosts)){ $name = new CLink($row['host'],'#','action'); if(isset($_REQUEST['reference']) && ($_REQUEST['reference'] =='dashboard')){ $action = get_window_opener($dstfrm, $dstfld1, $srcfld2). @@ -586,14 +580,12 @@ include_once "include/page_header.php"; } $table->Show(); } - else if($srctbl == "usrgrp") - { + else if($srctbl == "usrgrp"){ $table = new CTableInfo(S_NO_GROUPS_DEFINED); $table->SetHeader(array(S_NAME)); $result = DBselect('select * from usrgrp where '.DBin_node('usrgrpid').' order by name'); - while($row = DBfetch($result)) - { + while($row = DBfetch($result)){ $name = new CLink( get_node_name_by_elid($row['usrgrpid']).$row['name'], '#', @@ -616,14 +608,12 @@ include_once "include/page_header.php"; } $table->Show(); } - else if($srctbl == "users") - { + else if($srctbl == "users"){ $table = new CTableInfo(S_NO_USERS_DEFINED); $table->SetHeader(array(S_NAME)); $result = DBselect('select * from users where '.DBin_node('userid').' order by name'); - while($row = DBfetch($result)) - { + while($row = DBfetch($result)){ $name = new CLink( get_node_name_by_elid($row['userid']).$row['alias'], '#', @@ -645,15 +635,13 @@ include_once "include/page_header.php"; } $table->Show(); } - else if($srctbl == "help_items") - { + else if($srctbl == "help_items"){ $table = new CTableInfo(S_NO_ITEMS); $table->SetHeader(array(S_KEY,S_DESCRIPTION)); $result = DBselect("select * from help_items where itemtype=".$itemtype." order by key_"); - while($row = DBfetch($result)) - { + while($row = DBfetch($result)){ $name = new CLink($row["key_"],"#","action"); if(isset($_REQUEST['reference']) && ($_REQUEST['reference'] =='dashboard')){ $action = get_window_opener($dstfrm, $dstfld1, $srcfld2). @@ -754,8 +742,7 @@ include_once "include/page_header.php"; } $table->Show(); } - else if($srctbl == "logitems") - { + else if($srctbl == "logitems"){ insert_js_function('add_item_variable'); $table = new CTableInfo(S_NO_ITEMS_DEFINED); diff --git a/frontends/php/popup_trexpr.php b/frontends/php/popup_trexpr.php index 27e9e69f..c7997b90 100644 --- a/frontends/php/popup_trexpr.php +++ b/frontends/php/popup_trexpr.php @@ -183,12 +183,12 @@ include_once "include/page_header.php"; $dstfld1 = get_request("dstfld1", ''); // destination field $itemid = get_request("itemid", 0); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if($item_data = DBfetch(DBselect('SELECT DISTINCT h.host,i.* '. ' FROM hosts h,items i '. ' WHERE h.hostid=i.hostid '. - ' AND h.hostid IN ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND i.itemid='.$itemid))) { $description = $item_data['host'].':'.item_description($item_data["description"],$item_data["key_"]); @@ -199,8 +199,7 @@ include_once "include/page_header.php"; } $expr_type = get_request("expr_type", 'last[=]'); - if(eregi('^([a-z]{1,})\[(['.implode('',array_keys($operators)).'])\]$',$expr_type,$expr_res)) - { + if(eregi('^([a-z]{1,})\[(['.implode('',array_keys($operators)).'])\]$',$expr_type,$expr_res)){ $function = $expr_res[1]; $operator = $expr_res[2]; diff --git a/frontends/php/queue.php b/frontends/php/queue.php index 8ee50f35..0684a2fc 100644 --- a/frontends/php/queue.php +++ b/frontends/php/queue.php @@ -39,7 +39,7 @@ include_once "include/page_header.php"; check_fields($fields); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); ?> setHeader(array(S_ITEMS,S_5_SECONDS,S_10_SECONDS,S_30_SECONDS,S_1_MINUTE,S_5_MINUTES,S_MORE_THAN_5_MINUTES)); - foreach($item_types as $type) - { + foreach($item_types as $type){ $elements=array( item_type2str($type), new CCol($sec_5[$type],($sec_5[$type])?"unknown_trigger":"normal"), @@ -127,16 +124,14 @@ include_once "include/page_header.php"; $table->addRow($elements); } } - else - { + else{ $table->SetHeader(array( S_NEXT_CHECK, is_show_subnodes() ? S_NODE : null, S_HOST, S_DESCRIPTION )); - while($row=DBfetch($result)) - { + while($row=DBfetch($result)){ $table->AddRow(array( date("m.d.Y H:i:s", $row["nextcheck"]), @@ -148,14 +143,11 @@ include_once "include/page_header.php"; } $table->Show(); -?> -GetNumRows()); } ?> - setHeader(array(is_show_subnodes() ? S_NODE : null,(($_REQUEST['hostid'] == 0) || (1 == $config))?S_HOST:NULL, S_NAME,S_TRUE,S_FALSE,S_UNKNOWN,S_GRAPH)); while($row=DBfetch($result)){ - if(!check_right_on_trigger_by_triggerid(null, $row['triggerid'], $accessible_hosts)) continue; + if(!check_right_on_trigger_by_triggerid(null, $row['triggerid'])) continue; $availability = calculate_availability($row['triggerid'],$_REQUEST['filter_timesince'],$_REQUEST['filter_timetill']); diff --git a/frontends/php/report5.php b/frontends/php/report5.php index e21a1c81..f2c011ca 100644 --- a/frontends/php/report5.php +++ b/frontends/php/report5.php @@ -71,7 +71,7 @@ include_once "include/page_header.php"; default: $time_dif=24*3600; break; } - $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $sql = 'SELECT h.host, t.triggerid, t.description, t.expression, t.priority, count(distinct e.eventid) as cnt_event '. ' FROM hosts h, triggers t, functions f, items i, events e'. ' WHERE h.hostid = i.hostid '. @@ -80,7 +80,7 @@ include_once "include/page_header.php"; ' and t.triggerid=e.objectid '. ' and e.object='.EVENT_OBJECT_TRIGGER. ' and e.clock>'.(time()-$time_dif). - ' and h.hostid in ('.$accessible_hosts.') '. + ' and '.DBcondition('h.hostid',$available_hosts). ' and '.DBin_node('t.triggerid'). ' GROUP BY h.host,t.triggerid,t.description,t.expression,t.priority '. ' ORDER BY cnt_event desc, h.host, t.description, t.triggerid'; @@ -88,7 +88,7 @@ include_once "include/page_header.php"; $result=DBselect($sql, 100); while($row=DBfetch($result)){ - if(!check_right_on_trigger_by_triggerid(null, $row['triggerid'], $accessible_hosts)) + if(!check_right_on_trigger_by_triggerid(null, $row['triggerid'], $available_hosts)) continue; $table->addRow(array( diff --git a/frontends/php/screens.php b/frontends/php/screens.php index 5e731b3a..bed79eb8 100644 --- a/frontends/php/screens.php +++ b/frontends/php/screens.php @@ -234,7 +234,7 @@ include_once "include/page_header.php"; validate_group_with_host(PERM_READ_ONLY,$options); $availiable_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST); - $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST); + $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,PERM_RES_IDS_ARRAY); $r_form = new CForm(); $r_form->SetMethod('get'); @@ -274,7 +274,7 @@ include_once "include/page_header.php"; ' AND h.hostid=i.hostid '. ' AND hg.groupid='.$_REQUEST['groupid']. ' AND hg.hostid=h.hostid '. - ' AND h.hostid IN ('.$availiable_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; } else{ @@ -283,7 +283,7 @@ include_once "include/page_header.php"; ' WHERE h.status='.HOST_STATUS_MONITORED. ' AND i.status='.ITEM_STATUS_ACTIVE. ' AND h.hostid=i.hostid'. - ' AND h.hostid IN ('.$availiable_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' ORDER BY h.host'; } diff --git a/frontends/php/scripts_exec.php b/frontends/php/scripts_exec.php index 279ecbd7..909684a8 100644 --- a/frontends/php/scripts_exec.php +++ b/frontends/php/scripts_exec.php @@ -46,7 +46,7 @@ check_fields($fields); if(isset($_REQUEST['execute'])){ if($script = get_script_by_scriptid($_REQUEST['scriptid'])){ if($script['host_access'] == SCRIPT_HOST_ACCESS_WRITE){ - $hosts_read_write = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE)); + $hosts_read_write = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_RES_IDS_ARRAY); if(uint_in_array($_REQUEST['hostid'],$hosts_read_write)){ //SDI('WRITE: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']); @@ -57,7 +57,7 @@ if(isset($_REQUEST['execute'])){ } } else { - $hosts_read_only = explode(',',get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY)); + $hosts_read_only = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if(uint_in_array($_REQUEST['hostid'],$hosts_read_only)){ //SDI('READ: '.$_REQUEST['scriptid'].' : '.$_REQUEST['hostid']); diff --git a/frontends/php/services_form.php b/frontends/php/services_form.php index 4352376d..d242d074 100644 --- a/frontends/php/services_form.php +++ b/frontends/php/services_form.php @@ -87,7 +87,7 @@ include_once "include/page_header.php"; //---------------------------------------------------------------------- - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if(isset($_REQUEST['serviceid']) && $_REQUEST['serviceid'] > 0){ @@ -154,7 +154,7 @@ if(isset($_REQUEST['saction'])){ $sql = 'SELECT h.* '. ' FROM hosts h '. ' WHERE '.DBin_node('h.hostid'). - ' AND h.hostid IN ('.$available_hosts.') '. + ' AND '.DBcondition('h.hostid',$available_hosts). ' AND h.hostid='.$_REQUEST["serverid"]; if(!$host_data = DBfetch(DBselect($sql))){ access_deny(); diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php index 3d75981c..f5a4872b 100644 --- a/frontends/php/srv_status.php +++ b/frontends/php/srv_status.php @@ -66,7 +66,7 @@ include_once "include/page_header.php"; unset($_REQUEST['serviceid']); } - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY); if(isset($_REQUEST["serviceid"]) && $_REQUEST["serviceid"] > 0){ diff --git a/frontends/php/sysmap.php b/frontends/php/sysmap.php index 87a5dc6c..e963cfed 100644 --- a/frontends/php/sysmap.php +++ b/frontends/php/sysmap.php @@ -119,7 +119,7 @@ include_once "include/page_header.php"; add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,'Name ['.$sysmap['name'].'] Link ['.$linkid.'] updated '); if($result) unset($_REQUEST["form"]); } - elseif(isset($_REQUEST["delete"])){ + else if(isset($_REQUEST["delete"])){ if(isset($_REQUEST["linkid"])){ $result=delete_link($_REQUEST["linkid"]); @@ -133,8 +133,7 @@ include_once "include/page_header.php"; unset($_REQUEST["form"]); } } - elseif(isset($_REQUEST["selementid"])) - { + else if(isset($_REQUEST["selementid"])){ $result=delete_sysmaps_element($_REQUEST["selementid"]); show_messages($result,"Element deleted","Cannot delete element"); add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP, @@ -147,7 +146,6 @@ include_once "include/page_header.php"; } } ?> - 1) - { + if($row["count"]>1){ show_table_header(S_CONNECTORS); echo SBR; insert_map_link_form(); } - else - { - info("No elements in this map"); + else{ + info('Not enough elements in this map'); } } else{ @@ -181,8 +177,7 @@ include_once "include/page_header.php"; $db_elements = DBselect("select * from sysmaps_elements where sysmapid=".$_REQUEST["sysmapid"]. " order by label"); - while($db_element = DBfetch($db_elements)) - { + while($db_element = DBfetch($db_elements)){ if( $db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_HOST) $type = S_HOST; elseif($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_MAP) $type = S_MAP; @@ -259,19 +254,19 @@ include_once "include/page_header.php"; } $table->Show(); } - + + show_messages(); + echo SBR; $map=get_sysmap_by_sysmapid($_REQUEST["sysmapid"]); show_table_header($map["name"]); $table = new CTable(NULL,"map"); - if(isset($_REQUEST["sysmapid"])) - { + if(isset($_REQUEST["sysmapid"])){ $linkMap = new CMap("links".$_REQUEST["sysmapid"]."_".rand(0,100000)); $db_elements = DBselect("select * from sysmaps_elements where sysmapid=".$_REQUEST["sysmapid"]); - while($db_element = DBfetch($db_elements)) - { + while($db_element = DBfetch($db_elements)){ $tmp_img = get_png_by_selementid($db_element["selementid"]); if(!$tmp_img) continue; @@ -286,6 +281,7 @@ include_once "include/page_header.php"; $db_element["label"]); } + $imgMap = new CImg("map.php?sysmapid=".$_REQUEST["sysmapid"]); $imgMap->SetMap($linkMap->GetName()); $table->AddRow($linkMap); diff --git a/frontends/php/tr_events.php b/frontends/php/tr_events.php index 98015919..d4398c10 100644 --- a/frontends/php/tr_events.php +++ b/frontends/php/tr_events.php @@ -43,6 +43,7 @@ $fields=array( 'triggerid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']), 'eventid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']), + 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), NULL), /* actions */ "save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, null, null), @@ -80,12 +81,20 @@ ' AND '.DBin_node('t.triggerid'))); ?> AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); + $fs_icon->AddAction('onclick',new CScript("javascript: document.location = '".$url."';")); +//------- $left_tab = new CTable(); $left_tab->SetCellPadding(3); $left_tab->SetCellSpacing(3); @@ -162,7 +171,17 @@ $outer_table->SetCellSpacing(1); $outer_table->AddRow(array($td_l,$td_r)); - $outer_table->Show(); + $p_elements[] = $outer_table; + + $latest_hat = create_hat( + $text, + $p_elements, + array($fs_icon), + 'hat_tr_events', + get_profile('web.tr_events.hats.hat_tr_events.state',1) + ); + + $latest_hat->Show(); ?> 'disaster', @@ -87,41 +87,118 @@ include_once "include/page_header.php"; $fields=array( 'groupid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'hostid'=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), - 'noactions'=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null), - 'compact'=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null), - - 'show_triggers'=> array(T_ZBX_INT, O_OPT, null, null, null), - 'show_events'=> array(T_ZBX_INT, O_OPT, P_SYS, null, null), - 'select'=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null), - 'txt_select'=> array(T_ZBX_STR, O_OPT, null, null, null), + 'fullscreen'=> array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), 'btnSelect'=> array(T_ZBX_STR, O_OPT, null, null, null), +// filter + 'filter_rst'=> array(T_ZBX_INT, O_OPT, P_SYS, IN(array(0,1)), NULL), + 'filter_set'=> array(T_ZBX_STR, O_OPT, P_SYS, null, NULL), + + 'show_triggers'=> array(T_ZBX_INT, O_OPT, null, null, null), + 'show_events'=> array(T_ZBX_INT, O_OPT, P_SYS, null, null), + 'show_severity'=> array(T_ZBX_INT, O_OPT, P_SYS, null, null), + + 'show_actions'=> array(T_ZBX_INT, O_OPT, null, null, null), + 'show_details'=> array(T_ZBX_INT, O_OPT, null, null, null), + + 'txt_select'=> array(T_ZBX_STR, O_OPT, null, null, null), + 'inverse_select'=> array(T_ZBX_INT, O_OPT, null, null, null), + //ajax - 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, NULL), + 'favobj'=> array(T_ZBX_STR, O_OPT, P_ACT, NULL, 'isset({favid})'), + 'favid'=> array(T_ZBX_STR, O_OPT, P_ACT, NOT_EMPTY, NULL), 'state'=> array(T_ZBX_INT, O_OPT, P_ACT, NOT_EMPTY, 'isset({favobj})'), - ); check_fields($fields); +/* AJAX */ if(isset($_REQUEST['favobj'])){ - if(str_in_array($_REQUEST['favobj'],array('sound'))){ + if('hat' == $_REQUEST['favobj']){ + update_profile('web.tr_status.hats.'.$_REQUEST['favid'].'.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } + else if(str_in_array($_REQUEST['favobj'],array('sound'))){ update_profile('web.tr_status.mute',$_REQUEST['state'], PROFILE_TYPE_INT); } + else if('filter' == $_REQUEST['favobj']){ + update_profile('web.tr_status.filter.state',$_REQUEST['state'], PROFILE_TYPE_INT); + } } if((PAGE_TYPE_JS == $page['type']) || (PAGE_TYPE_HTML_BLOCK == $page['type'])){ exit(); } +//-------- + + $config=select_config(); - validate_sort_and_sortorder('t.lastchange',ZBX_SORT_DOWN); +/* FILTER */ + if(isset($_REQUEST['filter_rst'])){ + $_REQUEST['show_actions'] = get_request('show_actions', 0); + $_REQUEST['show_details'] = get_request('show_details', 0); + + $_REQUEST['show_triggers'] = get_request('show_triggers', TRIGGERS_OPTION_ONLYTRUE); + $_REQUEST['show_events'] = get_request('show_events', EVENTS_OPTION_NOEVENT); + $_REQUEST['show_severity'] = get_request('show_severity', -1); + + $_REQUEST['txt_select'] = get_request('txt_select', ''); + $_REQUEST['inverse_select'] = get_request('inverse_select', 0); + } + + if(isset($_REQUEST['filter_set'])){ + $_REQUEST['show_actions'] = get_request('show_actions', 0); + $_REQUEST['show_details'] = get_request('show_details', 0); + + $_REQUEST['inverse_select'] = get_request('inverse_select', 0); + } + else{ + $_REQUEST['show_actions'] = get_request('show_actions', get_profile('web.tr_status.filter.show_actions',0)); + $_REQUEST['show_details'] = get_request('show_details', get_profile('web.tr_status.filter.show_details',0)); + + $_REQUEST['inverse_select'] = get_request('inverse_select', get_profile('web.tr_status.filter.inverse_select',0)); + } + + $_REQUEST['show_triggers'] = get_request('show_triggers', get_profile('web.tr_status.filter.show_triggers',TRIGGERS_OPTION_ONLYTRUE)); + $_REQUEST['show_events'] = get_request('show_events', get_profile('web.tr_status.filter.show_events',EVENTS_OPTION_NOEVENT)); + + $_REQUEST['show_severity'] = get_request('show_severity', get_profile('web.tr_status.filter.show_severity',-1)); + + $_REQUEST['txt_select'] = get_request('txt_select', get_profile('web.tr_status.filter.select','')); + +// if trigger option is NOFALSEFORB than only 1 option avalable for events and we are setting it!!! + if(TRIGGERS_OPTION_NOFALSEFORB && ($_REQUEST['show_triggers'] == TRIGGERS_OPTION_NOFALSEFORB)){ + $_REQUEST['show_events'] = EVENTS_OPTION_NOFALSEFORB; + } + + if(($_REQUEST['show_events'] == EVENTS_OPTION_NOFALSEFORB) && ($_REQUEST['show_triggers'] != TRIGGERS_OPTION_NOFALSEFORB)){ + $_REQUEST['show_events'] = EVENTS_OPTION_NOEVENT; + } - $_REQUEST['show_triggers'] = get_request('show_triggers', get_profile('web.tr_status.show_triggers', TRIGGERS_OPTION_ONLYTRUE)); - $_REQUEST['show_events'] = get_request('show_events',get_profile('web.tr_status.show_events', EVENTS_OPTION_NOEVENT)); + if(!$config['event_ack_enable'] && (($_REQUEST['show_events'] != EVENTS_OPTION_NOEVENT) || ($_REQUEST['show_events'] != EVENTS_OPTION_ALL))){ + $_REQUEST['show_events'] = EVENTS_OPTION_NOEVENT; + } +//-- - $_REQUEST['noactions'] = get_request('noactions', get_profile('web.tr_status.noactions', 'true')); - $_REQUEST['compact'] = get_request('compact', get_profile('web.tr_status.compact', 'true')); + if(isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])){ + update_profile('web.tr_status.filter.show_actions',$_REQUEST['show_actions'], PROFILE_TYPE_INT); + update_profile('web.tr_status.filter.show_details',$_REQUEST['show_details'], PROFILE_TYPE_INT); + + update_profile('web.tr_status.filter.show_triggers',$_REQUEST['show_triggers'], PROFILE_TYPE_INT); + update_profile('web.tr_status.filter.show_events',$_REQUEST['show_events'], PROFILE_TYPE_INT); + + update_profile('web.tr_status.filter.show_severity',$_REQUEST['show_severity'], PROFILE_TYPE_INT); + + update_profile('web.tr_status.filter.txt_select',$_REQUEST['txt_select'], PROFILE_TYPE_STR); + update_profile('web.tr_status.filter.inverse_select',$_REQUEST['inverse_select'], PROFILE_TYPE_INT); + } + + $show_triggers = $_REQUEST['show_triggers']; + $show_events = $_REQUEST['show_events']; + $show_severity = $_REQUEST['show_severity']; +// -------------- + + validate_sort_and_sortorder('t.lastchange',ZBX_SORT_DOWN); $options = array('allow_all_hosts','monitored_hosts','with_monitored_items'); if(!$ZBX_WITH_SUBNODES) array_push($options,'only_current_node'); @@ -138,44 +215,11 @@ include_once "include/page_header.php"; validate_group_with_host(PERM_READ_ONLY,$options,'web.tr_status.groupid','web.tr_status.hostid'); - update_profile('web.tr_status.show_triggers',$_REQUEST['show_triggers'], PROFILE_TYPE_INT); - update_profile('web.tr_status.show_events',$_REQUEST['show_events'], PROFILE_TYPE_INT); - - update_profile('web.tr_status.noactions',$_REQUEST['noactions'], PROFILE_TYPE_STR); - update_profile('web.tr_status.compact',$_REQUEST['compact'], PROFILE_TYPE_STR); - - $config=select_config(); - $mute = get_profile('web.tr_status.mute',0); - if(isset($audio) && !$mute){ play_sound($audio); } ?> - SetMethod('get'); @@ -186,12 +230,11 @@ include_once "include/page_header.php"; $cmbGroup->AddItem(0,S_ALL_SMALL); $cmbHosts->AddItem(0,S_ALL_SMALL); - $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); - $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); + $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_RES_IDS_ARRAY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY,PERM_RES_IDS_ARRAY); - $scripts_by_hosts = get_accessible_scripts_by_hosts(explode(',',$available_hosts)); + $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts); $sql = 'SELECT DISTINCT g.groupid,g.name '. ' FROM groups g, hosts_groups hg, hosts h, items i '. @@ -216,7 +259,7 @@ include_once "include/page_header.php"; $sql='SELECT DISTINCT h.hostid,h.host '. - ' FROM hosts_groups hg, hosts h, items i, functions f, triggers t '. + ' FROM hosts h, items i, functions f, triggers t '.($_REQUEST['groupid']?', hosts_groups hg ':''). ' WHERE '.DBcondition('t.triggerid',$available_triggers). ' AND t.status='.TRIGGER_STATUS_ENABLED. ' AND f.triggerid=t.triggerid '. @@ -224,8 +267,7 @@ include_once "include/page_header.php"; ' AND i.status='.ITEM_STATUS_ACTIVE. ' AND h.hostid=i.hostid '. ' AND h.status='.HOST_STATUS_MONITORED. - ' AND hg.hostid=h.hostid '. - ($_REQUEST['groupid']?' AND hg.groupid='.$_REQUEST['groupid']:''). + ($_REQUEST['groupid']?' AND hg.hostid=h.hostid AND hg.groupid='.$_REQUEST['groupid']:''). ' ORDER BY h.host'; $result=DBselect($sql); @@ -240,23 +282,13 @@ include_once "include/page_header.php"; if(!$flag) $_REQUEST['hostid'] = 0; $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts)); - $r_form->AddVar('compact',$compact); - $r_form->AddVar('show_triggers',$show_triggers); - $r_form->AddVar('show_events',$show_events); - $r_form->AddVar('noactions',$noactions); - $r_form->AddVar('select',$select); - $r_form->AddVar('txt_select',$txt_select); - $r_form->AddVar('btnSelect',get_request('btnSelect')); $r_form->AddVar('fullscreen',$_REQUEST['fullscreen']); + $p_elemetns = array(); $text = array(S_STATUS_OF_TRIGGERS_BIG,SPACE,date('[H:i:s]',time())); - $url = 'tr_status.php?show_triggers='.$show_triggers. - url_param('show_events'). - url_param('noactions'). - url_param('compact'). - ($_REQUEST['fullscreen']?'':'&fullscreen=1'); + $url = 'tr_status.php'.($_REQUEST['fullscreen']?'':'?fullscreen=1'); $fs_icon = new CDiv(SPACE,'fullscreen'); $fs_icon->AddOption('title',$_REQUEST['fullscreen']?S_NORMAL.' '.S_VIEW:S_FULLSCREEN); @@ -266,96 +298,85 @@ include_once "include/page_header.php"; $mute_icon->AddOption('title',S_SOUND.' '.S_ON.'/'.S_OFF); $mute_icon->AddAction('onclick',new CScript("javascript: switch_mute(this);")); - $icon_tab = new CTable(); - $icon_tab->AddRow(array($fs_icon,$mute_icon,SPACE,$text)); - - $text = $icon_tab; + $p_elements[] = get_table_header(S_TRIGGERS,$r_form); - show_table_header($text,$r_form); +/************************* FILTER **************************/ +/***********************************************************/ + + $filterForm = new CFormTable(S_FILTER);//,'tr_status.php?filter_set=1','POST',null,'sform'); + $filterForm->AddOption('name','zbx_filter'); + $filterForm->AddOption('id','zbx_filter'); + $filterForm->SetMethod('post'); + + $filterForm->AddVar('fullscreen',$_REQUEST['fullscreen']); + $tr_select = new CComboBox('show_triggers',$show_triggers,'javasctipt: submit();'); + if(TRIGGERS_OPTION_ONLYTRUE){ + $tr_select->Additem(TRIGGERS_OPTION_ONLYTRUE,S_SHOW_ONLY_TRUE); + } - if(!$_REQUEST["fullscreen"]){ - $left_col = array(); - - $tr_form = new CForm('tr_status.php'); - $tr_form->SetMethod('get'); - $tr_form->AddOption('style','display: inline;'); - - $tr_form->AddVar("compact",$compact); - $tr_form->AddVar("noactions",$noactions); - $tr_form->AddVar("select",$select); - $tr_form->AddVar('txt_select',$txt_select); - $tr_form->AddVar('btnSelect',get_request('btnSelect')); - $tr_form->AddVar('fullscreen',$_REQUEST['fullscreen']); - - $tr_select = new CComboBox('show_triggers',S_TRIGGERS,'javascript: submit();'); - if(TRIGGERS_OPTION_ONLYTRUE){ - $tr_select->Additem(TRIGGERS_OPTION_ONLYTRUE,S_SHOW_ONLY_TRUE,(TRIGGERS_OPTION_ONLYTRUE==$show_triggers)?'yes':'no'); - } - if(TRIGGERS_OPTION_ALL){ - $tr_select->Additem(TRIGGERS_OPTION_ALL,S_SHOW_ALL,(TRIGGERS_OPTION_ALL==$show_triggers)?'yes':'no'); - } - if(TRIGGERS_OPTION_NOFALSEFORB && $config['event_ack_enable']){ - $tr_select->Additem(TRIGGERS_OPTION_NOFALSEFORB,S_SHOW_NOFALSEFORB,(TRIGGERS_OPTION_NOFALSEFORB==$show_triggers)?'yes':'no'); - } - - $ev_select = new CComboBox('show_events',S_EVENTS,'javascript: submit();'); - if(EVENTS_OPTION_NOEVENT){ - $ev_select->Additem(EVENTS_OPTION_NOEVENT,S_HIDE_ALL,(EVENTS_OPTION_NOEVENT==$show_events)?'yes':'no'); - } - if(EVENTS_OPTION_ALL){ - $ev_select->Additem(EVENTS_OPTION_ALL,S_SHOW_ALL.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')',(EVENTS_OPTION_ALL==$show_events)?'yes':'no'); - } - if(EVENTS_OPTION_NOT_ACK && $config['event_ack_enable']){ - $ev_select->Additem(EVENTS_OPTION_NOT_ACK,S_SHOW_UNACKNOWLEDGED.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')',(EVENTS_OPTION_NOT_ACK==$show_events)?'yes':'no'); - } - if(EVENTS_OPTION_ONLYTRUE_NOTACK && $config['event_ack_enable']){ - $ev_select->Additem(EVENTS_OPTION_ONLYTRUE_NOTACK,S_SHOW_TRUE_UNACKNOWLEDGED.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')',(EVENTS_OPTION_ONLYTRUE_NOTACK==$show_events)?'yes':'no'); - } + if(TRIGGERS_OPTION_ALL){ + $tr_select->AddItem(TRIGGERS_OPTION_ALL,S_SHOW_ALL); + } + + if(TRIGGERS_OPTION_NOFALSEFORB && $config['event_ack_enable']){ + $tr_select->AddItem(TRIGGERS_OPTION_NOFALSEFORB,S_SHOW_NOFALSEFORB); + } + + $ev_select = new CComboBox('show_events',$show_events,'javasctipt: submit();'); + if(EVENTS_OPTION_NOEVENT){ + $ev_select->AddItem(EVENTS_OPTION_NOEVENT,S_HIDE_ALL); + } + + if(EVENTS_OPTION_ALL){ + $ev_select->AddItem(EVENTS_OPTION_ALL,S_SHOW_ALL.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')'); + } + + if(EVENTS_OPTION_NOT_ACK && $config['event_ack_enable']){ + $ev_select->AddItem(EVENTS_OPTION_NOT_ACK,S_SHOW_UNACKNOWLEDGED.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')'); + } + + if(EVENTS_OPTION_ONLYTRUE_NOTACK && $config['event_ack_enable']){ + $ev_select->AddItem(EVENTS_OPTION_ONLYTRUE_NOTACK,S_SHOW_TRUE_UNACKNOWLEDGED.SPACE.'('.$config['event_expire'].SPACE.(($config['event_expire']>1)?S_DAYS:S_DAY).')'); + } + //------- JP ------- - if($show_triggers==TRIGGERS_OPTION_NOFALSEFORB){ - $ev_select->Additem(EVENTS_OPTION_NOFALSEFORB,' - ','yes'); - $ev_select->AddOption('disabled','disabled'); - } - - $tr_form->AddItem(S_TRIGGERS); - $tr_form->AddItem($tr_select); - - $tr_form->AddItem(SPACE.SPACE.S_EVENTS); - $tr_form->AddItem($ev_select); - - array_push($left_col,$tr_form,SPACE); - - array_push($left_col, '[', new CLink($noactions != 'true' ? S_HIDE_ACTIONS : S_SHOW_ACTIONS, - "tr_status.php?noactions=".($noactions != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&compact=$compact&select=$select&txt_select=$txt_select".url_param('btnSelect') - ), ']'.SPACE); - - array_push($left_col, '[', new CLink($compact != 'true' ? S_HIDE_DETAILS: S_SHOW_DETAILS, - "tr_status.php?compact=".($compact != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&select=$select&txt_select=$txt_select".url_param('btnSelect') - ), ']'.SPACE); - - array_push($left_col, '[', new CLink($select != 'true' ? S_SELECT : S_HIDE_SELECT, - "tr_status.php?select=".($select != 'true' ? 'true' : 'false'). - "&show_triggers=$show_triggers&show_events=$show_events&noactions=$noactions&compact=$compact&txt_select=$txt_select".url_param('btnSelect') - ), ']'); - - if($select=='true'){ - - $form = new CForm(); - $form->SetMethod('get'); - - $form->AddItem(new CTextBox("txt_select",$txt_select,15)); - $form->AddItem(new CButton("btnSelect", S_SELECT)); - $form->AddItem(new CButton("btnSelect", S_INVERSE_SELECT)); - $form->AddVar("compact",$compact); - $form->AddVar("noactions",$noactions); - $form->AddVar("select",$select); - array_push($left_col,BR(),$form); - } - show_table_header($left_col); + if($show_triggers==TRIGGERS_OPTION_NOFALSEFORB){ + $ev_select->Additem(EVENTS_OPTION_NOFALSEFORB,' - ','yes'); + $ev_select->AddOption('disabled','disabled'); } +//--- + + $filterForm->AddRow(S_TRIGGERS,$tr_select); + $filterForm->AddRow(S_EVENTS,$ev_select); + + $severity_select = new CComboBox('show_severity',$show_severity,'javasctipt: submit();'); + $severity_select->AddItem(-1, S_ALL); + $severity_select->AddItem(TRIGGER_SEVERITY_NOT_CLASSIFIED, S_NOT_CLASSIFIED); + $severity_select->AddItem(TRIGGER_SEVERITY_INFORMATION, S_INFORMATION); + $severity_select->AddItem(TRIGGER_SEVERITY_WARNING, S_WARNING); + $severity_select->AddItem(TRIGGER_SEVERITY_AVERAGE, S_AVERAGE); + $severity_select->AddItem(TRIGGER_SEVERITY_HIGH, S_HIGH); + $severity_select->AddItem(TRIGGER_SEVERITY_DISASTER, S_DISASTER); + + $filterForm->AddRow(S_MIN_SEVERITY,$severity_select); + + $filterForm->AddRow(S_SHOW_ACTIONS, new CCheckBox('show_actions',$_REQUEST['show_actions'],null,1)); + $filterForm->AddRow(S_SHOW_DETAILS, new CCheckBox('show_details',$_REQUEST['show_details'],null,1)); + + $filterForm->AddRow(S_SELECT, new CTextBox("txt_select",$_REQUEST['txt_select'],40)); + $filterForm->AddRow(S_INVERSE_SELECT, new CCheckBox('inverse_select',$_REQUEST['inverse_select'],null,1)); + + $reset = new CButton("filter_rst",S_RESET); + $reset->SetType('button'); + $reset->SetAction('javascript: var uri = new url(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();'); + + $filterForm->AddItemToBottomRow(new CButton("filter_set",S_FILTER)); + $filterForm->AddItemToBottomRow($reset); + + $p_elements[] = create_filter(S_FILTER,null,$filterForm,'tr_filter',get_profile('web.tr_status.filter.state',0)); +/*************** FILTER END ******************/ + if($_REQUEST["fullscreen"]){ $triggerInfo = new CTriggersInfo(); $triggerInfo->HideHeader(); @@ -382,11 +403,11 @@ include_once "include/page_header.php"; make_sorting_link(S_SEVERITY,'t.priority'), S_STATUS, make_sorting_link(S_LAST_CHANGE,'t.lastchange'), - is_show_subnodes() ? make_sorting_link(S_NODE,'h.hostid') : null, - $_REQUEST["hostid"] >0 ? null : make_sorting_link(S_HOST,'h.host'), + is_show_subnodes()?make_sorting_link(S_NODE,'h.hostid'):null, + ($_REQUEST["hostid"]>0)?null:make_sorting_link(S_HOST,'h.host'), make_sorting_link(S_NAME,'t.description'), - ($noactions!='true')?S_ACTIONS:NULL, - ($config['event_ack_enable'])? S_ACKNOWLEDGED : NULL, + $_REQUEST['show_actions']?S_ACTIONS:NULL, + $config['event_ack_enable']?S_ACKNOWLEDGED:NULL, S_COMMENTS )); @@ -405,19 +426,22 @@ include_once "include/page_header.php"; $cond.=' AND ((t.value='.TRIGGER_VALUE_TRUE.') OR ((t.value='.TRIGGER_VALUE_FALSE.') AND (('.time().'-t.lastchange)<'.TRIGGER_FALSE_PERIOD.')))'; break; } + + if($show_severity > -1){ + $cond.=' AND t.priority>='.$show_severity; + } $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description, t.expression,t.priority, '. - ' t.lastchange,t.comments,t.url,t.value,h.host,h.hostid,t.type '. - ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg '. - ' WHERE f.itemid=i.itemid '. - ' AND h.hostid=i.hostid '. - ' AND hg.hostid=h.hostid '. - ' AND t.triggerid=f.triggerid '. - ' AND t.status='.TRIGGER_STATUS_ENABLED. - ' AND i.status='.ITEM_STATUS_ACTIVE. - ' AND '.DBcondition('t.triggerid',$available_triggers). - ' AND h.status='.HOST_STATUS_MONITORED.' '.$cond. - order_by('h.host,h.hostid,t.description,t.priority,t.lastchange'); + ' t.lastchange,t.comments,t.url,t.value,h.host,h.hostid,t.type '. + ' FROM triggers t,hosts h,items i,functions f '. + ' WHERE f.itemid=i.itemid '. + ' AND h.hostid=i.hostid '. + ' AND t.triggerid=f.triggerid '. + ' AND t.status='.TRIGGER_STATUS_ENABLED. + ' AND i.status='.ITEM_STATUS_ACTIVE. + ' AND '.DBcondition('t.triggerid',$available_triggers). + ' AND h.status='.HOST_STATUS_MONITORED.' '.$cond. + order_by('h.host,h.hostid,t.description,t.priority,t.lastchange'); $result = DBselect($sql); @@ -461,15 +485,13 @@ include_once "include/page_header.php"; $description = expand_trigger_description($row['triggerid']); - if(isset($_REQUEST["btnSelect"]) && '' != $txt_select && ((zbx_stristr($description, $txt_select)) == ($_REQUEST["btnSelect"]==S_INVERSE_SELECT))) continue; + if(!zbx_empty($_REQUEST['txt_select']) && ((bool)zbx_stristr($description, $_REQUEST['txt_select']) == (bool)$_REQUEST['inverse_select'])) continue; - if($row["url"] != "") - { - $description = new CLink($description, $row["url"]); + if(!zbx_empty($row['url'])){ + $description = new CLink($description, $row['url']); } - if($compact != 'true') - { + if($_REQUEST['show_details']){ $font = new CTag('font','yes'); $font->AddOption('color','#000'); $font->AddOption('size','-2'); @@ -498,7 +520,7 @@ include_once "include/page_header.php"; unset($img, $dep_table, $dependency); //------------------------ - if((time(NULL)-$row["lastchange"])AddOption('name','blink'); } @@ -508,12 +530,11 @@ include_once "include/page_header.php"; $value = new CSpan($tr_status, get_trigger_value_style($row["value"])); - if($noactions=='true'){ - $actions=NULL; + if($_REQUEST['show_actions']){ + $actions=array(new CLink(S_CHANGE,'triggers.php?form=update&triggerid='.$row["triggerid"].url_param('hostid'),"action")); } else{ - $actions=array( - new CLink(S_CHANGE,'triggers.php?form=update&triggerid='.$row["triggerid"].url_param('hostid'),"action")); + $actions=NULL; } $host = null; @@ -551,7 +572,7 @@ include_once "include/page_header.php"; $description, $actions, ($config['event_ack_enable'])?SPACE:NULL, - new CLink(($row["comments"] == "") ? S_ADD : S_SHOW,"tr_comments.php?triggerid=".$row["triggerid"],"action") + new CLink(zbx_empty($row['comments'])?S_ADD:S_SHOW,'tr_comments.php?triggerid='.$row['triggerid'],'action') )); $event_limit=0; @@ -567,8 +588,7 @@ include_once "include/page_header.php"; $value = new CSpan(trigger_value2str($row_event['value']), get_trigger_value_style($row_event['value'])); if($config['event_ack_enable']){ - if($row_event['acknowledged'] == 1) - { + if($row_event['acknowledged'] == 1){ $acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid='.$row_event['eventid'])); $ack=array( new CSpan(S_YES,"off"), @@ -584,14 +604,6 @@ include_once "include/page_header.php"; array_merge($row, array("clock"=>$row_event["clock"])), ZBX_FLAG_EVENT); - if($compact != 'true'){ - $font = new CTag('font','yes'); - $font->AddOption('color','#000'); - $font->AddOption('size','-2'); - $font->AddItem(explode_exp($row["expression"],1)); - $description = array($description, $font); - } - $font = new CTag('font','yes'); $font->AddOption('color','#808080'); $font->AddItem(array(' - ',$description)); @@ -628,14 +640,29 @@ include_once "include/page_header.php"; ))); $m_form->AddItem($table); - $m_form->Show(); unset($table); +// $m_form->Show(); + $p_elements[] = $m_form; + $triggers_hat = create_hat( + $text, + $p_elements, + array($mute_icon,$fs_icon), + 'hat_triggers', + get_profile('web.tr_status.hats.hat_triggers.state',1) + ); + + $triggers_hat->Show(); + + + zbx_add_post_js('blink.init();'); $jsmenu = new CPUMenu(null,170); $jsmenu->InsertJavaScript(); ?> diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php index 96635cb3..885cc3b6 100644 --- a/frontends/php/triggers.php +++ b/frontends/php/triggers.php @@ -365,77 +365,74 @@ include_once "include/page_header.php"; show_table_header(S_CONFIGURATION_OF_TRIGGERS_BIG,$form); echo SBR; - - $r_form = new CForm(); - $r_form->SetMethod('get'); - $r_form->AddItem(array('[', - new CLink($showdisabled ? S_HIDE_DISABLED_TRIGGERS : S_SHOW_DISABLED_TRIGGERS, - 'triggers.php?showdisabled='.($showdisabled ? 0 : 1),NULL), - ']', SPACE)); - - $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()"); - $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()"); - - $cmbGroup->AddItem(0,S_ALL_SMALL); - - $result=DBselect('SELECT DISTINCT g.groupid,g.name '. - ' FROM groups g, hosts_groups hg, hosts h, items i '. - ' WHERE '.DBcondition('h.hostid',$available_hosts). - ' AND hg.groupid=g.groupid '. - ' AND h.hostid=i.hostid '. - ' AND hg.hostid=h.hostid '. - ' ORDER BY g.name'); - while($row=DBfetch($result)){ - $cmbGroup->AddItem($row['groupid'],$row['name']); - } - $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup)); - - if($_REQUEST['groupid'] > 0){ - $sql='SELECT h.hostid,h.host '. - ' FROM hosts h,items i,hosts_groups hg '. - ' WHERE h.hostid=i.hostid '. - ' AND hg.groupid='.$_REQUEST['groupid']. - ' AND hg.hostid=h.hostid'. - ' AND '.DBcondition('h.hostid',$available_hosts). - ' GROUP BY h.hostid,h.host '. - ' ORDER BY h.host'; - } - else{ - $cmbHosts->AddItem(0,S_ALL_SMALL); - $sql='SELECT h.hostid,h.host '. - ' FROM hosts h,items i '. - ' WHERE h.hostid=i.hostid '. - ' AND '.DBcondition('h.hostid',$available_hosts). - ' GROUP BY h.hostid,h.host '. - ' ORDER BY h.host'; - } - - $result=DBselect($sql); - while($row=DBfetch($result)){ - $cmbHosts->AddItem($row["hostid"],$row["host"]); - } - - $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts)); - - show_table_header(S_TRIGGERS_BIG, $r_form); ?> SetMethod('get'); + $r_form->AddItem(array('[', + new CLink($showdisabled ? S_HIDE_DISABLED_TRIGGERS : S_SHOW_DISABLED_TRIGGERS, + 'triggers.php?showdisabled='.($showdisabled ? 0 : 1),NULL), + ']', SPACE)); + + $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()"); + $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()"); + + $cmbGroup->AddItem(0,S_ALL_SMALL); + + $result=DBselect('SELECT DISTINCT g.groupid,g.name '. + ' FROM groups g, hosts_groups hg, hosts h, items i '. + ' WHERE '.DBcondition('h.hostid',$available_hosts). + ' AND hg.groupid=g.groupid '. + ' AND h.hostid=i.hostid '. + ' AND hg.hostid=h.hostid '. + ' ORDER BY g.name'); + while($row=DBfetch($result)){ + $cmbGroup->AddItem($row['groupid'],$row['name']); + } + $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup)); + + if($_REQUEST['groupid'] > 0){ + $sql='SELECT h.hostid,h.host '. + ' FROM hosts h,items i,hosts_groups hg '. + ' WHERE h.hostid=i.hostid '. + ' AND hg.groupid='.$_REQUEST['groupid']. + ' AND hg.hostid=h.hostid'. + ' AND '.DBcondition('h.hostid',$available_hosts). + ' GROUP BY h.hostid,h.host '. + ' ORDER BY h.host'; + } + else{ + $cmbHosts->AddItem(0,S_ALL_SMALL); + $sql='SELECT h.hostid,h.host '. + ' FROM hosts h,items i '. + ' WHERE h.hostid=i.hostid '. + ' AND '.DBcondition('h.hostid',$available_hosts). + ' GROUP BY h.hostid,h.host '. + ' ORDER BY h.host'; + } + + $result=DBselect($sql); + while($row=DBfetch($result)){ + $cmbHosts->AddItem($row["hostid"],$row["host"]); + } + + $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts)); + + show_table_header(S_TRIGGERS_BIG, $r_form); + $form = new CForm('triggers.php'); $form->SetName('triggers'); $form->SetMethod('post'); -- cgit