diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin_prune.php --- a/punbb/admin_prune.php Sun Sep 02 11:00:57 2007 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,233 +0,0 @@ -query('SELECT id FROM '.$pun_db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $pun_db->error()); - $num_forums = $pun_db->num_rows($result); - - for ($i = 0; $i < $num_forums; ++$i) - { - $fid = $pun_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 = $pun_db->query('SELECT t1.id FROM '.$pun_db->prefix.'topics AS t1 LEFT JOIN '.$pun_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('Unable to fetch redirect topics', __FILE__, __LINE__, $pun_db->error()); - $num_orphans = $pun_db->num_rows($result); - - if ($num_orphans) - { - for ($i = 0; $i < $num_orphans; ++$i) - $orphans[] = $pun_db->result($result, $i); - - $pun_db->query('DELETE FROM '.$pun_db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $pun_db->error()); - } - - pun_redirect('admin_prune.php', 'Posts pruned. Redirecting …'); - } - - - $prune_days = $_POST['req_prune_days']; - if (!@preg_match('#^\d+$#', $prune_days)) - message('Days to prune must be a positive integer.'); - - $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 '.$pun_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 = $pun_db->query('SELECT forum_name FROM '.$pun_db->prefix.'forums WHERE id='.$prune_from) or error('Unable to fetch forum name', __FILE__, __LINE__, $pun_db->error()); - $forum = '"'.pun_htmlspecialchars($pun_db->result($result)).'"'; - } - else - $forum = 'all forums'; - - $result = $pun_db->query($sql) or error('Unable to fetch topic prune count', __FILE__, __LINE__, $pun_db->error()); - $num_topics = $pun_db->result($result); - - if (!$num_topics) - message('There are no topics that are '.$prune_days.' days old. Please decrease the value of "Days old" and try again.'); - - - $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Prune'; - require PUN_ROOT.'header.php'; - - generate_admin_menu('prune'); - -?> -