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

