download all bans, then compare in PHP; saves DB effort and allows more flexible ban matching
git-svn-id: file:///home/shish/svn/shimmie2/trunk@738 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
abc2fe278a
commit
fe8ab42901
@ -91,10 +91,12 @@ class IPBan extends Extension {
|
|||||||
// }}}
|
// }}}
|
||||||
// deal with banned person {{{
|
// deal with banned person {{{
|
||||||
private function check_ip_ban() {
|
private function check_ip_ban() {
|
||||||
$row = $this->get_ip_ban($_SERVER['REMOTE_ADDR']);
|
|
||||||
if($row) {
|
|
||||||
global $config;
|
global $config;
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
$bans = $this->get_active_bans();
|
||||||
|
foreach($bans as $row) {
|
||||||
|
if($row['ip'] == $_SERVER['REMOTE_ADDR']) {
|
||||||
$admin = $database->get_user_by_id($row['banner_id']);
|
$admin = $database->get_user_by_id($row['banner_id']);
|
||||||
print "IP <b>{$row['ip']}</b> has been banned by <b>{$admin->name}</b> because of <b>{$row['reason']}</b>";
|
print "IP <b>{$row['ip']}</b> has been banned by <b>{$admin->name}</b> because of <b>{$row['reason']}</b>";
|
||||||
|
|
||||||
@ -105,6 +107,7 @@ class IPBan extends Extension {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// database {{{
|
// database {{{
|
||||||
private function get_bans() {
|
private function get_bans() {
|
||||||
@ -114,6 +117,13 @@ class IPBan extends Extension {
|
|||||||
else {return array();}
|
else {return array();}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function get_active_bans() {
|
||||||
|
global $database;
|
||||||
|
$bans = $database->get_all("SELECT * FROM bans WHERE (date < now()) AND (end > now() OR isnull(end))");
|
||||||
|
if($bans) {return $bans;}
|
||||||
|
else {return array();}
|
||||||
|
}
|
||||||
|
|
||||||
private function get_ip_ban($ip) {
|
private function get_ip_ban($ip) {
|
||||||
global $database;
|
global $database;
|
||||||
return $database->db->GetRow("SELECT * FROM bans WHERE ip = ? AND date < now() AND (end > now() OR isnull(end))", array($ip));
|
return $database->db->GetRow("SELECT * FROM bans WHERE ip = ? AND date < now() AND (end > now() OR isnull(end))", array($ip));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user