Checking : Array
(
[80.140.2.2] => 80.140.*.*
[80.141.2.2] => 80.140.*.*
[80.140.2.3] => 80.140/16
[1.2.3.4] => 1.2.3.0-1.2.255.255
[90.35.6.12] => 80.140.0.0-80.140.255.255
[80.76.201.37] => 80.76.201.32/27
[80.76.201.38] => 80.76.201.32/255.255.255.224
[80.76.201.39] => 80.76.201.32/255.255.255.*
[80.76.201.40] => 80.76.201.64/27
[192.168.1.42] => 192.168.3.0/24
[128.0.0.0] => 127.0.0.0-129.0.0.0
[2001:470:e090:f:215:c5ff:fe10:37fb] => 2001:470:e090::/48
[2002:470:e090:f:215:c5ff:fe10:37fb] => 2001:470:e090::/48
)
-------------------
Checking for 80.140.2.2 in 80.140.*.*
80.140.2.2 in 80.140.*.* = OK
-------------------
-------------------
Checking for 80.141.2.2 in 80.140.*.*
80.141.2.2 in 80.140.*.* = Fail
-------------------
-------------------
Checking for 80.140.2.3 in 80.140/16
80.140.2.3 in 80.140/16 = OK
-------------------
-------------------
Checking for 1.2.3.4 in 1.2.3.0-1.2.255.255
1.2.3.4 in 1.2.3.0-1.2.255.255 = OK
-------------------
-------------------
Checking for 90.35.6.12 in 80.140.0.0-80.140.255.255
90.35.6.12 in 80.140.0.0-80.140.255.255 = Fail
-------------------
-------------------
Checking for 80.76.201.37 in 80.76.201.32/27
80.76.201.37 in 80.76.201.32/27 = OK
-------------------
-------------------
Checking for 80.76.201.38 in 80.76.201.32/255.255.255.224
80.76.201.38 in 80.76.201.32/255.255.255.224 = OK
-------------------
-------------------
Checking for 80.76.201.39 in 80.76.201.32/255.255.255.*
80.76.201.39 in 80.76.201.32/255.255.255.* = OK
-------------------
-------------------
Checking for 80.76.201.40 in 80.76.201.64/27
80.76.201.40 in 80.76.201.64/27 = Fail
-------------------
-------------------
Checking for 192.168.1.42 in 192.168.3.0/24
192.168.1.42 in 192.168.3.0/24 = Fail
-------------------
-------------------
Checking for 128.0.0.0 in 127.0.0.0-129.0.0.0
128.0.0.0 in 127.0.0.0-129.0.0.0 = OK
-------------------
-------------------
Checking for 2001:470:e090:f:215:c5ff:fe10:37fb in 2001:470:e090::/48
Deprecated: Function split() is deprecated in /u1/web/pgregg.com/source/projects/php/ip_in_range/ip_in_range2.php on line 45
Deprecated: Function split() is deprecated in /u1/web/pgregg.com/source/projects/php/ip_in_range/ip_in_range2.php on line 45
2001:470:e090:f:215:c5ff:fe10:37fb in 2001:470:e090::/48 = OK
-------------------
-------------------
Checking for 2002:470:e090:f:215:c5ff:fe10:37fb in 2001:470:e090::/48
Deprecated: Function split() is deprecated in /u1/web/pgregg.com/source/projects/php/ip_in_range/ip_in_range2.php on line 45
Deprecated: Function split() is deprecated in /u1/web/pgregg.com/source/projects/php/ip_in_range/ip_in_range2.php on line 45
2002:470:e090:f:215:c5ff:fe10:37fb in 2001:470:e090::/48 = Fail
-------------------
<?php
if (isset($_SERVER['REMOTE_ADDR'])) echo '<pre>';
$checkips = array(
'80.140.2.2' => '80.140.*.*',
'80.141.2.2' => '80.140.*.*',
'80.140.2.3' => '80.140/16',
'1.2.3.4' => '1.2.3.0-1.2.255.255',
'90.35.6.12' => '80.140.0.0-80.140.255.255',
'80.76.201.37' => '80.76.201.32/27',
'80.76.201.38' => '80.76.201.32/255.255.255.224',
'80.76.201.39' => '80.76.201.32/255.255.255.*',
'80.76.201.40' => '80.76.201.64/27',
'192.168.1.42' => '192.168.3.0/24',
'128.0.0.0' => '127.0.0.0-129.0.0.0',
'2001:470:e090:f:215:c5ff:fe10:37fb' => '2001:470:e090::/48',
'2002:470:e090:f:215:c5ff:fe10:37fb' => '2001:470:e090::/48',
);
echo 'Checking : ', print_r($checkips, true);
include 'ip_in_range2.php';
foreach ($checkips as $ip => $range) {
echo '-------------------', "\n";
echo "Checking for $ip in $range\n";
$ok = ip_in_range($ip, $range);
echo $ip, ' in ', $range, ' = ', ($ok ? ' OK' : ' Fail'), "\n";
echo '-------------------', "\n";
}
if (isset($_SERVER['REMOTE_ADDR'])) echo '</pre>';
else exit;
echo '<br /><hr>';
show_source(__FILE__);