PUN_ADMIN) message($lang_common['No permission']); if (isset($_GET['action']) || isset($_POST['prune']) || isset($_POST['prune_comply'])) { if (isset($_POST['prune_comply'])) { confirm_referrer('admin_prune.php'); $prune_from = $_POST['prune_from']; $prune_days = intval($_POST['prune_days']); $prune_date = ($prune_days) ? time() - ($prune_days*86400) : -1; @set_time_limit(0); if ($prune_from == 'all') { $result = $db->query('SELECT id FROM '.$db->prefix.'forums') or error('Impossible de retrouver la liste des forums', __FILE__, __LINE__, $db->error()); $num_forums = $db->num_rows($result); for ($i = 0; $i < $num_forums; ++$i) { $fid = $db->result($result, $i); prune($fid, $_POST['prune_sticky'], $prune_date); update_forum($fid); } } else { $prune_from = intval($prune_from); prune($prune_from, $_POST['prune_sticky'], $prune_date); update_forum($prune_from); } // Locate any "orphaned redirect topics" and delete them $result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Impossible de retrouver les sujets de redirection', __FILE__, __LINE__, $db->error()); $num_orphans = $db->num_rows($result); if ($num_orphans) { for ($i = 0; $i < $num_orphans; ++$i) $orphans[] = $db->result($result, $i); $db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error()); } redirect('admin_prune.php', 'Messages supprimés. Redirection ...'); } $prune_days = $_POST['req_prune_days']; if (!preg_match('#^\d+$#', $prune_days)) message('Le nombre de jours d\'ancienneté doit être un entier positif.'); $prune_date = time() - ($prune_days*86400); $prune_from = $_POST['prune_from']; // Concatenate together the query for counting number or topics to prune $sql = 'SELECT COUNT(id) FROM '.$db->prefix.'topics WHERE last_post<'.$prune_date.' AND moved_to IS NULL'; if ($_POST['prune_sticky'] == '0') $sql .= ' AND sticky=\'0\''; if ($prune_from != 'all') { $prune_from = intval($prune_from); $sql .= ' AND forum_id='.$prune_from; // Fetch the forum name (just for cosmetic reasons) $result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$prune_from) or error('Impossible de retrouver le nom du forum', __FILE__, __LINE__, $db->error()); $forum = '"'.pun_htmlspecialchars($db->result($result)).'"'; } else $forum = 'tous les forums'; $result = $db->query($sql) or error('Impossible de retrouver le nombre de discussions supprimées', __FILE__, __LINE__, $db->error()); $num_topics = $db->result($result); if (!$num_topics) message('Il n\'y a pas de sujets anciens de '.$prune_days.' jours. Diminuez la valeur de Jours d\'ancienneté et essayez à nouveau.'); $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Élaguage'; require PUN_ROOT.'header.php'; generate_admin_menu('prune'); ?>