Im trying to create an IP blocking script that I can implement only on necessary pages as opposed to using .htaccess which although effective is a little to powerful for my needs.
I have the following scripts but do not know how to incorporate the two so that the resulting script will allow a lookup of IP's in a .php or .ini file (eg: banlist.php) and feed that user the resulting message.
Any help getting this working would be greatly appreciated.
Thank you in advance
1.
$blockip = file($file)
if (in_array($_SERVER['REMOTE_ADDR'], $bannedlist))
{
echo "You Have Been Banned from using this page";
exit();
}
2.
$blockip = array(
'1xy.2xy.3xy.4xy'=> 'You\'ve a spammed !',
);
foreach($blockip as $key=>$val)
{if ($_SERVER['REMOTE_ADDR'] == $key)
{
die("You Have Been Banned from using this page because<br><br> $val");
}
}