cache ip bans

This commit is contained in:
Shish 2009-01-19 10:53:09 -08:00
parent be696e46de
commit 954edd9610

View File

@ -203,6 +203,10 @@ class IPBan implements Extension {
private function get_active_bans() { private function get_active_bans() {
global $database; global $database;
$cached = $database->cache_get("bans");
if($cached) return $cached;
$bans = $database->get_all(" $bans = $database->get_all("
SELECT bans.*, users.name as banner_name SELECT bans.*, users.name as banner_name
FROM bans FROM bans
@ -210,6 +214,9 @@ class IPBan implements Extension {
WHERE (end_timestamp > UNIX_TIMESTAMP(now())) OR (end_timestamp IS NULL) WHERE (end_timestamp > UNIX_TIMESTAMP(now())) OR (end_timestamp IS NULL)
ORDER BY end_timestamp, id ORDER BY end_timestamp, id
"); ");
$database->cache_set("bans", $bans);
if($bans) {return $bans;} if($bans) {return $bans;}
else {return array();} else {return array();}
} }
@ -218,6 +225,7 @@ class IPBan implements Extension {
global $database; global $database;
$sql = "INSERT INTO bans (ip, reason, end_timestamp, banner_id) VALUES (?, ?, ?, ?)"; $sql = "INSERT INTO bans (ip, reason, end_timestamp, banner_id) VALUES (?, ?, ?, ?)";
$database->Execute($sql, array($ip, $reason, strtotime($end), $user->id)); $database->Execute($sql, array($ip, $reason, strtotime($end), $user->id));
$database->cache_delete("bans");
} }
// }}} // }}}
} }