1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-28 01:10:51 +01:00

bans.php: make the purge configurable

This commit is contained in:
Zankaria 2024-06-30 17:01:53 +02:00 committed by Zankaria
parent 75714505a0
commit cbaf19cb7a
2 changed files with 15 additions and 4 deletions

View File

@ -342,9 +342,20 @@ class Bans {
rebuildThemes('bans');
}
static public function purge() {
$query = query("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < " . time() . " AND `seen` = 1") or error(db_error());
rebuildThemes('bans');
static public function purge($require_seen) {
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');
}
return $affected;
}
static public function delete($ban_id, $modlog = false, $boards = false, $dont_rebuild = false) {

View File

@ -907,7 +907,7 @@ function checkBan($board = false) {
return;
}
Bans::purge();
Bans::purge($config['require_ban_view']);
if ($config['cache']['enabled'])
cache::set('purged_bans_last', time());