diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index 74ba506c..237c7c07 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -163,16 +163,20 @@ class IPBan implements Extension { global $config; global $database; + $prefix = ($database->engine->name == "sqlite" ? "bans." : ""); + $remote = $_SERVER['REMOTE_ADDR']; $bans = $this->get_active_bans(); foreach($bans as $row) { + $ip = $row[$prefix."ip"]; if( - (strstr($row['ip'], '/') && ip_in_range($remote, $row['ip'])) || - ($row['ip'] == $remote) + (strstr($ip, '/') && ip_in_range($remote, $ip)) || + ($ip == $remote) ) { - $admin = User::by_id($row['banner_id']); - $date = date("Y-m-d", $row['end_timestamp']); - print "IP {$row['ip']} has been banned until $date by {$admin->name} because of {$row['reason']}"; + $reason = $row[$prefix.'reason']; + $admin = User::by_id($row[$prefix.'banner_id']); + $date = date("Y-m-d", $row[$prefix.'end_timestamp']); + print "IP $ip has been banned until $date by {$admin->name} because of $reason"; $contact_link = $config->get_string("contact_link"); if(!empty($contact_link)) { @@ -190,7 +194,7 @@ class IPBan implements Extension { SELECT bans.*, users.name as banner_name FROM bans JOIN users ON banner_id = users.id - ORDER BY end_timestamp, id + ORDER BY end_timestamp, bans.id "); if($bans) {return $bans;} else {return array();} @@ -207,7 +211,7 @@ class IPBan implements Extension { FROM bans JOIN users ON banner_id = users.id WHERE (end_timestamp > UNIX_TIMESTAMP(now())) OR (end_timestamp IS NULL) - ORDER BY end_timestamp, id + ORDER BY end_timestamp, bans.id "); $database->cache->set("bans", $bans); diff --git a/contrib/ipban/theme.php b/contrib/ipban/theme.php index 0d46efd4..67007b89 100644 --- a/contrib/ipban/theme.php +++ b/contrib/ipban/theme.php @@ -12,21 +12,23 @@ class IPBanTheme extends Themelet { * ) */ public function display_bans(Page $page, $bans) { - global $user; + global $database, $user; $h_bans = ""; $n = 0; + $prefix = ($database->engine->name == "sqlite" ? "bans." : ""); + $prefix2 = ($database->engine->name == "sqlite" ? "users." : ""); foreach($bans as $ban) { - $end_human = date('Y-m-d', $ban['end_timestamp']); + $end_human = date('Y-m-d', $ban[$prefix.'end_timestamp']); $oe = ($n++ % 2 == 0) ? "even" : "odd"; $h_bans .= "