Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/IpUtils.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
16 * | 16 * |
17 * @author Fabien Potencier <fabien@symfony.com> | 17 * @author Fabien Potencier <fabien@symfony.com> |
18 */ | 18 */ |
19 class IpUtils | 19 class IpUtils |
20 { | 20 { |
21 private static $checkedIps = array(); | 21 private static $checkedIps = []; |
22 | 22 |
23 /** | 23 /** |
24 * This class should not be instantiated. | 24 * This class should not be instantiated. |
25 */ | 25 */ |
26 private function __construct() | 26 private function __construct() |
35 * | 35 * |
36 * @return bool Whether the IP is valid | 36 * @return bool Whether the IP is valid |
37 */ | 37 */ |
38 public static function checkIp($requestIp, $ips) | 38 public static function checkIp($requestIp, $ips) |
39 { | 39 { |
40 if (!is_array($ips)) { | 40 if (!\is_array($ips)) { |
41 $ips = array($ips); | 41 $ips = [$ips]; |
42 } | 42 } |
43 | 43 |
44 $method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4'; | 44 $method = substr_count($requestIp, ':') > 1 ? 'checkIp6' : 'checkIp4'; |
45 | 45 |
46 foreach ($ips as $ip) { | 46 foreach ($ips as $ip) { |
114 $cacheKey = $requestIp.'-'.$ip; | 114 $cacheKey = $requestIp.'-'.$ip; |
115 if (isset(self::$checkedIps[$cacheKey])) { | 115 if (isset(self::$checkedIps[$cacheKey])) { |
116 return self::$checkedIps[$cacheKey]; | 116 return self::$checkedIps[$cacheKey]; |
117 } | 117 } |
118 | 118 |
119 if (!((extension_loaded('sockets') && defined('AF_INET6')) || @inet_pton('::1'))) { | 119 if (!((\extension_loaded('sockets') && \defined('AF_INET6')) || @inet_pton('::1'))) { |
120 throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".'); | 120 throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".'); |
121 } | 121 } |
122 | 122 |
123 if (false !== strpos($ip, '/')) { | 123 if (false !== strpos($ip, '/')) { |
124 list($address, $netmask) = explode('/', $ip, 2); | 124 list($address, $netmask) = explode('/', $ip, 2); |