phpBB
Statistics
| Revision:

root / tags / release_2_0_2 / phpBB / modcp.php

History | View | Annotate | Download (33.8 kB)

1 561 uid29890
<?php
2 877 thefinn
/***************************************************************************
3 932 psotfx
 *                                 modcp.php
4 877 thefinn
 *                            -------------------
5 572 thefinn
 *   begin                : July 4, 2001
6 877 thefinn
 *   copyright            : (C) 2001 The phpBB Group
7 877 thefinn
 *   email                : support@phpbb.com
8 877 thefinn
 *
9 877 thefinn
 *   $Id$
10 877 thefinn
 *
11 877 thefinn
 *
12 877 thefinn
 ***************************************************************************/
13 561 uid29890
14 976 thefinn
/***************************************************************************
15 976 thefinn
 *
16 976 thefinn
 *   This program is free software; you can redistribute it and/or modify
17 976 thefinn
 *   it under the terms of the GNU General Public License as published by
18 976 thefinn
 *   the Free Software Foundation; either version 2 of the License, or
19 976 thefinn
 *   (at your option) any later version.
20 976 thefinn
 *
21 976 thefinn
 ***************************************************************************/
22 976 thefinn
23 561 uid29890
/**
24 561 uid29890
 * Moderator Control Panel
25 561 uid29890
 *
26 561 uid29890
 * From this 'Control Panel' the moderator of a forum will be able to do
27 561 uid29890
 * mass topic operations (locking/unlocking/moving/deleteing), and it will
28 877 thefinn
 * provide an interface to do quick locking/unlocking/moving/deleting of
29 561 uid29890
 * topics via the moderator operations buttons on all of the viewtopic pages.
30 561 uid29890
 */
31 877 thefinn
32 2305 psotfx
define('IN_PHPBB', true);
33 2350 psotfx
$phpbb_root_path = './';
34 646 psotfx
include($phpbb_root_path . 'extension.inc');
35 646 psotfx
include($phpbb_root_path . 'common.'.$phpEx);
36 646 psotfx
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
37 2305 psotfx
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
38 561 uid29890
39 1043 psotfx
//
40 1043 psotfx
// Obtain initial var settings
41 1043 psotfx
//
42 2350 psotfx
if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
43 1043 psotfx
{
44 1307 psotfx
        $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
45 1043 psotfx
}
46 1043 psotfx
else
47 1043 psotfx
{
48 2350 psotfx
        $forum_id = '';
49 1043 psotfx
}
50 561 uid29890
51 2350 psotfx
if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
52 1043 psotfx
{
53 1307 psotfx
        $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
54 1043 psotfx
}
55 1043 psotfx
else
56 1043 psotfx
{
57 2350 psotfx
        $post_id = '';
58 1043 psotfx
}
59 561 uid29890
60 2350 psotfx
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
61 561 uid29890
{
62 1307 psotfx
        $topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
63 1043 psotfx
}
64 1043 psotfx
else
65 1043 psotfx
{
66 2350 psotfx
        $topic_id = '';
67 1043 psotfx
}
68 1043 psotfx
69 1307 psotfx
$confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
70 1043 psotfx
71 1043 psotfx
//
72 1043 psotfx
// Continue var definitions
73 1043 psotfx
//
74 2599 psotfx
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
75 1043 psotfx
76 2350 psotfx
$delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
77 2350 psotfx
$move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
78 2350 psotfx
$lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
79 2350 psotfx
$unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
80 1043 psotfx
81 2350 psotfx
if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
82 1043 psotfx
{
83 1043 psotfx
        $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
84 1043 psotfx
}
85 1043 psotfx
else
86 1043 psotfx
{
87 2350 psotfx
        if ( $delete )
88 1043 psotfx
        {
89 1043 psotfx
                $mode = 'delete';
90 1043 psotfx
        }
91 2350 psotfx
        else if ( $move )
92 1043 psotfx
        {
93 1043 psotfx
                $mode = 'move';
94 1043 psotfx
        }
95 2350 psotfx
        else if ( $lock )
96 1043 psotfx
        {
97 1043 psotfx
                $mode = 'lock';
98 1043 psotfx
        }
99 2350 psotfx
        else if ( $unlock )
100 1043 psotfx
        {
101 1043 psotfx
                $mode = 'unlock';
102 1043 psotfx
        }
103 1043 psotfx
        else
104 1043 psotfx
        {
105 2350 psotfx
                $mode = '';
106 1043 psotfx
        }
107 1043 psotfx
}
108 1043 psotfx
109 1043 psotfx
//
110 1043 psotfx
// Obtain relevant data
111 1043 psotfx
//
112 2347 psotfx
if ( !empty($topic_id) )
113 1043 psotfx
{
114 877 thefinn
        $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
115 877 thefinn
                FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
116 877 thefinn
                WHERE t.topic_id = " . $topic_id . "
117 686 psotfx
                        AND f.forum_id = t.forum_id";
118 2347 psotfx
        if ( !($result = $db->sql_query($sql)) )
119 561 uid29890
        {
120 2347 psotfx
                message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
121 561 uid29890
        }
122 1043 psotfx
        $topic_row = $db->sql_fetchrow($result);
123 686 psotfx
124 2476 psotfx
        $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
125 1043 psotfx
        $forum_id = $topic_row['forum_id'];
126 1043 psotfx
        $forum_name = $topic_row['forum_name'];
127 561 uid29890
}
128 2347 psotfx
else if ( !empty($forum_id) )
129 561 uid29890
{
130 877 thefinn
        $sql = "SELECT forum_name, forum_topics
131 877 thefinn
                FROM " . FORUMS_TABLE . "
132 686 psotfx
                WHERE forum_id = " . $forum_id;
133 2347 psotfx
        if ( !($result = $db->sql_query($sql)) )
134 561 uid29890
        {
135 2347 psotfx
                message_die(GENERAL_MESSAGE, 'Forum_not_exist');
136 561 uid29890
        }
137 1043 psotfx
        $topic_row = $db->sql_fetchrow($result);
138 686 psotfx
139 2476 psotfx
        $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
140 1043 psotfx
        $forum_name = $topic_row['forum_name'];
141 561 uid29890
}
142 2347 psotfx
else
143 2347 psotfx
{
144 2347 psotfx
        message_die(GENERAL_MESSAGE, 'Forum_not_exist');
145 2347 psotfx
}
146 561 uid29890
147 561 uid29890
//
148 561 uid29890
// Start session management
149 561 uid29890
//
150 2260 psotfx
$userdata = session_pagestart($user_ip, $forum_id);
151 561 uid29890
init_userprefs($userdata);
152 561 uid29890
//
153 561 uid29890
// End session management
154 561 uid29890
//
155 561 uid29890
156 561 uid29890
//
157 2570 psotfx
// Check if user did or did not confirm
158 2570 psotfx
// If they did not, forward them to the last page they were on
159 2570 psotfx
//
160 2570 psotfx
if ( isset($HTTP_POST_VARS['cancel']) )
161 2570 psotfx
{
162 2570 psotfx
        if ( $topic_id )
163 2570 psotfx
        {
164 2570 psotfx
                $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
165 2570 psotfx
        }
166 2570 psotfx
        else if ( $forum_id )
167 2570 psotfx
        {
168 2570 psotfx
                $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
169 2570 psotfx
        }
170 2570 psotfx
        else
171 2570 psotfx
        {
172 2570 psotfx
                $redirect = "index.$phpEx";
173 2570 psotfx
        }
174 2570 psotfx
175 2570 psotfx
        $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ) ? 'Refresh: 0; URL=' : 'Location: ';
