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,18 +91,21 @@ class IPBan extends Extension {
|
||||
// }}}
|
||||
// deal with banned person {{{
|
||||
private function check_ip_ban() {
|
||||
$row = $this->get_ip_ban($_SERVER['REMOTE_ADDR']);
|
||||
if($row) {
|
||||
global $config;
|
||||
global $database;
|
||||
$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>";
|
||||
global $config;
|
||||
global $database;
|
||||
|
||||
$contact_link = $config->get_string("contact_link");
|
||||
if(!empty($contact_link)) {
|
||||
print "<p><a href='$contact_link'>Contact The Admin</a>";
|
||||
$bans = $this->get_active_bans();
|
||||
foreach($bans as $row) {
|
||||
if($row['ip'] == $_SERVER['REMOTE_ADDR']) {
|
||||
$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>";
|
||||
|
||||
$contact_link = $config->get_string("contact_link");
|
||||
if(!empty($contact_link)) {
|
||||
print "<p><a href='$contact_link'>Contact The Admin</a>";
|
||||
}
|
||||
exit;
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
@ -114,6 +117,13 @@ class IPBan extends Extension {
|
||||
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) {
|
||||
global $database;
|
||||
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