summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-17 16:33:34 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-17 16:33:34 +0000
commit9eaf71aa5dcdaa32ee823059500d60e597f856e4 (patch)
treef667c5383c76967f9ae1cc203d59ca17efe56a87
parent0f6562e1ff12b714a422703215ad9f0e6e00ed8d (diff)
downloadzabbix-9eaf71aa5dcdaa32ee823059500d60e597f856e4.tar.gz
zabbix-9eaf71aa5dcdaa32ee823059500d60e597f856e4.tar.xz
zabbix-9eaf71aa5dcdaa32ee823059500d60e597f856e4.zip
Minor changes.
git-svn-id: svn://svn.zabbix.com/trunk@2535 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--frontends/php/config.php30
-rw-r--r--frontends/php/include/validate.inc.php59
-rw-r--r--frontends/php/items.php12
3 files changed, 94 insertions, 7 deletions
diff --git a/frontends/php/config.php b/frontends/php/config.php
index 8548a2c1..1e5185fc 100644
--- a/frontends/php/config.php
+++ b/frontends/php/config.php
@@ -44,6 +44,36 @@
?>
<?php
+ function BETWEEN($min,$max)
+ {
+ return "({}>=$min&&{}<=$max)&&";
+ }
+
+ function GT($value)
+ {
+ return "({}>=$value)&&";
+ }
+
+ function IN($array)
+ {
+ return "in_array({},array($array))&&";
+ }
+
+ define("NOT_EMPTY","({}!='')&&");
+
+// VAR TYPE OPTIONAL TABLE FIELD OPTIONAL VALIDATION EXCEPTION
+ $fields=array(
+ "config"=> array(T_ZBX_INT, O_OPT, NULL, NULL, IN("0,1,3,4,5"), NULL),
+ "refresh_unsupported"=> array(T_ZBX_INT, O_MAND, "config", NULL, BETWEEN(30,65535), NULL)
+ );
+
+ if(!check_fields($fields))
+ {
+ show_messages();
+ }
+?>
+
+<?php
/* if(isset($_REQUEST["config"])) $_REQUEST["config"]=$_REQUEST["config"]; */
$_REQUEST["config"]=@iif(isset($_REQUEST["config"]),$_REQUEST["config"],get_profile("web.config.config",0));
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php
index ce1c6cc3..848a4099 100644
--- a/frontends/php/include/validate.inc.php
+++ b/frontends/php/include/validate.inc.php
@@ -54,6 +54,20 @@
return $ret;
}
+ function calc_exp($field,$expression)
+ {
+ global $_REQUEST;
+
+ if(strstr($expression,"{}"))
+ {
+ if(!isset($_REQUEST[$field])) return FALSE;
+ }
+ $exec = str_replace("{}",'$_REQUEST["'.$field.'"]',$expression);
+ $exec = "return ".$exec.'1;';
+// echo $exec,"<br>";
+ return eval($exec);
+ }
+
function check_fields($fields)
{
global $_REQUEST;
@@ -62,7 +76,50 @@
foreach($fields as $field => $checks)
{
- list($type,$opt,$table,$field,$validation,$exception)=$checks;
+ list($type,$opt,$table,$column,$validation,$exception)=$checks;
+
+
+ if($exception==NULL) $except=FALSE;
+ else $except=calc_exp($field,$exception);
+
+
+ if($opt == O_MAND && $exception) $opt = O_NO;
+ else if($opt == O_OPT && $exception) $opt = O_MAND;
+ else if($opt == O_NO && $exception) $opt = O_MAND;
+
+ if($opt == O_MAND)
+ {
+ if(!isset($_REQUEST[$field]))
+ {
+ info("Field [".$field."] is mandatory"); $ret = 0; continue;
+ }
+ }
+
+ if($opt == O_NO)
+ {
+ if(isset($_REQUEST[$field]))
+ {
+ info("Field [".$field."] must be missing"); $ret = 0; continue;
+ }
+ else continue;
+ }
+
+
+ if( ($type == T_ZBX_INT) && !is_numeric($_REQUEST[$field])) {
+ info("Field [".$field."] is not integer"); $ret = 0; continue;
+ }
+
+ if( ($type == T_ZBX_DBL) && !is_numeric($_REQUEST[$field])) {
+ info("Field [".$field."] is not double"); $ret = 0; continue;
+ }
+
+ if($validation==NULL) $valid=TRUE;
+ else $valid=calc_exp($field,$validation);
+
+ if(!$valid)
+ {
+ info("Field [".$field."] is invalid"); $ret = 0; continue;
+ }
}
return $ret;
}
diff --git a/frontends/php/items.php b/frontends/php/items.php
index 532e2cab..c0f97c7e 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -42,12 +42,12 @@
function BETWEEN($min,$max)
{
- return "({}=>$min&&{}<=$max)&&";
+ return "({}>=$min&&{}<=$max)&&";
}
function GT($value)
{
- return "({}=>$value)&&";
+ return "({}>=$value)&&";
}
function IN($array)
@@ -84,10 +84,10 @@
"groupid"=> array(T_ZBX_INT, O_MAND, "items", NULL, BETWEEN(0,65535*65536), NULL)
);
- if(!check_fields($fields))
- {
- info("ZZZ");
- }
+// if(!check_fields($fields))
+// {
+// show_messages();
+// }
?>
<?php