diff -r e3d7322305bf -r 5e1f1e916419 punbb/admin/prune.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/admin/prune.php Sat Apr 05 23:56:45 2008 -0400 @@ -0,0 +1,302 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('apr_start')) ? eval($hook) : null; + +if ($session->user_level < USER_LEVEL_ADMIN) + message($lang_common['No permission']); + +// Load the admin.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/admin.php'; +$GLOBALS['lang_admin'] = $lang_admin; + + +if (isset($_GET['action']) || isset($_POST['prune']) || isset($_POST['prune_comply'])) +{ + if (isset($_POST['prune_comply'])) + { + $prune_from = $_POST['prune_from']; + $prune_days = intval($_POST['prune_days']); + $prune_date = ($prune_days) ? time() - ($prune_days*86400) : -1; + + ($hook = get_hook('apr_prune_comply_form_submitted')) ? eval($hook) : null; + + @set_time_limit(0); + + if ($prune_from == 'all') + { + $query = array( + 'SELECT' => 'f.id', + 'FROM' => 'forums AS f' + ); + + ($hook = get_hook('apr_qr_get_all_forums')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $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); + sync_forum($fid); + } + } + else + { + $prune_from = intval($prune_from); + prune($prune_from, $_POST['prune_sticky'], $prune_date); + sync_forum($prune_from); + } + + delete_orphans(); + + pun_redirect(pun_link($pun_url['admin_prune']), 'Posts pruned. Redirecting …'); + } + + + $prune_days = intval($_POST['req_prune_days']); + if ($prune_days < 0) + message($lang_admin['Days to prune message']); + + $prune_date = time() - ($prune_days*86400); + $prune_from = $_POST['prune_from']; + + if ($prune_from != 'all') + { + $prune_from = intval($prune_from); + + // Fetch the forum name (just for cosmetic reasons) + $query = array( + 'SELECT' => 'f.forum_name', + 'FROM' => 'forums AS f', + 'WHERE' => 'f.id='.$prune_from + ); + + ($hook = get_hook('apr_qr_get_forum_name')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $forum = htmlspecialchars($pun_db->result($result)); + } + else + $forum = 'all forums'; + + // Count the number of topics to prune + $query = array( + 'SELECT' => 'COUNT(t.id)', + 'FROM' => 'topics AS t', + 'WHERE' => 't.last_post<'.$prune_date.' AND t.moved_to IS NULL' + ); + + if ($prune_from != 'all') + $query['WHERE'] .= ' AND t.forum_id='.$prune_from; + if (!isset($_POST['prune_sticky'])) + $query['WHERE'] .= ' AND t.sticky=0'; + + ($hook = get_hook('apr_qr_get_topic_count')) ? eval($hook) : null; + $result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + $num_topics = $pun_db->result($result); + + if (!$num_topics) + message($lang_admin['No days old message']); + + + // Setup breadcrumbs + $pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($lang_admin['Forum administration'], pun_link($pun_url['admin_index'])), + array($lang_admin['Prune topics'], pun_link($pun_url['admin_prune'])), + $lang_admin['Confirm prune heading'] + ); + + ($hook = get_hook('apr_prune_comply_pre_header_load')) ? eval($hook) : null; + + define('PUN_PAGE_SECTION', 'management'); + define('PUN_PAGE', 'admin-prune'); + require PUN_ROOT.'header.php'; + +?> +
+ + + + +
+

{ }

+
+ +
+
+

+
+
+ +
+

+

+
+ +
+ +
+
+
+ +
+ +
+ + + +
+

{ }

+
+ +
+
+

+
+
+

+

+
+
+

'.$lang_common['Required'].'') ?>

+
+
+ + +
+ + +
+ +
+
+ +
+
+ +
+ +
+ +
+ +
+
+
+ +
+