summaryrefslogtreecommitdiff
path: root/kohana/helpers/valid.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-17 19:28:26 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-17 19:28:26 +0000
commitfe396410894f9fcf430e31216312f70db800d96e (patch)
treefc1222c074e0f8ffd2d952688353f5bf79e360f5 /kohana/helpers/valid.php
parent093fb407a839b1bdacd0cd6036b349a42dcfea7d (diff)
Update Kohana code to r3799 from their svn head. All tests pass.
Resolved upstream tickets: http://dev.kohanaphp.com/ticket/972 Command: svn merge -c19275 vendor/kohana/modified/kohana trunk/kohana
Diffstat (limited to 'kohana/helpers/valid.php')
-rw-r--r--kohana/helpers/valid.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/kohana/helpers/valid.php b/kohana/helpers/valid.php
index d71dbcae..3d3206c8 100644
--- a/kohana/helpers/valid.php
+++ b/kohana/helpers/valid.php
@@ -87,10 +87,12 @@ class valid_Core {
* @param boolean allow IPv6 addresses
* @return boolean
*/
- public static function ip($ip, $ipv6 = FALSE)
+ public static function ip($ip, $ipv6 = FALSE, $allow_private = FALSE)
{
- // Do not allow private and reserved range IPs
+ // By default do not allow private and reserved range IPs
$flags = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
+ if ($allow_private === TRUE)
+ $flags = FILTER_FLAG_NO_RES_RANGE;
if ($ipv6 === TRUE)
return (bool) filter_var($ip, FILTER_VALIDATE_IP, $flags);
@@ -264,12 +266,17 @@ class valid_Core {
/**
* Checks whether a string is a valid number (negative and decimal numbers allowed).
*
+ * @see Uses locale conversion to allow decimal point to be locale specific.
+ * @see http://www.php.net/manual/en/function.localeconv.php
+ *
* @param string input string
* @return boolean
*/
public static function numeric($str)
{
- return (is_numeric($str) AND preg_match('/^[-0-9.]++$/D', (string) $str));
+ // Use localeconv to set the decimal_point value: Usually a comma or period.
+ $locale = localeconv();
+ return (preg_match('/^[-0-9'.$locale['decimal_point'].']++$/D', (string) $str));
}
/**