]> git.vanrenterghem.biz Git - www.vanrenterghem.biz.git/blob - phpBB2_old/modcp.php
46fceb2cd269b545a8dcee922df9e9af982b5e9e
[www.vanrenterghem.biz.git] / phpBB2_old / 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.24 2004/07/11 16:46:15 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;
75 $delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
76 $move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
77 $lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
78 $unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
80 if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
81 {
82         $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
83         $mode = htmlspecialchars($mode);
84 }
85 else
86 {
87         if ( $delete )
88         {
89                 $mode = 'delete';
90         }
91         else if ( $move )
92         {
93                 $mode = 'move';
94         }
95         else if ( $lock )
96         {
97                 $mode = 'lock';
98         }
99         else if ( $unlock )
100         {
101                 $mode = 'unlock';
102         }
103         else
104         {
105                 $mode = '';
106         }
109 // session id check
110 if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
112         $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
114 else
116         $sid = '';
119 //
120 // Obtain relevant data
121 //
122 if ( !empty($topic_id) )
124         $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
125                 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
126                 WHERE t.topic_id = " . $topic_id . "
127                         AND f.forum_id = t.forum_id";
128         if ( !($result = $db->sql_query($sql)) )
129         {
130                 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
131         }
132         $topic_row = $db->sql_fetchrow($result);
134         $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
135         $forum_id = $topic_row['forum_id'];
136         $forum_name = $topic_row['forum_name'];
138 else if ( !empty($forum_id) )
140         $sql = "SELECT forum_name, forum_topics
141                 FROM " . FORUMS_TABLE . "
142                 WHERE forum_id = " . $forum_id;
143         if ( !($result = $db->sql_query($sql)) )
144         {
145                 message_die(GENERAL_MESSAGE, 'Forum_not_exist');
146         }
147         $topic_row = $db->sql_fetchrow($result);
149         $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
150         $forum_name = $topic_row['forum_name'];
152 else
154         message_die(GENERAL_MESSAGE, 'Forum_not_exist');
157 //
158 // Start session management
159 //
160 $userdata = session_pagestart($user_ip, $forum_id);
161 init_userprefs($userdata);
162 //
163 // End session management
164 //
166 // session id check
167 if ($sid == '' || $sid != $userdata['session_id'])
169         message_die(GENERAL_ERROR, 'Invalid_session');
172 //
173 // Check if user did or did not confirm
174 // If they did not, forward them to the last page they were on
175 //
176 if ( isset($HTTP_POST_VARS['cancel']) )
178         if ( $topic_id )
179         {
180                 $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
181         }
182         else if ( $forum_id )
183         {
184                 $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
185         }
186         else
187         {
188                 $redirect = "index.$phpEx";
189         }
191         redirect(append_sid($redirect, true));
194 //
195 // Start auth check
196 //
197 $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
199 if ( !$is_auth['auth_mod'] )
201         message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
203 //
204 // End Auth Check
205 //
207 //
208 // Do major work ...
209 //
210 switch( $mode )
212         case 'delete':
213                 if (!$is_auth['auth_delete'])
214                 {
215                         message_die(MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
216                 }
218                 $page_title = $lang['Mod_CP'];
219                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
221                 if ( $confirm )
222                 {
223                         include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
225                         $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
227                         $topic_id_sql = '';
228                         for($i = 0; $i < count($topics); $i++)
229                         {
230                                 $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
231                         }
233                         $sql = "SELECT topic_id 
234                                 FROM " . TOPICS_TABLE . "
235                                 WHERE topic_id IN ($topic_id_sql)
236                                         AND forum_id = $forum_id";
237                         if ( !($result = $db->sql_query($sql)) )
238                         {
239                                 message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql);
240                         }
241                         
242                         $topic_id_sql = '';
243                         while ($row = $db->sql_fetchrow($result))
244                         {
245                                 $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);
246                         }
247                         $db->sql_freeresult($result);
249                         $sql = "SELECT poster_id, COUNT(post_id) AS posts 
250                                 FROM " . POSTS_TABLE . " 
251                                 WHERE topic_id IN ($topic_id_sql) 
252                                 GROUP BY poster_id";
253                         if ( !($result = $db->sql_query($sql)) )
254                         {
255                                 message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
256                         }
258                         $count_sql = array();
259                         while ( $row = $db->sql_fetchrow($result) )
260                         {
261                                 $count_sql[] = "UPDATE " . USERS_TABLE . " 
262                                         SET user_posts = user_posts - " . $row['posts'] . " 
263                                         WHERE user_id = " . $row['poster_id'];
264                         }
265                         $db->sql_freeresult($result);
267                         if ( sizeof($count_sql) )
268                         {
269                                 for($i = 0; $i < sizeof($count_sql); $i++)
270                                 {
271                                         if ( !$db->sql_query($count_sql[$i]) )
272                                         {
273                                                 message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
274                                         }
275                                 }
276                         }
277                         
278                         $sql = "SELECT post_id 
279                                 FROM " . POSTS_TABLE . " 
280                                 WHERE topic_id IN ($topic_id_sql)";
281                         if ( !($result = $db->sql_query($sql)) )
282                         {
283                                 message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
284                         }
286                         $post_id_sql = '';
287                         while ( $row = $db->sql_fetchrow($result) )
288                         {
289                                 $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row['post_id']);
290                         }
291                         $db->sql_freeresult($result);
293                         $sql = "SELECT vote_id 
294                                 FROM " . VOTE_DESC_TABLE . " 
295                                 WHERE topic_id IN ($topic_id_sql)";
296                         if ( !($result = $db->sql_query($sql)) )
297                         {
298                                 message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
299                         }
301                         $vote_id_sql = '';
302                         while ( $row = $db->sql_fetchrow($result) )
303                         {
304                                 $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
305                         }
306                         $db->sql_freeresult($result);
308                         //
309                         // Got all required info so go ahead and start deleting everything
310                         //
311                         $sql = "DELETE 
312                                 FROM " . TOPICS_TABLE . " 
313                                 WHERE topic_id IN ($topic_id_sql) 
314                                         OR topic_moved_id IN ($topic_id_sql)";
315                         if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
316                         {
317                                 message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
318                         }
320                         if ( $post_id_sql != '' )
321                         {
322                                 $sql = "DELETE 
323                                         FROM " . POSTS_TABLE . " 
324                                         WHERE post_id IN ($post_id_sql)";
325                                 if ( !$db->sql_query($sql) )
326                                 {
327                                         message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
328                                 }
330                                 $sql = "DELETE 
331                                         FROM " . POSTS_TEXT_TABLE . " 
332                                         WHERE post_id IN ($post_id_sql)";
333                                 if ( !$db->sql_query($sql) )
334                                 {
335                                         message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
336                                 }
338                                 remove_search_post($post_id_sql);
339                         }
341                         if ( $vote_id_sql != '' )
342                         {
343                                 $sql = "DELETE 
344                                         FROM " . VOTE_DESC_TABLE . " 
345                                         WHERE vote_id IN ($vote_id_sql)";
346                                 if ( !$db->sql_query($sql) )
347                                 {
348                                         message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
349                                 }
351                                 $sql = "DELETE 
352                                         FROM " . VOTE_RESULTS_TABLE . " 
353                                         WHERE vote_id IN ($vote_id_sql)";
354                                 if ( !$db->sql_query($sql) )
355                                 {
356                                         message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
357                                 }
359                                 $sql = "DELETE 
360                                         FROM " . VOTE_USERS_TABLE . " 
361                                         WHERE vote_id IN ($vote_id_sql)";
362                                 if ( !$db->sql_query($sql) )
363                                 {
364                                         message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
365                                 }
366                         }
368                         $sql = "DELETE 
369                                 FROM " . TOPICS_WATCH_TABLE . " 
370                                 WHERE topic_id IN ($topic_id_sql)";
371                         if ( !$db->sql_query($sql, END_TRANSACTION) )
372                         {
373                                 message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
374                         }
376                         sync('forum', $forum_id);
378                         if ( !empty($topic_id) )
379                         {
380                                 $redirect_page = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
381                                 $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
382                         }
383                         else
384                         {
385                                 $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
386                                 $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
387                         }
389                         $template->assign_vars(array(
390                                 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
391                         );
393                         message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
394                 }
395                 else
396                 {
397                         // Not confirmed, show confirmation message
398                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
399                         {
400                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
401                         }
403                         $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 . '" />';
405                         if ( isset($HTTP_POST_VARS['topic_id_list']) )
406                         {
407                                 $topics = $HTTP_POST_VARS['topic_id_list'];
408                                 for($i = 0; $i < count($topics); $i++)
409                                 {
410                                         $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
411                                 }
412                         }
413                         else
414                         {
415                                 $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
416                         }
418                         //
419                         // Set template files
420                         //
421                         $template->set_filenames(array(
422                                 'confirm' => 'confirm_body.tpl')
423                         );
425                         $template->assign_vars(array(
426                                 'MESSAGE_TITLE' => $lang['Confirm'],
427                                 'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
429                                 'L_YES' => $lang['Yes'],
430                                 'L_NO' => $lang['No'],
432                                 'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
433                                 'S_HIDDEN_FIELDS' => $hidden_fields)
434                         );
436                         $template->pparse('confirm');
438                         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
439                 }
440                 break;
442         case 'move':
443                 $page_title = $lang['Mod_CP'];
444                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
446                 if ( $confirm )
447                 {
448                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
449                         {
450                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
451                         }
453                         $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
454                         $old_forum_id = $forum_id;
456                         if ( $new_forum_id != $old_forum_id )
457                         {
458                                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
460                                 $topic_list = '';
461                                 for($i = 0; $i < count($topics); $i++)
462                                 {
463                                         $topic_list .= ( ( $topic_list != '' ) ? ', ' : '' ) . intval($topics[$i]);
464                                 }
466                                 $sql = "SELECT * 
467                                         FROM " . TOPICS_TABLE . " 
468                                         WHERE topic_id IN ($topic_list)
469                                                 AND forum_id = $old_forum_id
470                                                 AND topic_status <> " . TOPIC_MOVED;
471                                 if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
472                                 {
473                                         message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
474                                 }
476                                 $row = $db->sql_fetchrowset($result);
477                                 $db->sql_freeresult($result);
479                                 for($i = 0; $i < count($row); $i++)
480                                 {
481                                         $topic_id = $row[$i]['topic_id'];
482                                         
483                                         if ( isset($HTTP_POST_VARS['move_leave_shadow']) )
484                                         {
485                                                 // Insert topic in the old forum that indicates that the forum has moved.
486                                                 $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)
487                                                         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)";
488                                                 if ( !$db->sql_query($sql) )
489                                                 {
490                                                         message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
491                                                 }
492                                         }
494                                         $sql = "UPDATE " . TOPICS_TABLE . " 
495                                                 SET forum_id = $new_forum_id  
496                                                 WHERE topic_id = $topic_id";
497                                         if ( !$db->sql_query($sql) )
498                                         {
499                                                 message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
500                                         }
502                                         $sql = "UPDATE " . POSTS_TABLE . " 
503                                                 SET forum_id = $new_forum_id 
504                                                 WHERE topic_id = $topic_id";
505                                         if ( !$db->sql_query($sql) )
506                                         {
507                                                 message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
508                                         }
509                                 }
511                                 // Sync the forum indexes
512                                 sync('forum', $new_forum_id);
513                                 sync('forum', $old_forum_id);
515                                 $message = $lang['Topics_Moved'] . '<br /><br />';
517                         }
518                         else
519                         {
520                                 $message = $lang['No_Topics_Moved'] . '<br /><br />';
521                         }
523                         if ( !empty($topic_id) )
524                         {
525                                 $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
526                                 $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
527                         }
528                         else
529                         {
530                                 $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
531                                 $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
532                         }
534                         $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>');
536                         $template->assign_vars(array(
537                                 'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
538                         );
540                         message_die(GENERAL_MESSAGE, $message);
541                 }
542                 else
543                 {
544                         if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
545                         {
546                                 message_die(GENERAL_MESSAGE, $lang['None_selected']);
547                         }
549                         $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 . '" />';
551                         if ( isset($HTTP_POST_VARS['topic_id_list']) )
552                         {
553                                 $topics = $HTTP_POST_VARS['topic_id_list'];
555                                 for($i = 0; $i < count($topics); $i++)
556                                 {
557                                         $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
558                                 }
559                         }
560                         else
561                         {
562                                 $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
563                         }
565                         //
566                         // Set template files
567                         //
568                         $template->set_filenames(array(
569                                 'movetopic' => 'modcp_move.tpl')
570                         );
572                         $template->assign_vars(array(
573                                 'MESSAGE_TITLE' => $lang['Confirm'],
574                                 'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
576                                 'L_MOVE_TO_FORUM' => $lang['Move_to_forum'], 
577                                 'L_LEAVESHADOW' => $lang['Leave_shadow_topic'], 
578                                 'L_YES' => $lang['Yes'],
579                                 'L_NO' => $lang['No'],
581                                 'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 
582                                 'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
583                                 'S_HIDDEN_FIELDS' => $hidden_fields)
584                         );
586                         $template->pparse('movetopic');
588                         include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
589                 }
590                 break;
592         case 'lock':
593                 if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
594                 {
595                         message_die(GENERAL_MESSAGE, $lang['None_selected']);
596                 }
598                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
600                 $topic_id_sql = '';
601                 for($i = 0; $i < count($topics); $i++)
602                 {
603                         $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
604                 }
606                 $sql = "UPDATE " . TOPICS_TABLE . " 
607                         SET topic_status = " . TOPIC_LOCKED . " 
608                         WHERE topic_id IN ($topic_id_sql) 
609                                 AND forum_id = $forum_id
610                                 AND topic_moved_id = 0";
611                 if ( !($result = $db->sql_query($sql)) )
612                 {
613                         message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
614                 }
616                 if ( !empty($topic_id) )
617                 {
618                         $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
619                         $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
620                 }
621                 else
622                 {
623                         $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
624                         $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
625                 }
627                 $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
629                 $template->assign_vars(array(
630                         'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
631                 );
633                 message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
635                 break;
637         case 'unlock':
638                 if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
639                 {
640                         message_die(GENERAL_MESSAGE, $lang['None_selected']);
641                 }
643                 $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
645                 $topic_id_sql = '';
646                 for($i = 0; $i < count($topics); $i++)
647                 {
648                         $topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);
649                 }
651                 $sql = "UPDATE " . TOPICS_TABLE . " 
652                         SET topic_status = " . TOPIC_UNLOCKED . " 
653                         WHERE topic_id IN ($topic_id_sql) 
654                                 AND forum_id = $forum_id
655                                 AND topic_moved_id = 0";
656                 if ( !($result = $db->sql_query($sql)) )
657                 {
658                         message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
659                 }
661                 if ( !empty($topic_id) )
662                 {
663                         $redirect_page = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
664                         $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
665                 }
666                 else
667                 {
668                         $redirect_page = "modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'];
669                         $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
670                 }
672                 $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
674                 $template->assign_vars(array(
675                         'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
676                 );
678                 message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
680                 break;
682         case 'split':
683                 $page_title = $lang['Mod_CP'];
684                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
686                 $post_id_sql = '';
688                 if (isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']))
689                 {
690                         $posts = $HTTP_POST_VARS['post_id_list'];
692                         for ($i = 0; $i < count($posts); $i++)
693                         {
694                                 $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($posts[$i]);
695                         }
696                 }
698                 if ($post_id_sql != '')
699                 {
700                         $sql = "SELECT post_id 
701                                 FROM " . POSTS_TABLE . "
702                                 WHERE post_id IN ($post_id_sql)
703                                         AND forum_id = $forum_id";
704                         if ( !($result = $db->sql_query($sql)) )
705                         {
706                                 message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
707                         }
708                         
709                         $post_id_sql = '';
710                         while ($row = $db->sql_fetchrow($result))
711                         {
712                                 $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);
713                         }
714                         $db->sql_freeresult($result);
716                         $sql = "SELECT post_id, poster_id, topic_id, post_time
717                                 FROM " . POSTS_TABLE . "
718                                 WHERE post_id IN ($post_id_sql) 
719                                 ORDER BY post_time ASC";
720                         if (!($result = $db->sql_query($sql)))
721                         {
722                                 message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
723                         }
725                         if ($row = $db->sql_fetchrow($result))
726                         {
727                                 $first_poster = $row['poster_id'];
728                                 $topic_id = $row['topic_id'];
729                                 $post_time = $row['post_time'];
731                                 $user_id_sql = '';
732                                 $post_id_sql = '';
733                                 do
734                                 {
735                                         $user_id_sql .= (($user_id_sql != '') ? ', ' : '') . intval($row['poster_id']);
736                                         $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);;
737                                 }
738                                 while ($row = $db->sql_fetchrow($result));
740                                 $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
741                                 if (empty($post_subject))
742                                 {
743                                         message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
744                                 }
746                                 $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
747                                 $topic_time = time();
748                                 
749                                 $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
750                                         VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
751                                 if (!($db->sql_query($sql, BEGIN_TRANSACTION)))
752                                 {
753                                         message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
754                                 }
756                                 $new_topic_id = $db->sql_nextid();
758                                 // Update topic watch table, switch users whose posts
759                                 // have moved, over to watching the new topic
760                                 $sql = "UPDATE " . TOPICS_WATCH_TABLE . " 
761                                         SET topic_id = $new_topic_id 
762                                         WHERE topic_id = $topic_id 
763                                                 AND user_id IN ($user_id_sql)";
764                                 if (!$db->sql_query($sql))
765                                 {
766                                         message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
767                                 }
769                                 $sql_where = (!empty($HTTP_POST_VARS['split_type_beyond'])) ? " post_time >= $post_time AND topic_id = $topic_id" : "post_id IN ($post_id_sql)";
771                                 $sql =  "UPDATE " . POSTS_TABLE . "
772                                         SET topic_id = $new_topic_id, forum_id = $new_forum_id 
773                                         WHERE $sql_where";
774                                 if (!$db->sql_query($sql, END_TRANSACTION))
775                                 {
776                                         message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
777                                 }
779                                 sync('topic', $new_topic_id);
780                                 sync('topic', $topic_id);
781                                 sync('forum', $new_forum_id);
782                                 sync('forum', $forum_id);
784                                 $template->assign_vars(array(
785                                         'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'] . '">')
786                                 );
788                                 $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>');
789                                 message_die(GENERAL_MESSAGE, $message);
790                         }
791                 }
792                 else
793                 {
794                         //
795                         // Set template files
796                         //
797                         $template->set_filenames(array(
798                                 'split_body' => 'modcp_split.tpl')
799                         );
801                         $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
802                                 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
803                                 WHERE p.topic_id = $topic_id
804                                         AND p.poster_id = u.user_id
805                                         AND p.post_id = pt.post_id
806                                 ORDER BY p.post_time ASC";
807                         if ( !($result = $db->sql_query($sql)) )
808                         {
809                                 message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
810                         }
812                         $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" />';
814                         if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
815                         {
816                                 $postrow = $db->sql_fetchrowset($result);
818                                 $template->assign_vars(array(
819                                         'L_SPLIT_TOPIC' => $lang['Split_Topic'],
820                                         'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
821                                         'L_AUTHOR' => $lang['Author'],
822                                         'L_MESSAGE' => $lang['Message'],
823                                         'L_SELECT' => $lang['Select'],
824                                         'L_SPLIT_SUBJECT' => $lang['Split_title'],
825                                         'L_SPLIT_FORUM' => $lang['Split_forum'],
826                                         'L_POSTED' => $lang['Posted'],
827                                         'L_SPLIT_POSTS' => $lang['Split_posts'],
828                                         'L_SUBMIT' => $lang['Submit'],
829                                         'L_SPLIT_AFTER' => $lang['Split_after'], 
830                                         'L_POST_SUBJECT' => $lang['Post_subject'], 
831                                         'L_MARK_ALL' => $lang['Mark_all'], 
832                                         'L_UNMARK_ALL' => $lang['Unmark_all'], 
833                                         'L_POST' => $lang['Post'], 
835                                         'FORUM_NAME' => $forum_name, 
837                                         'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
839                                         'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
840                                         'S_HIDDEN_FIELDS' => $s_hidden_fields,
841                                         'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
842                                 );
844                                 //
845                                 // Define censored word matches
846                                 //
847                                 $orig_word = array();
848                                 $replacement_word = array();
849                                 obtain_word_list($orig_word, $replacement_word);
851                                 for($i = 0; $i < $total_posts; $i++)
852                                 {
853                                         $post_id = $postrow[$i]['post_id'];
854                                         $poster_id = $postrow[$i]['poster_id'];
855                                         $poster = $postrow[$i]['username'];
857                                         $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
859                                         $bbcode_uid = $postrow[$i]['bbcode_uid'];
860                                         $message = $postrow[$i]['post_text'];
861                                         $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title;
863                                         //
864                                         // If the board has HTML off but the post has HTML
865                                         // on then we process it, else leave it alone
866                                         //
867                                         if ( !$board_config['allow_html'] )
868                                         {
869                                                 if ( $postrow[$i]['enable_html'] )
870                                                 {
871                                                         $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
872                                                 }
873                                         }
875                                         if ( $bbcode_uid != '' )
876                                         {
877                                                 $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
878                                         }
880                                         if ( count($orig_word) )
881                                         {
882                                                 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
883                                                 $message = preg_replace($orig_word, $replacement_word, $message);
884                                         }
886                                         $message = make_clickable($message);
888                                         if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
889                                         {
890                                                 $message = smilies_pass($message);
891                                         }
893                                         $message = str_replace("\n", '<br />', $message);
894                                         
895                                         $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
896                                         $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
898                                         $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : '&nbsp;';
899                                         
900                                         $template->assign_block_vars('postrow', array(
901                                                 'ROW_COLOR' => '#' . $row_color,
902                                                 'ROW_CLASS' => $row_class,
903                                                 'POSTER_NAME' => $poster,
904                                                 'POST_DATE' => $post_date,
905                                                 'POST_SUBJECT' => $post_subject,
906                                                 'MESSAGE' => $message,
907                                                 'POST_ID' => $post_id,
908                                                 
909                                                 'S_SPLIT_CHECKBOX' => $checkbox)
910                                         );
911                                 }
913                                 $template->pparse('split_body');
914                         }
915                 }
916                 break;
918         case 'ip':
919                 $page_title = $lang['Mod_CP'];
920                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
922                 $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
924                 if ( !$post_id )
925                 {
926                         message_die(GENERAL_MESSAGE, $lang['No_such_post']);
927                 }
929                 //
930                 // Set template files
931                 //
932                 $template->set_filenames(array(
933                         'viewip' => 'modcp_viewip.tpl')
934                 );
936                 // Look up relevent data for this post
937                 $sql = "SELECT poster_ip, poster_id 
938                         FROM " . POSTS_TABLE . " 
939                         WHERE post_id = $post_id
940                                 AND forum_id = $forum_id";
941                 if ( !($result = $db->sql_query($sql)) )
942                 {
943                         message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
944                 }
945                 
946                 if ( !($post_row = $db->sql_fetchrow($result)) )
947                 {
948                         message_die(GENERAL_MESSAGE, $lang['No_such_post']);
949                 }
951                 $ip_this_post = decode_ip($post_row['poster_ip']);
952                 $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post;
954                 $poster_id = $post_row['poster_id'];
956                 $template->assign_vars(array(
957                         'L_IP_INFO' => $lang['IP_info'],
958                         'L_THIS_POST_IP' => $lang['This_posts_IP'],
959                         'L_OTHER_IPS' => $lang['Other_IP_this_user'],
960                         'L_OTHER_USERS' => $lang['Users_this_IP'],
961                         'L_LOOKUP_IP' => $lang['Lookup_IP'], 
962                         'L_SEARCH' => $lang['Search'],
964                         'SEARCH_IMG' => $images['icon_search'], 
966                         'IP' => $ip_this_post, 
967                                 
968                         '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'])
969                 );
971                 //
972                 // Get other IP's this user has posted under
973                 //
974                 $sql = "SELECT poster_ip, COUNT(*) AS postings 
975                         FROM " . POSTS_TABLE . " 
976                         WHERE poster_id = $poster_id 
977                         GROUP BY poster_ip 
978                         ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
979                 if ( !($result = $db->sql_query($sql)) )
980                 {
981                         message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
982                 }
984                 if ( $row = $db->sql_fetchrow($result) )
985                 {
986                         $i = 0;
987                         do
988                         {
989                                 if ( $row['poster_ip'] == $post_row['poster_ip'] )
990                                 {
991                                         $template->assign_vars(array(
992                                                 'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
993                                         );
994                                         continue;
995                                 }
997                                 $ip = decode_ip($row['poster_ip']);
998                                 $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
1000                                 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1001                                 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1003                                 $template->assign_block_vars('iprow', array(
1004                                         'ROW_COLOR' => '#' . $row_color, 
1005                                         'ROW_CLASS' => $row_class, 
1006                                         'IP' => $ip,
1007                                         'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1009                                         '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'])
1010                                 );
1012                                 $i++; 
1013                         }
1014                         while ( $row = $db->sql_fetchrow($result) );
1015                 }
1017                 //
1018                 // Get other users who've posted under this IP
1019                 //
1020                 $sql = "SELECT u.user_id, u.username, COUNT(*) as postings 
1021                         FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p 
1022                         WHERE p.poster_id = u.user_id 
1023                                 AND p.poster_ip = '" . $post_row['poster_ip'] . "'
1024                         GROUP BY u.user_id, u.username
1025                         ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
1026                 if ( !($result = $db->sql_query($sql)) )
1027                 {
1028                         message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
1029                 }
1031                 if ( $row = $db->sql_fetchrow($result) )
1032                 {
1033                         $i = 0;
1034                         do
1035                         {
1036                                 $id = $row['user_id'];
1037                                 $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
1039                                 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1040                                 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1042                                 $template->assign_block_vars('userrow', array(
1043                                         'ROW_COLOR' => '#' . $row_color, 
1044                                         'ROW_CLASS' => $row_class, 
1045                                         'USERNAME' => $username,
1046                                         'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1047                                         'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username), 
1049                                         '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"),
1050                                         'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics"))
1051                                 );
1053                                 $i++; 
1054                         }
1055                         while ( $row = $db->sql_fetchrow($result) );
1056                 }
1058                 $template->pparse('viewip');
1060                 break;
1062         default:
1063                 $page_title = $lang['Mod_CP'];
1064                 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
1066                 $template->assign_vars(array(
1067                         'FORUM_NAME' => $forum_name,
1069                         'L_MOD_CP' => $lang['Mod_CP'],
1070                         'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
1071                         'L_SELECT' => $lang['Select'],
1072                         'L_DELETE' => $lang['Delete'],
1073                         'L_MOVE' => $lang['Move'],
1074                         'L_LOCK' => $lang['Lock'],
1075                         'L_UNLOCK' => $lang['Unlock'],
1076                         'L_TOPICS' => $lang['Topics'], 
1077                         'L_REPLIES' => $lang['Replies'], 
1078                         'L_LASTPOST' => $lang['Last_Post'], 
1079                         'L_SELECT' => $lang['Select'], 
1081                         'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
1082                         'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />',
1083                         'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
1084                 );
1086                 $template->set_filenames(array(
1087                         'body' => 'modcp_body.tpl')
1088                 );
1089                 make_jumpbox('modcp.'.$phpEx);
1091                 //
1092                 // Define censored word matches
1093                 //
1094                 $orig_word = array();
1095                 $replacement_word = array();
1096                 obtain_word_list($orig_word, $replacement_word);
1098                 $sql = "SELECT t.*, u.username, u.user_id, p.post_time
1099                         FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
1100                         WHERE t.forum_id = $forum_id
1101                                 AND t.topic_poster = u.user_id
1102                                 AND p.post_id = t.topic_last_post_id
1103                         ORDER BY t.topic_type DESC, p.post_time DESC
1104                         LIMIT $start, " . $board_config['topics_per_page'];
1105                 if ( !($result = $db->sql_query($sql)) )
1106                 {
1107                         message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
1108                 }
1110                 while ( $row = $db->sql_fetchrow($result) )
1111                 {
1112                         $topic_title = '';
1114                         if ( $row['topic_status'] == TOPIC_LOCKED )
1115                         {
1116                                 $folder_img = $images['folder_locked'];
1117                                 $folder_alt = $lang['Topic_locked'];
1118                         }
1119                         else
1120                         {
1121                                 if ( $row['topic_type'] == POST_ANNOUNCE )
1122                                 {
1123                                         $folder_img = $images['folder_announce'];
1124                                         $folder_alt = $lang['Topic_Announcement'];
1125                                 }
1126                                 else if ( $row['topic_type'] == POST_STICKY )
1127                                 {
1128                                         $folder_img = $images['folder_sticky'];
1129                                         $folder_alt = $lang['Topic_Sticky'];
1130                                 }
1131                                 else 
1132                                 {
1133                                         $folder_img = $images['folder'];
1134                                         $folder_alt = $lang['No_new_posts'];
1135                                 }
1136                         }
1138                         $topic_id = $row['topic_id'];
1139                         $topic_type = $row['topic_type'];
1140                         $topic_status = $row['topic_status'];
1141                         
1142                         if ( $topic_type == POST_ANNOUNCE )
1143                         {
1144                                 $topic_type = $lang['Topic_Announcement'] . ' ';
1145                         }
1146                         else if ( $topic_type == POST_STICKY )
1147                         {
1148                                 $topic_type = $lang['Topic_Sticky'] . ' ';
1149                         }
1150                         else if ( $topic_status == TOPIC_MOVED )
1151                         {
1152                                 $topic_type = $lang['Topic_Moved'] . ' ';
1153                         }
1154                         else
1155                         {
1156                                 $topic_type = '';               
1157                         }
1158         
1159                         if ( $row['topic_vote'] )
1160                         {
1161                                 $topic_type .= $lang['Topic_Poll'] . ' ';
1162                         }
1163         
1164                         $topic_title = $row['topic_title'];
1165                         if ( count($orig_word) )
1166                         {
1167                                 $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
1168                         }
1170                         $u_view_topic = "modcp.$phpEx?mode=split&amp;" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'];
1171                         $topic_replies = $row['topic_replies'];
1173                         $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
1175                         $template->assign_block_vars('topicrow', array(
1176                                 'U_VIEW_TOPIC' => $u_view_topic,
1178                                 'TOPIC_FOLDER_IMG' => $folder_img, 
1179                                 'TOPIC_TYPE' => $topic_type, 
1180                                 'TOPIC_TITLE' => $topic_title,
1181                                 'REPLIES' => $topic_replies,
1182                                 'LAST_POST_TIME' => $last_post_time,
1183                                 'TOPIC_ID' => $topic_id,
1184                                         
1185                                 'L_TOPIC_FOLDER_ALT' => $folder_alt)
1186                         );
1187                 }
1189                 $template->assign_vars(array(
1190                         'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'], $forum_topics, $board_config['topics_per_page'], $start),
1191                         'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )), 
1192                         'L_GOTO_PAGE' => $lang['Goto_page'])
1193                 );
1195                 $template->pparse('body');
1197                 break;
1200 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1202 ?>