1 | <?php |
||
16 | class IPUtils { |
||
|
|||
17 | /** |
||
18 | * This class should not be instantiated. |
||
19 | */ |
||
20 | private function __construct() |
||
23 | /** |
||
24 | * Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets. |
||
25 | * |
||
26 | * @param string $requestIP IP to check |
||
27 | * @param string|array $ips List of IPs or subnets (can be a string if only a single one) |
||
28 | * |
||
29 | * @return bool Whether the IP is valid |
||
30 | * |
||
31 | * @package framework |
||
32 | * @subpackage core |
||
33 | */ |
||
34 | public static function checkIP($requestIP, $ips) { |
||
49 | /** |
||
50 | * Compares two IPv4 addresses. |
||
51 | * In case a subnet is given, it checks if it contains the request IP. |
||
52 | * |
||
53 | * @param string $requestIP IPv4 address to check |
||
54 | * @param string $ip IPv4 address or subnet in CIDR notation |
||
55 | * |
||
56 | * @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet |
||
57 | */ |
||
58 | public static function checkIP4($requestIP, $ip) { |
||
80 | /** |
||
81 | * Compares two IPv6 addresses. |
||
82 | * In case a subnet is given, it checks if it contains the request IP. |
||
83 | * |
||
84 | * @author David Soria Parra <dsp at php dot net> |
||
85 | * |
||
86 | * @see https://github.com/dsp/v6tools |
||
87 | * |
||
88 | * @param string $requestIP IPv6 address to check |
||
89 | * @param string $ip IPv6 address or subnet in CIDR notation |
||
90 | * |
||
91 | * @return bool Whether the IP is valid |
||
92 | * |
||
93 | * @throws \RuntimeException When IPV6 support is not enabled |
||
94 | */ |
||
95 | public static function checkIP6($requestIP, $ip) { |
||
129 | } |
||
130 |