Browse Source

Bugfix - Bugfix to Archive code

main
PupperWoff 7 years ago
committed by discomrade
parent
commit
932b0b9e63
  1. 14
      inc/archive.php
  2. 6
      inc/functions.php

14
inc/archive.php

@ -82,16 +82,16 @@ class Archive {
}
// Insert Archive Data in Database
$query = prepare(sprintf("INSERT INTO ``archive_%s`` VALUES (:thread_id, :snippet, :time, :files, 0)", $board['uri']));
$query = prepare(sprintf("INSERT INTO ``archive_%s`` VALUES (:thread_id, :snippet, :lifetime, :files, 0)", $board['uri']));
$query->bindValue(':thread_id', $thread_id, PDO::PARAM_INT);
$query->bindValue(':snippet', $thread_data['snippet'], PDO::PARAM_STR);
$query->bindValue(':time', (!$config['archive']['lifetime'])?0:strtotime("+".$config['archive']['lifetime']." days"), PDO::PARAM_INT);
$query->bindValue(':lifetime', time(), PDO::PARAM_INT);
$query->bindValue(':files', json_encode($file_list));
$query->execute() or error(db_error($query));
// Purge Threads that have timed out
if(!$config['archive']['cron_job'])
if(!$config['archive']['cron_job']['purge'])
self::purgeArchive();
// Rebuild Archive Index
@ -108,8 +108,14 @@ class Archive {
static public function purgeArchive() {
global $config, $board;
// If archive is set to live forever return
if(!$config['archive']['lifetime'])
return;
// Delete all static pages and files for archived threads that has timed out
$query = query(sprintf("SELECT `id`, `files` FROM ``archive_%s`` WHERE `lifetime` < %d AND `featured` = 0", $board['uri'], time())) or error(db_error());
$query = prepare(sprintf("SELECT `id`, `files` FROM ``archive_%s`` WHERE `lifetime` < :lifetime AND `featured` = 0", $board['uri']));
$query->bindValue(':lifetime', strtotime("+".$config['archive']['lifetime']." days"), PDO::PARAM_INT);
$query->execute() or error(db_error($query));
while($thread = $query->fetch(PDO::FETCH_ASSOC)) {
// Delete Files
foreach (json_decode($thread['files']) as $f) {

6
inc/functions.php

@ -1534,10 +1534,12 @@ function clean($pid = false) {
while ($post = $query->fetch(PDO::FETCH_ASSOC)) {
if($config['archive']['threads']) {
Archive::archiveThread($post['id']);
deletePost($post['id'], false, false);
if ($pid) modLog("Automatically archived thread #{$post['id']} due to new thread #{$pid}");
} else {
deletePost($post['id'], false, false);
if ($pid) modLog("Automatically deleting thread #{$post['id']} due to new thread #{$pid}");
}
deletePost($post['id'], false, false);
if ($pid) modLog("Automatically deleting thread #{$post['id']} due to new thread #{$pid}");
}
// Bump off threads with X replies earlier, spam prevention method

Loading…
Cancel
Save