forked from leftypol/leftypol
IP range bans
This commit is contained in:
parent
6f62e038d4
commit
b4aa39ca2d
3 changed files with 18 additions and 5 deletions
|
@ -195,9 +195,14 @@
|
|||
return;
|
||||
}
|
||||
|
||||
$query = prepare("SELECT * FROM `bans` WHERE `ip` = :ip LIMIT 1");
|
||||
$query = prepare("SELECT * FROM `bans` WHERE `ip` = :ip ORDER BY `expires` IS NULL DESC, `expires` DESC, `expires` DESC LIMIT 1");
|
||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||
$query->execute() or error(db_error($query));
|
||||
if($query->rowCount() < 1 && $config['ban_range']) {
|
||||
$query = prepare("SELECT * FROM `bans` WHERE :ip REGEXP CONCAT('^', REPLACE(REPLACE(`ip`, '.', '\\.'), '*', '[0-9]*'), '$') ORDER BY `expires` IS NULL DESC, `expires` DESC LIMIT 1");
|
||||
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
|
||||
$query->execute() or error(db_error($query));
|
||||
}
|
||||
|
||||
if($ban = $query->fetch()) {
|
||||
if($ban['expires'] && $ban['expires'] < time()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue