forked from leftypol/leftypol
bans.php: make the purge configurable
This commit is contained in:
parent
bcfc934604
commit
d0b1c388eb
2 changed files with 15 additions and 4 deletions
15
inc/bans.php
15
inc/bans.php
|
@ -349,10 +349,21 @@ class Bans {
|
||||||
rebuildThemes('bans');
|
rebuildThemes('bans');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function purge() {
|
static public function purge($require_seen) {
|
||||||
query("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < " . time() . " AND `seen` = 1") or error(db_error());
|
if ($require_seen) {
|
||||||
|
$query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :curr_time AND `seen` = 1");
|
||||||
|
} else {
|
||||||
|
$query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :curr_time");
|
||||||
|
}
|
||||||
|
$query->bindValue(':curr_time', time());
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
|
$affected = $query->rowCount();
|
||||||
|
if ($affected > 0) {
|
||||||
rebuildThemes('bans');
|
rebuildThemes('bans');
|
||||||
}
|
}
|
||||||
|
return $affected;
|
||||||
|
}
|
||||||
|
|
||||||
static public function delete($ban_id, $modlog = false, $boards = false, $dont_rebuild = false) {
|
static public function delete($ban_id, $modlog = false, $boards = false, $dont_rebuild = false) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
|
@ -907,7 +907,7 @@ function checkBan($board = false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bans::purge();
|
Bans::purge($config['require_ban_view']);
|
||||||
|
|
||||||
if ($config['cache']['enabled'])
|
if ($config['cache']['enabled'])
|
||||||
cache::set('purged_bans_last', time());
|
cache::set('purged_bans_last', time());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue