Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/http-foundation/IpUtils.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 7a779792577d |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
73 } | 73 } |
74 | 74 |
75 if (false !== strpos($ip, '/')) { | 75 if (false !== strpos($ip, '/')) { |
76 list($address, $netmask) = explode('/', $ip, 2); | 76 list($address, $netmask) = explode('/', $ip, 2); |
77 | 77 |
78 if ($netmask === '0') { | 78 if ('0' === $netmask) { |
79 return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); | 79 return self::$checkedIps[$cacheKey] = filter_var($address, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); |
80 } | 80 } |
81 | 81 |
82 if ($netmask < 0 || $netmask > 32) { | 82 if ($netmask < 0 || $netmask > 32) { |
83 return self::$checkedIps[$cacheKey] = false; | 83 return self::$checkedIps[$cacheKey] = false; |
84 } | 84 } |
85 } else { | 85 } else { |
86 $address = $ip; | 86 $address = $ip; |
87 $netmask = 32; | 87 $netmask = 32; |
88 } | |
89 | |
90 if (false === ip2long($address)) { | |
91 return self::$checkedIps[$cacheKey] = false; | |
88 } | 92 } |
89 | 93 |
90 return self::$checkedIps[$cacheKey] = 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask); | 94 return self::$checkedIps[$cacheKey] = 0 === substr_compare(sprintf('%032b', ip2long($requestIp)), sprintf('%032b', ip2long($address)), 0, $netmask); |
91 } | 95 } |
92 | 96 |
117 } | 121 } |
118 | 122 |
119 if (false !== strpos($ip, '/')) { | 123 if (false !== strpos($ip, '/')) { |
120 list($address, $netmask) = explode('/', $ip, 2); | 124 list($address, $netmask) = explode('/', $ip, 2); |
121 | 125 |
126 if ('0' === $netmask) { | |
127 return (bool) unpack('n*', @inet_pton($address)); | |
128 } | |
129 | |
122 if ($netmask < 1 || $netmask > 128) { | 130 if ($netmask < 1 || $netmask > 128) { |
123 return self::$checkedIps[$cacheKey] = false; | 131 return self::$checkedIps[$cacheKey] = false; |
124 } | 132 } |
125 } else { | 133 } else { |
126 $address = $ip; | 134 $address = $ip; |