root / tags / release_2_0_2 / phpBB / admin / admin_forum_prune.php
History | View | Annotate | Download (5.4 kB)
| 1 | <?php
|
|---|---|
| 2 | /***************************************************************************
|
| 3 | * admin_forum_prune.php |
| 4 | * ------------------- |
| 5 | * begin : Mon Jul 31, 2001 |
| 6 | * copyright : (C) 2001 The phpBB Group |
| 7 | * email : support@phpbb.com |
| 8 | * |
| 9 | * $Id: admin_forum_prune.php 2570 2002-05-12 15:57:47Z psotfx $ |
| 10 | * |
| 11 | ****************************************************************************/ |
| 12 | |
| 13 | /***************************************************************************
|
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or modify |
| 16 | * it under the terms of the GNU General Public License as published by |
| 17 | * the Free Software Foundation; either version 2 of the License, or |
| 18 | * (at your option) any later version. |
| 19 | * |
| 20 | ***************************************************************************/ |
| 21 | |
| 22 | define('IN_PHPBB', true); |
| 23 | |
| 24 | if ( !empty($setmodules) ) |
| 25 | {
|
| 26 | $filename = basename(__FILE__); |
| 27 | $module['Forums']['Prune'] = $filename; |
| 28 | |
| 29 | return;
|
| 30 | } |
| 31 | |
| 32 | //
|
| 33 | // Load default header
|
| 34 | //
|
| 35 | $phpbb_root_path = "./../"; |
| 36 | require($phpbb_root_path . 'extension.inc'); |
| 37 | require('./pagestart.' . $phpEx); |
| 38 | require($phpbb_root_path . 'includes/prune.'.$phpEx); |
| 39 | require($phpbb_root_path . 'includes/functions_admin.'.$phpEx); |
| 40 | |
| 41 | //
|
| 42 | // Get the forum ID for pruning
|
| 43 | //
|
| 44 | if( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) ) |
| 45 | {
|
| 46 | $forum_id = ( isset($HTTP_POST_VARS[POST_FORUM_URL]) ) ? $HTTP_POST_VARS[POST_FORUM_URL] : $HTTP_GET_VARS[POST_FORUM_URL]; |
| 47 | |
| 48 | if( $forum_id == -1 ) |
| 49 | {
|
| 50 | $forum_sql = ''; |
| 51 | } |
| 52 | else
|
| 53 | {
|
| 54 | $forum_id = intval($forum_id); |
| 55 | $forum_sql = "AND forum_id = $forum_id"; |
| 56 | } |
| 57 | } |
| 58 | else
|
| 59 | {
|
| 60 | $forum_id = ''; |
| 61 | $forum_sql = ''; |
| 62 | } |
| 63 | //
|
| 64 | // Get a list of forum's or the data for the forum that we are pruning.
|
| 65 | //
|
| 66 | $sql = "SELECT f.* |
| 67 | FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE . " c |
| 68 | WHERE c.cat_id = f.cat_id |
| 69 | $forum_sql |
| 70 | ORDER BY c.cat_order ASC, f.forum_order ASC";
|
| 71 | if( !($result = $db->sql_query($sql)) ) |
| 72 | {
|
| 73 | message_die(GENERAL_ERROR, 'Could not obtain list of forums for pruning', '', __LINE__, __FILE__, $sql); |
| 74 | } |
| 75 | |
| 76 | $forum_rows = array(); |
| 77 | while( $row = $db->sql_fetchrow($result) ) |
| 78 | {
|
| 79 | $forum_rows[] = $row; |
| 80 | } |
| 81 | |
| 82 | //
|
| 83 | // Check for submit to be equal to Prune. If so then proceed with the pruning.
|
| 84 | //
|
| 85 | if( isset($HTTP_POST_VARS['doprune']) ) |
| 86 | {
|
| 87 | $prunedays = ( isset($HTTP_POST_VARS['prunedays']) ) ? intval($HTTP_POST_VARS['prunedays']) : 0; |
| 88 | |
| 89 | // Convert days to seconds for timestamp functions...
|
| 90 | $prunedate = time() - ( $prunedays * 86400 ); |
| 91 | |
| 92 | $template->set_filenames(array( |
| 93 | 'body' => 'admin/forum_prune_result_body.tpl') |
| 94 | ); |
| 95 | |
| 96 | for($i = 0; $i < count($forum_rows); $i++) |
| 97 | {
|
| 98 | $p_result = prune($forum_rows[$i]['forum_id'], $prunedate); |
| 99 | sync('forum', $forum_rows[$i]['forum_id']); |
| 100 | |
| 101 | $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2']; |
| 102 | $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2']; |
| 103 | |
| 104 | $template->assign_block_vars('prune_results', array( |
| 105 | 'ROW_COLOR' => '#' . $row_color, |
| 106 | 'ROW_CLASS' => $row_class, |
| 107 | 'FORUM_NAME' => $forum_rows[$i]['forum_name'], |
| 108 | 'FORUM_TOPICS' => $p_result['topics'], |
| 109 | 'FORUM_POSTS' => $p_result['posts']) |
| 110 | ); |
| 111 | } |
| 112 | |
| 113 | $template->assign_vars(array( |
| 114 | 'L_FORUM_PRUNE' => $lang['Forum_Prune'], |
| 115 | 'L_FORUM' => $lang['Forum'], |
| 116 | 'L_TOPICS_PRUNED' => $lang['Topics_pruned'], |
| 117 | 'L_POSTS_PRUNED' => $lang['Posts_pruned'], |
| 118 | 'L_PRUNE_RESULT' => $lang['Prune_success']) |
| 119 | ); |
| 120 | } |
| 121 | else
|
| 122 | {
|
| 123 | //
|
| 124 | // If they haven't selected a forum for pruning yet then
|
| 125 | // display a select box to use for pruning.
|
| 126 | //
|
| 127 | if( empty($HTTP_POST_VARS[POST_FORUM_URL]) ) |
| 128 | {
|
| 129 | //
|
| 130 | // Output a selection table if no forum id has been specified.
|
| 131 | //
|
| 132 | $template->set_filenames(array( |
| 133 | 'body' => 'admin/forum_prune_select_body.tpl') |
| 134 | ); |
| 135 | |
| 136 | $select_list = '<select name="' . POST_FORUM_URL . '">'; |
| 137 | $select_list .= '<option value="-1">' . $lang['All_Forums'] . '</option>'; |
| 138 | |
| 139 | for($i = 0; $i < count($forum_rows); $i++) |
| 140 | {
|
| 141 | $select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>'; |
| 142 | } |
| 143 | $select_list .= '</select>'; |
| 144 | |
| 145 | //
|
| 146 | // Assign the template variables.
|
| 147 | //
|
| 148 | $template->assign_vars(array( |
| 149 | 'L_FORUM_PRUNE' => $lang['Forum_Prune'], |
| 150 | 'L_SELECT_FORUM' => $lang['Select_a_Forum'], |
| 151 | 'L_LOOK_UP' => $lang['Look_up_Forum'], |
| 152 | |
| 153 | 'S_FORUMPRUNE_ACTION' => append_sid("admin_forum_prune.$phpEx"), |
| 154 | 'S_FORUMS_SELECT' => $select_list) |
| 155 | ); |
| 156 | } |
| 157 | else
|
| 158 | {
|
| 159 | $forum_id = intval($HTTP_POST_VARS[POST_FORUM_URL]); |
| 160 | |
| 161 | //
|
| 162 | // Output the form to retrieve Prune information.
|
| 163 | //
|
| 164 | $template->set_filenames(array( |
| 165 | 'body' => 'admin/forum_prune_body.tpl') |
| 166 | ); |
| 167 | |
| 168 | $forum_name = ( $forum_id == -1 ) ? $lang['All_Forums'] : $forum_rows[0]['forum_name']; |
| 169 | |
| 170 | $prune_data = $lang['Prune_topics_not_posted'] . " "; |
| 171 | $prune_data .= '<input type="text" name="prunedays" size="4"> ' . $lang['Days']; |
| 172 | |
| 173 | $hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">'; |
| 174 | |
| 175 | //
|
| 176 | // Assign the template variables.
|
| 177 | //
|
| 178 | $template->assign_vars(array( |
| 179 | 'FORUM_NAME' => $forum_name, |
| 180 | |
| 181 | 'L_FORUM' => $lang['Forum'], |
| 182 | 'L_FORUM_PRUNE' => $lang['Forum_Prune'], |
| 183 | 'L_FORUM_PRUNE_EXPLAIN' => $lang['Forum_Prune_explain'], |
| 184 | 'L_DO_PRUNE' => $lang['Do_Prune'], |
| 185 | |
| 186 | 'S_FORUMPRUNE_ACTION' => append_sid("admin_forum_prune.$phpEx"), |
| 187 | 'S_PRUNE_DATA' => $prune_data, |
| 188 | 'S_HIDDEN_VARS' => $hidden_input) |
| 189 | ); |
| 190 | } |
| 191 | } |
| 192 | //
|
| 193 | // Actually output the page here.
|
| 194 | //
|
| 195 | $template->pparse('body'); |
| 196 | |
| 197 | include('./page_footer_admin.'.$phpEx); |
| 198 | |
| 199 | ?> |

