From: Janusz Dobrowolski Date: Fri, 14 Mar 2008 20:26:13 +0000 (+0000) Subject: Added checks for numeric input in user native format. X-Git-Tag: v2.4.2~19^2~2182 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=193f28f3518aae0fbf3b0ce523a5ac13dc8074f4;p=fa-stable.git Added checks for numeric input in user native format. --- 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