From 193f28f3518aae0fbf3b0ce523a5ac13dc8074f4 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 14 Mar 2008 20:26:13 +0000 Subject: [PATCH] Added checks for numeric input in user native format. --- includes/data_checks.inc | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/includes/data_checks.inc b/includes/data_checks.inc index ef33acfd..89d57d63 100644 --- a/includes/data_checks.inc +++ b/includes/data_checks.inc @@ -1,5 +1,4 @@ 0; } +// +// Integer input check +// Return 1 if number has proper form and is within range +// +function check_int($postname, $min=null, $max=null) { + if(!isset($_POST[$postname])) + return 0; + $num = input_num($postname); + if(!is_int($num)) + return 0; + if (isset($min) && ($num<$min)) + return 0; + if (isset($max) && ($num>$max)) + return 0; + return 1; +} +// +// Numeric input check. +// Return 1 if number has proper form and is within range +// +function check_num($postname, $min=null, $max=null) { + if(!isset($_POST[$postname])) + return 0; + $num = input_num($postname); + if ($num === false) + return 0; + if (isset($min) && ($num<$min)) + return 0; + if (isset($max) && ($num>$max)) + return 0; + return 1; +} + ?> \ No newline at end of file -- 2.30.2