mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Converted validation to use filter_var with ipv4/ipv6 separation matching 1.3 operation.
This commit is contained in:
parent
298b44a550
commit
396c025529
1 changed files with 10 additions and 2 deletions
|
@ -430,8 +430,16 @@ class Validation {
|
||||||
* @param string $ipVersion The IP Protocol version to validate against
|
* @param string $ipVersion The IP Protocol version to validate against
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function ip($check, $type = 'IPv4') {
|
public function ip($check, $type = 'both') {
|
||||||
return (boolean) filter_var($check, FILTER_VALIDATE_IP);
|
$type = strtolower($type);
|
||||||
|
$filterFlags = array();
|
||||||
|
if ($type === 'ipv4' || $type === 'both') {
|
||||||
|
$filterFlags[] = FILTER_FLAG_IPV4;
|
||||||
|
}
|
||||||
|
if ($type === 'ipv6' || $type === 'both') {
|
||||||
|
$filterFlags[] = FILTER_FLAG_IPV6;
|
||||||
|
}
|
||||||
|
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $filterFlags));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue