diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-26 08:17:13 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-10-26 08:17:13 +0000 |
| commit | 1b9fa06acb3c68871d5d87053d047430ff0acbfb (patch) | |
| tree | 39e1430c9c1e3531d0ec406c883a5643f59e6cb9 /frontends/php/include/validate.inc.php | |
| parent | 4d02efc00fc5a4c076f12c4039197baf080c33d4 (diff) | |
| download | zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.tar.gz zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.tar.xz zabbix-1b9fa06acb3c68871d5d87053d047430ff0acbfb.zip | |
- developed IP input box (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3384 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/validate.inc.php')
| -rw-r--r-- | frontends/php/include/validate.inc.php | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php index dba4ffae..2489c52a 100644 --- a/frontends/php/include/validate.inc.php +++ b/frontends/php/include/validate.inc.php @@ -92,8 +92,8 @@ { foreach($_REQUEST[$field] as $key => $val) { - $expression = str_replace("{}",'$_REQUEST["'.$field.'"]['.$key.']',$expression); - if(calc_exp2($fields,$field,$expression)==FALSE) + $expression2 = str_replace("{}",'$_REQUEST["'.$field.'"]['.$key.']',$expression); + if(calc_exp2($fields,$field,$expression2)==FALSE) return FALSE; } return TRUE; @@ -150,7 +150,7 @@ function check_type(&$field, $flags, &$var, $type) { - if(is_array($var)) + if(is_array($var) && $type != T_ZBX_IP) { $err = ZBX_VALID_OK; foreach($var as $el) @@ -160,6 +160,27 @@ return $err; } + if($type == T_ZBX_IP) + { + if(!is_array($var)) $var = explode('.',$var); + if(!isset($var[0]) || !isset($var[1]) || !isset($var[2]) || !isset($var[3])) + { + if($flags&P_SYS) + { + info("Critical error. Field [".$field."] is not IP"); + return ZBX_VALID_ERROR; + } + else + { + info("Warning. Field [".$field."] is not IP"); + return ZBX_VALID_WARNING; + } + } + $err = ZBX_VALID_OK; + foreach($var as $el) $err |= check_type($field, $flags, $el, T_ZBX_INT); + return $err; + } + if(($type == T_ZBX_INT) && !is_numeric($var)) { if($flags&P_SYS) { @@ -220,6 +241,8 @@ { list($type,$opt,$flags,$validation,$exception)=$checks; + if($type == T_ZBX_IP) $validation = BETWEEN(0,255); + //echo "Field: $field<br>"; if($exception==NULL) $except=FALSE; @@ -294,6 +317,12 @@ } } } + + if($type == T_ZBX_IP) + { + $_REQUEST[$field] = implode('.', $_REQUEST[$field]); + } + return ZBX_VALID_OK; } |
