Forum Moderators: coopster
<?php
$range_start = ip2long("68.61.156.0");
$range_end = ip2long("61.181.255");
$ip = ip2long($_SERVER['REMOTE_ADDR']);
if ($ip >= $range_start && $ip <= $range_end) {
// blocked
}
?>
<?php
$blocklist = array(
'123.45.67.89', // Single IP
array('68.61.156.0','61.181.255'), // IP Range
'111.111.111.111' // Another single IP
);
$ip = ip2long($_SERVER['REMOTE_ADDR']);
foreach ($blocklist as $b) {
if (is_array($b)) {
$s = ip2long($b[0]);
$e = ip2long($b[1]);
if ($ip >= $s && $ip <= $e) {
print 'Blocked IP'; exit();
}
}
elseif ($ip == ip2long($b)) {
print 'Blocked IP'; exit();
}
}
?>