summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-07 12:16:12 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2008-08-07 12:16:12 +0000
commitc613bdfadf062a5831d4781b7a5e139b4bd749dd (patch)
tree8525f42c16d945f0ea803a32d80220eefc29dcbd
parent5132f1679c3106da0ce8bda401ecdec3af45bd55 (diff)
downloadzabbix-c613bdfadf062a5831d4781b7a5e139b4bd749dd.tar.gz
zabbix-c613bdfadf062a5831d4781b7a5e139b4bd749dd.tar.xz
zabbix-c613bdfadf062a5831d4781b7a5e139b4bd749dd.zip
- [DEV-137] added selection of the first host in group on group change (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5883 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--frontends/php/charts.php2
-rw-r--r--frontends/php/events.php2
-rw-r--r--frontends/php/httpmon.php2
-rw-r--r--frontends/php/include/hosts.inc.php114
-rw-r--r--frontends/php/include/validate.inc.php284
-rw-r--r--frontends/php/latest.php4
-rw-r--r--frontends/php/tr_status.php11
7 files changed, 169 insertions, 250 deletions
diff --git a/frontends/php/charts.php b/frontends/php/charts.php
index 0243c331..ad447b6c 100644
--- a/frontends/php/charts.php
+++ b/frontends/php/charts.php
@@ -105,7 +105,7 @@ include_once 'include/page_header.php';
$effectiveperiod = navigation_bar_calc();
- $options = array("allow_all_hosts","monitored_hosts","with_items");//, "always_select_first_host");//
+ $options = array('allow_all_hosts','monitored_hosts','with_items','always_select_first_host');
if(!$ZBX_WITH_SUBNODES) array_push($options,"only_current_node");
validate_group_with_host(PERM_READ_ONLY,$options);
diff --git a/frontends/php/events.php b/frontends/php/events.php
index bbf6a067..2c782527 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -174,7 +174,7 @@ include_once "include/page_header.php";
}
//SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']);
- validate_group_with_host(PERM_READ_ONLY, array('allow_all_hosts','monitored_hosts','with_items'));
+ validate_group_with_host(PERM_READ_ONLY, array('allow_all_hosts','monitored_hosts','with_items','always_select_first_host'));
$cmbGroup = new CComboBox('groupid',$_REQUEST['groupid'],'submit()');
$cmbHosts = new CComboBox('hostid',$_REQUEST['hostid'],'submit()');
diff --git a/frontends/php/httpmon.php b/frontends/php/httpmon.php
index 875e801a..bdd8f560 100644
--- a/frontends/php/httpmon.php
+++ b/frontends/php/httpmon.php
@@ -67,7 +67,7 @@ include_once "include/page_header.php";
validate_sort_and_sortorder('wt.name',ZBX_SORT_DOWN);
- $options = array('allow_all_hosts','monitored_hosts');//,'always_select_first_host'
+ $options = array('allow_all_hosts','monitored_hosts','always_select_first_host');
$_REQUEST['groupid'] = get_request('groupid',get_profile('web.latest.groupid',-1));
if($_REQUEST['groupid'] == -1) array_push($options,'always_select_first_host');
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index a57f0032..c9bf4b8a 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -697,10 +697,10 @@ require_once "include/httptest.inc.php";
$first_hostid_in_group = 0;
- $allow_all_hosts = (str_in_array("allow_all_hosts",$options)) ? 1 : 0;
- $always_select_first_host = str_in_array("always_select_first_host",$options) ? 1 : 0;
- $only_current_node = str_in_array("only_current_node",$options) ? 1 : 0;
-
+ $allow_all_hosts = str_in_array('allow_all_hosts',$options)?1:0;
+ $always_select_first_host = str_in_array('always_select_first_host',$options)?1:0;
+ $only_current_node = str_in_array('only_current_node',$options)?1:0;
+
if(str_in_array('monitored_hosts',$options))
$with_host_status = ' AND h.status='.HOST_STATUS_MONITORED;
else if(str_in_array('real_hosts',$options))
@@ -751,13 +751,16 @@ require_once "include/httptest.inc.php";
if($groupid > 0){
$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 '.DBcondition('h.hostid',$available_hosts).
- ' AND g.groupid='.$groupid.$with_host_status.$with_items.$with_node)))
- {
+ $sql = '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 '.DBcondition('h.hostid',$available_hosts).
+ ' AND g.groupid='.$groupid.
+ $with_host_status.
+ $with_items.
+ $with_node;
+ if(!DBfetch(DBselect($sql))){
$groupid = 0;
}
}
@@ -769,35 +772,38 @@ require_once "include/httptest.inc.php";
else{
$hostid = $a_hostid;
/* is not 'All' selected */
- if(!(($hostid == 0) && ($allow_all_hosts == 1))) {
+// if(!(($hostid == 0) && ($allow_all_hosts == 1))) {
+ if(($hostid != 0) || ($allow_all_hosts != 1)){
$group_table = '';
- $witth_group = '';
+ $with_group = '';
if($groupid != 0){
$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))){
- $hostid = 0;
+ $sql = 'SELECT hg.hostid '.
+ ' FROM hosts_groups hg'.
+ ' WHERE hg.groupid='.$groupid.
+ ' AND hg.hostid='.$hostid.
+ $with_node;
+ if(!DBfetch(DBselect($sql))){
+ $hostid = -1;
}
$group_table = ' ,hosts_groups hg ';
- $witth_group = ' AND hg.hostid=h.hostid AND hg.groupid='.$groupid;
+ $with_group = ' AND hg.hostid=h.hostid AND hg.groupid='.$groupid;
}
$with_node = ' AND '.DBin_node('h.hostid',get_current_nodeid(!$only_current_node));
//SDI('C: '.$a_groupid.' : '.$a_hostid);
-
- if($db_host = DBfetch(DBselect('SELECT DISTINCT h.hostid,h.host FROM hosts h '.
- $item_table.
- $group_table.
+ $sql = 'SELECT DISTINCT h.hostid,h.host '.
+ ' FROM hosts h '.$item_table.$group_table.
' WHERE '.DBcondition('h.hostid',$available_hosts).
- $with_host_status.
- $with_items.
- $witth_group.
- $with_node.
- ' ORDER BY h.host')))
- {
- $first_hostid_in_group = $db_host["hostid"];
+ $with_host_status.
+ $with_items.
+ $with_group.
+ $with_node.
+ ' ORDER BY h.host';
+ if($db_host = DBfetch(DBselect($sql))){
+ $first_hostid_in_group = $db_host['hostid'];
}
if($first_hostid_in_group == 0) $hostid = 0; /* no hosts in selected groupe */
@@ -811,23 +817,27 @@ require_once "include/httptest.inc.php";
$with_items.
$with_node)))
{
- $hostid = 0;
+ $hostid = -1;
}
}
- if(($hostid < 0) || ($hostid == 0 && $always_select_first_host == 1)) /* incorrect host */{
- $hostid = $first_hostid_in_group;
+
+ if($hostid < 0){
+ if($always_select_first_host == 1)
+ $hostid = $first_hostid_in_group;
+ else
+ $hostid = 0;
}
}
}
- $group_correct = (bccomp($groupid ,$a_groupid)==0) ? 1 : 0;
- $host_correct = (bccomp($hostid ,$a_hostid)==0) ? 1 : 0;
+ $group_correct = (bccomp($groupid ,$a_groupid)==0)?1:0;
+ $host_correct = (bccomp($hostid ,$a_hostid)==0)?1:0;
return array(
"groupid" => $groupid,
"group_correct" => $group_correct,
"hostid" => $hostid,
"host_correct" => $host_correct,
- "correct" => ($group_correct && $host_correct) ? 1 : 0
+ "correct" => ($group_correct && $host_correct)?1:0
);
}
@@ -842,35 +852,35 @@ require_once "include/httptest.inc.php";
* Eugene Grigorjev (eugene.grigorjev@zabbix.com)
*
* Comments:
- *
+ * mod by Aly
*/
function validate_group_with_host($perm, $options = array(),$group_var=null,$host_var=null){
- if(is_null($group_var)) $group_var = "web.latest.groupid";
- if(is_null($host_var)) $host_var = "web.latest.hostid";
+ if(is_null($group_var)) $group_var = 'web.latest.groupid';
+ if(is_null($host_var)) $host_var = 'web.latest.hostid';
- $_REQUEST["groupid"] = get_request("groupid", -1);
- $_REQUEST["hostid"] = get_request("hostid", get_profile($host_var, 0, PROFILE_TYPE_ID));
+ $_REQUEST['groupid'] = get_request('groupid', -1);
+ $_REQUEST['hostid'] = get_request('hostid', get_profile($host_var, -1));
- if(-1 == $_REQUEST["groupid"]){
- $_REQUEST["groupid"] = get_profile($group_var, 0, PROFILE_TYPE_ID);
+ if(-1 == $_REQUEST['groupid']){
+ $_REQUEST['groupid'] = get_profile($group_var, 0, PROFILE_TYPE_ID);
- if(!in_node($_REQUEST["groupid"])) $_REQUEST["groupid"] = 0;
+ if(!in_node($_REQUEST['groupid'])) $_REQUEST['groupid'] = 0;
- if(($_REQUEST["hostid"] > 0) && !DBfetch(DBselect('SELECT groupid FROM hosts_groups WHERE hostid='.$_REQUEST["hostid"].' AND groupid='.$_REQUEST["groupid"]))){
- $_REQUEST["groupid"] = 0;
+ if(($_REQUEST['hostid'] > 0) && !DBfetch(DBselect('SELECT groupid FROM hosts_groups WHERE hostid='.$_REQUEST['hostid'].' AND groupid='.$_REQUEST['groupid']))){
+ $_REQUEST['groupid'] = 0;
}
}
- if(str_in_array("always_select_first_host",$options) && ($_REQUEST["hostid"] == 0) && ($_REQUEST["groupid"] != 0))
- $_REQUEST["hostid"] = -1;
+// if(str_in_array('always_select_first_host',$options) && ($_REQUEST['hostid'] == 0) && ($_REQUEST['groupid'] != 0))
+// $_REQUEST['hostid'] = -1;
- $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options);
+ $result = get_correct_group_and_host($_REQUEST['groupid'],$_REQUEST['hostid'], $perm, $options);
- $_REQUEST["groupid"] = $result["groupid"];
- $_REQUEST["hostid"] = $result["hostid"];
+ $_REQUEST['groupid'] = $result['groupid'];
+ $_REQUEST['hostid'] = $result['hostid'];
- update_profile($host_var,$_REQUEST["hostid"], PROFILE_TYPE_ID);
- update_profile($group_var,$_REQUEST["groupid"], PROFILE_TYPE_ID);
+ update_profile($host_var,$_REQUEST['hostid'], PROFILE_TYPE_ID);
+ update_profile($group_var,$_REQUEST['groupid'], PROFILE_TYPE_ID);
}
/*
@@ -887,7 +897,7 @@ require_once "include/httptest.inc.php";
*/
function validate_group($perm, $options = array(),$group_var=null){
if(is_null($group_var)) $group_var = 'web.latest.groupid';
- $_REQUEST["groupid"] = get_request('groupid',get_profile($group_var, 0, PROFILE_TYPE_ID));
+ $_REQUEST['groupid'] = get_request('groupid',get_profile($group_var, 0, PROFILE_TYPE_ID));
if(!in_node($_REQUEST['groupid'])) $_REQUEST['groupid'] = 0;
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php
index 2b4875b2..ea2d51c8 100644
--- a/frontends/php/include/validate.inc.php
+++ b/frontends/php/include/validate.inc.php
@@ -19,8 +19,7 @@
**/
?>
<?php
- function unset_request($key,$requester='unknown')
- {
+ function unset_request($key,$requester='unknown'){
unset($_REQUEST[$key]);
}
@@ -28,10 +27,8 @@
define('ZBX_VALID_ERROR', 1);
define('ZBX_VALID_WARNING', 2);
- function is_int_range($value)
- {
- if( !empty($value) ) foreach(explode(',',$value) as $int_range)
- {
+ function is_int_range($value){
+ if( !empty($value) ) foreach(explode(',',$value) as $int_range){
$int_range = explode('-', $int_range);
if(count($int_range) > 2) return false;
foreach($int_range as $int_val)
@@ -41,43 +38,35 @@
return true;
}
- function is_hex_color($value)
- {
+ function is_hex_color($value){
return eregi('^[0-9,A-F]{6}$', $value);
}
- function BETWEEN($min,$max,$var=NULL)
- {
+ function BETWEEN($min,$max,$var=NULL){
return "({".$var."}>=".$min."&&{".$var."}<=".$max.")&&";
}
- function GT($value,$var='')
- {
+ function GT($value,$var=''){
return "({".$var."}>=".$value.")&&";
}
- function IN($array,$var='')
- {
+ function IN($array,$var=''){
if(is_array($array)) $array = implode(',', $array);
return "str_in_array({".$var."},array(".$array."))&&";
}
- function HEX($var=NULL)
- {
+ function HEX($var=NULL){
return "ereg(\"^[a-zA-Z0-9]{1,}$\",{".$var."})&&";
}
- function KEY_PARAM($var=NULL)
- {
+ function KEY_PARAM($var=NULL){
return 'ereg(\'^([0-9a-zA-Z\_\.[.'.ZBX_EREG_SPACE_SYMB.'.]\$ ]+)$\',{'.$var.'})&&';
}
- function validate_ipv4($str,&$arr)
- {
+ function validate_ipv4($str,&$arr){
if( !ereg('^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$', $str, $arr) ) return false;
for($i=1; $i<=4; $i++) if( !is_numeric($arr[$i]) || $arr[$i] > 255 || $arr[$i] < 0 ) return false;
return true;
}
- function validate_ipv6($str,&$arr)
- {
+ function validate_ipv6($str,&$arr){
$pattern1 = '([A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}';
$pattern2 = ':(:[A-Fa-f0-9]{1,4}){1,7}';
$pattern3 = '[A-Fa-f0-9]{1,4}::([A-Fa-f0-9]{1,4}:){0,5}[A-Fa-f0-9]{1,4}';
@@ -93,21 +82,17 @@
return true;
}
- function validate_ip($str,&$arr)
- {
+ function validate_ip($str,&$arr){
if(validate_ipv4($str,$arr))
return true;
- if(defined('ZBX_HAVE_IPV6'))
- {
+ if(defined('ZBX_HAVE_IPV6')){
return validate_ipv6($str,$arr);
}
return false;
}
-/* function validate_ip_range($str)
- {
- foreach(explode(',',$str) as $ip_range)
- {
+/* function validate_ip_range($str){
+ foreach(explode(',',$str) as $ip_range){
$ip_parts = explode('.', $ip_range);
if(count($ip_parts) != 4) return false;
@@ -117,8 +102,7 @@
$last_part = explode('-', $ip_parts[3]);
if(count($last_part) > 2) return false;
- foreach($last_part as $ip_p)
- {
+ foreach($last_part as $ip_p){
if( !is_numeric($ip_p) || $ip_p < 0 || $ip_p > 255 ) return false;
}
if(count($last_part) == 2 && $last_part[0] > $last_part[1]) return false;
@@ -127,20 +111,16 @@
return true;
}
*/
- function validate_ip_range($str)
- {
- foreach(explode(',',$str) as $ip_range)
- {
+ function validate_ip_range($str){
+ foreach(explode(',',$str) as $ip_range){
$parts = explode('-', $ip_range);
$parts_count = count($parts);
if($parts_count > 2) return false;
- if(validate_ipv4($parts[0], $arr))
- {
+ if(validate_ipv4($parts[0], $arr)){
$ip_parts = explode('.', $parts[0]);
- if( $parts_count == 2 )
- {
+ if( $parts_count == 2 ){
if( !ereg('^[0-9]{1,3}$', $parts[1]) ) return false;
sscanf($ip_parts[3], "%d", $from_value);
@@ -148,13 +128,11 @@
if($to_value > 255 || $from_value > $to_value) return false;
}
}
- else if( defined('ZBX_HAVE_IPV6') && validate_ipv6($parts[0], $arr) )
- {
+ else if( defined('ZBX_HAVE_IPV6') && validate_ipv6($parts[0], $arr) ){
$ip_parts = explode(':', $parts[0]);
$ip_parts_count = count($ip_parts);
- if( $parts_count == 2 )
- {
+ if( $parts_count == 2 ){
if( !ereg('^[A-Fa-f0-9]{1,4}$', $parts[1]) ) return false;
sscanf($ip_parts[$ip_parts_count - 1], "%x", $from_value);
@@ -162,8 +140,7 @@
if($from_value > $to_value) return false;
}
}
- else
- {
+ else{
return false;
}
@@ -171,30 +148,25 @@
return true;
}
-/* function validate_ip_range($str)
- {
- if(defined('ZBX_HAVE_IPV6'))
- {
+/* function validate_ip_range($str){
+ if(defined('ZBX_HAVE_IPV6')){
return validate_ipv4_ipv6_range($str);
}
- else
- {
+ else{
return validate_ipv4_range($str);
}
return false;
}
*/
- function validate_port_list($str)
- {
- foreach(explode(',',$str) as $port_range)
- {
+ function validate_port_list($str){
+ foreach(explode(',',$str) as $port_range){
$port_range = explode('-', $port_range);
if(count($port_range) > 2) return false;
foreach($port_range as $port)
if( !is_numeric($port) || $port > 65535 || $port < 0 )
return false;
}
- return true;
+ return true;
}
@@ -203,14 +175,11 @@
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
- function calc_exp2($fields,$field,$expression)
- {
- foreach($fields as $f => $checks)
- {
+ function calc_exp2($fields,$field,$expression){
+ foreach($fields as $f => $checks){
/*
// If an unset variable used in expression, return FALSE
- if(zbx_strstr($expression,'{'.$f.'}')&&!isset($_REQUEST[$f]))
- {
+ if(zbx_strstr($expression,'{'.$f.'}')&&!isset($_REQUEST[$f])){
//SDI("Variable [$f] is not set. $expression is FALSE");
//info("Variable [$f] is not set. $expression is FALSE");
// return FALSE;
@@ -229,8 +198,7 @@
return $ret;
}
- function calc_exp($fields,$field,$expression)
- {
+ function calc_exp($fields,$field,$expression){
//SDI("$field - expression: ".$expression);
if(zbx_strstr($expression,"{}") && !isset($_REQUEST[$field]))
@@ -239,10 +207,8 @@
if(zbx_strstr($expression,"{}") && !is_array($_REQUEST[$field]))
$expression = str_replace("{}",'$_REQUEST["'.$field.'"]',$expression);
- if(zbx_strstr($expression,"{}") && is_array($_REQUEST[$field]))
- {
- foreach($_REQUEST[$field] as $key => $val)
- {
+ if(zbx_strstr($expression,"{}") && is_array($_REQUEST[$field])){
+ foreach($_REQUEST[$field] as $key => $val){
$expression2 = str_replace("{}",'$_REQUEST["'.$field.'"]["'.$key.'"]',$expression);
if(calc_exp2($fields,$field,$expression2)==FALSE)
return FALSE;
@@ -253,75 +219,57 @@
return calc_exp2($fields,$field,$expression);
}
- function unset_not_in_list(&$fields)
- {
- foreach($_REQUEST as $key => $val)
- {
- if(!isset($fields[$key]))
- {
+ function unset_not_in_list(&$fields){
+ foreach($_REQUEST as $key => $val){
+ if(!isset($fields[$key])){
unset_request($key,'unset_not_in_list');
}
}
}
- function unset_if_zero($fields)
- {
- foreach($fields as $field => $checks)
- {
+ function unset_if_zero($fields){
+ foreach($fields as $field => $checks){
list($type,$opt,$flags,$validation,$exception)=$checks;
- if(($flags&P_NZERO)&&(isset($_REQUEST[$field]))&&(is_numeric($_REQUEST[$field]))&&($_REQUEST[$field]==0))
- {
+ if(($flags&P_NZERO)&&(isset($_REQUEST[$field]))&&(is_numeric($_REQUEST[$field]))&&($_REQUEST[$field]==0)){
unset_request($field,'unset_if_zero');
}
}
}
- function unset_action_vars($fields)
- {
- foreach($fields as $field => $checks)
- {
+ function unset_action_vars($fields){
+ foreach($fields as $field => $checks){
list($type,$opt,$flags,$validation,$exception)=$checks;
- if(($flags&P_ACT)&&(isset($_REQUEST[$field])))
- {
+ if(($flags&P_ACT)&&(isset($_REQUEST[$field]))){
unset_request($field,'unset_action_vars');
}
}
}
- function unset_all()
- {
- foreach($_REQUEST as $key => $val)
- {
+ function unset_all(){
+ foreach($_REQUEST as $key => $val){
unset_request($key,'unset_all');
}
}
- function check_type(&$field, $flags, &$var, $type)
- {
- if(is_array($var) && $type != T_ZBX_IP)
- {
+ function check_type(&$field, $flags, &$var, $type){
+ if(is_array($var) && $type != T_ZBX_IP){
$err = ZBX_VALID_OK;
- foreach($var as $el)
- {
+ foreach($var as $el){
$err |= check_type($field, $flags, $el, $type);
}
return $err;
}
- if($type == T_ZBX_IP)
- {
- if( !validate_ip($var,$arr) )
- {
- if($flags&P_SYS)
- {
+ if($type == T_ZBX_IP){
+ if( !validate_ip($var,$arr) ){
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not IP");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not IP");
return ZBX_VALID_WARNING;
}
@@ -329,17 +277,13 @@
return ZBX_VALID_OK;
}
- if($type == T_ZBX_IP_RANGE)
- {
- if( !validate_ip_range($var) )
- {
- if($flags&P_SYS)
- {
+ if($type == T_ZBX_IP_RANGE){
+ if( !validate_ip_range($var) ){
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not IP range");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not IP range");
return ZBX_VALID_WARNING;
}
@@ -347,8 +291,7 @@
return ZBX_VALID_OK;
}
- if($type == T_ZBX_PORTS)
- {
+ if($type == T_ZBX_PORTS){
$err = ZBX_VALID_OK;
foreach(explode(',', $var) as $el)
foreach(explode('-', $el) as $p)
@@ -356,17 +299,13 @@
return $err;
}
- if($type == T_ZBX_INT_RANGE)
- {
- if( !is_int_range($var) )
- {
- if($flags&P_SYS)
- {
+ if($type == T_ZBX_INT_RANGE){
+ if( !is_int_range($var) ){
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not integer range");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not integer range");
return ZBX_VALID_WARNING;
}
@@ -375,52 +314,44 @@
}
if(($type == T_ZBX_INT) && !is_numeric($var)) {
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not integer");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not integer");
return ZBX_VALID_WARNING;
}
}
if(($type == T_ZBX_DBL) && !is_numeric($var)) {
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not double");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not double");
return ZBX_VALID_WARNING;
}
}
if(($type == T_ZBX_STR) && !is_string($var)) {
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not string");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not string");
return ZBX_VALID_WARNING;
}
}
//*
if(($type == T_ZBX_STR) && !defined('ZBX_ALLOW_UNICODE') && (strlen($var) != zbx_strlen($var))){
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] contains Multibyte chars");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] - multibyte chars are restricted");
return ZBX_VALID_ERROR;
}
@@ -428,13 +359,11 @@
//*/
if(($type == T_ZBX_CLR) && !is_hex_color($var)) {
$var = 'FFFFFF';
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is not color");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is not color");
return ZBX_VALID_WARNING;
}
@@ -442,27 +371,21 @@
return ZBX_VALID_OK;
}
- function check_trim(&$var)
- {
- if(is_string($var))
- {
+ function check_trim(&$var){
+ if(is_string($var)) {
$var = trim($var);
}
- elseif(is_array($var))
- {
- foreach($var as $key => $val)
- {
+ else if(is_array($var)){
+ foreach($var as $key => $val){
check_trim($var[$key]);
}
}
}
- function check_field(&$fields, &$field, $checks)
- {
+ function check_field(&$fields, &$field, $checks){
list($type,$opt,$flags,$validation,$exception)=$checks;
- if($flags&P_UNSET_EMPTY && isset($_REQUEST[$field]) && $_REQUEST[$field]=='')
- {
+ if($flags&P_UNSET_EMPTY && isset($_REQUEST[$field]) && $_REQUEST[$field]==''){
unset_request($field,'P_UNSET_EMPTY');
}
@@ -475,42 +398,34 @@
else if($opt == O_OPT && $except) $opt = O_MAND;
else if($opt == O_NO && $except) $opt = O_MAND;
- if($opt == O_MAND)
- {
- if(!isset($_REQUEST[$field]))
- {
- if($flags&P_SYS)
- {
+ if($opt == O_MAND){
+ if(!isset($_REQUEST[$field])){
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] is mandatory");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] is mandatory");
return ZBX_VALID_WARNING;
}
}
}
- elseif($opt == O_NO)
- {
+ else if($opt == O_NO){
if(!isset($_REQUEST[$field]))
return ZBX_VALID_OK;
unset_request($field,'O_NO');
- if($flags&P_SYS)
- {
+ if($flags&P_SYS){
info("Critical error. Field [".$field."] must be missing");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Field [".$field."] must be missing");
return ZBX_VALID_WARNING;
}
}
- elseif($opt == O_OPT)
- {
+ else if($opt == O_OPT){
if(!isset($_REQUEST[$field]))
return ZBX_VALID_OK;
}
@@ -521,20 +436,16 @@
if($err != ZBX_VALID_OK)
return $err;
- if(($exception==NULL)||($except==TRUE))
- {
+ if(($exception==NULL)||($except==TRUE)){
if(!$validation) $valid=TRUE;
else $valid=calc_exp($fields,$field,$validation);
- if(!$valid)
- {
- if($flags&P_SYS)
- {
+ if(!$valid){
+ if($flags&P_SYS){
info("Critical error. Incorrect value for [".$field."] = '".$_REQUEST[$field]."'");
return ZBX_VALID_ERROR;
}
- else
- {
+ else{
info("Warning. Incorrect value for [".$field."]");
return ZBX_VALID_WARNING;
}
@@ -555,16 +466,14 @@
'sortorder'=> array(T_ZBX_STR, O_OPT, P_SYS, NULL,NULL)
);
- function invalid_url()
- {
+ function invalid_url(){
include_once "include/page_header.php";
unset_all();
show_error_message(S_INVALID_URL);
include_once "include/page_footer.php";
}
- function check_fields(&$fields, $show_messages=true)
- {
+ function check_fields(&$fields, $show_messages=true){
global $_REQUEST;
global $system_fields;
@@ -573,22 +482,19 @@
$fields = array_merge($fields, $system_fields);
- foreach($fields as $field => $checks)
- {
+ foreach($fields as $field => $checks){
$err |= check_field($fields, $field,$checks);
}
unset_not_in_list($fields);
unset_if_zero($fields);
- if($err!=ZBX_VALID_OK)
- {
+ if($err!=ZBX_VALID_OK){
unset_action_vars($fields);
}
$fields = null;
- if($err&ZBX_VALID_ERROR)
- {
+ if($err&ZBX_VALID_ERROR){
invalid_url();
}
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 8c2e8dd7..80e50fab 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -63,7 +63,7 @@ include_once "include/page_header.php";
$_REQUEST['select'] = get_request('select',get_profile('web.latest.filter.select', ''));
update_profile('web.latest.filter.select', $_REQUEST['select'], PROFILE_TYPE_STR);
- $options = array('allow_all_hosts','monitored_hosts','with_monitored_items');
+ $options = array('allow_all_hosts','monitored_hosts','with_monitored_items','always_select_first_host');
$_REQUEST['hostid'] = get_request('hostid',get_profile('web.latest.last.hostid', null));
if(is_null($_REQUEST['hostid'])){
@@ -71,7 +71,7 @@ include_once "include/page_header.php";
$_REQUEST['groupid'] = get_request('groupid',get_profile('web.latest.last.groupid', null));
if(is_null($_REQUEST['groupid'])){
- validate_group(PERM_READ_ONLY,array('allow_all_hosts','monitored_hosts','with_monitored_items','always_select_first_group'),'web.latest.last.groupid');
+ validate_group(PERM_READ_ONLY,$options,'web.latest.last.groupid');
}
}
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index f8399d4d..3d9bb977 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -200,7 +200,7 @@ include_once "include/page_header.php";
validate_sort_and_sortorder('t.lastchange',ZBX_SORT_DOWN);
- $options = array('allow_all_hosts','monitored_hosts','with_monitored_items');
+ $options = array('allow_all_hosts','monitored_hosts','with_monitored_items','always_select_first_host'); //always_select_first_host
if(!$ZBX_WITH_SUBNODES) array_push($options,'only_current_node');
$_REQUEST['hostid'] = get_request('hostid',get_profile('web.tr_status.hostid', null, PROFILE_TYPE_ID));
@@ -212,7 +212,8 @@ include_once "include/page_header.php";
validate_group(PERM_READ_ONLY,array('allow_all_hosts','monitored_hosts','with_monitored_items','always_select_first_group'),'web.tr_status.groupid');
}
}
-
+
+//SDI($_REQUEST['groupid'].' : '.$_REQUEST['hostid']);
validate_group_with_host(PERM_READ_ONLY,$options,'web.tr_status.groupid','web.tr_status.hostid');
$mute = get_profile('web.tr_status.mute',0);
@@ -269,7 +270,7 @@ include_once "include/page_header.php";
' AND h.status='.HOST_STATUS_MONITORED.
($_REQUEST['groupid']?' AND hg.hostid=h.hostid AND hg.groupid='.$_REQUEST['groupid']:'').
' ORDER BY h.host';
-
+
$result=DBselect($sql);
$flag = false;
while($row=DBfetch($result)){
@@ -309,6 +310,8 @@ include_once "include/page_header.php";
$filterForm->SetMethod('post');
$filterForm->AddVar('fullscreen',$_REQUEST['fullscreen']);
+ $filterForm->AddVar('groupid',$_REQUEST['groupid']);
+ $filterForm->AddVar('hostid',$_REQUEST['hostid']);
$tr_select = new CComboBox('show_triggers',$show_triggers,'javasctipt: submit();');
if(TRIGGERS_OPTION_ONLYTRUE){
@@ -441,7 +444,7 @@ include_once "include/page_header.php";
' AND i.status='.ITEM_STATUS_ACTIVE.
' AND '.DBcondition('t.triggerid',$available_triggers).
' AND h.status='.HOST_STATUS_MONITORED.' '.$cond.
- order_by('h.host,h.hostid,t.description,t.priority,t.lastchange');
+ order_by('h.host,h.hostid,t.description,t.priority,t.lastchange');
$result = DBselect($sql);