Re: Ip Blocking
| From: | Andrey Hristov | Date: | Fri, 05 Oct 2001 18:18:34 +0000 |
| Subject: | Re: Ip Blocking | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-70124@lists.php.net to get a copy of this message | ||
Interesting. After hlaf a minute an idea came to my brain.
create table blocked( from_ip bigint unsigned, to_ip bigint unsigned);
<?php
list($is_bad)=mysql_fetch_array(mysql_query("select count(*) from blocked
where $REMOTE_ADDR>=from_ip and $REMOTE_ADDR<=to_ip;"));
?>
Hope this helps.
$REMOTE_ADDR have to be integer => use ip2long().
For single IP the ints in the row are equivalent. from_ip and to_ip gives you
range.
Andrey Hristov
IcyGEN Corporation
BALANCED SOLUTIONS
http://www.icygen.com
;
On Friday 05 October 2001 21:12, you wrote:
> What would be the most effective way to create blocking of users by ip
> using mysql. In such as way that the "blocking system" allows for masks
> such as 24.127.89.*
> 24.*.*.*
> etc...
>
> So far the what I've come up with is either breaking the ip into 4 INTs and
> then running an SQL query to check if that ip is found in "Blocked Users"
> table.
>
> Replies would be appriciated
>
> Prottoss
--