- Impact
- 1
I wanting to create a better ip blocker but can't seem to figure it out.
First here is the code that I get the ip with
This is a sample of the $ip output after that line
$ip = "216.86.152.216";
When an ip is blocked it is added to a table in the database. When the page is accessed it checks for the ip output from the above line against what is in the table.
Now here is my problem, for instance if 216.86.152.216 is a banned ip and they have a dynamic ip their next access may be 216.86.152.153. How can I ban the range of an ip without having to redo the input to the db. Is there a way to do it when the ip is checked against the db? For example when I ban 216.86.152.216, I want it to ban all ip's 216.86.152.XXX
First here is the code that I get the ip with
PHP:
$ip = ($_SERVER['HTTP_X_FORWARDED_FOR'])
? $_SERVER['HTTP_X_FORWARDED_FOR']
: $_SERVER['REMOTE_ADDR'];
This is a sample of the $ip output after that line
$ip = "216.86.152.216";
When an ip is blocked it is added to a table in the database. When the page is accessed it checks for the ip output from the above line against what is in the table.
PHP:
$query=mysql_query("SELECT * FROM bans WHERE banip LIKE '%$ip%'", $c);
$count=mysql_num_rows($query);
mysql_free_result($query);
if($count == 1)
{
die("<b><font color=red size=+1>Your IP has been banned, there is no way around this.</font></b></body></html>");
}
Now here is my problem, for instance if 216.86.152.216 is a banned ip and they have a dynamic ip their next access may be 216.86.152.153. How can I ban the range of an ip without having to redo the input to the db. Is there a way to do it when the ip is checked against the db? For example when I ban 216.86.152.216, I want it to ban all ip's 216.86.152.XXX





