public static function IpUtils::checkIp in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/IpUtils.php \Symfony\Component\HttpFoundation\IpUtils::checkIp()
Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets.
Parameters
string $requestIp IP to check:
string|array $ips List of IPs or subnets (can be a string if only a single one):
Return value
bool Whether the IP is valid
6 calls to IpUtils::checkIp()
- IpUtilsTest::testAnIpv6WithOptionDisabledIpv6 in vendor/
symfony/ http-foundation/ Tests/ IpUtilsTest.php - @expectedException \RuntimeException
- IpUtilsTest::testIpv4 in vendor/
symfony/ http-foundation/ Tests/ IpUtilsTest.php - @dataProvider testIpv4Provider
- IpUtilsTest::testIpv6 in vendor/
symfony/ http-foundation/ Tests/ IpUtilsTest.php - @dataProvider testIpv6Provider
- Request::getClientIps in vendor/
symfony/ http-foundation/ Request.php - Returns the client IP addresses.
- Request::isFromTrustedProxy in vendor/
symfony/ http-foundation/ Request.php
File
- vendor/
symfony/ http-foundation/ IpUtils.php, line 36
Class
- IpUtils
- Http utility functions.
Namespace
Symfony\Component\HttpFoundationCode
public static function checkIp($requestIp, $ips) {
if (!is_array($ips)) {
$ips = array(
$ips,
);
}
$method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4';
foreach ($ips as $ip) {
if (self::$method($requestIp, $ip)) {
return true;
}
}
return false;
}