summaryrefslogtreecommitdiffstats
path: root/frontends
diff options
context:
space:
mode:
Diffstat (limited to 'frontends')
-rw-r--r--frontends/php/acknow.php25
-rw-r--r--frontends/php/chart_sla.php21
-rw-r--r--frontends/php/history.php112
-rw-r--r--frontends/php/include/forms.inc.php125
-rw-r--r--frontends/php/include/html.inc.php13
-rw-r--r--frontends/php/include/import.inc.php19
-rw-r--r--frontends/php/include/maps.inc.php128
-rw-r--r--frontends/php/latest.php53
-rw-r--r--frontends/php/popup.php97
-rw-r--r--frontends/php/popup_trexpr.php13
-rw-r--r--frontends/php/report3.php115
-rw-r--r--frontends/php/tr_comments.php23
12 files changed, 359 insertions, 385 deletions
diff --git a/frontends/php/acknow.php b/frontends/php/acknow.php
index 07f55ac9..e2552b3e 100644
--- a/frontends/php/acknow.php
+++ b/frontends/php/acknow.php
@@ -62,7 +62,7 @@ include_once "include/page_header.php";
//$bulk = (count($events) > 1);
?>
<?php
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
$eventids = '';
foreach($events as $id => $eventid){
@@ -71,13 +71,9 @@ include_once "include/page_header.php";
$eventids = trim($eventids,',');
$db_data = DBfetch(DBselect('SELECT COUNT(DISTINCT e.eventid) as cnt'.
- ' FROM hosts h, items i, functions f, events e, triggers t'.
- ' WHERE h.hostid=i.hostid '.
- ' AND i.itemid=f.itemid '.
- ' AND f.triggerid=t.triggerid '.
- ' AND e.eventid in ('.$eventids.') '.
- ' AND i.hostid not in ('.$denyed_hosts.') '.
- ' AND e.objectid=t.triggerid '.
+ ' FROM events e'.
+ ' WHERE e.eventid in ('.$eventids.') '.
+ ' AND e.objectid IN ('.$available_triggers.') '.
' AND e.object='.EVENT_OBJECT_TRIGGER.
' AND '.DBin_node('e.eventid')
));
@@ -92,24 +88,21 @@ include_once "include/page_header.php";
' AND i.itemid=f.itemid '.
' AND f.triggerid=t.triggerid '.
' AND e.eventid in ('.$eventids.') '.
- ' AND i.hostid not in ('.$denyed_hosts.') '.
- ' AND e.objectid=t.triggerid '.
' AND e.object='.EVENT_OBJECT_TRIGGER.
+ ' AND e.objectid=t.triggerid '.
+ ' AND t.triggerid IN ('.$available_triggers.') '.
' AND '.DBin_node('e.eventid')
));
-
- unset($denyed_hosts);
- if(isset($_REQUEST['save']) && !$bulk)
- {
+ if(isset($_REQUEST['save']) && !$bulk){
$result = add_acknowledge_coment(
$db_data['eventid'],
$USER_DETAILS['userid'],
$_REQUEST['message']);
show_messages($result, S_COMMENT_ADDED, S_CANNOT_ADD_COMMENT);
- if($result)
- {
+
+ if($result){
add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_TRIGGER, S_ACKNOWLEDGE_ADDED.
' ['.expand_trigger_description_by_data($db_data).']'.
' ['.$_REQUEST["message"].']');
diff --git a/frontends/php/chart_sla.php b/frontends/php/chart_sla.php
index 5759bbeb..1fe9f888 100644
--- a/frontends/php/chart_sla.php
+++ b/frontends/php/chart_sla.php
@@ -38,22 +38,19 @@ include_once "include/page_header.php";
check_fields($fields);
?>
<?php
- if(! (DBfetch(DBselect('select serviceid from services where serviceid='.$_REQUEST["serviceid"]))) )
- {
+ if(!DBfetch(DBselect('select serviceid from services where serviceid='.$_REQUEST["serviceid"])) ){
fatal_error(S_NO_IT_SERVICE_DEFINED);
}
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
- if( !($service = DBfetch(DBselect('SELECT s.* '.
- ' FROM services s '.
- ' LEFT JOIN triggers t ON s.triggerid=t.triggerid '.
- ' LEFT JOIN functions f ON t.triggerid=f.triggerid '.
- ' LEFT JOIN items i ON f.itemid=i.itemid '.
- ' WHERE (i.hostid is NULL or i.hostid not in ('.$denyed_hosts.')) '.
- ' AND s.serviceid='.$_REQUEST['serviceid']
- ))))
- {
+ $sql = 'SELECT s.* '.
+ ' FROM services s '.
+ ' WHERE s.serviceid='.$_REQUEST['serviceid'].
+ ' AND (s.triggerid IS NULL OR s.triggerid in ('.$available_triggers.')) '.
+ ' AND DBin_node('s.serviceid')';
+
+ if(!$service = DBfetch(DBselect($sql))){
access_deny();
}
?>
diff --git a/frontends/php/history.php b/frontends/php/history.php
index 463b499a..ddf396af 100644
--- a/frontends/php/history.php
+++ b/frontends/php/history.php
@@ -112,50 +112,44 @@ include_once "include/page_header.php";
$_REQUEST["action"] = get_request("action", "showgraph");
/*** Prepare page header - start ***/
- if(is_array($_REQUEST["itemid"]))
- {
-
+ if(is_array($_REQUEST["itemid"])){
$_REQUEST["itemid"] = array_unique($_REQUEST["itemid"]);
- if(isset($_REQUEST["remove_log"]) && isset($_REQUEST["cmbloglist"]))
- {
+ if(isset($_REQUEST["remove_log"]) && isset($_REQUEST["cmbloglist"])){
foreach($_REQUEST["itemid"] as $id => $itemid)
if((bccomp($itemid , $_REQUEST["cmbloglist"])==0))
unset($_REQUEST["itemid"][$id]);
}
$items_count = count($_REQUEST["itemid"]);
- if($items_count > 1)
- {
+ if($items_count > 1){
$main_header = count($_REQUEST["itemid"])." log files";
}
- else
- {
+ else{
$_REQUEST["itemid"] = array_pop($_REQUEST["itemid"]);
}
}
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
-
- $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid());
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid());
- 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 in (".$denyed_hosts.")"))))
+ 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.')')))
{
access_deny();
}
- $item_data = DBfetch(DBselect("select h.host,i.hostid,i.* from items i,hosts h ".
- " where i.itemid in (".(is_array($_REQUEST["itemid"]) ? implode(',', $_REQUEST["itemid"]) : $_REQUEST["itemid"]).") ".
- " and h.hostid=i.hostid "));
+ $item_data = DBfetch(DBselect('SELECT h.host,i.hostid,i.* '.
+ ' FROM items i,hosts h '.
+ ' WHERE i.itemid in ('.(is_array($_REQUEST["itemid"]) ? implode(',', $_REQUEST["itemid"]) : $_REQUEST["itemid"]).') '.
+ ' AND h.hostid=i.hostid '));
$item_type = $item_data["value_type"];
$l_header = null;
- if(!is_array($_REQUEST["itemid"]))
- {
+ if(!is_array($_REQUEST["itemid"])){
$main_header = $item_data["host"].": ".item_description($item_data["description"],$item_data["key_"]);
if(isset($_REQUEST["plaintext"]))
@@ -381,15 +375,16 @@ include_once "include/page_header.php";
}
- $sql = "select hst.host,i.itemid,i.key_,i.description,h.clock,h.value,i.valuemapid,h.timestamp,h.source,h.severity".
- " from history_log h, items i, hosts hst".
- " where hst.hostid=i.hostid and h.itemid=i.itemid".$sql_filter." and i.itemid in (".$itemid_lst.")".$cond_clock.
- " order by h.clock desc, h.id desc";
+ $sql = 'SELECT hst.host,i.itemid,i.key_,i.description,h.clock,h.value,i.valuemapid,h.timestamp,h.source,h.severity'.
+ ' FROM history_log h, items i, hosts hst'.
+ ' WHERE hst.hostid=i.hostid '.
+ ' AND h.itemid=i.itemid'.$sql_filter.
+ ' AND i.itemid in ('.$itemid_lst.')'.$cond_clock.
+ ' ORDER BY h.clock desc, h.id desc';
$result=DBselect($sql,$limit);
- if(!isset($_REQUEST["plaintext"]))
- {
+ if(!isset($_REQUEST['plaintext'])){
$table = new CTableInfo('...','log_history_table');
$table->SetHeader(array(S_TIMESTAMP,
$item_cout > 1 ? S_ITEM : null,
@@ -397,17 +392,14 @@ include_once "include/page_header.php";
$table->ShowStart(); // to solve memory leak we call 'Show' method by steps
}
- else
- {
+ else{
echo "<pre>\n";
}
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
$color_style = null;
- if(isset($_REQUEST["filter"]) && $_REQUEST["filter"]!="")
- {
+ if(isset($_REQUEST["filter"]) && $_REQUEST["filter"]!=""){
$contain = zbx_stristr($row["value"],$_REQUEST["filter"]) ? TRUE : FALSE;
if(!isset($_REQUEST["mark_color"])) $_REQUEST["mark_color"] = MARK_COLOR_RED;
@@ -417,8 +409,7 @@ include_once "include/page_header.php";
if((!$contain) && ($_REQUEST["filter_task"] == FILTER_TAST_INVERT_MARK))
$color_style = $_REQUEST["mark_color"];
- switch($color_style)
- {
+ switch($color_style){
case MARK_COLOR_RED: $color_style="mark_as_red"; break;
case MARK_COLOR_GREEN: $color_style="mark_as_green"; break;
case MARK_COLOR_BLUE: $color_style="mark_as_blue"; break;
@@ -430,21 +421,17 @@ include_once "include/page_header.php";
if($item_cout > 1)
array_push($new_row,$row["host"].":".item_description($row["description"],$row["key_"]));
- if($row["timestamp"] == 0)
- {
+ if($row["timestamp"] == 0){
array_push($new_row,new CCol("-","center"));
}
- else
- {
+ else{
array_push($new_row,date("Y.M.d H:i:s",$row["timestamp"]));
}
- if($row["source"] == "")
- {
+ if($row["source"] == ""){
array_push($new_row,new CCol("-","center"));
}
- else
- {
+ else{
array_push($new_row,$row["source"]);
}
@@ -459,27 +446,25 @@ include_once "include/page_header.php";
// array_push($new_row,htmlspecialchars($row["value"]));
array_push($new_row,htmlspecialchars(encode_log($row["value"])));
- if(!isset($_REQUEST["plaintext"]))
- {
+ if(!isset($_REQUEST["plaintext"])){
$crow = new CRow($new_row);
- if(is_null($color_style) && is_array($_REQUEST["itemid"]))
- {
+ if(is_null($color_style) && is_array($_REQUEST["itemid"])){
$min_color = 0x98;
$max_color = 0xF8;
$int_color = ($max_color - $min_color) / count($_REQUEST["itemid"]);
$int_color *= array_search($row["itemid"],$_REQUEST["itemid"]);
$int_color += $min_color;
$crow->AddOption("style","background-color: ".sprintf("#%X%X%X",$int_color,$int_color,$int_color));
- } else {
+ }
+ else {
$crow->SetClass($color_style);
}
$crow->Show(); // to solve memory leak we call 'Show' method for each element
}
- else
- {
+ else{
echo date("Y-m-d H:i:s",$row["clock"]);
echo "\t".$row["clock"]."\t".$row["value"]."\n";
}
@@ -489,39 +474,36 @@ include_once "include/page_header.php";
else
echo "</pre>";
}
- else
- {
- switch($item_type)
- {
+ else{
+ switch($item_type){
case ITEM_VALUE_TYPE_FLOAT: $h_table = "history"; break;
case ITEM_VALUE_TYPE_UINT64: $h_table = "history_uint"; break;
case ITEM_VALUE_TYPE_TEXT: $h_table = "history_text"; break;
default: $h_table = "history_str";
}
- $result = DBselect("select h.clock,h.value,i.valuemapid from $h_table h, items i".
- " where h.itemid=i.itemid and i.itemid=".$_REQUEST["itemid"].
- $cond_clock." order by clock desc",
+ $result = DBselect('SELECT h.clock,h.value,i.valuemapid '.
+ ' FROM '.$h_table.' h, items i '.
+ ' WHERE h.itemid=i.itemid '.
+ ' AND i.itemid='.$_REQUEST['itemid'].
+ $cond_clock.
+ ' ORDER BY clock desc',
$limit);
- if(!isset($_REQUEST["plaintext"]))
- {
+ if(!isset($_REQUEST["plaintext"])){
$table = new CTableInfo();
$table->SetHeader(array(S_TIMESTAMP, S_VALUE));
$table->AddOption('id','graph');
$table->ShowStart(); // to solve memory leak we call 'Show' method by steps
}
- else
- {
+ else{
echo "<pre>\n";
}
COpt::profiling_start("history");
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
- if($DB_TYPE == "ORACLE" && $item_type == ITEM_VALUE_TYPE_TEXT)
- {
+ if($DB_TYPE == "ORACLE" && $item_type == ITEM_VALUE_TYPE_TEXT){
if(isset($row["value"]))
$row["value"] = $row["value"]->load();
else
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 288a437b..fb774f30 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -995,8 +995,8 @@
'SELECT r.*,n.name as name FROM rights r, nodes n WHERE r.groupid='.$_REQUEST["usrgrpid"].
' AND r.type='.RESOURCE_TYPE_NODE.' AND r.id=n.nodeid',
'SELECT r.*, n.name as node_name, g.name as name FROM groups g '.
- ' left join rights r on r.type='.RESOURCE_TYPE_GROUP.' AND r.id=g.groupid '.
- ' left join nodes n on n.nodeid='.DBid2nodeid('g.groupid').
+ ' LEFT JOIN rights r on r.type='.RESOURCE_TYPE_GROUP.' AND r.id=g.groupid '.
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('g.groupid').
' WHERE r.groupid='.$_REQUEST["usrgrpid"],
);
foreach($sqls as $sql)
@@ -2327,10 +2327,12 @@
$comments = $trigger["comments"];
$url = $trigger["url"];
- $trigs=DBselect("SELECT t.triggerid,t.description,t.expression FROM triggers t,trigger_depends d".
- " WHERE t.triggerid=d.triggerid_up AND d.triggerid_down=".$_REQUEST["triggerid"]);
- while($trig=DBfetch($trigs))
- {
+ $trigs=DBselect('SELECT t.triggerid,t.description,t.expression '.
+ ' FROM triggers t,trigger_depends d '.
+ ' WHERE t.triggerid=d.triggerid_up '.
+ ' AND d.triggerid_down='.$_REQUEST['triggerid']);
+
+ while($trig=DBfetch($trigs)){
if(uint_in_array($trig["triggerid"],$dependencies)) continue;
array_push($dependencies,$trig["triggerid"]);
}
@@ -2417,11 +2419,14 @@
$frmTrig->Show();
}
- function insert_trigger_comment_form($triggerid)
- {
- $trigger = DBfetch(DBselect('SELECT t.*, h.* FROM triggers t, functions f, items i, hosts h '.
- ' WHERE t.triggerid='.$triggerid.' AND f.triggerid=t.triggerid AND f.itemid=i.itemid '.
- ' AND i.hostid=h.hostid '));
+ function insert_trigger_comment_form($triggerid){
+
+ $trigger = DBfetch(DBselect('SELECT t.*, h.* '.
+ ' FROM triggers t, functions f, items i, hosts h '.
+ ' WHERE t.triggerid='.$triggerid.
+ ' AND f.triggerid=t.triggerid '.
+ ' AND f.itemid=i.itemid '.
+ ' AND i.hostid=h.hostid '));
$frmComent = new CFormTable(S_COMMENTS." for ".$trigger['host']." : \"".expand_trigger_description_by_data($trigger)."\"");
$frmComent->SetHelp("web.tr_comments.comments.php");
@@ -2433,8 +2438,7 @@
$frmComent->Show();
}
- function insert_graph_form()
- {
+ function insert_graph_form(){
global $_REQUEST;
$frmGraph = new CFormTable(S_GRAPH,null,'post');
@@ -3734,7 +3738,7 @@ include_once 'include/discovery.inc.php';
if($resourceid > 0){
$result=DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ '.
' FROM hosts h,items i '.
- ' left join nodes n on n.nodeid='.DBid2nodeid('i.itemid').
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('i.itemid').
' WHERE h.hostid=i.hostid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
@@ -3797,7 +3801,7 @@ include_once 'include/discovery.inc.php';
if($resourceid > 0){
$result=DBselect('SELECT n.name as node_name,h.host,i.description,i.itemid,i.key_ '.
' FROM hosts h,items i '.
- ' left join nodes n on n.nodeid='.DBid2nodeid('i.itemid').
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('i.itemid').
' WHERE h.hostid=i.hostid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
@@ -4804,16 +4808,15 @@ include_once 'include/discovery.inc.php';
$frmEl->SetHelp("web.sysmap.host.php");
$frmEl->AddVar("sysmapid",$_REQUEST["sysmapid"]);
- if(isset($_REQUEST["selementid"]))
- {
+ if(isset($_REQUEST["selementid"])){
$frmEl->AddVar("selementid",$_REQUEST["selementid"]);
$element = get_sysmaps_element_by_selementid($_REQUEST["selementid"]);
$frmEl->SetTitle("Map element \"".$element["label"]."\"");
}
- if(isset($_REQUEST["selementid"]) && !isset($_REQUEST["form_refresh"]))
- {
+ if(isset($_REQUEST["selementid"]) && !isset($_REQUEST["form_refresh"])){
+
$elementid = $element["elementid"];
$elementtype = $element["elementtype"];
$label = $element["label"];
@@ -4826,8 +4829,8 @@ include_once 'include/discovery.inc.php';
$label_location = $element["label_location"];
if(is_null($label_location)) $label_location = -1;
}
- else
- {
+ else{
+
$elementid = get_request("elementid", 0);
$elementtype = get_request("elementtype", SYSMAP_ELEMENT_TYPE_HOST);
$label = get_request("label", "");
@@ -4842,17 +4845,19 @@ include_once 'include/discovery.inc.php';
$cmbType = new CComboBox("elementtype",$elementtype,"submit()");
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
- $allowed_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY);
+ $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_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
- $db_hosts = DBselect("SELECT DISTINCT n.name as node_name,h.hostid,h.host FROM hosts h".
- " left join nodes n on n.nodeid=".DBid2nodeid("h.hostid").
- " WHERE h.hostid not in(".$denyed_hosts.")".
- " order by node_name,h.host");
+ $db_hosts = DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host '.
+ ' FROM hosts h'.
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('h.hostid').
+ ' WHERE h.hostid IN ('.$available_hosts.')'.
+ ' ORDER BY node_name,h.host');
if($db_hosts)
$cmbType->AddItem(SYSMAP_ELEMENT_TYPE_HOST, S_HOST);
- $db_maps = DBselect("SELECT sysmapid FROM sysmaps WHERE sysmapid!=".$_REQUEST["sysmapid"]);
+ $db_maps = DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid!='.$_REQUEST['sysmapid']);
if(DBfetch($db_maps))
$cmbType->AddItem(SYSMAP_ELEMENT_TYPE_MAP, S_MAP);
@@ -4871,14 +4876,13 @@ include_once 'include/discovery.inc.php';
$cmbLocation->AddItem(3,S_TOP);
$frmEl->AddRow(S_LABEL_LOCATION,$cmbLocation);
- if($elementtype==SYSMAP_ELEMENT_TYPE_HOST)
- {
- $host = "";
+ if($elementtype==SYSMAP_ELEMENT_TYPE_HOST) {
+ $host = '';
$host_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host '.
' FROM hosts h '.
' LEFT JOIN nodes n ON n.nodeid='.DBid2nodeid("h.hostid").
- ' WHERE h.hostid not in('.$denyed_hosts.') '.
+ ' WHERE h.hostid IN ('.$available_hosts.') '.
' AND hostid='.$elementid.
' ORDER BY node_name,h.host'));
if($host_info)
@@ -4899,66 +4903,65 @@ include_once 'include/discovery.inc.php';
"T")
));
}
- elseif($elementtype==SYSMAP_ELEMENT_TYPE_MAP)
- {
+ else if($elementtype==SYSMAP_ELEMENT_TYPE_MAP){
$cmbMaps = new CComboBox("elementid",$elementid);
$db_maps = DBselect('SELECT DISTINCT n.name as node_name,s.sysmapid,s.name '.
' FROM sysmaps s'.
- ' left join nodes n on n.nodeid='.DBid2nodeid("s.sysmapid").
- ' order by node_name,s.name');
- while($db_map = DBfetch($db_maps))
- {
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('s.sysmapid').
+ ' ORDER BY node_name,s.name');
+ while($db_map = DBfetch($db_maps)){
if(!sysmap_accessible($db_map["sysmapid"],PERM_READ_ONLY)) continue;
$node_name = isset($db_map['node_name']) ? '('.$db_map['node_name'].') ' : '';
$cmbMaps->AddItem($db_map["sysmapid"],$node_name.$db_map["name"]);
}
$frmEl->AddRow(S_MAP, $cmbMaps);
}
- elseif($elementtype==SYSMAP_ELEMENT_TYPE_TRIGGER)
- {
+ else if($elementtype==SYSMAP_ELEMENT_TYPE_TRIGGER){
$trigger = "";
- $trigger_info = DBfetch(DBselect("SELECT DISTINCT n.name as node_name,h.hostid,h.host,t.*".
- " FROM triggers t left join functions f on t.triggerid=f.triggerid ".
- " left join items i on i.itemid=f.itemid left join hosts h on h.hostid=i.hostid ".
- " left join nodes n on n.nodeid=".DBid2nodeid("t.triggerid").
- " WHERE h.hostid not in (".$denyed_hosts.") AND t.triggerid=".$elementid.
- " order by node_name,h.host,t.description"));
+ $trigger_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host,t.*'.
+ ' FROM triggers t '.
+ ' LEFT JOIN functions f on t.triggerid=f.triggerid '.
+ ' LEFT JOIN items i on i.itemid=f.itemid '.
+ ' LEFT JOIN hosts h on h.hostid=i.hostid '.
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('t.triggerid').
+ ' WHERE t.triggerid='.$elementid.
+ ' AND t.triggerid IN ('.$available_triggers.') '.
+ ' ORDER BY node_name,h.host,t.description'));
if($trigger_info)
$trigger = expand_trigger_description_by_data($trigger_info);
else
$elementid=0;
- if($elementid==0)
- {
- $trigger = "";
+ if($elementid==0){
+ $trigger = '';
$elementid = 0;
}
- $frmEl->AddVar("elementid",$elementid);
+ $frmEl->AddVar('elementid',$elementid);
$frmEl->AddRow(S_TRIGGER, array(
- new CTextBox("trigger",$trigger,32,'yes'),
- new CButton("btn1",S_SELECT,"return PopUp('popup.php?dstfrm=".$frmEl->GetName().
+ new CTextBox('trigger',$trigger,32,'yes'),
+ new CButton('btn1',S_SELECT,"return PopUp('popup.php?dstfrm=".$frmEl->GetName().
"&dstfld1=elementid&dstfld2=trigger&srctbl=triggers&srcfld1=triggerid&srcfld2=description');",
"T")
));
}
- elseif($elementtype==SYSMAP_ELEMENT_TYPE_HOST_GROUP)
- {
- $group = "";
+ else if($elementtype==SYSMAP_ELEMENT_TYPE_HOST_GROUP){
+ $group = '';
- $group_info = DBfetch(DBselect("SELECT DISTINCT n.name as node_name,g.groupid,g.name FROM groups g ".
- " left join nodes n on n.nodeid=".DBid2nodeid("g.groupid").
- " WHERE g.groupid in (".$allowed_groups.") AND g.groupid=".$elementid.
- " order by node_name,g.name"));
+ $group_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name '.
+ ' FROM groups g '.
+ ' LEFT JOIN nodes n on n.nodeid='.DBid2nodeid('g.groupid').
+ ' WHERE g.groupid in ('.$available_groups.') '.
+ ' AND g.groupid='.$elementid.
+ ' ORDER BY node_name,g.name'));
if($group_info)
$group = $group_info["name"];
else
$elementid=0;
- if($elementid==0)
- {
+ if($elementid==0){
$group = "";
$elementid = 0;
}
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php
index a3c7ff08..a84b2139 100644
--- a/frontends/php/include/html.inc.php
+++ b/frontends/php/include/html.inc.php
@@ -65,16 +65,12 @@
{
$result = "";
- if(is_array($var))
- {
+ if(is_array($var)){
foreach($var as $id => $par)
- $result .= prepare_url($par,
- isset($varname) ? $varname."[".$id."]": $id
- );
+ $result .= prepare_url($par,isset($varname) ? $varname."[".$id."]": $id);
}
- else
- {
- $result = "&".$varname."=".urlencode($var);
+ else{
+ $result = '&'.$varname.'='.urlencode($var);
}
return $result;
}
@@ -100,6 +96,7 @@
if(isset($var)){
$result = prepare_url($var,$name);
}
+
return $result;
}
diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php
index 242f4871..0563cc37 100644
--- a/frontends/php/include/import.inc.php
+++ b/frontends/php/include/import.inc.php
@@ -36,13 +36,13 @@
$this->trigger = array('exist' => 0, 'missed' => 0);
$this->graph = array('exist' => 0, 'missed' => 0);
- $this->accessible_groups = get_accessible_groups_by_user($USER_DETAILS,
+ $this->available_groups = get_accessible_groups_by_user($USER_DETAILS,
PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
- $this->accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,
+ $this->available_hosts = get_accessible_hosts_by_user($USER_DETAILS,
PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
- $this->accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,
+ $this->available_nodes = get_accessible_nodes_by_user($USER_DETAILS,
PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
}
@@ -92,7 +92,7 @@
if($host_data = DBfetch(DBselect('select hostid from hosts'.
' where host='.zbx_dbstr($data['name']).
- ' and '.DBin_node('hostid',get_current_nodeid(false)))))
+ ' and '.DBin_node('hostid',get_current_nodeid(false)))))
{ /* exist */
if($this->host['exist']==1) /* skip */
{
@@ -100,7 +100,7 @@
info('Host ['.$data['name'].'] skipped - user rule');
break; // case
}
- if(!uint_in_array($host_data['hostid'], $this->accessible_hosts)){
+ if(!uint_in_array($host_data['hostid'], $this->available_hosts)){
error('Host ['.$data['name'].'] skipped - Access deny.');
break; // case
}
@@ -117,8 +117,8 @@
break; // case
}
-// if( count($this->accessible_nodes) > 0 ){
- if(!uint_in_array(get_current_nodeid(),$this->accessible_nodes)){
+// if( count($this->available_nodes) > 0 ){
+ if(!uint_in_array(get_current_nodeid(),$this->available_nodes)){
error('Host ['.$data['name'].'] skipped - Access deny.');
break; // case
}
@@ -183,7 +183,6 @@
global $USER_DETAILS;
$data = &$this->data[$name];
-
switch($name)
{
case XML_TAG_HOST:
@@ -243,7 +242,7 @@
break; // case
}
- if(!uint_in_array($group["groupid"], $this->accessible_groups))
+ if(!uint_in_array($group["groupid"], $this->available_groups))
{
error('Group ['.$this->element_data.'] skipped - Access deny.');
break; // case
@@ -287,7 +286,7 @@
break; // case
}
- if(!uint_in_array($template["hostid"], $this->accessible_hosts))
+ if(!uint_in_array($template["hostid"], $this->available_hosts))
{
error('Template ['.$this->element_data.'] skipped - Access deny.');
break; // case
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index 6c7c24e6..303bced6 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -77,8 +77,7 @@
* Eugene Grigorjev
*
*/
- function sysmap_accessible($sysmapid,$perm)
- {
+ function sysmap_accessible($sysmapid,$perm){
global $USER_DETAILS;
$result = false;
@@ -102,43 +101,42 @@
$result &= sysmap_accessible($se_data['elementid'], PERM_READ_ONLY);
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
- if(DBfetch(DBselect('SELECT triggerid FROM triggers WHERE triggerid='.$se_data['elementid']))){
- $sql = 'SELECT DISTINCT t.triggerid'.
- ' FROM triggers t,items i,functions f'.
- ' WHERE f.itemid=i.itemid '.
- ' AND t.triggerid=f.triggerid'.
- ' AND i.hostid NOT IN ('.$available_hosts.') '.
- ' AND t.triggerid='.$se_data['elementid'];
- if(DBfetch(DBselect($sql,1))){
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
+
+ $sql = 'SELECT t.triggerid '.
+ ' FROM triggers t'.
+ ' WHERE t.triggerid='.$se_data['elementid'].
+ ' AND t.triggerid NOT IN ('.$available_triggers.') ';
+ if(DBfetch(DBselect($sql,1))){
$result = false;
- }
- }
+ }
+
break;
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
- $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY, null, PERM_RES_IDS_ARRAY);
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY, null);
- $sql = 'SELECT groupid '.
- ' FROM groups '.
- ' WHERE groupid='.$se_data['elementid'];
+ $sql = 'SELECT g.groupid '.
+ ' FROM groups g '.
+ ' WHERE g.groupid='.$se_data['elementid'].
+ ' AND g.groupid NOT IN('.$available_groups.') ';
- if(DBfetch(DBselect($sql,1)) && !uint_in_array($se_data['elementid'],$available_groups)){
+ if(DBfetch(DBselect($sql,1))){
$result = false;
}
break;
}
}
}
- else
- {
- if(DBselect('select sysmapid from sysmaps where sysmapid='.$sysmapid.
- ' and '.DBin_node('sysmapid', get_current_nodeid($perm))))
+ else{
+ if(DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid='.$sysmapid.
+ ' AND '.DBin_node('sysmapid', get_current_nodeid($perm))))
$result = true;
}
return $result;
}
function get_sysmap_by_sysmapid($sysmapid){
- $row = DBfetch(DBselect("select * from sysmaps where sysmapid=".$sysmapid));
+ $row = DBfetch(DBselect('SELECT * FROM sysmaps WHERE sysmapid='.$sysmapid));
if($row){
return $row;
}
@@ -147,7 +145,7 @@
}
function get_sysmaps_element_by_selementid($selementid){
- $sql="select * from sysmaps_elements where selementid=$selementid";
+ $sql="select * FROM sysmaps_elements WHERE selementid=$selementid";
$result=DBselect($sql);
$row=DBfetch($result);
if($row){
@@ -181,7 +179,7 @@
{
return DBexecute("update sysmaps set name=".zbx_dbstr($name).",width=$width,height=$height,".
"backgroundid=".$backgroundid.",label_type=$label_type,".
- "label_location=$label_location where sysmapid=$sysmapid");
+ "label_location=$label_location WHERE sysmapid=$sysmapid");
}
// Delete System Map
@@ -194,16 +192,16 @@
while($rows = DBfetch($res)){
$result&=delete_link($rows['linkid']);
}
-// $result = DBexecute("delete from sysmaps_links where sysmapid=$sysmapid");
+// $result = DBexecute("delete FROM sysmaps_links WHERE sysmapid=$sysmapid");
// if(!$result) return $result;
- $result = DBexecute("delete from sysmaps_elements where sysmapid=$sysmapid");
+ $result = DBexecute("delete FROM sysmaps_elements WHERE sysmapid=$sysmapid");
if(!$result) return $result;
$result = rm4favorites('web.favorite.sysmapids',$sysmapd,ZBX_FAVORITES_ALL,'sysmapid');
if(!$result) return $result;
- return DBexecute("delete from sysmaps where sysmapid=$sysmapid");
+ return DBexecute("delete FROM sysmaps WHERE sysmapid=$sysmapid");
}
// LINKS
@@ -253,7 +251,7 @@
function delete_link($linkid){
$result = delete_all_link_triggers($linkid);
- $result&= DBexecute("delete from sysmaps_links where linkid=$linkid");
+ $result&= DBexecute("delete FROM sysmaps_links WHERE linkid=$linkid");
return $result;
}
@@ -304,8 +302,8 @@
if(bccomp($sysmapid ,$elementid)==0) return TRUE;
- $db_elements = DBselect("select elementid, elementtype from sysmaps_elements".
- " where sysmapid=$elementid");
+ $db_elements = DBselect("select elementid, elementtype FROM sysmaps_elements".
+ " WHERE sysmapid=$elementid");
while($element = DBfetch($db_elements))
{
@@ -341,7 +339,7 @@
return $selementid;
}
- # Update Element from system map
+ # Update Element FROM system map
function update_sysmap_element($selementid,$sysmapid,$elementid,$elementtype,
$label,$x,$y,$iconid_off,$iconid_unknown,$iconid_on,$url,$label_location)
@@ -363,7 +361,7 @@
/******************************************************************************
* *
- * Purpose: Delete Element from sysmap definition *
+ * Purpose: Delete Element FROM sysmap definition *
* *
* Comments: !!! Don't forget sync code with C !!! *
* *
@@ -382,7 +380,7 @@
if(!$result) return $result;
- return DBexecute("delete from sysmaps_elements where selementid=$selementid");
+ return DBexecute("delete FROM sysmaps_elements WHERE selementid=$selementid");
}
/******************************************************************************
@@ -391,8 +389,8 @@
* *
******************************************************************************/
function delete_sysmaps_elements_with_hostid($hostid){
- $db_elements = DBselect("select selementid from sysmaps_elements".
- " where elementid=$hostid and elementtype=".SYSMAP_ELEMENT_TYPE_HOST);
+ $db_elements = DBselect("select selementid FROM sysmaps_elements".
+ " WHERE elementid=$hostid AND elementtype=".SYSMAP_ELEMENT_TYPE_HOST);
while($db_element = DBfetch($db_elements)){
delete_sysmaps_element($db_element["selementid"]);
}
@@ -400,8 +398,8 @@
}
function delete_sysmaps_elements_with_sysmapid($sysmapid){
- $db_elements = DBselect("select selementid from sysmaps_elements".
- " where elementid=$sysmapid and elementtype=".SYSMAP_ELEMENT_TYPE_MAP);
+ $db_elements = DBselect("select selementid FROM sysmaps_elements".
+ " WHERE elementid=$sysmapid AND elementtype=".SYSMAP_ELEMENT_TYPE_MAP);
while($db_element = DBfetch($db_elements))
{
delete_sysmaps_element($db_element["selementid"]);
@@ -438,7 +436,7 @@
function get_png_by_selementid($selementid)
{
- $elements = DBselect("select * from sysmaps_elements where selementid=$selementid");
+ $elements = DBselect("select * FROM sysmaps_elements WHERE selementid=$selementid");
if(!$elements) return FALSE;
$element = DBfetch($elements);
@@ -474,26 +472,36 @@
$el_type =& $db_element["elementtype"];
$sql = array(
- SYSMAP_ELEMENT_TYPE_TRIGGER => 'select distinct t.triggerid, t.priority, t.value, t.description, t.expression, h.host '.
- 'from triggers t, items i, functions f, hosts h where t.triggerid='.$db_element['elementid'].
- ' and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid '.
- ' and h.status='.HOST_STATUS_MONITORED.' and i.status='.ITEM_STATUS_ACTIVE,
- SYSMAP_ELEMENT_TYPE_HOST_GROUP => 'select distinct t.triggerid, t.priority, t.value,'.
- ' t.description, t.expression, h.host, g.name as el_name '.
- ' from items i,functions f,triggers t,hosts h,hosts_groups hg,groups g '.
- ' where h.hostid=i.hostid and hg.groupid=g.groupid and g.groupid='.$db_element['elementid'].
- ' and hg.hostid=h.hostid and i.itemid=f.itemid'.
- ' and f.triggerid=t.triggerid and t.status='.TRIGGER_STATUS_ENABLED.
- ' and h.status='.HOST_STATUS_MONITORED.' and i.status='.ITEM_STATUS_ACTIVE,
- SYSMAP_ELEMENT_TYPE_HOST => 'select distinct t.triggerid, t.priority, t.value,'.
- ' t.description, t.expression, h.host, h.host as el_name'.
- ' from items i,functions f,triggers t,hosts h where h.hostid=i.hostid'.
- ' and i.hostid='.$db_element['elementid'].' and i.itemid=f.itemid'.
- ' and f.triggerid=t.triggerid and t.status='.TRIGGER_STATUS_ENABLED.
- ' and h.status='.HOST_STATUS_MONITORED.' and i.status='.ITEM_STATUS_ACTIVE
+ SYSMAP_ELEMENT_TYPE_TRIGGER => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host '.
+ ' FROM triggers t, items i, functions f, hosts h '.
+ ' WHERE t.triggerid='.$db_element['elementid'].
+ ' AND h.hostid=i.hostid '.
+ ' AND i.itemid=f.itemid '.
+ ' AND f.triggerid=t.triggerid '.
+ ' AND h.status='.HOST_STATUS_MONITORED.
+ ' AND i.status='.ITEM_STATUS_ACTIVE,
+ SYSMAP_ELEMENT_TYPE_HOST_GROUP => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host, g.name as el_name '.
+ ' FROM items i,functions f,triggers t,hosts h,hosts_groups hg,groups g '.
+ ' WHERE h.hostid=i.hostid '.
+ ' AND hg.groupid=g.groupid '.
+ ' AND g.groupid='.$db_element['elementid'].
+ ' AND hg.hostid=h.hostid '.
+ ' AND i.itemid=f.itemid'.
+ ' AND f.triggerid=t.triggerid '.
+ ' AND t.status='.TRIGGER_STATUS_ENABLED.
+ ' AND h.status='.HOST_STATUS_MONITORED.
+ ' AND i.status='.ITEM_STATUS_ACTIVE,
+ SYSMAP_ELEMENT_TYPE_HOST => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host, h.host as el_name'.
+ ' FROM items i,functions f,triggers t,hosts h WHERE h.hostid=i.hostid'.
+ ' AND i.hostid='.$db_element['elementid'].
+ ' AND i.itemid=f.itemid'.
+ ' AND f.triggerid=t.triggerid '.
+ ' AND t.status='.TRIGGER_STATUS_ENABLED.
+ ' AND h.status='.HOST_STATUS_MONITORED.
+ ' AND i.status='.ITEM_STATUS_ACTIVE
);
- if( isset($sql[$el_type]) )
- {
+
+ if( isset($sql[$el_type]) ){
$db_triggers = DBselect($sql[$el_type]);
$trigger = DBfetch($db_triggers);
if($trigger)
@@ -542,11 +550,11 @@
}
elseif($el_type==SYSMAP_ELEMENT_TYPE_MAP)
{
- $db_map = DBfetch(DBselect('select name from sysmaps where sysmapid='.$db_element["elementid"]));
+ $db_map = DBfetch(DBselect('select name FROM sysmaps WHERE sysmapid='.$db_element["elementid"]));
$el_name = $db_map['name'];
- $db_subelements = DBselect("select selementid from sysmaps_elements".
- " where sysmapid=".$db_element["elementid"]);
+ $db_subelements = DBselect("select selementid FROM sysmaps_elements".
+ " WHERE sysmapid=".$db_element["elementid"]);
while($db_subelement = DBfetch($db_subelements))
{// recursion
$inf = get_info_by_selementid($db_subelement["selementid"]);
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 71d02176..d3038e76 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -190,15 +190,13 @@ include_once "include/page_header.php";
S_HISTORY));
$table->ShowStart();
- $compare_host = ($_REQUEST['hostid'] > 0)?(' and h.hostid='.$_REQUEST['hostid']):'';
- $compare_host.= ($_REQUEST['groupid']> 0)?' AND hg.groupid ='.$_REQUEST['groupid']:'';
+ $compare_host = $_REQUEST['hostid']?' AND h.hostid='.$_REQUEST['hostid']:'';
+ $compare_host.= $_REQUEST['groupid']?' AND hg.hostid=h.hostid AND hg.groupid ='.$_REQUEST['groupid']:'';
- $any_app_exist = false;
-
$db_applications = DBselect('SELECT DISTINCT h.host,h.hostid,a.* '.
- ' FROM applications a, hosts h, hosts_groups hg '.
- ' WHERE a.hostid=h.hostid'.$compare_host.
- ' AND hg.hostid=h.hostid '.
+ ' FROM applications a, hosts h'.($_REQUEST['groupid']?', hosts_groups hg ':'').
+ ' WHERE a.hostid=h.hostid'.
+ $compare_host.
' AND h.hostid IN ('.$available_hosts.')'.
' AND h.status='.HOST_STATUS_MONITORED.
order_by('h.host,h.hostid','a.name,a.applicationid'));
@@ -216,7 +214,7 @@ include_once "include/page_header.php";
while($db_item = DBfetch($db_items)){
$description = item_description($db_item["description"],$db_item["key_"]);
- if( '' != $_REQUEST["select"] && !zbx_stristr($description, $_REQUEST["select"]) ) continue;
+ if(!empty($_REQUEST["select"]) && !zbx_stristr($description, $_REQUEST["select"]) ) continue;
++$item_cnt;
if(!uint_in_array($db_app["applicationid"],$_REQUEST["applications"]) && !isset($show_all_apps)) continue;
@@ -259,22 +257,26 @@ include_once "include/page_header.php";
$actions
)));
}
-
+
if($item_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"].
- url_param("groupid").url_param("hostid").url_param("applications").
+ url_param("groupid").
+ url_param("hostid").
+ url_param("applications").
url_param("select"));
}
else{
$link = new CLink(new CImg("images/general/closed.gif"),
"?open=1&applicationid=".$db_app["applicationid"].
- url_param("groupid").url_param("hostid").url_param("applications").
+ url_param("groupid").
+ url_param("hostid").
+ url_param("applications").
url_param("select"));
}
- $col = new CCol(array($link,SPACE,bold($db_app["name"]),SPACE."(".$item_cnt.SPACE.S_ITEMS.")"));
+ $col = new CCol(array($link,SPACE,bold($db_app["name"]),SPACE.'('.$item_cnt.SPACE.S_ITEMS.')'));
$col->SetColSpan(5);
$table->ShowRow(array(
@@ -283,21 +285,19 @@ include_once "include/page_header.php";
$col
));
- $any_app_exist = true;
-
foreach($app_rows as $row) $table->ShowRow($row);
}
}
$sql = 'SELECT DISTINCT h.host,h.hostid '.
- ' FROM hosts h, hosts_groups hg, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid'.
+ ' FROM hosts h'.($_REQUEST['groupid']?', hosts_groups hg ':'').', items i '.
+ ' LEFT JOIN items_applications ia ON ia.itemid=i.itemid'.
' WHERE ia.itemid is NULL '.
- ' AND hg.hostid=h.hostid '.
+ $compare_host.
' AND h.hostid=i.hostid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
- $compare_host.
' AND h.hostid in ('.$available_hosts.') '.
' ORDER BY h.host';
@@ -306,13 +306,13 @@ include_once "include/page_header.php";
while($db_appitem = DBfetch($db_appitems)){
$sql = 'SELECT h.host,h.hostid,i.* '.
- ' FROM hosts h, hosts_groups hg, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid'.
+ ' FROM hosts h'.($_REQUEST['groupid']?', hosts_groups hg ':'').', items i '.
+ ' LEFT JOIN items_applications ia ON ia.itemid=i.itemid'.
' WHERE ia.itemid is NULL '.
- ' AND hg.hostid=h.hostid '.
+ $compare_host.
' AND h.hostid=i.hostid '.
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
- $compare_host.
' AND h.hostid='.$db_appitem['hostid'].
' ORDER BY i.description,i.itemid';
@@ -324,10 +324,11 @@ include_once "include/page_header.php";
while($db_item = DBfetch($db_items)){
$description = item_description($db_item["description"],$db_item["key_"]);
- if( '' != $_REQUEST["select"] && !zbx_stristr($description, $_REQUEST["select"]) ) continue;
+ if(!empty($_REQUEST["select"]) && !zbx_stristr($description, $_REQUEST["select"]) ) continue;
++$item_cnt;
- if(!uint_in_array(0,$_REQUEST["applications"]) && $any_app_exist && !isset($show_all_apps)) continue;
+
+ if(!uint_in_array(0,$_REQUEST["applications"]) && !isset($show_all_apps)) continue;
if(isset($db_item["lastclock"]))
$lastclock=zbx_date2str(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]);
@@ -353,7 +354,7 @@ include_once "include/page_header.php";
$change=new CCol("-","center");
}
- if(($db_item["value_type"]==ITEM_VALUE_TYPE_FLOAT) ||($db_item["value_type"]==ITEM_VALUE_TYPE_UINT64)){
+ if(($db_item["value_type"]==ITEM_VALUE_TYPE_FLOAT) || ($db_item["value_type"]==ITEM_VALUE_TYPE_UINT64)){
$actions=new CLink(S_GRAPH,"history.php?action=showgraph&itemid=".$db_item["itemid"],"action");
}
else{
@@ -362,8 +363,8 @@ include_once "include/page_header.php";
array_push($app_rows, new CRow(array(
is_show_subnodes()?($item_cnt?SPACE:get_node_name_by_elid($db_item['itemid'])):null,
- $_REQUEST["hostid"] > 0 ? NULL : ($item_cnt?SPACE:$db_item["host"]),
- str_repeat(SPACE, ($any_app_exist ? 6 : 0)).$description,
+ $_REQUEST["hostid"]?NULL:($item_cnt?SPACE:$db_item["host"]),
+ str_repeat(SPACE, 6).$description,
$lastclock,
new CCol($lastvalue, $lastvalue == '-' ? 'center' : null),
$change,
@@ -386,7 +387,7 @@ include_once "include/page_header.php";
url_param("select"));
}
- $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS),SPACE."(".$item_cnt.SPACE.S_ITEMS.")"));
+ $col = new CCol(array($link,SPACE,bold(S_MINUS_OTHER_MINUS),SPACE.'('.$item_cnt.SPACE.S_ITEMS.')'));
$col->SetColSpan(5);
$table->ShowRow(array(
diff --git a/frontends/php/popup.php b/frontends/php/popup.php
index 0960b8d0..f9d47538 100644
--- a/frontends/php/popup.php
+++ b/frontends/php/popup.php
@@ -250,8 +250,7 @@ include_once "include/page_header.php";
validate_group(PERM_READ_LIST,$validation_param);
}
- $accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid(true));
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+ $available_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid(true));
$available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
$nodeid = get_current_nodeid();
@@ -260,42 +259,42 @@ include_once "include/page_header.php";
if(!isset($_REQUEST["hostid"]) || (bccomp($_REQUEST["hostid"], $only_hostid) != 0)) access_deny();
$hostid = $only_hostid;
}
- else
- {
+ else{
if(str_in_array($srctbl,array('hosts','host_group','triggers','logitems','items',
'applications','screens','slides','graphs','simple_graph',
'sysmaps','plain_text','screens2','overview','host_group_scr')))
{
- if(ZBX_DISTRIBUTED)
- {
+ if(ZBX_DISTRIBUTED){
$nodeid = get_request('nodeid', $nodeid);
$cmbNode = new CComboBox('nodeid', $nodeid, 'submit()');
- $db_nodes = DBselect('select * from nodes where nodeid in ('.$accessible_nodes.')');
- while($node_data = DBfetch($db_nodes))
- {
+ $db_nodes = DBselect('select * from nodes where nodeid in ('.$available_nodes.')');
+
+ while($node_data = DBfetch($db_nodes)){
$cmbNode->AddItem($node_data['nodeid'], $node_data['name']);
if((bccomp($nodeid , $node_data['nodeid']) == 0)) $ok = true;
}
$frmTitle->AddItem(array(SPACE,S_NODE,SPACE,$cmbNode));
}
- }
+ }
+
if(!isset($ok)) $nodeid = get_current_nodeid();
unset($ok);
- if(str_in_array($srctbl,array('hosts','templates','triggers','logitems','items','applications','host_templates','graphs','simple_graph','plain_text')))
- {
+ if(str_in_array($srctbl,array('hosts','templates','triggers','logitems','items','applications','host_templates','graphs','simple_graph','plain_text'))){
$groupid = get_request('groupid',get_profile('web.popup.groupid',0));
$cmbGroups = new CComboBox('groupid',$groupid,'submit()');
$cmbGroups->AddItem(0,S_ALL_SMALL);
- $db_groups = DBselect('SELECT DISTINCT g.groupid,g.name from groups g, hosts_groups hg, hosts h '.
- ' where '.DBin_node('g.groupid', $nodeid).
- ' AND g.groupid=hg.groupid AND hg.hostid=h.hostid'.
- ' and h.hostid in ('.$available_hosts.')'.
- ' and h.status in ('.implode(',', $host_status).')'.
- ' order by name');
- while($group = DBfetch($db_groups))
- {
+ $db_groups = DBselect('SELECT DISTINCT g.groupid,g.name '.
+ ' FROM groups g, hosts_groups hg, hosts h '.
+ ' WHERE '.DBin_node('g.groupid', $nodeid).
+ ' AND g.groupid=hg.groupid '.
+ ' AND hg.hostid=h.hostid'.
+ ' AND h.hostid in ('.$available_hosts.')'.
+ ' AND h.status in ('.implode(',', $host_status).')'.
+ ' ORDER BY name');
+
+ while($group = DBfetch($db_groups)){
$cmbGroups->AddItem($group["groupid"],$group["name"]);
if((bccomp($groupid , $group["groupid"]) == 0)) $ok = true;
}
@@ -304,50 +303,48 @@ include_once "include/page_header.php";
if(!isset($ok) || $groupid == 0) unset($groupid);
unset($ok);
}
- if(str_in_array($srctbl,array("help_items")))
- {
+
+ if(str_in_array($srctbl,array("help_items"))){
$itemtype = get_request("itemtype",get_profile("web.popup.itemtype",0));
$cmbTypes = new CComboBox("itemtype",$itemtype,"submit()");
foreach($allowed_item_types as $type)
$cmbTypes->AddItem($type, item_type2str($type));
$frmTitle->AddItem(array(S_TYPE,SPACE,$cmbTypes));
}
- if(str_in_array($srctbl,array("triggers","logitems","items",'applications','graphs','simple_graph','plain_text')))
- {
+
+ if(str_in_array($srctbl,array("triggers","logitems","items",'applications','graphs','simple_graph','plain_text'))){
$hostid = get_request("hostid",get_profile("web.popup.hostid",0));
$cmbHosts = new CComboBox("hostid",$hostid,"submit()");
$sql = 'SELECT DISTINCT h.hostid,h.host FROM hosts h';
- if(isset($groupid))
- {
+ if(isset($groupid)){
$sql .= ',hosts_groups hg WHERE '.
' h.hostid=hg.hostid AND hg.groupid='.$groupid.' AND ';
}
- else
- {
+ else{
$sql .= ' WHERE ';
$cmbHosts->AddItem(0,S_ALL_SMALL);
}
$sql .= DBin_node('h.hostid', $nodeid).
- ' and h.hostid in ('.$available_hosts.')'.
- ' and h.status in ('.implode(',', $host_status).')'.
+ ' and h.hostid in ('.$available_hosts.')'.
+ ' and h.status in ('.implode(',', $host_status).')'.
' order by host,h.hostid';
$db_hosts = DBselect($sql);
- while($host = DBfetch($db_hosts))
- {
+
+ while($host = DBfetch($db_hosts)){
$cmbHosts->AddItem($host["hostid"],$host["host"]);
if(bccomp($hostid , $host["hostid"]) == 0) $ok = true;
}
+
$frmTitle->AddItem(array(SPACE,S_HOST,SPACE,$cmbHosts));
update_profile("web.popup.hostid",$hostid);
if(!isset($ok) || $hostid == 0) unset($hostid);
unset($ok);
}
- if(str_in_array($srctbl,array("triggers","hosts")))
- {
+ if(str_in_array($srctbl,array("triggers","hosts"))){
$btnEmpty = new CButton("empty",S_EMPTY,
get_window_opener($dstfrm, $dstfld1, 0).
get_window_opener($dstfrm, $dstfld2, '').
@@ -361,22 +358,22 @@ include_once "include/page_header.php";
show_table_header($page["title"], $frmTitle);
?>
<?php
- if($srctbl == "hosts")
- {
+ if($srctbl == "hosts"){
$table = new CTableInfo(S_NO_HOSTS_DEFINED);
$table->SetHeader(array(S_HOST,S_DNS,S_IP,S_PORT,S_STATUS,S_AVAILABILITY));
- $sql = "SELECT DISTINCT h.* from hosts h";
+ $sql = 'SELECT DISTINCT h.* FROM hosts h';
+
if(isset($groupid))
- $sql .= ",hosts_groups hg where hg.groupid=".$groupid.
- " AND h.hostid=hg.hostid AND ";
+ $sql .= ',hosts_groups hg WHERE hg.groupid='.$groupid.
+ ' AND h.hostid=hg.hostid AND ';
else
- $sql .= " where ";
+ $sql .= ' WHERE ';
$sql .= DBin_node('h.hostid', $nodeid).
- ' and h.hostid in ('.$available_hosts.')'.
- ' and h.status in ('.implode(',', $host_status).')'.
- " order by h.host,h.hostid";
+ ' and h.hostid in ('.$available_hosts.')'.
+ ' and h.status in ('.implode(',', $host_status).')'.
+ ' order by h.host,h.hostid';
$db_hosts = DBselect($sql);
@@ -915,7 +912,7 @@ include_once "include/page_header.php";
$table = new CTableInfo(S_NO_NODES_DEFINED);
$table->SetHeader(S_NAME);
- $result = DBselect('SELECT DISTINCT * from nodes where nodeid in ('.$accessible_nodes.')');
+ $result = DBselect('SELECT DISTINCT * from nodes where nodeid in ('.$available_nodes.')');
while($row = DBfetch($result))
{
@@ -1000,8 +997,8 @@ include_once "include/page_header.php";
}
$table->Show();
}
- else if($srctbl == "simple_graph")
- {
+ else if($srctbl == "simple_graph"){
+
$table = new CTableInfo(S_NO_ITEMS_DEFINED);
$table->SetHeader(array(
(isset($hostid) ? null : S_HOST),
@@ -1018,7 +1015,7 @@ include_once "include/page_header.php";
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
' AND '.DBin_node('i.itemid', $nodeid).
- ' AND h.hostid not in ('.$denyed_hosts.')';
+ ' AND h.hostid IN ('.$available_hosts.')';
if(isset($hostid))
$sql .= ' AND h.hostid='.$hostid;
@@ -1095,8 +1092,8 @@ include_once "include/page_header.php";
}
$table->Show();
}
- else if($srctbl == "plain_text")
- {
+ else if($srctbl == "plain_text"){
+
$table = new CTableInfo(S_NO_ITEMS_DEFINED);
$table->SetHeader(array(
(isset($hostid) ? null : S_HOST),
@@ -1113,7 +1110,7 @@ include_once "include/page_header.php";
' AND h.status='.HOST_STATUS_MONITORED.
' AND i.status='.ITEM_STATUS_ACTIVE.
' AND '.DBin_node('i.itemid', $nodeid).
- ' AND h.hostid not in ('.$denyed_hosts.')';
+ ' AND h.hostid IN ('.$available_hosts.')';
if(isset($hostid))
$sql .= ' AND h.hostid='.$hostid;
diff --git a/frontends/php/popup_trexpr.php b/frontends/php/popup_trexpr.php
index 53d0af5b..27e9e69f 100644
--- a/frontends/php/popup_trexpr.php
+++ b/frontends/php/popup_trexpr.php
@@ -183,16 +183,17 @@ include_once "include/page_header.php";
$dstfld1 = get_request("dstfld1", ''); // destination field
$itemid = get_request("itemid", 0);
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
- if($item_data = DBfetch(DBselect("select distinct h.host,i.* from hosts h,items i ".
- " where h.hostid=i.hostid and h.hostid not in (".$denyed_hosts.")".
- " and i.itemid=".$itemid)))
+ 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 i.itemid='.$itemid)))
{
$description = $item_data['host'].':'.item_description($item_data["description"],$item_data["key_"]);
}
- else
- {
+ else{
$itemid = 0;
$description = '';
}
diff --git a/frontends/php/report3.php b/frontends/php/report3.php
index 660dfeab..bb071dd7 100644
--- a/frontends/php/report3.php
+++ b/frontends/php/report3.php
@@ -45,23 +45,19 @@ include_once "include/page_header.php";
define("YEAR_LEFT_SHIFT", 5);
?>
<?php
- if(! (DBfetch(DBselect('select serviceid from services where serviceid='.$_REQUEST["serviceid"]))) )
- {
+ if(!DBfetch(DBselect('select serviceid from services where serviceid='.$_REQUEST["serviceid"]))){
fatal_error(S_NO_IT_SERVICE_DEFINED);
}
-
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
- if( !($service = DBfetch(DBselect('SELECT s.* '.
- ' FROM services s '.
- ' LEFT JOIN triggers t on s.triggerid=t.triggerid '.
- ' LEFT JOIN functions f on t.triggerid=f.triggerid '.
- ' LEFT JOIN items i on f.itemid=i.itemid '.
- ' WHERE (i.hostid is NULL or i.hostid not in ('.$denyed_hosts.')) '.
- ' AND '.DBin_node('s.serviceid').
- ' AND s.serviceid='.$_REQUEST['serviceid']
- ))))
- {
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
+
+ $sql = 'SELECT s.* '.
+ ' FROM services s '.
+ ' WHERE s.serviceid='.$_REQUEST['serviceid'].
+ ' AND (s.triggerid IS NULL OR s.triggerid IN ('.$available_triggers.')) '.
+ ' AND DBin_node('s.serviceid')';
+
+ if(!$service = DBfetch(DBselect($sql))){
access_deny();
}
?>
@@ -78,10 +74,11 @@ include_once "include/page_header.php";
$form->AddItem(array(SPACE.S_PERIOD.SPACE, $cmbPeriod));
$cmbYear = new CComboBox("year", $year, "submit();");
- for($y = (date("Y") - YEAR_LEFT_SHIFT); $y <= date("Y"); $y++)
- {
+
+ for($y = (date("Y") - YEAR_LEFT_SHIFT); $y <= date("Y"); $y++){
$cmbYear->AddItem($y, $y);
}
+
$form->AddItem(array(SPACE.S_YEAR.SPACE, $cmbYear));
show_table_header(array(
@@ -97,50 +94,48 @@ include_once "include/page_header.php";
$header = array(S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA);
- switch($period)
- {
- case "yearly":
- $from = (date("Y") - YEAR_LEFT_SHIFT);
- $to = date("Y");
- array_unshift($header, new CCol(S_YEAR,"center"));
- function get_time($y) { return mktime(0,0,0,1,1,$y); }
- function format_time($t){ return date("Y", $t); }
- function format_time2($t){ return null; };
- break;
- case "monthly":
- $from = 1;
- $to = 12;
- array_unshift($header, new CCol(S_MONTH,"center"));
- function get_time($m) { global $year; return mktime(0,0,0,$m,1,$year); }
- function format_time($t){ return date("M Y",$t); }
- function format_time2($t){ return null; };
- break;
- case "dayly":
- $from = 1;
- $to = 365;
- array_unshift($header, new CCol(S_DAY,"center"));
- function get_time($d) { global $year; return mktime(0,0,0,1,$d,$year); }
- function format_time($t){ return date("d M Y",$t); }
- function format_time2($t){ return null; };
- break;
- case "weekly":
- default:
- $from = 0;
- $to = 52;
- array_unshift($header,new CCol(S_FROM,"center"),new CCol(S_TILL,"center"));
- function get_time($w) {
- global $year;
-
- $time = mktime(0,0,0,1, 1, $year);
- $wd = date("w", $time);
- $wd = $wd == 0 ? 6 : $wd - 1;
-
- return ($time + ($w*7 - $wd)*24*3600);
- }
- function format_time($t){ return date("d M Y H:i",$t); }
- function format_time2($t){ return format_time($t); };
- break;
-
+ switch($period){
+ case "yearly":
+ $from = (date("Y") - YEAR_LEFT_SHIFT);
+ $to = date("Y");
+ array_unshift($header, new CCol(S_YEAR,"center"));
+ function get_time($y) { return mktime(0,0,0,1,1,$y); }
+ function format_time($t){ return date("Y", $t); }
+ function format_time2($t){ return null; };
+ break;
+ case "monthly":
+ $from = 1;
+ $to = 12;
+ array_unshift($header, new CCol(S_MONTH,"center"));
+ function get_time($m) { global $year; return mktime(0,0,0,$m,1,$year); }
+ function format_time($t){ return date("M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "dayly":
+ $from = 1;
+ $to = 365;
+ array_unshift($header, new CCol(S_DAY,"center"));
+ function get_time($d) { global $year; return mktime(0,0,0,1,$d,$year); }
+ function format_time($t){ return date("d M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "weekly":
+ default:
+ $from = 0;
+ $to = 52;
+ array_unshift($header,new CCol(S_FROM,"center"),new CCol(S_TILL,"center"));
+ function get_time($w) {
+ global $year;
+
+ $time = mktime(0,0,0,1, 1, $year);
+ $wd = date("w", $time);
+ $wd = $wd == 0 ? 6 : $wd - 1;
+
+ return ($time + ($w*7 - $wd)*24*3600);
+ }
+ function format_time($t){ return date("d M Y H:i",$t); }
+ function format_time2($t){ return format_time($t); };
+ break;
}
$table->SetHeader($header);
diff --git a/frontends/php/tr_comments.php b/frontends/php/tr_comments.php
index f93ef1e8..bfb35422 100644
--- a/frontends/php/tr_comments.php
+++ b/frontends/php/tr_comments.php
@@ -50,26 +50,27 @@ include_once "include/page_header.php";
check_fields($fields);
?>
<?php
- $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
- if(! ($db_data = DBfetch(DBselect('select * from items i, functions f '.
- ' where i.itemid=f.itemid and f.triggerid='.$_REQUEST["triggerid"].
- " and i.hostid not in (".$denyed_hosts.")".
- ' and '.DBin_node('f.triggerid')
- ))))
+ $available_triggers = get_accessible_triggers(PERM_READ_ONLY, null, get_current_nodeid());
+
+ if(!$db_data = DBfetch(DBselect('SELECT * '.
+ ' FROM items i, functions f '.
+ ' WHERE i.itemid=f.itemid '.
+ ' AND f.triggerid='.$_REQUEST["triggerid"].
+ ' AND f.triggerid IN ('.$available_triggers.') '.
+ ' AND '.DBin_node('f.triggerid')
+ )))
{
access_deny();
}
$trigger_hostid = $db_data['hostid'];
- if(isset($_REQUEST["save"]))
- {
- $result = update_trigger_comments($_REQUEST["triggerid"],$_REQUEST["comments"]);
+ if(isset($_REQUEST["save"])){
+ $result = update_trigger_comments($_REQUEST["triggerid"],$_REQUEST["comments"]);
show_messages($result, S_COMMENT_UPDATED, S_CANNOT_UPDATE_COMMENT);
- if($result)
- {
+ if($result){
add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_TRIGGER,
S_TRIGGER." [".$_REQUEST["triggerid"]."] [".expand_trigger_description($_REQUEST["triggerid"])."] ".
S_COMMENTS." [".$_REQUEST["comments"]."]");