diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-14 12:26:49 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-14 12:26:49 +0000 |
| commit | d144df19e9190a100f3d12a2e70c0637f0bda38d (patch) | |
| tree | f7b9e5d1aeba8ee1a89a84c78e681ab24d526692 /frontends/php/include/validate.inc.php | |
| parent | 1562339df0317816bbbee60d1478234e58d4f6f8 (diff) | |
| download | zabbix-d144df19e9190a100f3d12a2e70c0637f0bda38d.tar.gz zabbix-d144df19e9190a100f3d12a2e70c0637f0bda38d.tar.xz zabbix-d144df19e9190a100f3d12a2e70c0637f0bda38d.zip | |
updated frontend for new discovefy
git-svn-id: svn://svn.zabbix.com/trunk@4011 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/validate.inc.php')
| -rw-r--r-- | frontends/php/include/validate.inc.php | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index 84d52440..223f5a9e 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -66,20 +66,25 @@ return true; } - function validate_ip_list($str) + function validate_ip_range($str) { foreach(explode(',',$str) as $ip_range) { - $networks = array(); - $ip_range = explode('-', $ip_range); - if(count($ip_range) > 2) return false; - foreach($ip_range as $ip) + $ip_parts = explode('.', $ip_range); + if(count($ip_parts) != 4) return false; + + if( !is_numeric($ip_parts[0]) || $ip_parts[0] < 0 || $ip_parts[0] > 255 ) return false; + if( !is_numeric($ip_parts[1]) || $ip_parts[1] < 0 || $ip_parts[1] > 255 ) return false; + if( !is_numeric($ip_parts[2]) || $ip_parts[2] < 0 || $ip_parts[2] > 255 ) return false; + + $last_part = explode('-', $ip_parts[3]); + if(count($last_part) > 2) return false; + foreach($last_part as $ip_p) { - if( !validate_ip($ip, $arr) ) return false; - $network = $arr[1].'.'.$arr['2'].'.'.$arr[3]; - $networks[$network] = $network; + if( !is_numeric($ip_p) || $ip_p < 0 || $ip_p > 255 ) return false; } - if( count($networks) > 1 ) return false; + if(count($last_part) == 2 && $last_part[0] > $last_part[1]) return false; + } return true; } @@ -228,6 +233,24 @@ return ZBX_VALID_OK; } + 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 + { + info("Warning. Field [".$field."] is not IP range"); + return ZBX_VALID_WARNING; + } + } + return ZBX_VALID_OK; + } + if($type == T_ZBX_PORTS) { $err = ZBX_VALID_OK; |
