root/admin/admin_forum_prune.php

Revision 212, 6.7 kB (checked in by Nafania, 3 years ago)

--

Line 
1 <?php
2 /***************************************************************************</span>
3 <span class="code-comment">*                             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,v 1.22.2.3 2002/12/18 14:14:07 psotfx Exp $
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 if ( !empty($setmodules) )</span>
23 <span class="code-keyword">{
24         $filename = basename(__FILE__);
25         $module['forums']['prune'] = $filename;
26
27         return;
28 }
29
30 define('IN_PHPBB', 1);
31
32 //</span>
33 <span class="code-comment">// Load default header
34 //
35 $root_path = './../';</span>
36 <span class="code-lang">require($root_path . 'extension.inc');
37 require('./pagestart.' . $phpEx);
38 require($root_path . 'phpBB2/includes/prune.'.$phpEx);
39 require($root_path . 'include/functions_admin.'.$phpEx);
40
41 //</span>
42 <span class="code-comment">// Get the forum ID for pruning
43 //
44 if( isset($_GET[POST_FORUM_URL]) || isset($_POST[POST_FORUM_URL]) )</span>
45 <span class="code-keyword">{
46         $forum_id = ( isset($_POST[POST_FORUM_URL]) ) ? $_POST[POST_FORUM_URL] : $_GET[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 //</span>
64 <span class="code-comment">// Get a list of forum's or the data for the forum that we are pruning.
65 //
66 $sql = "SELECT f.*</span>
67 <span class="code-lang">        FROM " . FORUMS_TABLE . " f, " . FORUM_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 $result = $db->sql_query($sql);
72
73 $forum_rows = array();</span>
74 <span class="code-lang">while( $row = $db->sql_fetchrow($result) )
75 {
76         $forum_rows[] = $row;
77 }
78
79 //</span>
80 <span class="code-comment">// Check for submit to be equal to Prune. If so then proceed with the pruning.
81 //
82 if( isset($_POST['doprune']) )</span>
83 <span class="code-keyword">{
84         $prunedays = ( isset($_POST['prunedays']) ) ? intval($_POST['prunedays']) : 0;
85
86         // Convert days to seconds for timestamp functions...
87         $prunedate = time() - ( $prunedays * 86400 );
88
89         $template->set_filenames(array(
90                 'body' => '../admin/forum_prune_result_body.tpl')
91         );
92
93         for($i = 0; $i < count($forum_rows); $i++)
94         {
95                 $p_result = prune($forum_rows[$i]['forum_id'], $prunedate);
96                 sync('forum', $forum_rows[$i]['forum_id']);
97
98                 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
99                 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
100
101                 $template->assign_block_vars('prune_results', array(
102                         'ROW_COLOR' => '#' . $row_color,
103                         'ROW_CLASS' => $row_class,
104                         'FORUM_NAME' => $forum_rows[$i]['forum_name'],
105                         'FORUM_TOPICS' => $p_result['topics'],
106                         'FORUM_POSTS' => $p_result['posts'])
107                 );
108         }
109
110         $template->assign_vars(array(
111                 'L_FORUM_PRUNE' => $lang['forum_prune'],
112                 'L_FORUM' => $lang['forum'],
113                 'L_TOPICS_PRUNED' => $lang['topics_pruned'],
114                 'L_POSTS_PRUNED' => $lang['posts_pruned'],
115                 'L_PRUNE_RESULT' => $lang['prune_success'])
116         );
117 }
118 else
119 {
120         //
121         // If they haven't selected a forum for pruning yet then
122         // display a select box to use for pruning.
123         //
124         if( empty($_POST[POST_FORUM_URL]) )
125         {
126                 //
127                 // Output a selection table if no forum id has been specified.
128                 //
129                 $template->set_filenames(array(
130                         'body' => '../admin/forum_prune_select_body.tpl')
131                 );
132
133                 $select_list = '<select name="' . POST_FORUM_URL . '">';
134                 $select_list .= '<option value="-1">' . $lang['all_forums'] . '</option>';
135
136                 for($i = 0; $i < count($forum_rows); $i++)
137                 {
138                         $select_list .= '<option value="' . $forum_rows[$i]['forum_id'] . '">' . $forum_rows[$i]['forum_name'] . '</option>';
139                 }
140                 $select_list .= '</select>';
141
142                 //
143                 // Assign the template variables.
144                 //
145                 $template->assign_vars(array(
146                         'L_FORUM_PRUNE' => $lang['forum_prune'],
147                         'L_SELECT_FORUM' => $lang['select_a_forum'],
148                         'L_LOOK_UP' => $lang['look_up_forum'],
149
150                         'S_FORUMPRUNE_ACTION' => append_sid("admin_forum_prune.$phpEx"),
151                         'S_FORUMS_SELECT' => $select_list)
152                 );
153         }
154         else
155         {
156                 $forum_id = intval($_POST[POST_FORUM_URL]);
157
158                 //
159                 // Output the form to retrieve Prune information.
160                 //
161                 $template->set_filenames(array(
162                         'body' => '../admin/forum_prune_body.tpl')
163                 );
164
165                 $forum_name = ( $forum_id == -1 ) ? $lang['all_forums'] : $forum_rows[0]['forum_name'];
166
167                 $prune_data = $lang['prune_topics_not_posted'] . " ";
168                 $prune_data .= '<input class="post" type="text" name="prunedays" size="4"> ' . $lang['days'];
169
170                 $hidden_input = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
171
172                 //
173                 // Assign the template variables.
174                 //
175                 $template->assign_vars(array(
176                         'FORUM_NAME' => $forum_name,
177
178                         'L_FORUM' => $lang['forum'],
179                         'L_FORUM_PRUNE' => $lang['forum_prune'],
180                         'L_FORUM_PRUNE_EXPLAIN' => $lang['forum_prune_explain'],
181                         'L_DO_PRUNE' => $lang['do_prune'],
182
183                         'S_FORUMPRUNE_ACTION' => append_sid("admin_forum_prune.$phpEx"),
184                         'S_PRUNE_DATA' => $prune_data,
185                         'S_HIDDEN_VARS' => $hidden_input)
186                 );
187         }
188 }
189 //</span>
190 <span class="code-comment">// Actually output the page here.
191 //
192 $template->display('body');</span>
193 <span class="code-lang">
194 include('./page_footer_admin.'.$phpEx);
195
196 ?>
Note: See TracBrowser for help on using the browser.