Don't OR options together.

By default FILTER_VALIDATE_IP does both.
This commit is contained in:
mark_story 2012-06-10 20:29:48 -04:00
parent 963f1ca449
commit c31858635f

View file

@ -468,11 +468,11 @@ class Validation {
public static function ip($check, $type = 'both') {
$type = strtolower($type);
$flags = 0;
if ($type === 'ipv4' || $type === 'both') {
$flags |= FILTER_FLAG_IPV4;
if ($type === 'ipv4') {
$flags = FILTER_FLAG_IPV4;
}
if ($type === 'ipv6' || $type === 'both') {
$flags |= FILTER_FLAG_IPV6;
if ($type === 'ipv6') {
$flags = FILTER_FLAG_IPV6;
}
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
}