diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-02 11:22:22 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-04-02 11:22:22 +0000 |
| commit | d2a3e65806eb484b59de7c3d8b7a8612249e70ca (patch) | |
| tree | a86c165cd36fe5284a3e59bcbcf6a10eb56077dc /frontends/php/include/validate.inc.php | |
| parent | 5297145c0a145eea288a0488e24e08d56c2b7dee (diff) | |
| download | zabbix-d2a3e65806eb484b59de7c3d8b7a8612249e70ca.tar.gz zabbix-d2a3e65806eb484b59de7c3d8b7a8612249e70ca.tar.xz zabbix-d2a3e65806eb484b59de7c3d8b7a8612249e70ca.zip | |
- Developed action configurations for discodery events (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3965 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/validate.inc.php')
| -rw-r--r-- | frontends/php/include/validate.inc.php | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index ea704e4b..90a4eb41 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -59,6 +59,45 @@ return 'ereg(\'^([0-9a-zA-Z\_\.[.-.]\$ ]+)$\',{'.$var.'})&&'; } + function validate_ip($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_ip_list($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) + { + if( !validate_ip($ip, $arr) ) return false; + $network = $arr[1].'.'.$arr['2'].'.'.$arr[3]; + $networks[$network] = $network; + } + if( count($networks) > 1 ) return false; + } + return true; + } + + 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; + } + + define("NOT_EMPTY","({}!='')&&"); define("DB_ID","({}>=0&&bccomp('{}',\"10000000000000000000\")<0)&&"); @@ -173,8 +212,7 @@ if($type == T_ZBX_IP) { - if(!is_array($var)) $var = explode('.',$var); - if(count($var) != 4) + if( !validate_ip($var) ) { if($flags&P_SYS) { @@ -187,9 +225,7 @@ return ZBX_VALID_WARNING; } } - $err = ZBX_VALID_OK; - foreach($var as $el) $err |= check_type($field, $flags, $el, T_ZBX_INT); - return $err; + return ZBX_VALID_OK; } if($type == T_ZBX_PORTS) @@ -275,8 +311,6 @@ { list($type,$opt,$flags,$validation,$exception)=$checks; - if($type == T_ZBX_IP) $validation = BETWEEN(0,255); - if($flags&P_UNSET_EMPTY && isset($_REQUEST[$field]) && $_REQUEST[$field]=='') { unset_request($field,'P_UNSET_EMPTY'); @@ -389,11 +423,6 @@ foreach($fields as $field => $checks) { $err |= check_field($fields, $field,$checks); - - if($checks[0] == T_ZBX_IP && isset($_REQUEST[$field])) - { - $_REQUEST[$field] = implode('.', $_REQUEST[$field]); - } } unset_not_in_list($fields); |
