Security
|
|
|
|
<?php
function checkIPorRange ($ip_address) {
if (ereg("-",$ip_address)) {
// Range
$ar = explode("-",$ip_address);
$your_long_ip = ip2long($_SERVER["REMOTE_ADDR"]);
if ( ($your_long_ip >= ip2long($ar[0])) && ($your_long_ip <= ip2long($ar[1])) ) {
return TRUE;
}
} else {
// Single IP
if ($_SERVER["REMOTE_ADDR"] == $ip_address) {
return TRUE;
}
}
return FALSE;
} ?>
|
|
|
Usage Example
|
$ip_range = "198.152.0.0-198.152.4.0";
if (checkIPorRange($ip_range)) {
print "IP OK";
}
If your IP was 198.152.1.32
The above would return: IP OK
|
|
|
Rate This Script
|
|
|
|