I’ve been customizing the hell out of my WP and part of my upgrading from NewsPRO/ASP to WP was importing my ASP IP banning script.
Currently, this is the script I am using and it works perfectly:
<?php
$banned_ip = array();
$banned_ip[] = '123.123.123.123'; //specific
$banned_ip[] = '222.222.222; //beginning with those 3 sets
$banned_ip[] = '222.222'; //222.222.1.1, 222.222.242.142, etc.
$banned_ip[] = '25'; //let's block anything beginning with 25
foreach($banned_ip as $banned) {
$ip = $_SERVER['REMOTE_ADDR'];
if(0 === strpos($ip, $banned)) {
header("Location: "."[URL TO SEND PEOPLE TO]");
exit();
}
}
?>
you can add as many IPs as you want, etc…