]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2/modcp.php
update brief bio
[www.vanrenterghem.biz.git] / phpBB2 / modcp.php
1 <?php
2 /***************************************************************************
3  *                                 modcp.php
4  *                            -------------------
5  *   begin                : July 4, 2001
6  *   copyright            : (C) 2001 The phpBB Group
7  *   email                : support@phpbb.com
8  *
9  *   $Id: modcp.php,v 1.71.2.29 2006/12/16 13:11:24 acydburn Exp $
10  *
11  ***************************************************************************/
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  ***************************************************************************/
22 /**
23  * Moderator Control Panel
24  *
25  * From this 'Control Panel' the moderator of a forum will be able to do
26  * mass topic operations (locking/unlocking/moving/deleteing), and it will
27  * provide an interface to do quick locking/unlocking/moving/deleting of
28  * topics via the moderator operations buttons on all of the viewtopic pages.
29  */
31 define('IN_PHPBB', true);
32 $phpbb_root_path = './';
33 include($phpbb_root_path . 'extension.inc');
34 include($phpbb_root_path . 'common.'.$phpEx);
35 include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
36 include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
38 //
39 // Obtain initial var settings
40 //
41 if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
42 {
43         $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
44 }
45 else
46 {
47         $forum_id = '';
48 }
50 if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
51 {
52         $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
53 }
54 else
55 {
56         $post_id = '';
57 }
59 if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
60 {
61         $topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
62 }
63 else
64 {
65         $topic_id = '';
66 }
68 $confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
70 //
71 // Continue var definitions
72 //
73 $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
74 $start = ($start < 0) ? 0 : $start;
76 $delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
77 $move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
78 $lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
79 $unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
81 if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
82 {
83         $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
84         $mode = htmlspecialchars($mode);
85 }
86 else
87 {
88         if ( $delete )
89         {
90                 $mode = 'delete';
91         }
92         else if ( $move )
93         {
94                 $mode = 'move';
95         }
96         else if ( $lock )
97         {
98                 $mode = 'lock';
99         }
100         else if ( $unlock )
101         {
102                 $mode = 'unlock';
103         }
104         else
105         {
106                 $mode = '';
107         }
110 // session id check
111 if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
113         $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
115 else
117         $sid = '';
120 //
121 // Obtain relevant data
122 //
123 if ( !empty($topic_id) )
125         $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
126                 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
127                 WHERE t.topic_id = " . $topic_id . "
128                         AND f.forum_id = t.forum_id";
129         if ( !($result = $db->sql_query($sql)) )
130         {
131                 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
132         }
133         $topic_row = $db->sql_fetchrow($result);
135         if (!$topic_row)
136         {
137                 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
138         }
140         $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
141         $forum_id = $topic_row['forum_id'];
142         $forum_name = $topic_row['forum_name'];
144 else if ( !empty($forum_id) )
146         $sql = "SELECT forum_name, forum_topics
147                 FROM " . FORUMS_TABLE . "
148                 WHERE forum_id = " . $forum_id;
149         if ( !($result = $db->sql_query($sql)) )
150         {
151                 message_die(GENERAL_MESSAGE, 'Forum_not_exist');
152         }
153         $topic_row = $db->sql_fetchrow($result);
155         if (!$topic_row)
156         {
157                 message_die(GENERAL_MESSAGE, 'Forum_not_exist');
158         }
160         $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
161         $forum_name = $topic_row['forum_name'];
163 else
165         message_die(GENERAL_MESSAGE, 'Forum_not_exist');
168 //
169 // Start session management
170 //
171 $userdata = session_pagestart($user_ip, $forum_id);
172 init_userprefs($userdata);
173 //
174 // End session management
175 //
177 // session id check
178 if ($sid == '' || $sid != $userdata['session_id'])
180         message_die(GENERAL_ERROR, 'Invalid_session');
183 //
184 // Check if user did or did not confirm
185 // If they did not, forward them to the last page they were on
186 //
187 if ( isset($HTTP_POST_VARS['cancel']) )
189         if ( $topic_id )
190         {
191                 $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
192         }
193         else if ( $forum_id )
194         {
195                 $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
196         }
197         else
198         {
199                 $redirect = "index.$phpEx";
200         }
202         redirect(append_sid($redirect, true));
205 //
206 // Start auth check
207 //
208 $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
210 if ( !$is_auth['auth_mod'] )
212         message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
214 //
215 // End Auth Check
216 //
218 //
219 // Do major work ...
220 //
221 switch( $mode )
223         case 'delete':
224                 if (!$is_auth['auth_delete'])
225                 {
226                         message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
227                 }
229                 $page_title = $lang['Mod_CP'];
230                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
232                 if ( $confirm )
233                 {
234                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
235                         {
236                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
237                         }
239                         include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
241                         $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
243                         $topic_id_sql = '';
244                         for($i = 0; $i < count($topics); $i++)
245                         {
246                                 $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
247                         }
249                         $sql = "SELECT topic_id 
250                                 FROM " . TOPICS_TABLE . "
251                                 WHERE topic_id IN ($topic_id_sql)
252                                         AND forum_id = $forum_id";
253                         if ( !($result = $db->sql_query($sql)) )
254                         {
255                                 message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql);
256                         }
257                         
258                         $topic_id_sql = '';
259                         while ($row = $db->sql_fetchrow($result))
260                         {
261                                 $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);
262                         }
263                         $db->sql_freeresult($result);
265                         if ( $topic_id_sql == '')
266                         {
267                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
268                         }
270                         $sql = "SELECT poster_id, COUNT(post_id) AS posts 
271                                 FROM " . POSTS_TABLE . " 
272                                 WHERE topic_id IN ($topic_id_sql) 
273                                 GROUP BY poster_id";
274                         if ( !($result = $db->sql_query($sql)) )
275                         {
276                                 message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
277                         }
279                         $count_sql = array();
280                         while ( $row = $db->sql_fetchrow($result) )
281                         {
282                                 $count_sql[] = "UPDATE " . USERS_TABLE . " 
283                                         SET user_posts = user_posts - " . $row['posts'] . " 
284                                         WHERE user_id = " . $row['poster_id'];
285                         }
286                         $db->sql_freeresult($result);
288                         if ( sizeof($count_sql) )
289                         {
290                                 for($i = 0; $i < sizeof($count_sql); $i++)
291                                 {
292                                         if ( !$db->sql_query($count_sql[$i]) )
293                                         {
294                                                 message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
295                                         }
296                                 }
297                         }
298                         
299                         $sql = "SELECT post_id 
300                                 FROM " . POSTS_TABLE . " 
301                                 WHERE topic_id IN ($topic_id_sql)";
302                         if ( !($result = $db->sql_query($sql)) )
303                         {
304                                 message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
305                         }
307                         $post_id_sql = '';
308                         while ( $row = $db->sql_fetchrow($result) )
309                         {
310                                 $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row['post_id']);
311                         }
312                         $db->sql_freeresult($result);
314                         $sql = "SELECT vote_id 
315                                 FROM " . VOTE_DESC_TABLE . " 
316                                 WHERE topic_id IN ($topic_id_sql)";
317                         if ( !($result = $db->sql_query($sql)) )
318                         {
319                                 message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
320                         }
322                         $vote_id_sql = '';
323                         while ( $row = $db->sql_fetchrow($result) )
324                         {
325                                 $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
326                         }
327                         $db->sql_freeresult($result);
329                         //
330                         // Got all required info so go ahead and start deleting everything
331                         //
332                         $sql = "DELETE 
333                                 FROM " . TOPICS_TABLE . " 
334                                 WHERE topic_id IN ($topic_id_sql) 
335                                         OR topic_moved_id IN ($topic_id_sql)";
336                         if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
337                         {
338                                 message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
339                         }
341                         if ( $post_id_sql != '' )
342                         {
343                                 $sql = "DELETE 
344                                         FROM " . POSTS_TABLE . " 
345                                         WHERE post_id IN ($post_id_sql)";
346                                 if ( !$db->sql_query($sql) )
347                                 {
348                                         message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
349                                 }
351                                 $sql = "DELETE 
352                                         FROM " . POSTS_TEXT_TABLE . " 
353                                         WHERE post_id IN ($post_id_sql)";
354                                 if ( !$db->sql_query($sql) )
355                                 {
356                                         message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
357                                 }
359                                 remove_search_post($post_id_sql);
360                         }
362                         if ( $vote_id_sql != '' )
363                         {
364                                 $sql = "DELETE 
365                                         FROM " . VOTE_DESC_TABLE . " 
366                                         WHERE vote_id IN ($vote_id_sql)";
367                                 if ( !$db->sql_query($sql) )
368                                 {
369                                         message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
370                                 }
372                                 $sql = "DELETE 
373                                         FROM " . VOTE_RESULTS_TABLE . " 
374                                         WHERE vote_id IN ($vote_id_sql)";
375                                 if ( !$db->sql_query($sql) )
376                                 {
377                                         message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
378                                 }
380                                 $sql = "DELETE 
381                                         FROM " . VOTE_USERS_TABLE . " 
382                                         WHERE vote_id IN ($vote_id_sql)";
383                                 if ( !$db->sql_query($sql) )
384                                 {
385                                         message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
386                                 }
387                         }
389                         $sql = "DELETE 
390                                 FROM " . TOPICS_WATCH_TABLE . " 
391                                 WHERE topic_id IN ($topic_id_sql)";
392                         if ( !$db->sql_query($sql, END_TRANSACTION) )
393                         {
394                                 message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
395                         }
397                         sync('forum', $forum_id);
399                         if ( !empty($topic_id) )
400                         {
401                                 $redirect_page = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
402                                 $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
403                         }
404                         else
405                         {
406                                 $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
407                                 $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
408                         }
410                         $template->assign_vars(array(
411                                 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
412                         );
414                         message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
415                 }
416                 else
417                 {
418                         // Not confirmed, show confirmation message
419                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
420                         {
421                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
422                         }
424                         $hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
426                         if ( isset($HTTP_POST_VARS['topic_id_list']) )
427                         {
428                                 $topics = $HTTP_POST_VARS['topic_id_list'];
429                                 for($i = 0; $i < count($topics); $i++)
430                                 {
431                                         $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
432                                 }
433                         }
434                         else
435                         {
436                                 $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
437                         }
439                         //
440                         // Set template files
441                         //
442                         $template->set_filenames(array(
443                                 'confirm' => 'confirm_body.tpl')
444                         );
446                         $template->assign_vars(array(
447                                 'MESSAGE_TITLE' => $lang['Confirm'],
448                                 'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
450                                 'L_YES' => $lang['Yes'],
451                                 'L_NO' => $lang['No'],
453                                 'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
454                                 'S_HIDDEN_FIELDS' => $hidden_fields)
455                         );
457                         $template->pparse('confirm');
459                         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
460                 }
461                 break;
463         case 'move':
464                 $page_title = $lang['Mod_CP'];
465                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
467                 if ( $confirm )
468                 {
469                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
470                         {
471                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
472                         }
474                         $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
475                         $old_forum_id = $forum_id;
477                         $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
478                                 WHERE forum_id = ' . $new_forum_id;
479                         if ( !($result = $db->sql_query($sql)) )
480                         {
481                                 message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
482                         }
483                         
484                         if (!$db->sql_fetchrow($result))
485                         {
486                                 message_die(GENERAL_MESSAGE, 'New forum does not exist');
487                         }
489                         $db->sql_freeresult($result);
491                         if ( $new_forum_id != $old_forum_id )
492                         {
493                                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
495                                 $topic_list = '';
496                                 for($i = 0; $i < count($topics); $i++)
497                                 {
498                                         $topic_list .= ( ( $topic_list != '' ) ? ', ' : '' ) . intval($topics[$i]);
499                                 }
501                                 $sql = "SELECT * 
502                                         FROM " . TOPICS_TABLE . " 
503                                         WHERE topic_id IN ($topic_list)
504                                                 AND forum_id = $old_forum_id
505                                                 AND topic_status <> " . TOPIC_MOVED;
506                                 if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
507                                 {
508                                         message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
509                                 }
511                                 $row = $db->sql_fetchrowset($result);
512                                 $db->sql_freeresult($result);
514                                 for($i = 0; $i < count($row); $i++)
515                                 {
516                                         $topic_id = $row[$i]['topic_id'];
517                                         
518                                         if ( isset($HTTP_POST_VARS['move_leave_shadow']) )
519                                         {
520                                                 // Insert topic in the old forum that indicates that the forum has moved.
521                                                 $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)
522                                                         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)";
523                                                 if ( !$db->sql_query($sql) )
524                                                 {
525                                                         message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
526                                                 }
527                                         }
529                                         $sql = "UPDATE " . TOPICS_TABLE . " 
530                                                 SET forum_id = $new_forum_id  
531                                                 WHERE topic_id = $topic_id";
532                                         if ( !$db->sql_query($sql) )
533                                         {
534                                                 message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
535                                         }
537                                         $sql = "UPDATE " . POSTS_TABLE . " 
538                                                 SET forum_id = $new_forum_id 
539                                                 WHERE topic_id = $topic_id";
540                                         if ( !$db->sql_query($sql) )
541                                         {
542                                                 message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
543                                         }
544                                 }
546                                 // Sync the forum indexes
547                                 sync('forum', $new_forum_id);
548                                 sync('forum', $old_forum_id);
550                                 $message = $lang['Topics_Moved'] . '<br /><br />';
552                         }
553                         else
554                         {
555                                 $message = $lang['No_Topics_Moved'] . '<br /><br />';
556                         }
558                         if ( !empty($topic_id) )
559                         {
560                                 $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
561                                 $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
562                         }
563                         else
564                         {
565                                 $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
566                                 $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
567                         }
569                         $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
571                         $template->assign_vars(array(
572                                 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
573                         );
575                         message_die(GENERAL_MESSAGE, $message);
576                 }
577                 else
578                 {
579                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
580                         {
581                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
582                         }
584                         $hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
586                         if ( isset($HTTP_POST_VARS['topic_id_list']) )
587                         {
588                                 $topics = $HTTP_POST_VARS['topic_id_list'];
590                                 for($i = 0; $i < count($topics); $i++)
591                                 {
592                                         $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
593                                 }
594                         }
595                         else
596                         {
597                                 $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
598                         }
600                         //
601                         // Set template files
602                         //
603                         $template->set_filenames(array(
604                                 'movetopic' => 'modcp_move.tpl')
605                         );
607                         $template->assign_vars(array(
608                                 'MESSAGE_TITLE' => $lang['Confirm'],
609                                 'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
611                                 'L_MOVE_TO_FORUM' => $lang['Move_to_forum'], 
612                                 'L_LEAVESHADOW' => $lang['Leave_shadow_topic'], 
613                                 'L_YES' => $lang['Yes'],
614                                 'L_NO' => $lang['No'],
616                                 'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 
617                                 'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
618                                 'S_HIDDEN_FIELDS' => $hidden_fields)
619                         );
621                         $template->pparse('movetopic');
623                         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
624                 }
625                 break;
627         case 'lock':
628                 if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
629                 {
630                         message_die(GENERAL_MESSAGE, $lang['None_selected']);
631                 }
633                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
635                 $topic_id_sql = '';
636                 for($i = 0; $i < count($topics); $i++)
637                 {
638                         $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
639                 }
641                 $sql = "UPDATE " . TOPICS_TABLE . " 
642                         SET topic_status = " . TOPIC_LOCKED . " 
643                         WHERE topic_id IN ($topic_id_sql) 
644                                 AND forum_id = $forum_id
645                                 AND topic_moved_id = 0";
646                 if ( !($result = $db->sql_query($sql)) )
647                 {
648                         message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
649                 }
651                 if ( !empty($topic_id) )
652                 {
653                         $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
654                         $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
655                 }
656                 else
657                 {
658                         $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
659                         $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
660                 }
662                 $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
664                 $template->assign_vars(array(
665                         'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
666                 );
668                 message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
670                 break;
672         case 'unlock':
673                 if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
674                 {
675                         message_die(GENERAL_MESSAGE, $lang['None_selected']);
676                 }
678                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
680                 $topic_id_sql = '';
681                 for($i = 0; $i < count($topics); $i++)
682                 {
683                         $topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);
684                 }
686                 $sql = "UPDATE " . TOPICS_TABLE . " 
687                         SET topic_status = " . TOPIC_UNLOCKED . " 
688                         WHERE topic_id IN ($topic_id_sql) 
689                                 AND forum_id = $forum_id
690                                 AND topic_moved_id = 0";
691                 if ( !($result = $db->sql_query($sql)) )
692                 {
693                         message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
694                 }
696                 if ( !empty($topic_id) )
697                 {
698                         $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
699                         $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
700                 }
701                 else
702                 {
703                         $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
704                         $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
705                 }
707                 $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
709                 $template->assign_vars(array(
710                         'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
711                 );
713                 message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
715                 break;
717         case 'split':
718                 $page_title = $lang['Mod_CP'];
719                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
721                 $post_id_sql = '';
723                 if (isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']))
724                 {
725                         $posts = $HTTP_POST_VARS['post_id_list'];
727                         for ($i = 0; $i < count($posts); $i++)
728                         {
729                                 $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($posts[$i]);
730                         }
731                 }
733                 if ($post_id_sql != '')
734                 {
735                         $sql = "SELECT post_id 
736                                 FROM " . POSTS_TABLE . "
737                                 WHERE post_id IN ($post_id_sql)
738                                         AND forum_id = $forum_id";
739                         if ( !($result = $db->sql_query($sql)) )
740                         {
741                                 message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
742                         }
743                         
744                         $post_id_sql = '';
745                         while ($row = $db->sql_fetchrow($result))
746                         {
747                                 $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);
748                         }
749                         $db->sql_freeresult($result);
751                         if ($post_id_sql == '')
752                         {
753                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
754                         }
756                         $sql = "SELECT post_id, poster_id, topic_id, post_time
757                                 FROM " . POSTS_TABLE . "
758                                 WHERE post_id IN ($post_id_sql) 
759                                 ORDER BY post_time ASC";
760                         if (!($result = $db->sql_query($sql)))
761                         {
762                                 message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
763                         }
765                         if ($row = $db->sql_fetchrow($result))
766                         {
767                                 $first_poster = $row['poster_id'];
768                                 $topic_id = $row['topic_id'];
769                                 $post_time = $row['post_time'];
771                                 $user_id_sql = '';
772                                 $post_id_sql = '';
773                                 do
774                                 {
775                                         $user_id_sql .= (($user_id_sql != '') ? ', ' : '') . intval($row['poster_id']);
776                                         $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);;
777                                 }
778                                 while ($row = $db->sql_fetchrow($result));
780                                 $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
781                                 if (empty($post_subject))
782                                 {
783                                         message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
784                                 }
786                                 $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
787                                 $topic_time = time();
788                                 
789                                 $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
790                                         WHERE forum_id = ' . $new_forum_id;
791                                 if ( !($result = $db->sql_query($sql)) )
792                                 {
793                                         message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
794                                 }
795                         
796                                 if (!$db->sql_fetchrow($result))
797                                 {
798                                         message_die(GENERAL_MESSAGE, 'New forum does not exist');
799                                 }
801                                 $db->sql_freeresult($result);
803                                 $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
804                                         VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
805                                 if (!($db->sql_query($sql, BEGIN_TRANSACTION)))
806                                 {
807                                         message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
808                                 }
810                                 $new_topic_id = $db->sql_nextid();
812                                 // Update topic watch table, switch users whose posts
813                                 // have moved, over to watching the new topic
814                                 $sql = "UPDATE " . TOPICS_WATCH_TABLE . " 
815                                         SET topic_id = $new_topic_id 
816                                         WHERE topic_id = $topic_id 
817                                                 AND user_id IN ($user_id_sql)";
818                                 if (!$db->sql_query($sql))
819                                 {
820                                         message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
821                                 }
823                                 $sql_where = (!empty($HTTP_POST_VARS['split_type_beyond'])) ? " post_time >= $post_time AND topic_id = $topic_id" : "post_id IN ($post_id_sql)";
825                                 $sql =  "UPDATE " . POSTS_TABLE . "
826                                         SET topic_id = $new_topic_id, forum_id = $new_forum_id 
827                                         WHERE $sql_where";
828                                 if (!$db->sql_query($sql, END_TRANSACTION))
829                                 {
830                                         message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
831                                 }
833                                 sync('topic', $new_topic_id);
834                                 sync('topic', $topic_id);
835                                 sync('forum', $new_forum_id);
836                                 sync('forum', $forum_id);
838                                 $template->assign_vars(array(
839                                         'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'] . '">')
840                                 );
842                                 $message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
843                                 message_die(GENERAL_MESSAGE, $message);
844                         }
845                 }
846                 else
847                 {
848                         //
849                         // Set template files
850                         //
851                         $template->set_filenames(array(
852                                 'split_body' => 'modcp_split.tpl')
853                         );
855                         $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
856                                 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
857                                 WHERE p.topic_id = $topic_id
858                                         AND p.poster_id = u.user_id
859                                         AND p.post_id = pt.post_id
860                                 ORDER BY p.post_time ASC";
861                         if ( !($result = $db->sql_query($sql)) )
862                         {
863                                 message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
864                         }
866                         $s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" /><input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" /><input type="hidden" name="mode" value="split" />';
868                         if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
869                         {
870                                 $postrow = $db->sql_fetchrowset($result);
872                                 $template->assign_vars(array(
873                                         'L_SPLIT_TOPIC' => $lang['Split_Topic'],
874                                         'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
875                                         'L_AUTHOR' => $lang['Author'],
876                                         'L_MESSAGE' => $lang['Message'],
877                                         'L_SELECT' => $lang['Select'],
878                                         'L_SPLIT_SUBJECT' => $lang['Split_title'],
879                                         'L_SPLIT_FORUM' => $lang['Split_forum'],
880                                         'L_POSTED' => $lang['Posted'],
881                                         'L_SPLIT_POSTS' => $lang['Split_posts'],
882                                         'L_SUBMIT' => $lang['Submit'],
883                                         'L_SPLIT_AFTER' => $lang['Split_after'], 
884                                         'L_POST_SUBJECT' => $lang['Post_subject'], 
885                                         'L_MARK_ALL' => $lang['Mark_all'], 
886                                         'L_UNMARK_ALL' => $lang['Unmark_all'], 
887                                         'L_POST' => $lang['Post'], 
889                                         'FORUM_NAME' => $forum_name, 
891                                         'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
893                                         'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
894                                         'S_HIDDEN_FIELDS' => $s_hidden_fields,
895                                         'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
896                                 );
898                                 //
899                                 // Define censored word matches
900                                 //
901                                 $orig_word = array();
902                                 $replacement_word = array();
903                                 obtain_word_list($orig_word, $replacement_word);
905                                 for($i = 0; $i < $total_posts; $i++)
906                                 {
907                                         $post_id = $postrow[$i]['post_id'];
908                                         $poster_id = $postrow[$i]['poster_id'];
909                                         $poster = $postrow[$i]['username'];
911                                         $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
913                                         $bbcode_uid = $postrow[$i]['bbcode_uid'];
914                                         $message = $postrow[$i]['post_text'];
915                                         $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title;
917                                         //
918                                         // If the board has HTML off but the post has HTML
919                                         // on then we process it, else leave it alone
920                                         //
921                                         if ( !$board_config['allow_html'] )
922                                         {
923                                                 if ( $postrow[$i]['enable_html'] )
924                                                 {
925                                                         $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
926                                                 }
927                                         }
929                                         if ( $bbcode_uid != '' )
930                                         {
931                                                 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
932                                         }
934                                         if ( count($orig_word) )
935                                         {
936                                                 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
937                                                 $message = preg_replace($orig_word, $replacement_word, $message);
938                                         }
940                                         $message = make_clickable($message);
942                                         if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
943                                         {
944                                                 $message = smilies_pass($message);
945                                         }
947                                         $message = str_replace("\n", '<br />', $message);
948                                         
949                                         $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
950                                         $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
952                                         $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : '&nbsp;';
953                                         
954                                         $template->assign_block_vars('postrow', array(
955                                                 'ROW_COLOR' => '#' . $row_color,
956                                                 'ROW_CLASS' => $row_class,
957                                                 'POSTER_NAME' => $poster,
958                                                 'POST_DATE' => $post_date,
959                                                 'POST_SUBJECT' => $post_subject,
960                                                 'MESSAGE' => $message,
961                                                 'POST_ID' => $post_id,
962                                                 
963                                                 'S_SPLIT_CHECKBOX' => $checkbox)
964                                         );
965                                 }
967                                 $template->pparse('split_body');
968                         }
969                 }
970                 break;
972         case 'ip':
973                 $page_title = $lang['Mod_CP'];
974                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
976                 $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
978                 if ( !$post_id )
979                 {
980                         message_die(GENERAL_MESSAGE, $lang['No_such_post']);
981                 }
983                 //
984                 // Set template files
985                 //
986                 $template->set_filenames(array(
987                         'viewip' => 'modcp_viewip.tpl')
988                 );
990                 // Look up relevent data for this post
991                 $sql = "SELECT poster_ip, poster_id 
992                         FROM " . POSTS_TABLE . " 
993                         WHERE post_id = $post_id
994                                 AND forum_id = $forum_id";
995                 if ( !($result = $db->sql_query($sql)) )
996                 {
997                         message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
998                 }
999                 
1000                 if ( !($post_row = $db->sql_fetchrow($result)) )
1001                 {
1002                         message_die(GENERAL_MESSAGE, $lang['No_such_post']);
1003                 }
1005                 $ip_this_post = decode_ip($post_row['poster_ip']);
1006                 $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? htmlspecialchars(gethostbyaddr($ip_this_post)) : $ip_this_post;
1008                 $poster_id = $post_row['poster_id'];
1010                 $template->assign_vars(array(
1011                         'L_IP_INFO' => $lang['IP_info'],
1012                         'L_THIS_POST_IP' => $lang['This_posts_IP'],
1013                         'L_OTHER_IPS' => $lang['Other_IP_this_user'],
1014                         'L_OTHER_USERS' => $lang['Users_this_IP'],
1015                         'L_LOOKUP_IP' => $lang['Lookup_IP'], 
1016                         'L_SEARCH' => $lang['Search'],
1018                         'SEARCH_IMG' => $images['icon_search'], 
1020                         'IP' => $ip_this_post, 
1021                                 
1022                         'U_LOOKUP_IP' => "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=$ip_this_post&amp;sid=" . $userdata['session_id'])
1023                 );
1025                 //
1026                 // Get other IP's this user has posted under
1027                 //
1028                 $sql = "SELECT poster_ip, COUNT(*) AS postings 
1029                         FROM " . POSTS_TABLE . " 
1030                         WHERE poster_id = $poster_id 
1031                         GROUP BY poster_ip 
1032                         ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
1033                 if ( !($result = $db->sql_query($sql)) )
1034                 {
1035                         message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
1036                 }
1038                 if ( $row = $db->sql_fetchrow($result) )
1039                 {
1040                         $i = 0;
1041                         do
1042                         {
1043                                 if ( $row['poster_ip'] == $post_row['poster_ip'] )
1044                                 {
1045                                         $template->assign_vars(array(
1046                                                 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
1047                                         );
1048                                         continue;
1049                                 }
1051                                 $ip = decode_ip($row['poster_ip']);
1052                                 $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? htmlspecialchars(gethostbyaddr($ip)) : $ip;
1054                                 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1055                                 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1057                                 $template->assign_block_vars('iprow', array(
1058                                         'ROW_COLOR' => '#' . $row_color, 
1059                                         'ROW_CLASS' => $row_class, 
1060                                         'IP' => $ip,
1061                                         'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1063                                         'U_LOOKUP_IP' => "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $row['poster_ip'] . "&amp;sid=" . $userdata['session_id'])
1064                                 );
1066                                 $i++; 
1067                         }
1068                         while ( $row = $db->sql_fetchrow($result) );
1069                 }
1071                 //
1072                 // Get other users who've posted under this IP
1073                 //
1074                 $sql = "SELECT u.user_id, u.username, COUNT(*) as postings 
1075                         FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p 
1076                         WHERE p.poster_id = u.user_id 
1077                                 AND p.poster_ip = '" . $post_row['poster_ip'] . "'
1078                         GROUP BY u.user_id, u.username
1079                         ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
1080                 if ( !($result = $db->sql_query($sql)) )
1081                 {
1082                         message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
1083                 }
1085                 if ( $row = $db->sql_fetchrow($result) )
1086                 {
1087                         $i = 0;
1088                         do
1089                         {
1090                                 $id = $row['user_id'];
1091                                 $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
1093                                 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1094                                 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1096                                 $template->assign_block_vars('userrow', array(
1097                                         'ROW_COLOR' => '#' . $row_color, 
1098                                         'ROW_CLASS' => $row_class, 
1099                                         'USERNAME' => $username,
1100                                         'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1101                                         'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username), 
1103                                         'U_PROFILE' => ($id == ANONYMOUS) ? "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $post_id . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id'] : append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
1104                                         'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . (($id == ANONYMOUS) ? 'Anonymous' : urlencode($username)) . "&amp;showresults=topics"))
1105                                 );
1107                                 $i++; 
1108                         }
1109                         while ( $row = $db->sql_fetchrow($result) );
1110                 }
1112                 $template->pparse('viewip');
1114                 break;
1116         default:
1117                 $page_title = $lang['Mod_CP'];
1118                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
1120                 $template->assign_vars(array(
1121                         'FORUM_NAME' => $forum_name,
1123                         'L_MOD_CP' => $lang['Mod_CP'],
1124                         'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
1125                         'L_SELECT' => $lang['Select'],
1126                         'L_DELETE' => $lang['Delete'],
1127                         'L_MOVE' => $lang['Move'],
1128                         'L_LOCK' => $lang['Lock'],
1129                         'L_UNLOCK' => $lang['Unlock'],
1130                         'L_TOPICS' => $lang['Topics'], 
1131                         'L_REPLIES' => $lang['Replies'], 
1132                         'L_LASTPOST' => $lang['Last_Post'], 
1133                         'L_SELECT' => $lang['Select'], 
1135                         'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
1136                         'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />',
1137                         'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
1138                 );
1140                 $template->set_filenames(array(
1141                         'body' => 'modcp_body.tpl')
1142                 );
1143                 make_jumpbox('modcp.'.$phpEx);
1145                 //
1146                 // Define censored word matches
1147                 //
1148                 $orig_word = array();
1149                 $replacement_word = array();
1150                 obtain_word_list($orig_word, $replacement_word);
1152                 $sql = "SELECT t.*, u.username, u.user_id, p.post_time
1153                         FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
1154                         WHERE t.forum_id = $forum_id
1155                                 AND t.topic_poster = u.user_id
1156                                 AND p.post_id = t.topic_last_post_id
1157                         ORDER BY t.topic_type DESC, p.post_time DESC
1158                         LIMIT $start, " . $board_config['topics_per_page'];
1159                 if ( !($result = $db->sql_query($sql)) )
1160                 {
1161                         message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
1162                 }
1164                 while ( $row = $db->sql_fetchrow($result) )
1165                 {
1166                         $topic_title = '';
1168                         if ( $row['topic_status'] == TOPIC_LOCKED )
1169                         {
1170                                 $folder_img = $images['folder_locked'];
1171                                 $folder_alt = $lang['Topic_locked'];
1172                         }
1173                         else
1174                         {
1175                                 if ( $row['topic_type'] == POST_ANNOUNCE )
1176                                 {
1177                                         $folder_img = $images['folder_announce'];
1178                                         $folder_alt = $lang['Topic_Announcement'];
1179                                 }
1180                                 else if ( $row['topic_type'] == POST_STICKY )
1181                                 {
1182                                         $folder_img = $images['folder_sticky'];
1183                                         $folder_alt = $lang['Topic_Sticky'];
1184                                 }
1185                                 else 
1186                                 {
1187                                         $folder_img = $images['folder'];
1188                                         $folder_alt = $lang['No_new_posts'];
1189                                 }
1190                         }
1192                         $topic_id = $row['topic_id'];
1193                         $topic_type = $row['topic_type'];
1194                         $topic_status = $row['topic_status'];
1195                         
1196                         if ( $topic_type == POST_ANNOUNCE )
1197                         {
1198                                 $topic_type = $lang['Topic_Announcement'] . ' ';
1199                         }
1200                         else if ( $topic_type == POST_STICKY )
1201                         {
1202                                 $topic_type = $lang['Topic_Sticky'] . ' ';
1203                         }
1204                         else if ( $topic_status == TOPIC_MOVED )
1205                         {
1206                                 $topic_type = $lang['Topic_Moved'] . ' ';
1207                         }
1208                         else
1209                         {
1210                                 $topic_type = '';               
1211                         }
1212         
1213                         if ( $row['topic_vote'] )
1214                         {
1215                                 $topic_type .= $lang['Topic_Poll'] . ' ';
1216                         }
1217         
1218                         $topic_title = $row['topic_title'];
1219                         if ( count($orig_word) )
1220                         {
1221                                 $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
1222                         }
1224                         $u_view_topic = "modcp.$phpEx?mode=split&amp;" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
1225                         $topic_replies = $row['topic_replies'];
1227                         $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
1229                         $template->assign_block_vars('topicrow', array(
1230                                 'U_VIEW_TOPIC' => $u_view_topic,
1232                                 'TOPIC_FOLDER_IMG' => $folder_img, 
1233                                 'TOPIC_TYPE' => $topic_type, 
1234                                 'TOPIC_TITLE' => $topic_title,
1235                                 'REPLIES' => $topic_replies,
1236                                 'LAST_POST_TIME' => $last_post_time,
1237                                 'TOPIC_ID' => $topic_id,
1238                                         
1239                                 'L_TOPIC_FOLDER_ALT' => $folder_alt)
1240                         );
1241                 }
1243                 $template->assign_vars(array(
1244                         'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'], $forum_topics, $board_config['topics_per_page'], $start),
1245                         'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )), 
1246                         'L_GOTO_PAGE' => $lang['Goto_page'])
1247                 );
1249                 $template->pparse('body');
1251                 break;
1254 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1256 ?>