summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-08-13 08:22:32 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-08-13 08:22:32 +0000
commitabaab90a1c9d3367f1ef636557cfe8e661716749 (patch)
tree3e266e5523a635c45a7e7ef6d4571e7323f26065 /frontends/php/include
parent8901654871973b4267f106a97183001189189c82 (diff)
downloadzabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.tar.gz
zabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.tar.xz
zabbix-abaab90a1c9d3367f1ef636557cfe8e661716749.zip
- merger rev. 4546:4547 of branches/1.4.j [developed data monitoring of multiple nodes]
git-svn-id: svn://svn.zabbix.com/trunk@4549 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/actions.inc.php28
-rw-r--r--frontends/php/include/classes/ctriggerinfo.mod.php4
-rw-r--r--frontends/php/include/config.inc.php108
-rw-r--r--frontends/php/include/db.inc.php72
-rw-r--r--frontends/php/include/discovery.inc.php7
-rw-r--r--frontends/php/include/events.inc.php31
-rw-r--r--frontends/php/include/forms.inc.php100
-rw-r--r--frontends/php/include/hosts.inc.php13
-rw-r--r--frontends/php/include/import.inc.php25
-rw-r--r--frontends/php/include/items.inc.php5
-rw-r--r--frontends/php/include/locales/en_gb.inc.php2
-rw-r--r--frontends/php/include/maps.inc.php8
-rw-r--r--frontends/php/include/nodes.inc.php14
-rw-r--r--frontends/php/include/page_header.php54
-rw-r--r--frontends/php/include/perm.inc.php18
-rw-r--r--frontends/php/include/screens.inc.php16
-rw-r--r--frontends/php/include/services.inc.php4
-rw-r--r--frontends/php/include/triggers.inc.php16
-rw-r--r--frontends/php/include/users.inc.php17
19 files changed, 356 insertions, 186 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index f8e90ab1..6d878a7f 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -28,8 +28,8 @@ include_once 'include/discovery.inc.php';
$result = false;
- if(DBselect("select actionid from actions where actionid=".$actionid.
- " and ".DBid2nodeid('actionid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ if ( DBselect('select actionid from actions where actionid='.$actionid.
+ ' and '.DBin_node('actionid')) )
{
$result = true;
@@ -603,14 +603,14 @@ include_once 'include/discovery.inc.php';
function validate_condition($conditiontype, $value)
{
- global $USER_DETAILS, $ZBX_CURNODEID;
+ global $USER_DETAILS;
switch($conditiontype)
{
case CONDITION_TYPE_HOST_GROUP:
if(!in_array($value,
get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY)))
{
error(S_INCORRECT_GROUP);
return false;
@@ -627,7 +627,7 @@ include_once 'include/discovery.inc.php';
case CONDITION_TYPE_HOST:
if(!in_array($value,
get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY)))
{
error(S_INCORRECT_HOST);
return false;
@@ -684,7 +684,7 @@ include_once 'include/discovery.inc.php';
function validate_operation($operation)
{
- global $USER_DETAILS, $ZBX_CURNODEID;
+ global $USER_DETAILS;
switch($operation['operationtype'])
{
@@ -719,7 +719,7 @@ include_once 'include/discovery.inc.php';
case OPERATION_TYPE_GROUP_REMOVE:
if(!in_array($operation['objectid'],
get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY)))
{
error(S_INCORRECT_GROUP);
return false;
@@ -729,7 +729,7 @@ include_once 'include/discovery.inc.php';
case OPERATION_TYPE_TEMPLATE_REMOVE:
if(!in_array($operation['objectid'],
get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY)))
{
error(S_INCORRECT_HOST);
return false;
@@ -782,12 +782,21 @@ include_once 'include/discovery.inc.php';
"a.error from alerts a,media_type mt,functions f,items i ".
" where mt.mediatypeid=a.mediatypeid and a.triggerid=f.triggerid and f.itemid=i.itemid ".
" and i.hostid not in (".$denyed_hosts.")".
+ ' and '.DBin_node('a.alertid').
" order by a.clock".
" desc",
10*$start+$num);
$table = new CTableInfo(S_NO_ACTIONS_FOUND);
- $table->SetHeader(array(S_TIME, S_TYPE, S_STATUS, S_RECIPIENTS, S_MESSAGE, S_ERROR));
+ $table->SetHeader(array(
+ is_show_subnodes() ? S_NODES : null,
+ S_TIME,
+ S_TYPE,
+ S_STATUS,
+ S_RECIPIENTS,
+ S_MESSAGE,
+ S_ERROR
+ ));
$col=0;
$skip=$start;
while(($row=DBfetch($result))&&($col<$num))
@@ -821,6 +830,7 @@ include_once 'include/discovery.inc.php';
$error=new CSpan($row["error"],"on");
}
$table->AddRow(array(
+ get_node_name_by_elid($row['alertid']),
new CCol($time, 'top'),
new CCol($row["description"], 'top'),
new CCol($status, 'top'),
diff --git a/frontends/php/include/classes/ctriggerinfo.mod.php b/frontends/php/include/classes/ctriggerinfo.mod.php
index 0f9c4b20..ad15c181 100644
--- a/frontends/php/include/classes/ctriggerinfo.mod.php
+++ b/frontends/php/include/classes/ctriggerinfo.mod.php
@@ -28,14 +28,12 @@
function CTriggersInfo($style = STYLE_HORISONTAL)
{
- global $ZBX_CURNODEID;
-
$this->style = null;
parent::CTable(NULL,"triggers_info");
$this->SetOrientation($style);
$this->show_header = true;
- $this->nodeid = $ZBX_CURNODEID;
+ $this->nodeid = get_current_nodeid();
}
function SetOrientation($value)
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index b60bacbb..46472344 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -176,41 +176,124 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
function init_nodes()
{
/* Init CURRENT NODE ID */
- global $USER_DETAILS;
- global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID;
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $_REQUEST,
+ $USER_DETAILS,
+ $ZBX_LOCALNODEID, $ZBX_LOCMASTERID,
+ $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_CURMASTERID,
+ $ZBX_NODES,
+ $ZBX_WITH_SUBNODES;
+
+ $ZBX_CURRENT_SUBNODES = array();
+ $ZBX_NODES = array();
if(!defined('ZBX_PAGE_NO_AUTHERIZATION') && ZBX_DISTRIBUTED)
{
- $ZBX_CURNODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node
+ $ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node
+ $ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false); // Show elements from subnodes
+
if(isset($_REQUEST['switch_node']))
{
if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$_REQUEST['switch_node'])))
{
- $ZBX_CURNODEID = $_REQUEST['switch_node'];
+ $ZBX_CURRENT_NODEID = $_REQUEST['switch_node'];
}
unset($node_data);
}
- if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$ZBX_CURNODEID)))
+ if(isset($_REQUEST['show_subnodes']))
+ {
+ $ZBX_WITH_SUBNODES = !empty($_REQUEST['show_subnodes']);
+ }
+
+ if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$ZBX_CURRENT_NODEID)))
{
$ZBX_CURMASTERID = $node_data['masterid'];
}
- if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)) <= 0)
+ $ZBX_NODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, null, PERM_RES_DATA_ARRAY);
+
+ if ( !isset($ZBX_NODES[$ZBX_CURRENT_NODEID]) )
{
$denyed_page_requested = true;
- $ZBX_CURNODEID = $ZBX_LOCALNODEID;
+ $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
}
+
+ foreach ( $ZBX_NODES as $nodeid => $node_data )
+ {
+ for ( $curr_node = &$node_data;
+ $curr_node['masterid'] != 0 &&
+ $curr_node['masterid'] != $ZBX_CURRENT_NODEID;
+ $curr_node = &$ZBX_NODES[$curr_node['masterid']]
+ );
+
+ if ( $curr_node['masterid'] == $ZBX_CURRENT_NODEID )
+ {
+ $ZBX_CURRENT_SUBNODES[$nodeid] = $nodeid;
+ }
+ }
- zbx_set_post_cookie('zbx_current_nodeid',$ZBX_CURNODEID);
+ zbx_set_post_cookie('zbx_current_nodeid',$ZBX_CURRENT_NODEID);
+ zbx_set_post_cookie('zbx_with_subnodes',$ZBX_WITH_SUBNODES);
}
else
{
- $ZBX_CURNODEID = $ZBX_LOCALNODEID;
+ $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID;
$ZBX_CURMASTERID = $ZBX_LOCMASTERID;
+ $ZBX_WITH_SUBNODES = false;
+ }
+
+ $ZBX_CURRENT_SUBNODES[$ZBX_CURRENT_NODEID] = $ZBX_CURRENT_NODEID;
+
+ if ( count($ZBX_CURRENT_SUBNODES) < 2 && !defined('ZBX_DISABLE_SUBNODES') )
+ define('ZBX_DISABLE_SUBNODES', 1);
+ }
+
+ function get_current_nodeid( $forse_with_subnodes = null, $perm = null )
+ {
+ global $ZBX_CURRENT_NODEID, $ZBX_CURRENT_SUBNODES, $ZBX_WITH_SUBNODES;
+
+ if ( !isset($ZBX_CURRENT_NODEID) ) init_nodes();
+
+ $result = ( is_show_subnodes($forse_with_subnodes) ? $ZBX_CURRENT_SUBNODES : $ZBX_CURRENT_NODEID );
+
+ if ( !is_null($perm) )
+ {
+ global $USER_DETAILS;
+
+ $result = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY, null, null, $result);
}
+
+ return $result;
+ }
+
+ function get_node_name_by_elid($id_val, $forse_with_subnodes = null)
+ {
+ global $ZBX_NODES;
+
+ if ( ! is_show_subnodes($forse_with_subnodes) )
+ return null;
+
+ $nodeid = id2nodeid($id_val);
+
+ if ( !isset($ZBX_NODES[$nodeid]) )
+ return null;
+
+ return '['.$ZBX_NODES[$nodeid]['name'].'] ';
+ }
+
+ function is_show_subnodes($forse_with_subnodes = null)
+ {
+ global $ZBX_WITH_SUBNODES;
+
+ if ( is_null($forse_with_subnodes) )
+ {
+ if ( defined('ZBX_DISABLE_SUBNODES') )
+ $forse_with_subnodes = false;
+ else
+ $forse_with_subnodes = $ZBX_WITH_SUBNODES;
+ }
+ return $forse_with_subnodes;
}
function access_deny()
@@ -924,8 +1007,6 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
function update_config($event_history,$alert_history,$refresh_unsupported,$work_period,$alert_usrgrpid)
{
- global $ZBX_CURNODEID;
-
$update = array();
if(!is_null($event_history))
@@ -965,8 +1046,7 @@ function TODO($msg) { echo "TODO: ".$msg.BR; } // DEBUG INFO!!!
}
return DBexecute('update config set '.implode(',',$update).
- ' where '.DBid2nodeid('configid')."=".$ZBX_CURNODEID);
-
+ ' where '.DBin_node('configid', get_current_nodeid(false)));
}
function &get_table_header($col1, $col2=SPACE)
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index a55254a9..d142e309 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -480,40 +480,80 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") {
function id2nodeid($id_var)
{
- return (int)bcdiv("$id_var","100000000000000");
+ return (int)bcdiv("$id_var",'100000000000000');
}
- function get_dbid($table,$field)
+ function DBin_node( $id_name, $nodes = null )
{
- global $ZBX_CURNODEID;
+ if ( is_null($nodes) ) $nodes = get_current_nodeid();
- if(!isset($ZBX_CURNODEID)) init_nodes();
+ if ( empty($nodes) ) $nodes = 0;
-/* $row=DBfetch(DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")"));
- if($row && !is_null($row["id"]))
+ if ( is_array($nodes) )
{
- return bcadd($row["id"],1);
+ $nodes = implode(',', $nodes);
}
- else
+ else if ( is_string($nodes) )
+ {
+ if ( !eregi('([0-9\,]+)', $nodes ) )
+ fatal_error('Incorrect "nodes" for "DBin_node". Passed ['.$nodes.']');
+ }
+ else if ( !is_numeric($nodes) )
{
- return bcadd(bcmul($ZBX_CURNODEID,"100000000000000"),1);
- }*/
+ fatal_error('Incorrect type of "nodes" for "DBin_node". Passed ['.gettype($nodes).']');
+ }
+
+ return (' '.DBid2nodeid($id_name).' in ('.$nodes.') ');
+ }
+
+ function in_node( $id_var, $nodes = null )
+ {
+ if ( is_null($nodes) ) $nodes = get_current_nodeid();
+ if ( empty($nodes) ) $nodes = 0;
+
+ if ( is_numeric($nodes) )
+ {
+ $nodes = array($nodes);
+ }
+ else if ( is_string($nodes) )
+ {
+ if ( !eregi('([0-9\,]+)', $nodes ) )
+ fatal_error('Incorrect "nodes" for "in_node". Passed ['.$nodes.']');
+
+ $nodes = explode(',', $nodes);
+ }
+ else if ( !is_array($nodes) )
+ {
+ fatal_error('Incorrect type of "nodes" for "in_node". Passed ['.gettype($nodes).']');
+ }
+
+ return in_array(id2nodeid($id_var), $nodes);
+ }
+
+ function get_dbid($table,$field)
+ {
+ $nodeid = get_current_nodeid(false);
$found = false;
do
{
- $row = DBfetch(DBselect("select nextid from ids where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'"));
+ $row = DBfetch(DBselect('select nextid from ids '.
+ ' where nodeid='.$nodeid.
+ ' and table_name=\''.$table.'\' '.
+ ' and field_name=\''.$field.'\''));
+
if(!$row || is_null($row["nextid"]))
{
- $row=DBfetch(DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")"));
+ $row=DBfetch(DBselect("select max($field) as id from $table where ".DBin_node($field, $nodeid)));
if(!$row || is_null($row["id"]))
{
- DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($ZBX_CURNODEID,'$table','$field',".bcadd(bcmul($ZBX_CURNODEID,"100000000000000"),1).")");
+ DBexecute("insert into ids (nodeid,table_name,field_name,nextid) ".
+ " values ($nodeid,'$table','$field',".bcadd(bcmul($nodeid,"100000000000000"),1).")");
}
else
{
- DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($ZBX_CURNODEID,'$table','$field',".$row["id"].")");
+ DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($nodeid,'$table','$field',".$row["id"].")");
}
continue;
}
@@ -521,9 +561,9 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") {
{
$ret1 = $row["nextid"];
- DBexecute("update ids set nextid=nextid+1 where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'");
+ DBexecute("update ids set nextid=nextid+1 where nodeid=$nodeid and table_name='$table' and field_name='$field'");
- $row = DBfetch(DBselect("select nextid from ids where nodeid=$ZBX_CURNODEID and table_name='$table' and field_name='$field'"));
+ $row = DBfetch(DBselect("select nextid from ids where nodeid=$nodeid and table_name='$table' and field_name='$field'"));
if(!$row || is_null($row["nextid"]))
{
/* Should never be here */
diff --git a/frontends/php/include/discovery.inc.php b/frontends/php/include/discovery.inc.php
index a44dc398..23636ac1 100644
--- a/frontends/php/include/discovery.inc.php
+++ b/frontends/php/include/discovery.inc.php
@@ -24,13 +24,12 @@
function check_right_on_discovery($permission)
{
global $USER_DETAILS;
- global $ZBX_CURNODEID;
if( $USER_DETAILS['type'] >= USER_TYPE_ZABBIX_ADMIN )
{
- $accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY);
-
- if( in_array($ZBX_CURNODEID, $accessible_nodes) )
+ if ( 0 == count(
+ get_accessible_nodes_by_user($USER_DETAILS, $permission, null, PERM_RES_IDS_ARRAY, get_current_nodeid())
+ ))
return true;
}
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index ee27102e..ac38ce40 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -29,15 +29,12 @@
}
}
- function get_history_of_triggers_events($start,$num, $groupid=0, $hostid=0, $nodeid=null)
+ function get_history_of_triggers_events($start,$num, $groupid=0, $hostid=0)
{
- global $ZBX_CURNODEID;
global $USER_DETAILS;
$show_unknown = get_profile('web.events.show_unknown',0);
- if(is_null($nodeid)) $nodeid = $ZBX_CURNODEID;
-
$sql_from = $sql_cond = "";
if($hostid > 0)
@@ -56,7 +53,7 @@
$result = DBselect('SELECT DISTINCT t.triggerid,t.priority,t.description,h.host,e.clock,e.value '.
' FROM events e, triggers t, functions f, items i, hosts h '.$sql_from.
- ' WHERE '.DBid2nodeid('t.triggerid').'='.$nodeid.
+ ' WHERE '.DBin_node('t.triggerid').
' AND e.objectid=t.triggerid and e.object='.EVENT_OBJECT_TRIGGER.
' AND t.triggerid=f.triggerid and f.itemid=i.itemid '.
' AND i.hostid=h.hostid '.$sql_cond.' and h.status='.HOST_STATUS_MONITORED.
@@ -64,7 +61,14 @@
);
$table = new CTableInfo(S_NO_EVENTS_FOUND);
- $table->SetHeader(array(S_TIME, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY));
+ $table->SetHeader(array(
+ S_TIME,
+ is_show_subnodes() ? S_NODE : null,
+ $hostid == 0 ? S_HOST : null,
+ S_DESCRIPTION,
+ S_VALUE,
+ S_SEVERITY
+ ));
$accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
@@ -94,8 +98,12 @@
$table->AddRow(array(
date("Y.M.d H:i:s",$row["clock"]),
+ get_node_name_by_elid($row['triggerid']),
$hostid == 0 ? $row['host'] : null,
- new CLink(expand_trigger_description_by_data($row),"tr_events.php?triggerid=".$row["triggerid"],"action"),
+ new CLink(
+ expand_trigger_description_by_data($row),
+ "tr_events.php?triggerid=".$row["triggerid"],"action"
+ ),
$value,
new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"]))));
$col++;
@@ -103,13 +111,8 @@
return $table;
}
- function get_history_of_discovery_events($start,$num,$nodeid=null)
+ function get_history_of_discovery_events($start,$num)
{
- global $ZBX_CURNODEID;
- global $USER_DETAILS;
-
- if(is_null($nodeid)) $nodeid = $ZBX_CURNODEID;
-
$db_events = DBselect('select distinct e.source,e.object,e.objectid,e.clock,e.value from events e'.
' where e.source='.EVENT_SOURCE_DISCOVERY.' order by e.clock desc',
10*($start+$num)
@@ -119,8 +122,6 @@
$table->SetHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
$col=0;
- $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
-
$skip = $start;
while(($event_data = DBfetch($db_events))&&($col<$num))
{
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 89b29fc3..06df821f 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -28,6 +28,8 @@
function insert_slideshow_form()
{
+ global $_REQUEST;
+
$form = new CFormTable(S_SLIDESHOW, null, 'post');
$form->SetHelp('config_advanced.php');
@@ -159,6 +161,8 @@
function insert_drule_form()
{
+ global $_REQUEST;
+
$frm_title = S_DISCOVERY_RULE;
if(isset($_REQUEST['druleid']))
@@ -341,6 +345,8 @@
function insert_httptest_form()
{
+ global $_REQUEST;
+
$form = new CFormTable(S_SCENARIO, null, 'post');
$form->SetHelp("web.webmon.httpconf.php");
@@ -532,7 +538,9 @@
function insert_node_form()
{
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $_REQUEST;
+
+ global $ZBX_CURMASTERID;
$frm_title = S_NODE;
@@ -576,7 +584,7 @@
$slave_trends = get_request('slave_trends',365);
$node_type = get_request('node_type', ZBX_NODE_REMOTE);
- $masterid = get_request('masterid', $ZBX_CURNODEID);
+ $masterid = get_request('masterid', get_current_nodeid(false));
}
$master_node = DBfetch(DBselect('select name from nodes where nodeid='.$masterid));
@@ -665,6 +673,8 @@
# Insert form for User
function insert_user_form($userid,$profile=0)
{
+ global $_REQUEST;
+
$frm_title = S_USER;
if(isset($userid))
{
@@ -938,7 +948,6 @@
function insert_usergroups_form()
{
global $_REQUEST;
- global $ZBX_CURNODEID;
$frm_title = S_USER_GROUP;
if(isset($_REQUEST["usrgrpid"]))
@@ -1173,7 +1182,7 @@
function insert_item_selection_form()
{
- global $ZBX_CURNODEID;
+ global $_REQUEST;
if(isset($_REQUEST['form_refresh']) && isset($_REQUEST['select']))
{
@@ -1455,7 +1464,6 @@
{
global $_REQUEST;
global $USER_DETAILS;
- global $ZBX_CURNODEID;
$frmItem = new CFormTable(S_ITEM,"items.php","post");
$frmItem->SetHelp("web.items.item.php");
@@ -1826,9 +1834,12 @@
{
$cmbMap = new CComboBox("valuemapid",$valuemapid);
$cmbMap->AddItem(0,S_AS_IS);
- $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID);
+ $db_valuemaps = DBselect('select * from valuemaps where '.DBin_node('valuemapid'));
while($db_valuemap = DBfetch($db_valuemaps))
- $cmbMap->AddItem($db_valuemap["valuemapid"],$db_valuemap["name"]);
+ $cmbMap->AddItem(
+ $db_valuemap["valuemapid"],
+ get_node_name_by_elid($db_valuemap["valuemapid"]).$db_valuemap["name"]
+ );
}
$link = new CLink("throw map","config.php?config=6","action");
@@ -1896,11 +1907,14 @@
$cmbGroups = new CComboBox("add_groupid",$add_groupid);
$groups=DBselect("select distinct groupid,name from groups ".
- "where groupid in (".get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,$ZBX_CURNODEID).") ".
+ "where groupid in (".get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid()).") ".
" order by name");
while($group=DBfetch($groups))
{
- $cmbGroups->AddItem($group["groupid"],$group["name"]);
+ $cmbGroups->AddItem(
+ $group["groupid"],
+ get_node_name_by_elid($group["groupid"]).$group["name"]
+ );
}
$frmItem->AddRow(S_GROUP,$cmbGroups);
@@ -1922,7 +1936,6 @@
{
global $_REQUEST;
global $USER_DETAILS;
- global $ZBX_CURNODEID;
$frmItem = new CFormTable(S_ITEM,null,'post');
$frmItem->SetHelp("web.items.item.php");
@@ -2086,9 +2099,12 @@
$cmbMap = new CComboBox('valuemapid',$valuemapid);
$cmbMap->AddItem(0,S_AS_IS);
- $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID);
+ $db_valuemaps = DBselect('select * from valuemaps where '.DBin_node('valuemapid'));
while($db_valuemap = DBfetch($db_valuemaps))
- $cmbMap->AddItem($db_valuemap["valuemapid"],$db_valuemap["name"]);
+ $cmbMap->AddItem(
+ $db_valuemap["valuemapid"],
+ get_node_name_by_elid($db_valuemap["valuemapid"]).$db_valuemap["name"]
+ );
$link = new CLink("throw map","config.php?config=6","action");
$link->AddOption("target","_blank");
@@ -2209,6 +2225,8 @@
# Insert form for Trigger
function insert_trigger_form()
{
+ global $_REQUEST;
+
$frmTrig = new CFormTable(S_TRIGGER,"triggers.php");
$frmTrig->SetHelp("config_triggers.php");
@@ -2587,6 +2605,8 @@
function insert_graphitem_form()
{
+ global $_REQUEST;
+
$frmGItem = new CFormTable(S_NEW_ITEM_FOR_THE_GRAPH);
$frmGItem->SetName('graph_item');
$frmGItem->SetHelp("web.graph.item.php");
@@ -2726,6 +2746,8 @@
function insert_value_mapping_form()
{
+ global $_REQUEST;
+
$frmValmap = new CFormTable(S_VALUE_MAP);
$frmValmap->SetHelp("web.mapping.php");
$frmValmap->AddVar("config",get_request("config",6));
@@ -2812,7 +2834,6 @@
include_once 'include/discovery.inc.php';
global $_REQUEST;
- global $ZBX_CURNODEID;
$uid=null;
@@ -3349,6 +3370,8 @@ include_once 'include/discovery.inc.php';
function insert_media_type_form()
{
+ global $_REQUEST;
+
$type = get_request("type",0);
$description = get_request("description","");
$smtp_server = get_request("smtp_server","localhost");
@@ -3424,6 +3447,8 @@ include_once 'include/discovery.inc.php';
function insert_image_form()
{
+ global $_REQUEST;
+
$frmImages = new CFormTable(S_IMAGE,"config.php","post","multipart/form-data");
$frmImages->SetHelp("web.config.images.php");
$frmImages->AddVar("config",get_request("config",3));
@@ -3810,7 +3835,6 @@ include_once 'include/discovery.inc.php';
{ /* NOTE: only NEW media is acessed */
global $_REQUEST;
- global $ZBX_CURNODEID;
$severity = get_request("severity",array(0,1,2,3,4,5));
$sendto = get_request("sendto","");
@@ -3825,10 +3849,13 @@ include_once 'include/discovery.inc.php';
$cmbType = new CComboBox("mediatypeid",$mediatypeid);
$types=DBselect("select mediatypeid,description from media_type".
- " where ".DBid2nodeid("mediatypeid")."=".$ZBX_CURNODEID." order by type");
+ ' where '.DBin_node('mediatypeid').' order by type');
while($type=DBfetch($types))
{
- $cmbType->AddItem($type["mediatypeid"],$type["description"]);
+ $cmbType->AddItem(
+ $type["mediatypeid"],
+ get_node_name_by_elid($type["mediatypeid"]).$type["description"]
+ );
}
$frmMedia->AddRow(S_TYPE,$cmbType);
@@ -3896,8 +3923,6 @@ include_once 'include/discovery.inc.php';
function insert_other_parameters_form()
{
- global $ZBX_CURNODEID;
-
$config=select_config();
$frmHouseKeep = new CFormTable(S_OTHER_PARAMETERS,'config.php');
@@ -3910,10 +3935,13 @@ include_once 'include/discovery.inc.php';
$cmbUsrGrp = new CComboBox('alert_usrgrpid', $config['alert_usrgrpid']);
$cmbUsrGrp->AddItem(0, S_NONE);
$result=DBselect('select usrgrpid,name from usrgrp'.
- ' where '.DBid2nodeid('usrgrpid').'='.$ZBX_CURNODEID.
+ ' where '.DBin_node('usrgrpid').
' order by name');
while($row=DBfetch($result))
- $cmbUsrGrp->AddItem($row['usrgrpid'], $row['name']);
+ $cmbUsrGrp->AddItem(
+ $row['usrgrpid'],
+ get_node_name_by_elid($row['usrgrpid']).$row['name']
+ );
$frmHouseKeep->AddRow(S_USER_GROUP_FOR_DATABASE_DOWN_MESSAGE,$cmbUsrGrp);
$frmHouseKeep->AddItemToBottomRow(new CButton('save',S_SAVE));
@@ -3922,7 +3950,6 @@ include_once 'include/discovery.inc.php';
function insert_host_form($show_only_tmp=0)
{
- global $ZBX_CURNODEID;
global $USER_DETAILS;
global $_REQUEST;
@@ -3981,7 +4008,7 @@ include_once 'include/discovery.inc.php';
// add groups
$db_groups=DBselect("select distinct groupid from hosts_groups where hostid=".$_REQUEST["hostid"].
" and groupid in (".
- get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,$ZBX_CURNODEID).
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid()).
") ");
while($db_group=DBfetch($db_groups)){
if(in_array($db_group["groupid"],$groups)) continue;
@@ -4031,7 +4058,7 @@ include_once 'include/discovery.inc.php';
$db_groups=DBselect("select distinct groupid,name from groups ".
" where groupid in (".
- get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,$ZBX_CURNODEID).
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid()).
") order by name");
while($db_group=DBfetch($db_groups))
{
@@ -4042,7 +4069,7 @@ include_once 'include/discovery.inc.php';
null,
$db_group["groupid"]
),
- $db_group["name"]
+ get_node_name_by_elid($db_group["groupid"]).$db_group["name"]
),
BR);
}
@@ -4184,7 +4211,6 @@ include_once 'include/discovery.inc.php';
{
global $_REQUEST;
global $USER_DETAILS;
- global $ZBX_CURNODEID;
$hosts = get_request("hosts",array());
$frm_title = S_HOST_GROUP;
@@ -4224,11 +4250,14 @@ include_once 'include/discovery.inc.php';
$cmbHosts = new CListBox("hosts[]",$hosts,10);
$db_hosts=DBselect("select distinct hostid,host from hosts".
" where status<>".HOST_STATUS_DELETED.
- " and hostid in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,$ZBX_CURNODEID).")".
+ " and hostid in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,get_current_nodeid()).")".
" order by host");
while($db_host=DBfetch($db_hosts))
{
- $cmbHosts->AddItem($db_host["hostid"],$db_host["host"]);
+ $cmbHosts->AddItem(
+ $db_host["hostid"],
+ get_node_name_by_elid($db_host["hostid"]).$db_host["host"]
+ );
}
$frmHostG->AddRow(S_HOSTS,$cmbHosts);
@@ -4252,6 +4281,8 @@ include_once 'include/discovery.inc.php';
# Insert host profile ReadOnly form
function insert_host_profile_form()
{
+ global $_REQUEST;
+
$frmHostP = new CFormTable(S_HOST_PROFILE);
$frmHostP->SetHelp("web.host_profile.php");
@@ -4366,7 +4397,6 @@ include_once 'include/discovery.inc.php';
function insert_map_form()
{
global $_REQUEST;
- global $ZBX_CURNODEID;
$frm_title = "New system map";
@@ -4408,10 +4438,13 @@ include_once 'include/discovery.inc.php';
$cmbImg = new CComboBox("backgroundid",$backgroundid);
$cmbImg->AddItem(0,"No image...");
- $result=DBselect("select * from images where imagetype=2 and ".DBid2nodeid("imageid")."=".$ZBX_CURNODEID." order by name");
+ $result=DBselect('select * from images where imagetype=2 and '.DBin_node('imageid').' order by name');
while($row=DBfetch($result))
{
- $cmbImg->AddItem($row["imageid"],$row["name"]);
+ $cmbImg->AddItem(
+ $row["imageid"],
+ get_node_name_by_elid($row["imageid"]).$row["name"]
+ );
}
$frmMap->AddRow(S_BACKGROUND_IMAGE,$cmbImg);
@@ -4447,7 +4480,6 @@ include_once 'include/discovery.inc.php';
function insert_map_element_form()
{
- global $ZBX_CURNODEID;
global $USER_DETAILS;
$frmEl = new CFormTable("New map element","sysmap.php");
@@ -4623,9 +4655,11 @@ include_once 'include/discovery.inc.php';
$cmbIconOff = new CComboBox("iconid_off",$iconid_off);
$cmbIconOn = new CComboBox("iconid_on",$iconid_on);
$cmbIconUnknown = new CComboBox("iconid_unknown",$iconid_unknown);
- $result = DBselect("select * from images where imagetype=1 and ".DBid2nodeid("imageid")."=".$ZBX_CURNODEID." order by name");
+ $result = DBselect('select * from images where imagetype=1 and '.DBin_node('imageid').' order by name');
while($row=DBfetch($result))
{
+ $row["name"] = get_node_name_by_elid($row["imageid"]).$row["name"];
+
$cmbIconOff->AddItem($row["imageid"],$row["name"]);
$cmbIconOn->AddItem($row["imageid"],$row["name"]);
$cmbIconUnknown->AddItem($row["imageid"],$row["name"]);
@@ -4653,6 +4687,8 @@ include_once 'include/discovery.inc.php';
function insert_map_link_form()
{
+ global $_REQUEST;
+
$frmCnct = new CFormTable("New connector","sysmap.php");
$frmCnct->SetHelp("web.sysmap.connector.php");
$frmCnct->AddVar("sysmapid",$_REQUEST["sysmapid"]);
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index 1edecfb4..eae56b7a 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -184,8 +184,6 @@ require_once "include/items.inc.php";
*/
function db_save_host($host,$port,$status,$useip,$dns,$ip,$templates,$hostid=null)
{
- global $ZBX_CURNODEID;
-
if( !eregi('^'.ZBX_EREG_HOST_FORMAT.'$', $host) )
{
error("Incorrect characters used for Hostname");
@@ -201,7 +199,7 @@ require_once "include/items.inc.php";
if(DBfetch(DBselect(
"select * from hosts where host=".zbx_dbstr($host).
- ' and '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID.
+ ' and '.DBin_node('hostid', get_current_nodeid(false)).
(isset($hostid) ? ' and hostid<>'.$hostid : '')
)))
{
@@ -591,7 +589,6 @@ require_once "include/items.inc.php";
}
global $USER_DETAILS;
- global $ZBX_CURNODEID;
$first_hostid_in_group = 0;
@@ -628,7 +625,7 @@ require_once "include/items.inc.php";
if($groupid > 0)
{
- if($only_current_node) $with_node = " and ".DBid2nodeid('g.groupid')."=".$ZBX_CURNODEID." ";
+ $with_node = " and ".DBin_node('g.groupid', get_current_nodeid(!$only_current_node));
if(!DBfetch(DBselect("select distinct g.groupid from groups g, hosts_groups hg, hosts h".$item_table.
" where hg.groupid=g.groupid and h.hostid=hg.hostid and h.hostid in (".$accessed_hosts.") ".
@@ -653,7 +650,7 @@ require_once "include/items.inc.php";
if($groupid != 0)
{
- if($only_current_node) $with_node = " and ".DBid2nodeid('hg.hostid')."=".$ZBX_CURNODEID." ";
+ $with_node = " and ".DBin_node('hg.hostid', get_current_nodeid(!$only_current_node));
if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
" where hg.groupid=".$groupid." and hg.hostid=".$hostid.$with_node)))
@@ -664,7 +661,7 @@ require_once "include/items.inc.php";
$witth_group = " and hg.hostid=h.hostid and hg.groupid=".$groupid;
}
- if($only_current_node) $with_node = " and ".DBid2nodeid('h.hostid')."=".$ZBX_CURNODEID." ";
+ $with_node = " and ".DBin_node('h.hostid',get_current_nodeid(!$only_current_node));
if($db_host = DBfetch(DBselect("select distinct h.hostid,h.host from hosts h ".$item_table.$group_table.
" where h.hostid in (".$accessed_hosts.") "
@@ -678,8 +675,6 @@ require_once "include/items.inc.php";
if($hostid > 0)
{
- if($only_current_node) $with_node = " and ".DBid2nodeid('h.hostid')."=".$ZBX_CURNODEID." ";
-
if(!DBfetch(DBselect("select distinct h.hostid from hosts h".$item_table.
" where h.hostid=".$hostid.$with_host_status.$with_items.$with_node.
" and h.hostid in (".$accessed_hosts.") ")))
diff --git a/frontends/php/include/import.inc.php b/frontends/php/include/import.inc.php
index e9f9349f..fe18026d 100644
--- a/frontends/php/include/import.inc.php
+++ b/frontends/php/include/import.inc.php
@@ -25,7 +25,7 @@
{
function CZabbixXMLImport()
{
- global $USER_DETAILS, $ZBX_CURNODEID;
+ global $USER_DETAILS;
$this->main_node= null;
$this->sub_node = null;
@@ -37,13 +37,13 @@
$this->graph = array('exist' => 0, 'missed' => 0);
$this->accessible_groups = get_accessible_groups_by_user($USER_DETAILS,
- PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, $ZBX_CURNODEID);
+ PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
$this->accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,
- PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, $ZBX_CURNODEID);
+ PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
$this->accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,
- PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, $ZBX_CURNODEID);
+ PERM_READ_WRITE, null, PERM_RES_IDS_ARRAY, get_current_nodeid());
}
function CharacterData($parser, $data)
@@ -76,8 +76,6 @@
return false;
}
- global $ZBX_CURNODEID;
-
$data = &$this->data[$name];
foreach($attrs as $id => $val)
@@ -94,7 +92,7 @@
if($host_data = DBfetch(DBselect('select hostid from hosts'.
' where host='.zbx_dbstr($data['name']).
- ' and '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID)))
+ ' and '.DBin_node('hostid',get_current_nodeid(false)))))
{ /* exist */
if($this->host['exist']==1) /* skip */
{
@@ -119,7 +117,7 @@
break; // case
}
- if(!in_array($ZBX_CURNODEID, $this->accessible_nodes)){
+ if( count($this->accessible_nodes) > 0 ){
error('Host ['.$data['name'].'] skipped - Access deny.');
break; // case
}
@@ -180,7 +178,6 @@
}
global $USER_DETAILS;
- global $ZBX_CURNODEID;
$data = &$this->data[$name];
@@ -208,7 +205,7 @@
break; //case
if(!($group = DBfetch(DBselect('select groupid, name from groups'.
- ' where '.DBid2nodeid('groupid').'='.$ZBX_CURNODEID.
+ ' where '.DBin_node('groupid',get_current_nodeid(false)).
' and name='.zbx_dbstr($this->element_data)))))
{
error('Missed group ['.$this->element_data.']');
@@ -232,7 +229,7 @@
break; //case
if(!($application = DBfetch(DBselect('select applicationid from applications'.
- ' where '.DBid2nodeid('applicationid').'='.$ZBX_CURNODEID.
+ ' where '.DBin_node('applicationid',get_current_nodeid(false)).
' and name='.zbx_dbstr($this->element_data).
' and hostid='.$this->data[XML_TAG_HOST]['hostid']))))
{
@@ -252,7 +249,7 @@
if(!($template = DBfetch(DBselect('SELECT DISTINCT host, hostid '.
' FROM hosts'.
- ' WHERE '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID.
+ ' WHERE '.DBin_node('hostid').
' AND host='.zbx_dbstr($this->element_data)))))
{
error('Missed template ['.$this->element_data.']');
@@ -307,7 +304,7 @@
if(!empty($data['valuemap']))
{
if( $valuemap = DBfetch(DBselect('select valuemapid from valuemaps '.
- ' where '.DBid2nodeid('valuemapid').'='.$ZBX_CURNODEID.
+ ' where '.DBin_node('valuemapid', get_current_nodeid(false)).
' and name='.zbx_dbstr($data['valuemap']))) )
{
$data['valuemapid'] = $valuemap['valuemapid'];
@@ -321,7 +318,7 @@
if($item = DBfetch(DBselect('select itemid,valuemapid,templateid from items'.
' where key_='.zbx_dbstr($data['key']).
' and hostid='.$this->data[XML_TAG_HOST]['hostid'].' and '.
- DBid2nodeid('itemid').'='.$ZBX_CURNODEID)))
+ DBin_node('itemid', get_current_nodeid(false)))))
{ /* exist */
if($this->item['exist']==1) /* skip */
{
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index d2a45d30..6e6cab02 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -838,7 +838,7 @@
* Comments:
*
*/
- function get_items_data_overview($groupid, $nodeid)
+ function get_items_data_overview($groupid)
{
global $USER_DETAILS;
@@ -856,7 +856,7 @@ COpt::profiling_start('prepare data');
' i.description, t.priority, i.valuemapid, t.value as tr_value, t.triggerid '.
' 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 ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $nodeid).') '.
+ ' h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, get_current_nodeid()).') '.
' and h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.status='.ITEM_STATUS_ACTIVE.
' order by i.description,i.itemid');
@@ -864,6 +864,7 @@ COpt::profiling_start('prepare data');
unset($hosts);
while($row = DBfetch($result))
{
+ $row['host'] = get_node_name_by_elid($row['hostid']).$row['host'];
$hosts[$row['host']] = $row['host'];
$items[item_description($row["description"],$row["key_"])][$row['host']] = array(
'itemid' => $row['itemid'],
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index 827cc08e..7ea7cdbc 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -182,6 +182,8 @@
'S_NODE_DELETED'=> 'Node deleted',
'S_CANNOT_DELETE_NODE'=> 'Cannot delete node',
'S_CURRENT_NODE'=> 'Current node',
+ 'S_CURRENT_NODE_ONLY'=> 'Current node only',
+ 'S_WITH_SUBNODES'=> 'With subnodes',
// acknow.php
'S_ACKNOWLEDGES'=> 'Acknowledges',
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index 802a64b3..7ade4c92 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -84,8 +84,8 @@
$result = false;
- if($db_result = DBselect("select * from sysmaps_elements where sysmapid=".$sysmapid.
- " and ".DBid2nodeid('sysmapid')." not in (".get_accessible_nodes_by_user($USER_DETAILS,$perm,PERM_MODE_LT).")"))
+ if($db_result = DBselect('select * from sysmaps_elements where sysmapid='.$sysmapid.
+ ' and '.DBin_node('sysmapid', get_current_nodeid($perm))))
{
$result = true;
@@ -127,8 +127,8 @@
}
else
{
- if(DBselect("select sysmapid from sysmaps where sysmapid=".$sysmapid.
- " and ".DBid2nodeid('sysmapid')." not in (".get_accessible_nodes_by_user($USER_DETAILS,$perm,PERM_MODE_LT).")"))
+ if(DBselect('select sysmapid from sysmaps where sysmapid='.$sysmapid.
+ ' and '.DBin_node('sysmapid', get_current_nodeid($perm))))
$result = true;
}
return $result;
diff --git a/frontends/php/include/nodes.inc.php b/frontends/php/include/nodes.inc.php
index b8e14035..19987371 100644
--- a/frontends/php/include/nodes.inc.php
+++ b/frontends/php/include/nodes.inc.php
@@ -22,11 +22,11 @@
<?php
function detect_node_type($node_data)
{
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $ZBX_CURMASTERID;
- if($node_data['nodeid'] == $ZBX_CURNODEID) $node_type = ZBX_NODE_LOCAL;
- else if($node_data['nodeid'] == $ZBX_CURMASTERID) $node_type = ZBX_NODE_MASTER;
- else if($node_data['masterid'] == $ZBX_CURNODEID) $node_type = ZBX_NODE_REMOTE;
+ if($node_data['nodeid'] == get_current_nodeid(false)) $node_type = ZBX_NODE_LOCAL;
+ else if($node_data['nodeid'] == $ZBX_CURMASTERID) $node_type = ZBX_NODE_MASTER;
+ else if($node_data['masterid'] == get_current_nodeid(false)) $node_type = ZBX_NODE_REMOTE;
else $node_type = -1;
return $node_type;
@@ -48,7 +48,7 @@
function add_node($new_nodeid,$name,$timezone,$ip,$port,$slave_history,$slave_trends,$node_type)
{
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $ZBX_CURMASTERID;
if( !eregi('^'.ZBX_EREG_NODE_FORMAT.'$', $name) )
{
@@ -59,7 +59,7 @@
switch($node_type)
{
case ZBX_NODE_REMOTE:
- $masterid = $ZBX_CURNODEID;
+ $masterid = get_current_nodeid(false);
$nodetype = 0;
break;
case ZBX_NODE_MASTER:
@@ -94,7 +94,7 @@
if($result && $node_type == ZBX_NODE_MASTER)
{
- DBexecute('update nodes set masterid='.$new_nodeid.' where nodeid='.$ZBX_CURNODEID);
+ DBexecute('update nodes set masterid='.$new_nodeid.' where nodeid='.get_current_nodeid(false));
$ZBX_CURMASTERID = $new_nodeid; /* applay Master node for this script */
}
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index 1bee7728..88038161 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -25,7 +25,7 @@
global $USER_DETAILS;
global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID;
- global $ZBX_CURNODEID, $ZBX_CURMASTERID;
+ global $ZBX_CURMASTERID;
global $page;
COpt::profiling_start("page");
@@ -63,7 +63,7 @@ COpt::profiling_start("page");
if(defined('ZBX_DISTRIBUTED'))
{
- if($curr_node_data = DBfetch(DBselect('select * from nodes where nodeid='.$ZBX_CURNODEID)))
+ if($curr_node_data = DBfetch(DBselect('select * from nodes where nodeid='.get_current_nodeid(false))))
$page['title'] .= ' ('.$curr_node_data['name'].')';
}
if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"])
@@ -115,7 +115,7 @@ COpt::profiling_start("page");
),
array("url"=>"screens.php" ,"label"=>S_SCREENS ),
array("url"=>"discovery.php" ,"label"=>S_DISCOVERY , "user_type"=>USER_TYPE_ZABBIX_ADMIN),
- array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES ,
+ array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES , 'forse_disable_subnodes' => true,
"sub_pages"=>array("report3.php","chart_sla.php","chart5.php")
),
array("url"=>"vtext.php"),
@@ -145,6 +145,7 @@ COpt::profiling_start("page");
"user_type" => USER_TYPE_ZABBIX_ADMIN,
"node_perm" => PERM_READ_LIST,
"default_page_id" => 0,
+ "forse_disable_subnodes"=> true,
"pages"=>array(
array("url"=>"config.php" ,"label"=>S_GENERAL ,
"sub_pages"=>array("image.php")
@@ -180,6 +181,7 @@ COpt::profiling_start("page");
"user_type" => USER_TYPE_SUPER_ADMIN,
"node_perm" => PERM_READ_WRITE,
"default_page_id" => 1,
+ "forse_disable_subnodes"=> true,
"pages"=>array(
ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null ,
array("url"=>"users.php" ,"label"=>S_USERS ,
@@ -196,6 +198,7 @@ COpt::profiling_start("page");
"login"=>array(
"label" => S_LOGIN,
"default_page_id" => 0,
+ "forse_disable_subnodes"=> true,
"pages"=>array(
array("url"=>"index.php",
"sub_pages"=>array("profile.php")
@@ -221,9 +224,9 @@ COpt::profiling_start("page");
if(isset($sub['node_perm']))
{
- if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user(
+ if ( 0 == count(get_accessible_nodes_by_user(
$USER_DETAILS,$sub['node_perm'],null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY,get_current_nodeid(false))))
$deny = true;
}
@@ -251,9 +254,9 @@ COpt::profiling_start("page");
if(isset($sub_pages['node_perm']))
{
- if(!in_array($ZBX_CURNODEID,get_accessible_nodes_by_user(
+ if ( 0 == count(get_accessible_nodes_by_user(
$USER_DETAILS,$sub_pages['node_perm'],null,
- PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ PERM_RES_IDS_ARRAY,get_current_nodeid(false))))
{
unset($sub['pages'][$id]);
continue;
@@ -284,6 +287,14 @@ COpt::profiling_start("page");
$sub['pages'][$id]['active'] = true; /* mark as active */
}
}
+
+ if ( isset($page_exist) &&
+ ( isset($sub['forse_disable_subnodes']) || isset($sub_pages['forse_disable_subnodes']) ) &&
+ !defined('ZBX_DISABLE_SUBNODES')
+ )
+ {
+ define('ZBX_DISABLE_SUBNODES', 1);
+ }
}
if(isset($menu_url)) /* active menu */
@@ -408,21 +419,36 @@ COpt::compare_files_with_menu($ZBX_MENU);
if(ZBX_DISTRIBUTED)
{
- $lst_nodes = new CComboBox('switch_node', $ZBX_CURNODEID);
- $db_nodes = DBselect('select * from nodes where nodeid in ('.
- get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '.
- ' order by name ');
+ $lst_nodes = new CComboBox('switch_node', get_current_nodeid(false));
+ $db_nodes = DBselect(
+ 'select * from nodes '.
+ ' where nodeid in ('.
+ get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).
+ ') '.
+ ' order by name '
+ );
while($node_data = DBfetch($db_nodes))
{
$lst_nodes->AddItem($node_data['nodeid'],$node_data['name']);
}
- if($lst_nodes->ItemsCount())
+ if( $lst_nodes->ItemsCount() > 1 )
{
$node_form = new CForm();
-/* $node_form->AddItem(S_CURRENT_NODE.' ['.$ZBX_CURNODEID.'] ');*/
- $node_form->AddItem($lst_nodes);
+ $node_form->AddItem(array(S_CURRENT_NODE,$lst_nodes));
unset($lst_nodes);
+
+ if ( !defined('ZBX_DISABLE_SUBNODES') )
+ {
+ global $ZBX_WITH_SUBNODES;
+
+ $cmd_show_subnodes = new CComboBox('show_subnodes', !empty($ZBX_WITH_SUBNODES) ? 1 : 0);
+ $cmd_show_subnodes->AddItem(0, S_CURRENT_NODE_ONLY);
+ $cmd_show_subnodes->AddItem(1, S_WITH_SUBNODES);
+
+ $node_form->AddItem(array(SPACE, S_SHOW, $cmd_show_subnodes));
+ }
+
$node_form->AddItem(new CButton('submit',S_SWITCH_NODE));
}
}
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 8df5a68f..f92da482 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -48,13 +48,13 @@
$USER_DETAILS = NULL;
$sessionid = get_cookie("zbx_sessionid");
-
+
if( !is_null($sessionid))
{
if(!($USER_DETAILS = DBfetch(DBselect("select u.*,s.* from sessions s,users u".
" where s.sessionid=".zbx_dbstr($sessionid)." and s.userid=u.userid".
" and ((s.lastaccess+u.autologout>".time().") or (u.autologout=0))".
- " and ".DBid2nodeid('u.userid')." = ".$ZBX_LOCALNODEID))))
+ " and ".DBin_node('u.userid', $ZBX_LOCALNODEID)))))
{
zbx_unsetcookie('zbx_sessionid');
DBexecute("delete from sessions where sessionid=".zbx_dbstr($sessionid));
@@ -72,7 +72,7 @@
if(!$USER_DETAILS)
{
if(!($USER_DETAILS = DBfetch(DBselect("select u.* from users u where u.alias=".zbx_dbstr(ZBX_GUEST_USER).
- " and ".DBid2nodeid('u.userid')."=$ZBX_LOCALNODEID"))))
+ " and ".DBin_node('u.userid', $ZBX_LOCALNODEID)))))
{
$missed_user_guest = true;
}
@@ -154,8 +154,7 @@ COpt::counter_up('perm');
$where = array();
- if(is_array($nodeid)) array_push($where, DBid2nodeid('h.hostid').' in ('.implode(',', $nodeid).') ');
- elseif(isset($nodeid)) array_push($where, DBid2nodeid('h.hostid').' in ('.$nodeid.') ');
+ if ( !is_null($nodeid) ) array_push($where, DBin_node('h.hostid', $nodeid));
if(is_array($hostid)) array_push($where, ' h.hostid in ('.implode(',', $hostid).') ');
elseif(isset($hostid)) array_push($where, ' h.hostid in ('.$hostid.') ');
@@ -241,8 +240,7 @@ COpt::counter_up('perm');
$where = array();
- if(is_array($nodeid)) array_push($where, DBid2nodeid('hg.groupid').' in ('.implode(',', $nodeid).') ');
- elseif(isset($nodeid)) array_push($where, DBid2nodeid('hg.groupid').' in ('.$nodeid.') ');
+ if ( !is_null($nodeid) ) array_push($where, DBin_node('hg.groupid', $nodeid));
if(count($where)) $where = ' where '.implode(' and ',$where);
else $where = '';
@@ -428,8 +426,7 @@ COpt::counter_up('perm');
$where = array();
- if(is_array($nodeid)) array_push($where, DBid2nodeid('h.hostid').' in ('.implode(',', $nodeid).') ');
- elseif(isset($nodeid)) array_push($where, DBid2nodeid('h.hostid').' in ('.$nodeid.') ');
+ if ( !is_null($nodeid) ) array_push($where, DBin_node('h.hostid', $nodeid));
if(count($where)) $where = ' where '.implode(' and ',$where);
else $where = '';
@@ -522,8 +519,7 @@ COpt::counter_up('perm');
$where = array();
- if(is_array($nodeid)) array_push($where, DBid2nodeid('g.groupid').' in ('.implode(',', $nodeid).') ');
- elseif(isset($nodeid)) array_push($where, DBid2nodeid('g.groupid').' in ('.$nodeid.') ');
+ if ( !is_null($nodeid) ) array_push($where, DBin_node('g.groupid', $nodeid));
if(count($where)) $where = ' where '.implode(' and ',$where);
else $where = '';
diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php
index 77e0e56d..9dcd35fb 100644
--- a/frontends/php/include/screens.inc.php
+++ b/frontends/php/include/screens.inc.php
@@ -28,8 +28,8 @@
$result = false;
- if(DBselect("select screenid from screens where screenid=".$screenid.
- " and ".DBid2nodeid('screenid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ if(DBselect('select screenid from screens where screenid='.$screenid.
+ ' and '.DBin_node('screenid', get_current_nodeid($perm))))
{
$result = true;
@@ -408,14 +408,12 @@
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_TRIGGERS_OVERVIEW) )
{
- global $ZBX_CURNODEID;
- $item = array(get_triggers_overview($resourceid, $ZBX_CURNODEID));
+ $item = array(get_triggers_overview($resourceid));
if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action));
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_DATA_OVERVIEW) )
{
- global $ZBX_CURNODEID;
- $item = array(get_items_data_overview($resourceid, $ZBX_CURNODEID));
+ $item = array(get_items_data_overview($resourceid));
if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action));
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_URL) )
@@ -463,12 +461,10 @@
function slideshow_accessiable($slideshowid, $perm)
{
- global $USER_DETAILS;
-
$result = false;
- if(DBselect("select slideshowid from slideshows where slideshowid=".$slideshowid.
- " and ".DBid2nodeid('slideshowid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ if(DBselect('select slideshowid from slideshows where slideshowid='.$slideshowid.
+ ' and '.DBin_node('slideshowid', get_current_nodeid($perm))))
{
$result = true;
$db_slides = DBselect('select distinct screenid from slides where slideshowid='.$slideshowid);
diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php
index 9399eeb8..1f474cdd 100644
--- a/frontends/php/include/services.inc.php
+++ b/frontends/php/include/services.inc.php
@@ -107,15 +107,13 @@
}
function add_host_to_services($hostid, $serviceid){
- global $ZBX_CURNODEID;
-
$result = DBselect('SELECT distinct h.host,t.triggerid,t.description '.
' FROM triggers t,hosts h,items i,functions f '.
' WHERE h.hostid='.$hostid.
' AND h.hostid=i.hostid '.
' AND i.itemid=f.itemid '.
' AND f.triggerid=t.triggerid '.
- ' AND '.DBid2nodeid('t.triggerid').'='.$ZBX_CURNODEID
+ ' AND '.DBin_node('t.triggerid', get_current_nodeid(false))
);
while($row=DBfetch($result)){
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index d54dac5a..144437a0 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -401,7 +401,7 @@
*/
function &get_hosts_by_expression($expression)
{
- global $ZBX_CURNODEID, $ZBX_TR_EXPR_ALLOWED_MACROS, $ZBX_TR_EXPR_REPLACE_TO;
+ global $ZBX_TR_EXPR_ALLOWED_MACROS, $ZBX_TR_EXPR_REPLACE_TO;
$expr = $expression;
@@ -424,7 +424,7 @@
if(count($hosts) == 0) $hosts = array('0');
- return DBselect('select distinct * from hosts where '.DBid2nodeid('hostid').'='.$ZBX_CURNODEID.
+ return DBselect('select distinct * from hosts where '.DBin_node('hostid', get_current_nodeid(false)).
' and host in ('.implode(',',$hosts).')');
}
@@ -530,7 +530,7 @@
*/
function validate_expression($expression)
{
- global $ZBX_CURNODEID, $ZBX_TR_EXPR_ALLOWED_MACROS, $ZBX_TR_EXPR_REPLACE_TO, $ZBX_TR_EXPR_ALLOWED_FUNCTIONS;
+ global $ZBX_TR_EXPR_ALLOWED_MACROS, $ZBX_TR_EXPR_REPLACE_TO, $ZBX_TR_EXPR_ALLOWED_FUNCTIONS;
if( empty($expression) )
{
@@ -557,7 +557,7 @@
/* Check host */
$row=DBfetch(DBselect('select count(*) as cnt,min(status) as status,min(hostid) as hostid from hosts h where h.host='.zbx_dbstr($host).
- ' and '.DBid2nodeid('h.hostid').'='.$ZBX_CURNODEID
+ ' and '.DBin_node('h.hostid', get_current_nodeid(false))
));
if($row['cnt']==0)
{
@@ -575,7 +575,7 @@
/* Check key */
if ( !($item = DBfetch(DBselect('select i.itemid,i.value_type from hosts h,items i where h.host='.zbx_dbstr($host).
' and i.key_='.zbx_dbstr($key).' and h.hostid=i.hostid '.
- ' and '.DBid2nodeid('h.hostid').'='.$ZBX_CURNODEID
+ ' and '.DBin_node('h.hostid', get_current_nodeid(false))
))) )
{
error('No such monitored parameter ('.$key.') for host ('.$host.')');
@@ -1580,7 +1580,7 @@
* Comments: !!! Don't forget sync code with C !!!
*
*/
- function get_triggers_overview($groupid, $nodeid)
+ function get_triggers_overview($groupid)
{
global $USER_DETAILS;
@@ -1595,13 +1595,15 @@
$result=DBselect('select distinct t.triggerid,t.description,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, null, null, $nodeid).') '.
+ ' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, get_current_nodeid()).') '.
' and t.status='.TRIGGER_STATUS_ENABLED.' and i.status='.ITEM_STATUS_ACTIVE.
' order by t.description');
unset($triggers);
unset($hosts);
while($row = DBfetch($result))
{
+ $row['host'] = get_node_name_by_elid($row['hostid']).$row['host'];
+
$hosts[$row['host']] = $row['host'];
$triggers[$row['description']][$row['host']] = array(
'hostid' => $row['hostid'],
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 9027e17e..44419f94 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -36,7 +36,6 @@
function add_user($name,$surname,$alias,$passwd,$url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
{
global $USER_DETAILS;
- global $ZBX_CURNODEID;
if($USER_DETAILS['type'] != USER_TYPE_SUPER_ADMIN)
{
@@ -44,7 +43,7 @@
return 0;
}
- if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias)." and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID)))
+ if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias)." and ".DBin_node('userid', get_current_nodeid(false)))))
{
error('User "'.$alias.'" already exists');
return 0;
@@ -90,10 +89,8 @@
function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
{
- global $ZBX_CURNODEID;
-
if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias).
- " and userid<>$userid and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID)))
+ " and userid<>$userid and ".DBin_node('userid', get_current_nodeid(false)))))
{
error("User '$alias' already exists");
return 0;
@@ -196,9 +193,7 @@
function add_user_group($name,$users=array(),$rights=array())
{
- global $ZBX_CURNODEID;
-
- if(DBfetch(DBselect("select * from usrgrp where name=".zbx_dbstr($name)." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID)))
+ if(DBfetch(DBselect('select * from usrgrp where name='.zbx_dbstr($name).' and '.DBin_node('usrgrpid', get_current_nodeid(false)))))
{
error("Group '$name' already exists");
return 0;
@@ -231,10 +226,8 @@
function update_user_group($usrgrpid,$name,$users=array(),$rights=array())
{
- global $ZBX_CURNODEID;
-
- if(DBfetch(DBselect("select * from usrgrp where name=".zbx_dbstr($name).
- " and usrgrpid<>".$usrgrpid." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID)))
+ if(DBfetch(DBselect('select * from usrgrp where name='.zbx_dbstr($name).
+ ' and usrgrpid<>'.$usrgrpid.' and '.DBin_node('usrgrpid', get_current_nodeid(false)))))
{
error("Group '$name' already exists");
return 0;