176 2570 psotfx
        header($header_location . append_sid($redirect, true));
177 2575 psotfx
        exit;
178 2570 psotfx
}
179 2570 psotfx
180 2570 psotfx
//
181 561 uid29890
// Start auth check
182 561 uid29890
//
183 561 uid29890
$is_auth = auth(AUTH_ALL, $forum_id, $userdata);
184 561 uid29890
185 2448 psotfx
if ( !$is_auth['auth_mod'] )
186 561 uid29890
{
187 676 psotfx
        message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
188 561 uid29890
}
189 1043 psotfx
//
190 1043 psotfx
// End Auth Check
191 1043 psotfx
//
192 561 uid29890
193 619 thefinn
//
194 1043 psotfx
// Do major work ...
195 1043 psotfx
//
196 2462 psotfx
switch( $mode )
197 561 uid29890
{
198 561 uid29890
        case 'delete':
199 1440 psotfx
                $page_title = $lang['Mod_CP'];
200 1440 psotfx
                include($phpbb_root_path . 'includes/page_header.'.$phpEx);
201 1440 psotfx
202 2104 psotfx
                if ( $confirm )
203 572 thefinn
                {
204 2347 psotfx
                        include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
205 2347 psotfx
206 1043 psotfx
                        $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
207 1043 psotfx
208 2350 psotfx
                        $topic_id_sql = '';
209 1043 psotfx
                        for($i = 0; $i < count($topics); $i++)
210 619 thefinn
                        {
211 2350 psotfx
                                $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i];
212 619 thefinn
                        }
213 1043 psotfx
214 2729 psotfx
                        $sql = "SELECT poster_id, COUNT(post_id) AS posts
215 2729 psotfx
                                FROM " . POSTS_TABLE . "
216 2729 psotfx
                                WHERE topic_id IN ($topic_id_sql)
217 2729 psotfx
                                GROUP BY poster_id";
218 2729 psotfx
                        if ( !($result = $db->sql_query($sql)) )
219 2729 psotfx
                        {
220 2729 psotfx
                                message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
221 2729 psotfx
                        }
222 2729 psotfx
223 2729 psotfx
                        $count_sql = array();
224 2729 psotfx
                        while ( $row = $db->sql_fetchrow($result) )
225 2729 psotfx
                        {
226 2729 psotfx
                                $count_sql[] = "UPDATE " . USERS_TABLE . "
227 2729 psotfx
                                        SET user_posts = user_posts - " . $row['posts'] . "
228 2729 psotfx
                                        WHERE user_id = " . $row['poster_id'];
229 2729 psotfx
                        }
230 2729 psotfx
                        $db->sql_freeresult($result);
231 2729 psotfx
232 2729 psotfx
                        if ( sizeof($count_sql) )
233 2729 psotfx
                        {
234 2729 psotfx
                                for($i = 0; $i < sizeof($count_sql); $i++)
235 2729 psotfx
                                {
236 2729 psotfx
                                        if ( !$db->sql_query($count_sql[$i]) )
237 2729 psotfx
                                        {
238 2729 psotfx
                                                message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
239 2729 psotfx
                                        }
240 2729 psotfx
                                }
241 2729 psotfx
                        }
242 2729 psotfx
243 1043 psotfx
                        $sql = "SELECT post_id
244 1043 psotfx
                                FROM " . POSTS_TABLE . "
245 1043 psotfx
                                WHERE topic_id IN ($topic_id_sql)";
246 2729 psotfx
                        if ( !($result = $db->sql_query($sql)) )
247 619 thefinn
                        {
248 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
249 619 thefinn
                        }
250 877 thefinn
251 2350 psotfx
                        $post_id_sql = '';
252 2462 psotfx
                        while ( $row = $db->sql_fetchrow($result) )
253 572 thefinn
                        {
254 2462 psotfx
                                $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $row['post_id'];
255 572 thefinn
                        }
256 2462 psotfx
                        $db->sql_freeresult($result);
257 877 thefinn
258 1043 psotfx
                        $sql = "SELECT vote_id
259 1043 psotfx
                                FROM " . VOTE_DESC_TABLE . "
260 1043 psotfx
                                WHERE topic_id IN ($topic_id_sql)";
261 2350 psotfx
                        if ( !($result = $db->sql_query($sql)) )
262 572 thefinn
                        {
263 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
264 572 thefinn
                        }
265 1043 psotfx
266 2350 psotfx
                        $vote_id_sql = '';
267 2462 psotfx
                        while ( $row = $db->sql_fetchrow($result) )
268 619 thefinn
                        {
269 2462 psotfx
                                $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
270 619 thefinn
                        }
271 2462 psotfx
                        $db->sql_freeresult($result);
272 877 thefinn
273 1043 psotfx
                        //
274 1043 psotfx
                        // Got all required info so go ahead and start deleting everything
275 1043 psotfx
                        //
276 1043 psotfx
                        $sql = "DELETE
277 1043 psotfx
                                FROM " . TOPICS_TABLE . "
278 1071 psotfx
                                WHERE topic_id IN ($topic_id_sql)
279 1071 psotfx
                                        OR topic_moved_id IN ($topic_id_sql)";
280 2462 psotfx
                        if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
281 877 thefinn
                        {
282 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
283 619 thefinn
                        }
284 877 thefinn
285 2350 psotfx
                        if ( $post_id_sql != '' )
286 619 thefinn
                        {
287 1314 bartvb
                                $sql = "DELETE
288 1314 bartvb
                                        FROM " . POSTS_TABLE . "
289 1314 bartvb
                                        WHERE post_id IN ($post_id_sql)";
290 2462 psotfx
                                if ( !$db->sql_query($sql) )
291 1314 bartvb
                                {
292 2350 psotfx
                                        message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
293 1314 bartvb
                                }
294 877 thefinn
295 1314 bartvb
                                $sql = "DELETE
296 1314 bartvb
                                        FROM " . POSTS_TEXT_TABLE . "
297 1314 bartvb
                                        WHERE post_id IN ($post_id_sql)";
298 2462 psotfx
                                if ( !$db->sql_query($sql) )
299 1314 bartvb
                                {
300 2350 psotfx
                                        message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
301 1314 bartvb
                                }
302 1439 psotfx
303 2337 psotfx
                                remove_search_post($post_id_sql);
304 619 thefinn
                        }
305 877 thefinn
306 2350 psotfx
                        if ( $vote_id_sql != '' )
307 890 gpolins
                        {
308 1071 psotfx
                                $sql = "DELETE
309 1071 psotfx
                                        FROM " . VOTE_DESC_TABLE . "
310 1071 psotfx
                                        WHERE vote_id IN ($vote_id_sql)";
311 2462 psotfx
                                if ( !$db->sql_query($sql) )
312 1071 psotfx
                                {
313 2350 psotfx
                                        message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
314 1071 psotfx
                                }
315 892 thefinn
316 1071 psotfx
                                $sql = "DELETE
317 1071 psotfx
                                        FROM " . VOTE_RESULTS_TABLE . "
318 1071 psotfx
                                        WHERE vote_id IN ($vote_id_sql)";
319 2462 psotfx
                                if ( !$db->sql_query($sql) )
320 1071 psotfx
                                {
321 2350 psotfx
                                        message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
322 1071 psotfx
                                }
323 1043 psotfx
324 1071 psotfx
                                $sql = "DELETE
325 1071 psotfx
                                        FROM " . VOTE_USERS_TABLE . "
326 1071 psotfx
                                        WHERE vote_id IN ($vote_id_sql)";
327 2462 psotfx
                                if ( !$db->sql_query($sql) )
328 1071 psotfx
                                {
329 2350 psotfx
                                        message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
330 1071 psotfx
                                }
331 1043 psotfx
                        }
332 1043 psotfx
333 1073 psotfx
                        $sql = "DELETE
334 1073 psotfx
                                FROM " . TOPICS_WATCH_TABLE . "
335 1073 psotfx
                                WHERE topic_id IN ($topic_id_sql)";
336 2462 psotfx
                        if ( !$db->sql_query($sql, END_TRANSACTION) )
337 1073 psotfx
                        {
338 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
339 1073 psotfx
                        }
340 1073 psotfx
341 2350 psotfx
                        sync('forum', $forum_id);
342 877 thefinn
343 2350 psotfx
                        if ( !empty($topic_id) )
344 625 thefinn
                        {
345 1307 psotfx
                                $redirect_page = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
346 2104 psotfx
                                $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
347 625 thefinn
                        }
348 625 thefinn
                        else
349 625 thefinn
                        {
350 2104 psotfx
                                $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
351 2104 psotfx
                                $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
352 625 thefinn
                        }
353 877 thefinn
354 1307 psotfx
                        $template->assign_vars(array(
355 2350 psotfx
                                'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
356 1307 psotfx
                        );
357 1307 psotfx
358 2350 psotfx
                        message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
359 609 thefinn
                }
360 609 thefinn
                else
361 609 thefinn
                {
362 2104 psotfx
                        // Not confirmed, show confirmation message
363 2350 psotfx
                        if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
364 976 thefinn
                        {
365 2350 psotfx
                                message_die(GENERAL_MESSAGE, $lang['None_selected']);
366 976 thefinn
                        }
367 1043 psotfx
368 2129 psotfx
                        $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
369 1043 psotfx
370 2350 psotfx
                        if ( isset($HTTP_POST_VARS['topic_id_list']) )
371 572 thefinn
                        {
372 1043 psotfx
                                $topics = $HTTP_POST_VARS['topic_id_list'];
373 1043 psotfx
                                for($i = 0; $i < count($topics); $i++)
374 619 thefinn
                                {
375 2503 psotfx
                                        $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
376 619 thefinn
                                }
377 572 thefinn
                        }
378 619 thefinn
                        else
379 572 thefinn
                        {
380 2129 psotfx
                                $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
381 572 thefinn
                        }
382 619 thefinn
383 1043 psotfx
                        //
384 1043 psotfx
                        // Set template files
385 1043 psotfx
                        //
386 1043 psotfx
                        $template->set_filenames(array(
387 2350 psotfx
                                'confirm' => 'confirm_body.tpl')
388 1043 psotfx
                        );
389 1043 psotfx
390 1043 psotfx
                        $template->assign_vars(array(
391 2350 psotfx
                                'MESSAGE_TITLE' => $lang['Confirm'],
392 2350 psotfx
                                'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
393 1043 psotfx
394 2350 psotfx
                                'L_YES' => $lang['Yes'],
395 2350 psotfx
                                'L_NO' => $lang['No'],
396 1043 psotfx
397 2350 psotfx
                                'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
398 2350 psotfx
                                'S_HIDDEN_FIELDS' => $hidden_fields)
399 1043 psotfx
                        );
400 1043 psotfx
401 2350 psotfx
                        $template->pparse('confirm');
402 1043 psotfx
403 646 psotfx
                        include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
404 572 thefinn
                }
405 646 psotfx
                break;
406 646 psotfx
407 561 uid29890
        case 'move':
408 1440 psotfx
                $page_title = $lang['Mod_CP'];
409 1440 psotfx
                include($phpbb_root_path . 'includes/page_header.'.$phpEx);
410 1440 psotfx
411 2350 psotfx
                if ( $confirm )
412 877 thefinn
                {
413 2564 psotfx
                        if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
414 2564 psotfx
                        {
415 2564 psotfx
                                message_die(GENERAL_MESSAGE, $lang['None_selected']);
416 2564 psotfx
                        }
417 2564 psotfx
418 1043 psotfx
                        $new_forum_id = $HTTP_POST_VARS['new_forum'];
419 1043 psotfx
                        $old_forum_id = $forum_id;
420 1043 psotfx
421 2350 psotfx
                        if ( $new_forum_id != $old_forum_id )
422 877 thefinn
                        {
423 1550 psotfx
                                $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
424 1550 psotfx
425 2350 psotfx
                                $topic_list = '';
426 1550 psotfx
                                for($i = 0; $i < count($topics); $i++)
427 1043 psotfx
                                {
428 2503 psotfx
                                        $topic_list .= ( ( $topic_list != '' ) ? ', ' : '' ) . intval($topics[$i]);
429 1043 psotfx
                                }
430 1043 psotfx
431 2448 psotfx
                                $sql = "SELECT *
432 1550 psotfx
                                        FROM " . TOPICS_TABLE . "
433 2104 psotfx
                                        WHERE topic_id IN ($topic_list)
434 2462 psotfx
                                                AND topic_status <> " . TOPIC_MOVED;
435 2448 psotfx
                                if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
436 1550 psotfx
                                {
437 2448 psotfx
                                        message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
438 1550 psotfx
                                }
439 1043 psotfx
440 1550 psotfx
                                $row = $db->sql_fetchrowset($result);
441 2104 psotfx
                                $db->sql_freeresult($result);
442 1043 psotfx
443 1550 psotfx
                                for($i = 0; $i < count($row); $i++)
444 877 thefinn
                                {
445 1550 psotfx
                                        $topic_id = $row[$i]['topic_id'];
446 1550 psotfx
447 2350 psotfx
                                        if ( isset($HTTP_POST_VARS['move_leave_shadow']) )
448 1550 psotfx
                                        {
449 1550 psotfx
                                                // Insert topic in the old forum that indicates that the forum has moved.
450 2061 psotfx
                                                $sql = "INSERT INTO " . TOPICS_TABLE . " (forum_id, topic_title, topic_poster, topic_time, topic_status, topic_type, topic_vote, topic_views, topic_replies, topic_first_post_id, topic_last_post_id, topic_moved_id)
451 2061 psotfx
                                                        VALUES ($old_forum_id, '" . addslashes(str_replace("\'", "''", $row[$i]['topic_title'])) . "', '" . str_replace("\'", "''", $row[$i]['topic_poster']) . "', " . $row[$i]['topic_time'] . ", " . TOPIC_MOVED . ", " . POST_NORMAL . ", " . $row[$i]['topic_vote'] . ", " . $row[$i]['topic_views'] . ", " . $row[$i]['topic_replies'] . ", " . $row[$i]['topic_first_post_id'] . ", " . $row[$i]['topic_last_post_id'] . ", $topic_id)";
452 2462 psotfx
                                                if ( !$db->sql_query($sql) )
453 1550 psotfx
                                                {
454 2350 psotfx
                                                        message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
455 1550 psotfx
                                                }
456 1550 psotfx
                                        }
457 1550 psotfx
458 1550 psotfx
                                        $sql = "UPDATE " . TOPICS_TABLE . "
459 1550 psotfx
                                                SET forum_id = $new_forum_id
460 1550 psotfx
                                                WHERE topic_id = $topic_id";
461 2462 psotfx
                                        if ( !$db->sql_query($sql) )
462 1314 bartvb
                                        {
463 2350 psotfx
                                                message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
464 1314 bartvb
                                        }
465 1043 psotfx
466 1550 psotfx
                                        $sql = "UPDATE " . POSTS_TABLE . "
467 1550 psotfx
                                                SET forum_id = $new_forum_id
468 1550 psotfx
                                                WHERE topic_id = $topic_id";
469 2462 psotfx
                                        if ( !$db->sql_query($sql) )
470 1550 psotfx
                                        {
471 2350 psotfx
                                                message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
472 1550 psotfx
                                        }
473 877 thefinn
                                }
474 1043 psotfx
475 1550 psotfx
                                // Sync the forum indexes
476 2350 psotfx
                                sync('forum', $new_forum_id);
477 2350 psotfx
                                sync('forum', $old_forum_id);
478 1550 psotfx
479 2350 psotfx
                                $message = $lang['Topics_Moved'] . '<br /><br />';
480 1550 psotfx
481 877 thefinn
                        }
482 1550 psotfx
                        else
483 1550 psotfx
                        {
484 2350 psotfx
                                $message = $lang['No_Topics_Moved'] . '<br /><br />';
485 1550 psotfx
                        }
486 851 gpolins
487 2350 psotfx
                        if ( !empty($topic_id) )
488 877 thefinn
                        {
489 1307 psotfx
                                $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
490 2104 psotfx
                                $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
491 877 thefinn
                        }
492 877 thefinn
                        else
493 877 thefinn
                        {
494 1307 psotfx
                                $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
495 2104 psotfx
                                $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
496 877 thefinn
                        }
497 1043 psotfx
498 2350 psotfx
                        $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id") . '">', '</a>');
499 1314 bartvb
500 1307 psotfx
                        $template->assign_vars(array(
501 2350 psotfx
                                'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
502 1307 psotfx
                        );
503 1043 psotfx
504 1550 psotfx
                        message_die(GENERAL_MESSAGE, $message);
505 877 thefinn
                }
506 877 thefinn
                else
507 877 thefinn
                {
508 2350 psotfx
                        if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
509 976 thefinn
                        {
510 1047 psotfx
                                message_die(GENERAL_MESSAGE, $lang['None_selected']);
511 976 thefinn
                        }
512 1043 psotfx
513 2129 psotfx
                        $hidden_fields = '<input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
514 1043 psotfx
515 2350 psotfx
                        if ( isset($HTTP_POST_VARS['topic_id_list']) )
516 877 thefinn
                        {
517 1043 psotfx
                                $topics = $HTTP_POST_VARS['topic_id_list'];
518 1307 psotfx
519 1043 psotfx
                                for($i = 0; $i < count($topics); $i++)
520 877 thefinn
                                {
521 2129 psotfx
                                        $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
522 877 thefinn
                                }
523 877 thefinn
                        }
524 877 thefinn
                        else
525 877 thefinn
                        {
526 2132 the_systech
                                $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
527 877 thefinn
                        }
528 1043 psotfx
529 1043 psotfx
                        //
530 1043 psotfx
                        // Set template files
531 1043 psotfx
                        //
532 1043 psotfx
                        $template->set_filenames(array(
533 2350 psotfx
                                'movetopic' => 'modcp_move.tpl')
534 1043 psotfx
                        );
535 1043 psotfx
536 1043 psotfx
                        $template->assign_vars(array(
537 2350 psotfx
                                'MESSAGE_TITLE' => $lang['Confirm'],
538 2350 psotfx
                                'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
539 1047 psotfx
540 2350 psotfx
                                'L_MOVE_TO_FORUM' => $lang['Move_to_forum'],
541 2350 psotfx
                                'L_LEAVESHADOW' => $lang['Leave_shadow_topic'],
542 2350 psotfx
                                'L_YES' => $lang['Yes'],
543 2350 psotfx
                                'L_NO' => $lang['No'],
544 1043 psotfx
545 2448 psotfx
                                'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id),
546 2350 psotfx
                                'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
547 2350 psotfx
                                'S_HIDDEN_FIELDS' => $hidden_fields)
548 1047 psotfx
                        );
549 1047 psotfx
550 2448 psotfx
                        $template->pparse('movetopic');
551 2448 psotfx
552 877 thefinn
                        include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
553 877 thefinn
                }
554 1043 psotfx
                break;
555 877 thefinn
556 561 uid29890
        case 'lock':
557 2564 psotfx
                if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
558 2564 psotfx
                {
559 2564 psotfx
                        message_die(GENERAL_MESSAGE, $lang['None_selected']);
560 2564 psotfx
                }
561 2564 psotfx
562 1439 psotfx
                $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
563 1439 psotfx
564 2350 psotfx
                $topic_id_sql = '';
565 1439 psotfx
                for($i = 0; $i < count($topics); $i++)
566 589 thefinn
                {
567 2350 psotfx
                        $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . $topics[$i];
568 1439 psotfx
                }
569 877 thefinn
570 1439 psotfx
                $sql = "UPDATE " . TOPICS_TABLE . "
571 1439 psotfx
                        SET topic_status = " . TOPIC_LOCKED . "
572 2104 psotfx
                        WHERE topic_id IN ($topic_id_sql)
573 2104 psotfx
                                AND topic_moved_id = 0";
574 2350 psotfx
                if ( !($result = $db->sql_query($sql)) )
575 1439 psotfx
                {
576 2350 psotfx
                        message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
577 1439 psotfx
                }
578 1043 psotfx
579 2350 psotfx
                if ( !empty($topic_id) )
580 1439 psotfx
                {
581 1439 psotfx
                        $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
582 2104 psotfx
                        $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
583 609 thefinn
                }
584 609 thefinn
                else
585 609 thefinn
                {
586 1439 psotfx
                        $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
587 2104 psotfx
                        $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
588 1439 psotfx
                }
589 1043 psotfx
590 2350 psotfx
                $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
591 2167 bartvb
592 1439 psotfx
                $template->assign_vars(array(
593 2350 psotfx
                        'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
594 1439 psotfx
                );
595 1043 psotfx
596 2350 psotfx
                message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
597 620 thefinn
598 1043 psotfx
                break;
599 609 thefinn
600 561 uid29890
        case 'unlock':
601 2564 psotfx
                if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
602 2564 psotfx
                {
603 2564 psotfx
                        message_die(GENERAL_MESSAGE, $lang['None_selected']);
604 2564 psotfx
                }
605 2564 psotfx
606 1439 psotfx
                $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
607 1439 psotfx
608 2350 psotfx
                $topic_id_sql = '';
609 1439 psotfx
                for($i = 0; $i < count($topics); $i++)
610 589 thefinn
                {
611 2350 psotfx
                        $topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . $topics[$i];
612 1439 psotfx
                }
613 877 thefinn
614 1439 psotfx
                $sql = "UPDATE " . TOPICS_TABLE . "
615 1439 psotfx
                        SET topic_status = " . TOPIC_UNLOCKED . "
616 2104 psotfx
                        WHERE topic_id IN ($topic_id_sql)
617 2104 psotfx
                                AND topic_moved_id = 0";
618 2350 psotfx
                if ( !($result = $db->sql_query($sql)) )
619 1439 psotfx
                {
620 2350 psotfx
                        message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
621 1439 psotfx
                }
622 1043 psotfx
623 2350 psotfx
                if ( !empty($topic_id) )
624 1439 psotfx
                {
625 1439 psotfx
                        $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
626 2104 psotfx
                        $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
627 589 thefinn
                }
628 609 thefinn
                else
629 609 thefinn
                {
630 1439 psotfx
                        $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
631 2104 psotfx
                        $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
632 1439 psotfx
                }
633 976 thefinn
634 2350 psotfx
                $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
635 2167 bartvb
636 1439 psotfx
                $template->assign_vars(array(
637 2350 psotfx
                        'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
638 1439 psotfx
                );
639 686 psotfx
640 2350 psotfx
                message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
641 620 thefinn
642 1439 psotfx
                break;
643 1043 psotfx
644 619 thefinn
        case 'split':
645 1440 psotfx
                $page_title = $lang['Mod_CP'];
646 1440 psotfx
                include($phpbb_root_path . 'includes/page_header.'.$phpEx);
647 1440 psotfx
648 2350 psotfx
                if ( isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']) )
649 619 thefinn
                {
650 1043 psotfx
                        $posts = $HTTP_POST_VARS['post_id_list'];
651 877 thefinn
652 877 thefinn
                        $sql = "SELECT poster_id, topic_id, post_time
653 877 thefinn
                                FROM " . POSTS_TABLE . "
654 1043 psotfx
                                WHERE post_id = " . $posts[0];
655 2350 psotfx
                        if ( !($result = $db->sql_query($sql)) )
656 627 thefinn
                        {
657 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
658 627 thefinn
                        }
659 877 thefinn
660 1043 psotfx
                        $post_rowset = $db->sql_fetchrow($result);
661 1668 psotfx
                        $first_poster = str_replace("\'", "''", $post_rowset['poster_id']);
662 1043 psotfx
                        $topic_id = $post_rowset['topic_id'];
663 1043 psotfx
                        $post_time = $post_rowset['post_time'];
664 877 thefinn
665 2462 psotfx
                        $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
666 2350 psotfx
                        if ( empty($post_subject) )
667 627 thefinn
                        {
668 686 psotfx
                                message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
669 654 thefinn
                        }
670 877 thefinn
671 2503 psotfx
                        $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
672 1043 psotfx
                        $topic_time = time();
673 877 thefinn
674 1755 psotfx
                        $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
675 1668 psotfx
                                VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
676 2350 psotfx
                        if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
677 654 thefinn
                        {
678 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
679 654 thefinn
                        }
680 877 thefinn
681 654 thefinn
                        $new_topic_id = $db->sql_nextid();
682 686 psotfx
683 2350 psotfx
                        if( !empty($HTTP_POST_VARS['split_type_all']) )
684 654 thefinn
                        {
685 2350 psotfx
                                $post_id_sql = '';
686 1043 psotfx
                                for($i = 0; $i < count($posts); $i++)
687 654 thefinn
                                {
688 2350 psotfx
                                        $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . $posts[$i];
689 654 thefinn
                                }
690 1043 psotfx
691 1043 psotfx
                                $sql = "UPDATE " . POSTS_TABLE . "
692 1755 psotfx
                                        SET topic_id = $new_topic_id, forum_id = $new_forum_id
693 1043 psotfx
                                        WHERE post_id IN ($post_id_sql)";
694 654 thefinn
                        }
695 2350 psotfx
                        else if( !empty($HTTP_POST_VARS['split_type_beyond']) )
696 654 thefinn
                        {
697 877 thefinn
                                $sql = "UPDATE " . POSTS_TABLE . "
698 1755 psotfx
                                        SET topic_id = $new_topic_id, forum_id = $new_forum_id
699 1411 thefinn
                                        WHERE post_time >= $post_time
700 686 psotfx
                                                AND topic_id = $topic_id";
701 654 thefinn
                        }
702 877 thefinn
703 2462 psotfx
                        if( !$db->sql_query($sql, END_TRANSACTION) )
704 654 thefinn
                        {
705 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
706 627 thefinn
                        }
707 686 psotfx
708 2350 psotfx
                        sync('topic', $new_topic_id);
709 2350 psotfx
                        sync('topic', $topic_id);
710 2350 psotfx
                        sync('forum', $new_forum_id);
711 2350 psotfx
                        sync('forum', $forum_id);
712 686 psotfx
713 1307 psotfx
                        $template->assign_vars(array(
714 2350 psotfx
                                'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
715 1307 psotfx
                        );
716 1307 psotfx
717 2350 psotfx
                        $message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
718 1043 psotfx
                        message_die(GENERAL_MESSAGE, $message);
719 619 thefinn
                }
720 619 thefinn
                else
721 619 thefinn
                {
722 1043 psotfx
                        //
723 1043 psotfx
                        // Set template files
724 1043 psotfx
                        //
725 1043 psotfx
                        $template->set_filenames(array(
726 2350 psotfx
                                'split_body' => 'modcp_split.tpl')
727 1043 psotfx
                        );
728 877 thefinn
729 1499 psotfx
                        $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
730 686 psotfx
                                FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
731 686 psotfx
                                WHERE p.topic_id = $topic_id
732 686 psotfx
                                        AND p.poster_id = u.user_id
733 686 psotfx
                                        AND p.post_id = pt.post_id
734 686 psotfx
                                ORDER BY p.post_time ASC";
735 2350 psotfx
                        if ( !($result = $db->sql_query($sql)) )
736 627 thefinn
                        {
737 2350 psotfx
                                message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
738 627 thefinn
                        }
739 877 thefinn
740 2129 psotfx
                        $s_hidden_fields = '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="mode" value="split" />';
741 686 psotfx
742 686 psotfx
                        if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
743 627 thefinn
                        {
744 627 thefinn
                                $postrow = $db->sql_fetchrowset($result);
745 877 thefinn
746 686 psotfx
                                $template->assign_vars(array(
747 2350 psotfx
                                        'L_SPLIT_TOPIC' => $lang['Split_Topic'],
748 2350 psotfx
                                        'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
749 2350 psotfx
                                        'L_AUTHOR' => $lang['Author'],
750 2350 psotfx
                                        'L_MESSAGE' => $lang['Message'],
751 2350 psotfx
                                        'L_SELECT' => $lang['Select'],
752 2350 psotfx
                                        'L_SPLIT_SUBJECT' => $lang['Split_title'],
753 2350 psotfx
                                        'L_SPLIT_FORUM' => $lang['Split_forum'],
754 2350 psotfx
                                        'L_POSTED' => $lang['Posted'],
755 2350 psotfx
                                        'L_SPLIT_POSTS' => $lang['Split_posts'],
756 2350 psotfx
                                        'L_SUBMIT' => $lang['Submit'],
757 2350 psotfx
                                        'L_SPLIT_AFTER' => $lang['Split_after'],
758 2350 psotfx
                                        'L_POST_SUBJECT' => $lang['Post_subject'],
759 2350 psotfx
                                        'L_MARK_ALL' => $lang['Mark_all'],
760 2350 psotfx
                                        'L_UNMARK_ALL' => $lang['Unmark_all'],
761 2448 psotfx
                                        'L_POST' => $lang['Post'],
762 686 psotfx
763 2350 psotfx
                                        'FORUM_NAME' => $forum_name,
764 1550 psotfx
765 2350 psotfx
                                        'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
766 1550 psotfx
767 2350 psotfx
                                        'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
768 2350 psotfx
                                        'S_HIDDEN_FIELDS' => $s_hidden_fields,
769 2726 psotfx
                                        'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
770 686 psotfx
                                );
771 877 thefinn
772 627 thefinn
                                for($i = 0; $i < $total_posts; $i++)
773 627 thefinn
                                {
774 686 psotfx
                                        $post_id = $postrow[$i]['post_id'];
775 627 thefinn
                                        $poster_id = $postrow[$i]['user_id'];
776 1043 psotfx
                                        $poster = $postrow[$i]['username'];
777 686 psotfx
778 1010 bartvb
                                        $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
779 877 thefinn
780 627 thefinn
                                        $bbcode_uid = $postrow[$i]['bbcode_uid'];
781 1043 psotfx
                                        $message = $postrow[$i]['post_text'];
782 2350 psotfx
                                        $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title;
783 877 thefinn
784 1043 psotfx
                                        //
785 1043 psotfx
                                        // If the board has HTML off but the post has HTML
786 1043 psotfx
                                        // on then we process it, else leave it alone
787 1043 psotfx
                                        //
788 2350 psotfx
                                        if ( !$board_config['allow_html'] )
789 627 thefinn
                                        {
790 2350 psotfx
                                                if ( $postrow[$i]['enable_html'] )
791 1043 psotfx
                                                {
792 2350 psotfx
                                                        $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
793 1043 psotfx
                                                }
794 627 thefinn
                                        }
795 877 thefinn
796 2350 psotfx
                                        if ( $bbcode_uid != '' )
797 627 thefinn
                                        {
798 2350 psotfx
                                                $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
799 627 thefinn
                                        }
800 877 thefinn
801 1043 psotfx
                                        //
802 1043 psotfx
                                        // Define censored word matches
803 1043 psotfx
                                        //
804 1043 psotfx
                                        $orig_word = array();
805 1043 psotfx
                                        $replacement_word = array();
806 1043 psotfx
                                        obtain_word_list($orig_word, $replacement_word);
807 877 thefinn
808 2350 psotfx
                                        if ( count($orig_word) )
809 686 psotfx
                                        {
810 1043 psotfx
                                                $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
811 1043 psotfx
                                                $message = preg_replace($orig_word, $replacement_word, $message);
812 686 psotfx
                                        }
813 1043 psotfx
814 1043 psotfx
                                        $message = make_clickable($message);
815 1043 psotfx
816 2350 psotfx
                                        if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
817 686 psotfx
                                        {
818 1043 psotfx
                                                $message = smilies_pass($message);
819 686 psotfx
                                        }
820 686 psotfx
821 2350 psotfx
                                        $message = str_replace("\n", '<br />', $message);
822 1043 psotfx
823 1043 psotfx
                                        $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
824 1043 psotfx
                                        $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
825 1043 psotfx
826 2439 thefinn
                                        $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : '&nbsp;';
827 2319 thefinn
828 2350 psotfx
                                        $template->assign_block_vars('postrow', array(
829 2350 psotfx
                                                'ROW_COLOR' => '#' . $row_color,
830 2350 psotfx
                                                'ROW_CLASS' => $row_class,
831 2350 psotfx
                                                'POSTER_NAME' => $poster,
832 2350 psotfx
                                                'POST_DATE' => $post_date,
833 2350 psotfx
                                                'POST_SUBJECT' => $post_subject,
834 2350 psotfx
                                                'MESSAGE' => $message,
835 2448 psotfx
                                                'POST_ID' => $post_id,
836 2448 psotfx
837 2448 psotfx
                                                'S_SPLIT_CHECKBOX' => $checkbox)
838 686 psotfx
                                        );
839 627 thefinn
                                }
840 686 psotfx
841 2350 psotfx
                                $template->pparse('split_body');
842 877 thefinn
                        }
843 619 thefinn
                }
844 1043 psotfx
                break;
845 1043 psotfx
846 976 thefinn
        case 'ip':
847 1440 psotfx
                $page_title = $lang['Mod_CP'];
848 1440 psotfx
                include($phpbb_root_path . 'includes/page_header.'.$phpEx);
849 1440 psotfx
850 1043 psotfx
                $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
851 1009 psotfx
852 2350 psotfx
                if ( !$post_id )
853 1043 psotfx
                {
854 2350 psotfx
                        message_die(GENERAL_MESSAGE, $lang['No_such_post']);
855 1043 psotfx
                }
856 590 thefinn
857 1043 psotfx
                //
858 1043 psotfx
                // Set template files
859 1043 psotfx
                //
860 1043 psotfx
                $template->set_filenames(array(
861 2350 psotfx
                        'viewip' => 'modcp_viewip.tpl')
862 1043 psotfx
                );
863 976 thefinn
864 1043 psotfx
                // Look up relevent data for this post
865 1043 psotfx
                $sql = "SELECT poster_ip, poster_id
866 1043 psotfx
                        FROM " . POSTS_TABLE . "
867 1043 psotfx
                        WHERE post_id = $post_id";
868 2350 psotfx
                if ( !($result = $db->sql_query($sql)) )
869 1043 psotfx
                {
870 2350 psotfx
                        message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
871 1043 psotfx
                }
872 1631 bartvb
873 2350 psotfx
                if ( !($post_row = $db->sql_fetchrow($result)) )
874 1631 bartvb
                {
875 2350 psotfx
                        message_die(GENERAL_MESSAGE, $lang['No_such_post']);
876 1631 bartvb
                }
877 1009 psotfx
878 1043 psotfx
                $ip_this_post = decode_ip($post_row['poster_ip']);
879 1043 psotfx
                $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post;
880 976 thefinn
881 1043 psotfx
                $poster_id = $post_row['poster_id'];
882 1008 thefinn
883 1043 psotfx
                $template->assign_vars(array(
884 2350 psotfx
                        'L_IP_INFO' => $lang['IP_info'],
885 2350 psotfx
                        'L_THIS_POST_IP' => $lang['This_posts_IP'],
886 2350 psotfx
                        'L_OTHER_IPS' => $lang['Other_IP_this_user'],
887 2350 psotfx
                        'L_OTHER_USERS' => $lang['Users_this_IP'],
888 2350 psotfx
                        'L_LOOKUP_IP' => $lang['Lookup_IP'],
889 2350 psotfx
                        'L_SEARCH' => $lang['Search'],
890 1009 psotfx
891 2350 psotfx
                        'SEARCH_IMG' => $images['icon_search'],
892 1009 psotfx
893 2350 psotfx
                        'IP' => $ip_this_post,
894 1043 psotfx
895 2350 psotfx
                        'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $ip_this_post))
896 1043 psotfx
                );
897 1008 thefinn
898 1043 psotfx
                //
899 1043 psotfx
                // Get other IP's this user has posted under
900 1043 psotfx
                //
901 2350 psotfx
                $sql = "SELECT poster_ip, COUNT(*) AS postings
902 1043 psotfx
                        FROM " . POSTS_TABLE . "
903 1043 psotfx
                        WHERE poster_id = $poster_id
904 2350 psotfx
                        GROUP BY poster_ip
905 2564 psotfx
                        ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
906 2350 psotfx
                if ( !($result = $db->sql_query($sql)) )
907 1043 psotfx
                {
908 2350 psotfx
                        message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
909 1043 psotfx
                }
910 1009 psotfx
911 2448 psotfx
                if ( $row = $db->sql_fetchrow($result) )
912 1043 psotfx
                {
913 2448 psotfx
                        $i = 0;
914 2448 psotfx
                        do
915 2239 bartvb
                        {
916 2448 psotfx
                                if ( $row['poster_ip'] == $post_row['poster_ip'] )
917 2448 psotfx
                                {
918 2448 psotfx
                                        $template->assign_vars(array(
919 2448 psotfx
                                                'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
920 2448 psotfx
                                        );
921 2448 psotfx
                                        continue;
922 2448 psotfx
                                }
923 1009 psotfx
924 2448 psotfx
                                $ip = decode_ip($row['poster_ip']);
925 2448 psotfx
                                $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
926 1009 psotfx
927 2448 psotfx
                                $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
928 2448 psotfx
                                $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
929 1008 thefinn
930 2448 psotfx
                                $template->assign_block_vars('iprow', array(
931 2448 psotfx
                                        'ROW_COLOR' => '#' . $row_color,
932 2448 psotfx
                                        'ROW_CLASS' => $row_class,
933 2448 psotfx
                                        'IP' => $ip,
934 2448 psotfx
                                        'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
935 2448 psotfx
936 2448 psotfx
                                        'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $row['poster_ip']))
937 2448 psotfx
                                );
938 2448 psotfx
939 2448 psotfx
                                $i++;
940 2448 psotfx
                        }
941 2448 psotfx
                        while ( $row = $db->sql_fetchrow($result) );
942 1043 psotfx
                }
943 976 thefinn
944 1043 psotfx
                //
945 1043 psotfx
                // Get other users who've posted under this IP
946 1043 psotfx
                //
947 2448 psotfx
                $sql = "SELECT u.user_id, u.username, COUNT(*) as postings
948 1043 psotfx
                        FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p
949 1043 psotfx
                        WHERE p.poster_id = u.user_id
950 2239 bartvb
                                AND p.poster_ip = '" . $post_row['poster_ip'] . "'
951 2239 bartvb
                        GROUP BY u.user_id, u.username
952 2564 psotfx
                        ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
953 2350 psotfx
                if ( !($result = $db->sql_query($sql)) )
954 1043 psotfx
                {
955 2350 psotfx
                        message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
956 1043 psotfx
                }
957 976 thefinn
958 2448 psotfx
                if ( $row = $db->sql_fetchrow($result) )
959 1043 psotfx
                {
960 2448 psotfx
                        $i = 0;
961 2448 psotfx
                        do
962 2448 psotfx
                        {
963 2448 psotfx
                                $id = $row['user_id'];
964 2448 psotfx
                                $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
965 1008 thefinn
966 2448 psotfx
                                $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
967 2448 psotfx
                                $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
968 1009 psotfx
969 2448 psotfx
                                $template->assign_block_vars('userrow', array(
970 2448 psotfx
                                        'ROW_COLOR' => '#' . $row_color,
971 2448 psotfx
                                        'ROW_CLASS' => $row_class,
972 2448 psotfx
                                        'USERNAME' => $username,
973 2448 psotfx
                                        'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
974 2448 psotfx
                                        'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username),
975 976 thefinn
976 2448 psotfx
                                        'U_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
977 2448 psotfx
                                        'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics"))
978 2448 psotfx
                                );
979 2448 psotfx
980 2448 psotfx
                                $i++;
981 2448 psotfx
                        }
982 2448 psotfx
                        while ( $row = $db->sql_fetchrow($result) );
983 1043 psotfx
                }
984 976 thefinn
985 2448 psotfx
                $template->pparse('viewip');
986 1043 psotfx
987 1043 psotfx
                break;
988 1043 psotfx
989 561 uid29890
        default:
990 1439 psotfx
                $page_title = $lang['Mod_CP'];
991 1439 psotfx
                include($phpbb_root_path . 'includes/page_header.'.$phpEx);
992 1439 psotfx
993 686 psotfx
                $template->assign_vars(array(
994 2350 psotfx
                        'FORUM_NAME' => $forum_name,
995 1439 psotfx
996 2350 psotfx
                        'L_MOD_CP' => $lang['Mod_CP'],
997 2350 psotfx
                        'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
998 2350 psotfx
                        'L_SELECT' => $lang['Select'],
999 2350 psotfx
                        'L_DELETE' => $lang['Delete'],
1000 2350 psotfx
                        'L_MOVE' => $lang['Move'],
1001 2350 psotfx
                        'L_LOCK' => $lang['Lock'],
1002 2350 psotfx
                        'L_UNLOCK' => $lang['Unlock'],
1003 2448 psotfx
                        'L_TOPICS' => $lang['Topics'],
1004 2448 psotfx
                        'L_REPLIES' => $lang['Replies'],
1005 2448 psotfx
                        'L_LASTPOST' => $lang['Last_Post'],
1006 2448 psotfx
                        'L_SELECT' => $lang['Select'],
1007 1439 psotfx
1008 2350 psotfx
                        'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
1009 2350 psotfx
                        'S_HIDDEN_FIELDS' => '<input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '">',
1010 2350 psotfx
                        'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
1011 686 psotfx
                );
1012 686 psotfx
1013 1043 psotfx
                $template->set_filenames(array(
1014 2350 psotfx
                        'body' => 'modcp_body.tpl')
1015 1043 psotfx
                );
1016 1043 psotfx
1017 1043 psotfx
                //
1018 1043 psotfx
                // Define censored word matches
1019 1043 psotfx
                //
1020 1043 psotfx
                $orig_word = array();
1021 1043 psotfx
                $replacement_word = array();
1022 1043 psotfx
                obtain_word_list($orig_word, $replacement_word);
1023 1043 psotfx
1024 2104 psotfx
                $sql = "SELECT t.*, u.username, u.user_id, p.post_time
1025 2104 psotfx
                        FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
1026 2104 psotfx
                        WHERE t.forum_id = $forum_id
1027 2104 psotfx
                                AND t.topic_poster = u.user_id
1028 2104 psotfx
                                AND p.post_id = t.topic_last_post_id
1029 2104 psotfx
                        ORDER BY t.topic_type DESC, p.post_time DESC
1030 2104 psotfx
                        LIMIT $start, " . $board_config['topics_per_page'];
1031 2104 psotfx
                if ( !($result = $db->sql_query($sql)) )
1032 877 thefinn
                {
1033 2350 psotfx
                           message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
1034 2104 psotfx
                }
1035 2104 psotfx
1036 2104 psotfx
                while ( $row = $db->sql_fetchrow($result) )
1037 2104 psotfx
                {
1038 2350 psotfx
                        $topic_title = '';
1039 1043 psotfx
1040 2104 psotfx
                        if ( $row['topic_status'] == TOPIC_LOCKED )
1041 877 thefinn
                        {
1042 2104 psotfx
                                $folder_img = $images['folder_locked'];
1043 2104 psotfx
                                $folder_alt = $lang['Topic_locked'];
1044 590 thefinn
                        }
1045 590 thefinn
                        else
1046 590 thefinn
                        {
1047 2104 psotfx
                                if ( $row['topic_type'] == POST_ANNOUNCE )
1048 1259 thefinn
                                {
1049 2104 psotfx
                                        $folder_img = $images['folder_announce'];
1050 2564 psotfx
                                        $folder_alt = $lang['Topic_Announcement'];
1051 1259 thefinn
                                }
1052 2104 psotfx
                                else if ( $row['topic_type'] == POST_STICKY )
1053 1259 thefinn
                                {
1054 2104 psotfx
                                        $folder_img = $images['folder_sticky'];
1055 2564 psotfx
                                        $folder_alt = $lang['Topic_Sticky'];
1056 1259 thefinn
                                }
1057 1259 thefinn
                                else
1058 1259 thefinn
                                {
1059 2104 psotfx
                                        $folder_img = $images['folder'];
1060 2104 psotfx
                                        $folder_alt = $lang['No_new_posts'];
1061 1259 thefinn
                                }
1062 590 thefinn
                        }
1063 877 thefinn
1064 2104 psotfx
                        $topic_id = $row['topic_id'];
1065 2104 psotfx
                        $topic_type = $row['topic_type'];
1066 2104 psotfx
                        $topic_status = $row['topic_status'];
1067 1259 thefinn
1068 2104 psotfx
                        if ( $topic_type == POST_ANNOUNCE )
1069 590 thefinn
                        {
1070 2350 psotfx
                                $topic_type = $lang['Topic_Announcement'] . ' ';
1071 590 thefinn
                        }
1072 2104 psotfx
                        else if ( $topic_type == POST_STICKY )
1073 590 thefinn
                        {
1074 2350 psotfx
                                $topic_type = $lang['Topic_Sticky'] . ' ';
1075 590 thefinn
                        }
1076 2104 psotfx
                        else if ( $topic_status == TOPIC_MOVED )
1077 1314 bartvb
                        {
1078 2350 psotfx
                                $topic_type = $lang['Topic_Moved'] . ' ';
1079 1314 bartvb
                        }
1080 1043 psotfx
                        else
1081 1043 psotfx
                        {
1082 2350 psotfx
                                $topic_type = '';
1083 1043 psotfx
                        }
1084 1259 thefinn
1085 2104 psotfx
                        if ( $row['topic_vote'] )
1086 1043 psotfx
                        {
1087 2350 psotfx
                                $topic_type .= $lang['Topic_Poll'] . ' ';
1088 1043 psotfx
                        }
1089 1259 thefinn
1090 2104 psotfx
                        $topic_title = $row['topic_title'];
1091 2104 psotfx
                        if ( count($orig_word) )
1092 1043 psotfx
                        {
1093 1043 psotfx
                                $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
1094 1043 psotfx
                        }
1095 561 uid29890
1096 1043 psotfx
                        $u_view_topic = append_sid("modcp.$phpEx?mode=split&amp;" . POST_TOPIC_URL . "=$topic_id");
1097 2104 psotfx
                        $topic_replies = $row['topic_replies'];
1098 877 thefinn
1099 2104 psotfx
                        $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
1100 1043 psotfx
1101 2350 psotfx
                        $template->assign_block_vars('topicrow', array(
1102 2350 psotfx
                                'U_VIEW_TOPIC' => $u_view_topic,
1103 686 psotfx
1104 2448 psotfx
                                'TOPIC_FOLDER_IMG' => $folder_img,
1105 2350 psotfx
                                'TOPIC_TYPE' => $topic_type,
1106 2350 psotfx
                                'TOPIC_TITLE' => $topic_title,
1107 2350 psotfx
                                'REPLIES' => $topic_replies,
1108 2448 psotfx
                                'LAST_POST_TIME' => $last_post_time,
1109 2448 psotfx
                                'TOPIC_ID' => $topic_id,
1110 2448 psotfx
1111 2448 psotfx
                                'L_TOPIC_FOLDER_ALT' => $folder_alt)
1112 686 psotfx
                        );
1113 561 uid29890
                }
1114 877 thefinn
1115 686 psotfx
                $template->assign_vars(array(
1116 2350 psotfx
                        'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id", $forum_topics, $board_config['topics_per_page'], $start),
1117 2350 psotfx
                        'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )),
1118 2350 psotfx
                        'L_GOTO_PAGE' => $lang['Goto_page'])
1119 646 psotfx
                );
1120 646 psotfx
1121 2350 psotfx
                $template->pparse('body');
1122 646 psotfx
1123 646 psotfx
                break;
1124 561 uid29890
}
1125 561 uid29890
1126 646 psotfx
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1127 877 thefinn
1128 2350 psotfx
?>