mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '2.1' into 2.2
This commit is contained in:
commit
76dd49145a
2 changed files with 6 additions and 6 deletions
|
@ -1657,7 +1657,7 @@ class ValidationTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testIpV4() {
|
public function testIpV4() {
|
||||||
$this->assertTrue(Validation::ip('0.0.0.0'));
|
$this->assertTrue(Validation::ip('0.0.0.0', 'ipv4'));
|
||||||
$this->assertTrue(Validation::ip('192.168.1.156'));
|
$this->assertTrue(Validation::ip('192.168.1.156'));
|
||||||
$this->assertTrue(Validation::ip('255.255.255.255'));
|
$this->assertTrue(Validation::ip('255.255.255.255'));
|
||||||
$this->assertFalse(Validation::ip('127.0.0'));
|
$this->assertFalse(Validation::ip('127.0.0'));
|
||||||
|
|
|
@ -468,12 +468,12 @@ class Validation {
|
||||||
*/
|
*/
|
||||||
public static function ip($check, $type = 'both') {
|
public static function ip($check, $type = 'both') {
|
||||||
$type = strtolower($type);
|
$type = strtolower($type);
|
||||||
$flags = null;
|
$flags = 0;
|
||||||
if ($type === 'ipv4' || $type === 'both') {
|
if ($type === 'ipv4') {
|
||||||
$flags |= FILTER_FLAG_IPV4;
|
$flags = FILTER_FLAG_IPV4;
|
||||||
}
|
}
|
||||||
if ($type === 'ipv6' || $type === 'both') {
|
if ($type === 'ipv6') {
|
||||||
$flags |= FILTER_FLAG_IPV6;
|
$flags = FILTER_FLAG_IPV6;
|
||||||
}
|
}
|
||||||
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
|
return (boolean)filter_var($check, FILTER_VALIDATE_IP, array('flags' => $flags));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue