Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

modcp.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 38.59 KiB


 0001  <?php
 0002  /***************************************************************************
 0003   *                                 modcp.php
 0004   *                            -------------------
 0005   *   begin                : July 4, 2001
 0006   *   copyright            : (C) 2001 The phpBB Group
 0007   *   email                : support@phpbb.com
 0008   *
 0009   *   $Id$
 0010   *
 0011   ***************************************************************************/
 0012   
 0013  /***************************************************************************
 0014   *
 0015   *   This program is free software; you can redistribute it and/or modify
 0016   *   it under the terms of the GNU General Public License as published by
 0017   *   the Free Software Foundation; either version 2 of the License, or
 0018   *   (at your option) any later version.
 0019   *
 0020   ***************************************************************************/
 0021   
 0022  /**
 0023   * Moderator Control Panel
 0024   *
 0025   * From this 'Control Panel' the moderator of a forum will be able to do
 0026   * mass topic operations (locking/unlocking/moving/deleteing), and it will
 0027   * provide an interface to do quick locking/unlocking/moving/deleting of
 0028   * topics via the moderator operations buttons on all of the viewtopic pages.
 0029   */
 0030   
 0031  define('IN_PHPBB', true);
 0032  $phpbb_root_path = './';
 0033  include($phpbb_root_path . 'extension.inc');
 0034  include($phpbb_root_path . 'common.'.$phpEx);
 0035  include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
 0036  include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
 0037   
 0038  //
 0039  // Obtain initial var settings
 0040  //
 0041  if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
 0042  {
 0043      $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
 0044  }
 0045  else
 0046  {
 0047      $forum_id = '';
 0048  }
 0049   
 0050  if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
 0051  {
 0052      $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
 0053  }
 0054  else
 0055  {
 0056      $post_id = '';
 0057  }
 0058   
 0059  if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
 0060  {
 0061      $topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
 0062  }
 0063  else
 0064  {
 0065      $topic_id = '';
 0066  }
 0067   
 0068  $confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
 0069   
 0070  //
 0071  // Continue var definitions
 0072  //
 0073  $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
 0074  $start = ($start < 0) ? 0 : $start;
 0075   
 0076  $delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
 0077  $move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
 0078  $lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
 0079  $unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
 0080   
 0081  if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
 0082  {
 0083      $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
 0084      $mode = htmlspecialchars($mode);
 0085  }
 0086  else
 0087  {
 0088      if ( $delete )
 0089      {
 0090          $mode = 'delete';
 0091      }
 0092      else if ( $move )
 0093      {
 0094          $mode = 'move';
 0095      }
 0096      else if ( $lock )
 0097      {
 0098          $mode = 'lock';
 0099      }
 0100      else if ( $unlock )
 0101      {
 0102          $mode = 'unlock';
 0103      }
 0104      else
 0105      {
 0106          $mode = '';
 0107      }
 0108  }
 0109   
 0110  // session id check
 0111  if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
 0112  {
 0113      $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
 0114  }
 0115  else
 0116  {
 0117      $sid = '';
 0118  }
 0119  // privileged session id check
 0120  if (!empty($HTTP_POST_VARS['p_sid']) || !empty($HTTP_GET_VARS['p_sid']))
 0121  {
 0122      $p_sid = (!empty($HTTP_POST_VARS['p_sid'])) ? $HTTP_POST_VARS['p_sid'] : $HTTP_GET_VARS['p_sid'];
 0123  }
 0124  else
 0125  {
 0126      $p_sid = '';
 0127  }
 0128   
 0129  //
 0130  // Obtain relevant data
 0131  //
 0132  if ( !empty($topic_id) )
 0133  {
 0134      $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
 0135          FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
 0136          WHERE t.topic_id = " . $topic_id . "
 0137              AND f.forum_id = t.forum_id";
 0138      if ( !($result = $db->sql_query($sql)) )
 0139      {
 0140          message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
 0141      }
 0142      $topic_row = $db->sql_fetchrow($result);
 0143   
 0144      if (!$topic_row)
 0145      {
 0146          message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
 0147      }
 0148   
 0149      $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
 0150      $forum_id = $topic_row['forum_id'];
 0151      $forum_name = $topic_row['forum_name'];
 0152  }
 0153  else if ( !empty($forum_id) )
 0154  {
 0155      $sql = "SELECT forum_name, forum_topics
 0156          FROM " . FORUMS_TABLE . "
 0157          WHERE forum_id = " . $forum_id;
 0158      if ( !($result = $db->sql_query($sql)) )
 0159      {
 0160          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 0161      }
 0162      $topic_row = $db->sql_fetchrow($result);
 0163   
 0164      if (!$topic_row)
 0165      {
 0166          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 0167      }
 0168   
 0169      $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
 0170      $forum_name = $topic_row['forum_name'];
 0171  }
 0172  else
 0173  {
 0174      message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 0175  }
 0176   
 0177  //
 0178  // Start session management
 0179  //
 0180  $userdata = session_pagestart($user_ip, $forum_id);
 0181  init_userprefs($userdata);
 0182  //
 0183  // End session management
 0184  //
 0185   
 0186  // session id check
 0187  if ($p_sid === '' || $p_sid !== $userdata['priv_session_id'])
 0188  {
 0189      message_die(GENERAL_ERROR, 'Invalid_session');
 0190  }
 0191   
 0192  //
 0193  // Check if user did or did not confirm
 0194  // If they did not, forward them to the last page they were on
 0195  //
 0196  if ( isset($HTTP_POST_VARS['cancel']) )
 0197  {
 0198      if ( $topic_id )
 0199      {
 0200          $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
 0201      }
 0202      else if ( $forum_id )
 0203      {
 0204          $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
 0205      }
 0206      else
 0207      {
 0208          $redirect = "index.$phpEx";
 0209      }
 0210   
 0211      redirect(append_sid($redirect, true));
 0212  }
 0213   
 0214  //
 0215  // Start auth check
 0216  //
 0217  $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
 0218   
 0219  if ( !$is_auth['auth_mod'] )
 0220  {
 0221      message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
 0222  }
 0223  //
 0224  // End Auth Check
 0225  //
 0226   
 0227  //
 0228  // Do major work ...
 0229  //
 0230  switch( $mode )
 0231  {
 0232      case 'delete':
 0233          if (!$is_auth['auth_delete'])
 0234          {
 0235              message_die(GENERAL_MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
 0236          }
 0237   
 0238          $page_title = $lang['Mod_CP'];
 0239          include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0240   
 0241          if ( $confirm )
 0242          {
 0243                if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0244              {
 0245                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0246              }
 0247   
 0248              include($phpbb_root_path . 'includes/functions_search.'.$phpEx);
 0249   
 0250              $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ? $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 0251   
 0252              $topic_id_sql = '';
 0253              for($i = 0; $i < count($topics); $i++)
 0254              {
 0255                  $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
 0256              }
 0257   
 0258              $sql = "SELECT topic_id 
 0259                  FROM " . TOPICS_TABLE . "
 0260                  WHERE topic_id IN ($topic_id_sql)
 0261                      AND forum_id = $forum_id";
 0262              if ( !($result = $db->sql_query($sql)) )
 0263              {
 0264                  message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql);
 0265              }
 0266              
 0267              $topic_id_sql = '';
 0268              while ($row = $db->sql_fetchrow($result))
 0269              {
 0270                  $topic_id_sql .= (($topic_id_sql != '') ? ', ' : '') . intval($row['topic_id']);
 0271              }
 0272              $db->sql_freeresult($result);
 0273   
 0274              if ( $topic_id_sql == '')
 0275              {
 0276                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0277              }
 0278   
 0279              $sql = "SELECT poster_id, COUNT(post_id) AS posts 
 0280                  FROM " . POSTS_TABLE . " 
 0281                  WHERE topic_id IN ($topic_id_sql) 
 0282                  GROUP BY poster_id";
 0283              if ( !($result = $db->sql_query($sql)) )
 0284              {
 0285                  message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
 0286              }
 0287   
 0288              $count_sql = array();
 0289              while ( $row = $db->sql_fetchrow($result) )
 0290              {
 0291                  $count_sql[] = "UPDATE " . USERS_TABLE . " 
 0292                      SET user_posts = user_posts - " . $row['posts'] . " 
 0293                      WHERE user_id = " . $row['poster_id'];
 0294              }
 0295              $db->sql_freeresult($result);
 0296   
 0297              if ( sizeof($count_sql) )
 0298              {
 0299                  for($i = 0; $i < sizeof($count_sql); $i++)
 0300                  {
 0301                      if ( !$db->sql_query($count_sql[$i]) )
 0302                      {
 0303                          message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
 0304                      }
 0305                  }
 0306              }
 0307              
 0308              $sql = "SELECT post_id 
 0309                  FROM " . POSTS_TABLE . " 
 0310                  WHERE topic_id IN ($topic_id_sql)";
 0311              if ( !($result = $db->sql_query($sql)) )
 0312              {
 0313                  message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
 0314              }
 0315   
 0316              $post_id_sql = '';
 0317              while ( $row = $db->sql_fetchrow($result) )
 0318              {
 0319                  $post_id_sql .= ( ( $post_id_sql != '' ) ? ', ' : '' ) . intval($row['post_id']);
 0320              }
 0321              $db->sql_freeresult($result);
 0322   
 0323              $sql = "SELECT vote_id 
 0324                  FROM " . VOTE_DESC_TABLE . " 
 0325                  WHERE topic_id IN ($topic_id_sql)";
 0326              if ( !($result = $db->sql_query($sql)) )
 0327              {
 0328                  message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
 0329              }
 0330   
 0331              $vote_id_sql = '';
 0332              while ( $row = $db->sql_fetchrow($result) )
 0333              {
 0334                  $vote_id_sql .= ( ( $vote_id_sql != '' ) ? ', ' : '' ) . $row['vote_id'];
 0335              }
 0336              $db->sql_freeresult($result);
 0337   
 0338              //
 0339              // Got all required info so go ahead and start deleting everything
 0340              //
 0341              $sql = "DELETE 
 0342                  FROM " . TOPICS_TABLE . " 
 0343                  WHERE topic_id IN ($topic_id_sql) 
 0344                      OR topic_moved_id IN ($topic_id_sql)";
 0345              if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
 0346              {
 0347                  message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
 0348              }
 0349   
 0350              if ( $post_id_sql != '' )
 0351              {
 0352                  $sql = "DELETE 
 0353                      FROM " . POSTS_TABLE . " 
 0354                      WHERE post_id IN ($post_id_sql)";
 0355                  if ( !$db->sql_query($sql) )
 0356                  {
 0357                      message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
 0358                  }
 0359   
 0360                  $sql = "DELETE 
 0361                      FROM " . POSTS_TEXT_TABLE . " 
 0362                      WHERE post_id IN ($post_id_sql)";
 0363                  if ( !$db->sql_query($sql) )
 0364                  {
 0365                      message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
 0366                  }
 0367   
 0368                  remove_search_post($post_id_sql);
 0369              }
 0370   
 0371              if ( $vote_id_sql != '' )
 0372              {
 0373                  $sql = "DELETE 
 0374                      FROM " . VOTE_DESC_TABLE . " 
 0375                      WHERE vote_id IN ($vote_id_sql)";
 0376                  if ( !$db->sql_query($sql) )
 0377                  {
 0378                      message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
 0379                  }
 0380   
 0381                  $sql = "DELETE 
 0382                      FROM " . VOTE_RESULTS_TABLE . " 
 0383                      WHERE vote_id IN ($vote_id_sql)";
 0384                  if ( !$db->sql_query($sql) )
 0385                  {
 0386                      message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
 0387                  }
 0388   
 0389                  $sql = "DELETE 
 0390                      FROM " . VOTE_USERS_TABLE . " 
 0391                      WHERE vote_id IN ($vote_id_sql)";
 0392                  if ( !$db->sql_query($sql) )
 0393                  {
 0394                      message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
 0395                  }
 0396              }
 0397   
 0398              $sql = "DELETE 
 0399                  FROM " . TOPICS_WATCH_TABLE . " 
 0400                  WHERE topic_id IN ($topic_id_sql)";
 0401              if ( !$db->sql_query($sql, END_TRANSACTION) )
 0402              {
 0403                  message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
 0404              }
 0405   
 0406              sync('forum', $forum_id);
 0407   
 0408              if ( !empty($topic_id) )
 0409              {
 0410                  $redirect_page = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 0411                  $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
 0412              }
 0413              else
 0414              {
 0415                  $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;p_sid=" . $userdata['priv_session_id']);
 0416                  $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 0417              }
 0418   
 0419              $template->assign_vars(array(
 0420                  'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 0421              );
 0422   
 0423              message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
 0424          }
 0425          else
 0426          {
 0427              // Not confirmed, show confirmation message
 0428              if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0429              {
 0430                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0431              }
 0432   
 0433              $hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="p_sid" value="' . $userdata['priv_session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
 0434   
 0435              if ( isset($HTTP_POST_VARS['topic_id_list']) )
 0436              {
 0437                  $topics = $HTTP_POST_VARS['topic_id_list'];
 0438                  for($i = 0; $i < count($topics); $i++)
 0439                  {
 0440                      $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
 0441                  }
 0442              }
 0443              else
 0444              {
 0445                  $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
 0446              }
 0447   
 0448              //
 0449              // Set template files
 0450              //
 0451              $template->set_filenames(array(
 0452                  'confirm' => 'confirm_body.tpl')
 0453              );
 0454   
 0455              $template->assign_vars(array(
 0456                  'MESSAGE_TITLE' => $lang['Confirm'],
 0457                  'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
 0458   
 0459                  'L_YES' => $lang['Yes'],
 0460                  'L_NO' => $lang['No'],
 0461   
 0462                  'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
 0463                  'S_HIDDEN_FIELDS' => $hidden_fields)
 0464              );
 0465   
 0466              $template->pparse('confirm');
 0467   
 0468              include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 0469          }
 0470          break;
 0471   
 0472      case 'move':
 0473          $page_title = $lang['Mod_CP'];
 0474          include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0475   
 0476          if ( $confirm )
 0477          {
 0478              if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0479              {
 0480                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0481              }
 0482   
 0483              $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
 0484              $old_forum_id = $forum_id;
 0485   
 0486              $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
 0487                  WHERE forum_id = ' . $new_forum_id;
 0488              if ( !($result = $db->sql_query($sql)) )
 0489              {
 0490                  message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
 0491              }
 0492              
 0493              if (!$db->sql_fetchrow($result))
 0494              {
 0495                  message_die(GENERAL_MESSAGE, 'New forum does not exist');
 0496              }
 0497   
 0498              $db->sql_freeresult($result);
 0499   
 0500              if ( $new_forum_id != $old_forum_id )
 0501              {
 0502                  $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 0503   
 0504                  $topic_list = '';
 0505                  for($i = 0; $i < count($topics); $i++)
 0506                  {
 0507                      $topic_list .= ( ( $topic_list != '' ) ? ', ' : '' ) . intval($topics[$i]);
 0508                  }
 0509   
 0510                  $sql = "SELECT * 
 0511                      FROM " . TOPICS_TABLE . " 
 0512                      WHERE topic_id IN ($topic_list)
 0513                          AND forum_id = $old_forum_id
 0514                          AND topic_status <> " . TOPIC_MOVED;
 0515                  if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
 0516                  {
 0517                      message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
 0518                  }
 0519   
 0520                  $row = $db->sql_fetchrowset($result);
 0521                  $db->sql_freeresult($result);
 0522   
 0523                  for($i = 0; $i < count($row); $i++)
 0524                  {
 0525                      $topic_id = $row[$i]['topic_id'];
 0526                      
 0527                      if ( isset($HTTP_POST_VARS['move_leave_shadow']) )
 0528                      {
 0529                          // Insert topic in the old forum that indicates that the forum has moved.
 0530                          $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)
 0531                              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)";
 0532                          if ( !$db->sql_query($sql) )
 0533                          {
 0534                              message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
 0535                          }
 0536                      }
 0537   
 0538                      $sql = "UPDATE " . TOPICS_TABLE . " 
 0539                          SET forum_id = $new_forum_id  
 0540                          WHERE topic_id = $topic_id";
 0541                      if ( !$db->sql_query($sql) )
 0542                      {
 0543                          message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
 0544                      }
 0545   
 0546                      $sql = "UPDATE " . POSTS_TABLE . " 
 0547                          SET forum_id = $new_forum_id 
 0548                          WHERE topic_id = $topic_id";
 0549                      if ( !$db->sql_query($sql) )
 0550                      {
 0551                          message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
 0552                      }
 0553                  }
 0554   
 0555                  // Sync the forum indexes
 0556                  sync('forum', $new_forum_id);
 0557                  sync('forum', $old_forum_id);
 0558   
 0559                  $message = $lang['Topics_Moved'] . '<br /><br />';
 0560   
 0561              }
 0562              else
 0563              {
 0564                  $message = $lang['No_Topics_Moved'] . '<br /><br />';
 0565              }
 0566   
 0567              if ( !empty($topic_id) )
 0568              {
 0569                  $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 0570                  $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 0571              }
 0572              else
 0573              {
 0574                  $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;p_sid=" . $userdata['priv_session_id']);
 0575                  $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 0576              }
 0577   
 0578              $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id&amp;p_sid=" . $userdata['priv_session_id']) . '">', '</a>');
 0579   
 0580              $template->assign_vars(array(
 0581                  'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 0582              );
 0583   
 0584              message_die(GENERAL_MESSAGE, $message);
 0585          }
 0586          else
 0587          {
 0588              if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0589              {
 0590                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0591              }
 0592   
 0593              $hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="p_sid" value="' . $userdata['priv_session_id'] . '" /><input type="hidden" name="mode" value="' . $mode . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';
 0594   
 0595              if ( isset($HTTP_POST_VARS['topic_id_list']) )
 0596              {
 0597                  $topics = $HTTP_POST_VARS['topic_id_list'];
 0598   
 0599                  for($i = 0; $i < count($topics); $i++)
 0600                  {
 0601                      $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
 0602                  }
 0603              }
 0604              else
 0605              {
 0606                  $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
 0607              }
 0608   
 0609              //
 0610              // Set template files
 0611              //
 0612              $template->set_filenames(array(
 0613                  'movetopic' => 'modcp_move.tpl')
 0614              );
 0615   
 0616              $template->assign_vars(array(
 0617                  'MESSAGE_TITLE' => $lang['Confirm'],
 0618                  'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
 0619   
 0620                  'L_MOVE_TO_FORUM' => $lang['Move_to_forum'], 
 0621                  'L_LEAVESHADOW' => $lang['Leave_shadow_topic'], 
 0622                  'L_YES' => $lang['Yes'],
 0623                  'L_NO' => $lang['No'],
 0624   
 0625                  'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id), 
 0626                  'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
 0627                  'S_HIDDEN_FIELDS' => $hidden_fields)
 0628              );
 0629   
 0630              $template->pparse('movetopic');
 0631   
 0632              include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 0633          }
 0634          break;
 0635   
 0636      case 'lock':
 0637          if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0638          {
 0639              message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0640          }
 0641   
 0642          $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 0643   
 0644          $topic_id_sql = '';
 0645          for($i = 0; $i < count($topics); $i++)
 0646          {
 0647              $topic_id_sql .= ( ( $topic_id_sql != '' ) ? ', ' : '' ) . intval($topics[$i]);
 0648          }
 0649   
 0650          $sql = "UPDATE " . TOPICS_TABLE . " 
 0651              SET topic_status = " . TOPIC_LOCKED . " 
 0652              WHERE topic_id IN ($topic_id_sql) 
 0653                  AND forum_id = $forum_id
 0654                  AND topic_moved_id = 0";
 0655          if ( !($result = $db->sql_query($sql)) )
 0656          {
 0657              message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
 0658          }
 0659   
 0660          if ( !empty($topic_id) )
 0661          {
 0662              $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 0663              $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 0664          }
 0665          else
 0666          {
 0667              $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;p_sid=" . $userdata['priv_session_id']);
 0668              $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 0669          }
 0670   
 0671          $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
 0672   
 0673          $template->assign_vars(array(
 0674              'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 0675          );
 0676   
 0677          message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
 0678   
 0679          break;
 0680   
 0681      case 'unlock':
 0682          if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 0683          {
 0684              message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0685          }
 0686   
 0687          $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 0688   
 0689          $topic_id_sql = '';
 0690          for($i = 0; $i < count($topics); $i++)
 0691          {
 0692              $topic_id_sql .= ( ( $topic_id_sql != "") ? ', ' : '' ) . intval($topics[$i]);
 0693          }
 0694   
 0695          $sql = "UPDATE " . TOPICS_TABLE . " 
 0696              SET topic_status = " . TOPIC_UNLOCKED . " 
 0697              WHERE topic_id IN ($topic_id_sql) 
 0698                  AND forum_id = $forum_id
 0699                  AND topic_moved_id = 0";
 0700          if ( !($result = $db->sql_query($sql)) )
 0701          {
 0702              message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
 0703          }
 0704   
 0705          if ( !empty($topic_id) )
 0706          {
 0707              $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 0708              $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 0709          }
 0710          else
 0711          {
 0712              $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;p_sid=" . $userdata['priv_session_id']);
 0713              $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 0714          }
 0715   
 0716          $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
 0717   
 0718          $template->assign_vars(array(
 0719              'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 0720          );
 0721   
 0722          message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
 0723   
 0724          break;
 0725   
 0726      case 'split':
 0727          $page_title = $lang['Mod_CP'];
 0728          include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0729   
 0730          $post_id_sql = '';
 0731   
 0732          if (isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']))
 0733          {
 0734              $posts = $HTTP_POST_VARS['post_id_list'];
 0735   
 0736              for ($i = 0; $i < count($posts); $i++)
 0737              {
 0738                  $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($posts[$i]);
 0739              }
 0740          }
 0741   
 0742          if ($post_id_sql != '')
 0743          {
 0744              $sql = "SELECT post_id 
 0745                  FROM " . POSTS_TABLE . "
 0746                  WHERE post_id IN ($post_id_sql)
 0747                      AND forum_id = $forum_id";
 0748              if ( !($result = $db->sql_query($sql)) )
 0749              {
 0750                  message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
 0751              }
 0752              
 0753              $post_id_sql = '';
 0754              while ($row = $db->sql_fetchrow($result))
 0755              {
 0756                  $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);
 0757              }
 0758              $db->sql_freeresult($result);
 0759   
 0760              if ($post_id_sql == '')
 0761              {
 0762                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 0763              }
 0764   
 0765              $sql = "SELECT post_id, poster_id, topic_id, post_time
 0766                  FROM " . POSTS_TABLE . "
 0767                  WHERE post_id IN ($post_id_sql) 
 0768                  ORDER BY post_time ASC";
 0769              if (!($result = $db->sql_query($sql)))
 0770              {
 0771                  message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
 0772              }
 0773   
 0774              if ($row = $db->sql_fetchrow($result))
 0775              {
 0776                  $first_poster = $row['poster_id'];
 0777                  $topic_id = $row['topic_id'];
 0778                  $post_time = $row['post_time'];
 0779   
 0780                  $user_id_sql = '';
 0781                  $post_id_sql = '';
 0782                  do
 0783                  {
 0784                      $user_id_sql .= (($user_id_sql != '') ? ', ' : '') . intval($row['poster_id']);
 0785                      $post_id_sql .= (($post_id_sql != '') ? ', ' : '') . intval($row['post_id']);;
 0786                  }
 0787                  while ($row = $db->sql_fetchrow($result));
 0788   
 0789                  $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
 0790                  if (empty($post_subject))
 0791                  {
 0792                      message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
 0793                  }
 0794   
 0795                  $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
 0796                  $topic_time = time();
 0797                  
 0798                  $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
 0799                      WHERE forum_id = ' . $new_forum_id;
 0800                  if ( !($result = $db->sql_query($sql)) )
 0801                  {
 0802                      message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
 0803                  }
 0804              
 0805                  if (!$db->sql_fetchrow($result))
 0806                  {
 0807                      message_die(GENERAL_MESSAGE, 'New forum does not exist');
 0808                  }
 0809   
 0810                  $db->sql_freeresult($result);
 0811   
 0812                  $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
 0813                      VALUES ('" . str_replace("\'", "''", $post_subject) . "', $first_poster, " . $topic_time . ", $new_forum_id, " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
 0814                  if (!($db->sql_query($sql, BEGIN_TRANSACTION)))
 0815                  {
 0816                      message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
 0817                  }
 0818   
 0819                  $new_topic_id = $db->sql_nextid();
 0820   
 0821                  // Update topic watch table, switch users whose posts
 0822                  // have moved, over to watching the new topic
 0823                  $sql = "UPDATE " . TOPICS_WATCH_TABLE . " 
 0824                      SET topic_id = $new_topic_id 
 0825                      WHERE topic_id = $topic_id 
 0826                          AND user_id IN ($user_id_sql)";
 0827                  if (!$db->sql_query($sql))
 0828                  {
 0829                      message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
 0830                  }
 0831   
 0832                  $sql_where = (!empty($HTTP_POST_VARS['split_type_beyond'])) ? " post_time >= $post_time AND topic_id = $topic_id" : "post_id IN ($post_id_sql)";
 0833   
 0834                  $sql =     "UPDATE " . POSTS_TABLE . "
 0835                      SET topic_id = $new_topic_id, forum_id = $new_forum_id 
 0836                      WHERE $sql_where";
 0837                  if (!$db->sql_query($sql, END_TRANSACTION))
 0838                  {
 0839                      message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
 0840                  }
 0841   
 0842                  sync('topic', $new_topic_id);
 0843                  sync('topic', $topic_id);
 0844                  sync('forum', $new_forum_id);
 0845                  sync('forum', $forum_id);
 0846   
 0847                  $template->assign_vars(array(
 0848                      'META' => '<meta http-equiv="refresh" content="3;url=' . "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;sid=" . $userdata['session_id'] . '">')
 0849                  );
 0850   
 0851                  $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>');
 0852                  message_die(GENERAL_MESSAGE, $message);
 0853              }
 0854          }
 0855          else
 0856          {
 0857              //
 0858              // Set template files
 0859              //
 0860              $template->set_filenames(array(
 0861                  'split_body' => 'modcp_split.tpl')
 0862              );
 0863   
 0864              $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
 0865                  FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
 0866                  WHERE p.topic_id = $topic_id
 0867                      AND p.poster_id = u.user_id
 0868                      AND p.post_id = pt.post_id
 0869                  ORDER BY p.post_time ASC";
 0870              if ( !($result = $db->sql_query($sql)) )
 0871              {
 0872                  message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
 0873              }
 0874   
 0875              $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" />';
 0876   
 0877              if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
 0878              {
 0879                  $postrow = $db->sql_fetchrowset($result);
 0880   
 0881                  $template->assign_vars(array(
 0882                      'L_SPLIT_TOPIC' => $lang['Split_Topic'],
 0883                      'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
 0884                      'L_AUTHOR' => $lang['Author'],
 0885                      'L_MESSAGE' => $lang['Message'],
 0886                      'L_SELECT' => $lang['Select'],
 0887                      'L_SPLIT_SUBJECT' => $lang['Split_title'],
 0888                      'L_SPLIT_FORUM' => $lang['Split_forum'],
 0889                      'L_POSTED' => $lang['Posted'],
 0890                      'L_SPLIT_POSTS' => $lang['Split_posts'],
 0891                      'L_SUBMIT' => $lang['Submit'],
 0892                      'L_SPLIT_AFTER' => $lang['Split_after'], 
 0893                      'L_POST_SUBJECT' => $lang['Post_subject'], 
 0894                      'L_MARK_ALL' => $lang['Mark_all'], 
 0895                      'L_UNMARK_ALL' => $lang['Unmark_all'], 
 0896                      'L_POST' => $lang['Post'], 
 0897   
 0898                      'FORUM_NAME' => $forum_name, 
 0899   
 0900                      'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
 0901   
 0902                      'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
 0903                      'S_HIDDEN_FIELDS' => $s_hidden_fields,
 0904                      'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
 0905                  );
 0906   
 0907                  //
 0908                  // Define censored word matches
 0909                  //
 0910                  $orig_word = array();
 0911                  $replacement_word = array();
 0912                  obtain_word_list($orig_word, $replacement_word);
 0913   
 0914                  for($i = 0; $i < $total_posts; $i++)
 0915                  {
 0916                      $post_id = $postrow[$i]['post_id'];
 0917                      $poster_id = $postrow[$i]['poster_id'];
 0918                      $poster = $postrow[$i]['username'];
 0919   
 0920                      $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
 0921   
 0922                      $bbcode_uid = $postrow[$i]['bbcode_uid'];
 0923                      $message = $postrow[$i]['post_text'];
 0924                      $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : $topic_title;
 0925   
 0926                      //
 0927                      // If the board has HTML off but the post has HTML
 0928                      // on then we process it, else leave it alone
 0929                      //
 0930                      if ( !$board_config['allow_html'] )
 0931                      {
 0932                          if ( $postrow[$i]['enable_html'] )
 0933                          {
 0934                              $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
 0935                          }
 0936                      }
 0937   
 0938                      if ( $bbcode_uid != '' )
 0939                      {
 0940                          $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
 0941                      }
 0942   
 0943                      if ( count($orig_word) )
 0944                      {
 0945                          $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
 0946                          $message = preg_replace($orig_word, $replacement_word, $message);
 0947                      }
 0948   
 0949                      $message = make_clickable($message);
 0950   
 0951                      if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
 0952                      {
 0953                          $message = smilies_pass($message);
 0954                      }
 0955   
 0956                      $message = str_replace("\n", '<br />', $message);
 0957                      
 0958                      $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
 0959                      $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 0960   
 0961                      $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : '&nbsp;';
 0962                      
 0963                      $template->assign_block_vars('postrow', array(
 0964                          'ROW_COLOR' => '#' . $row_color,
 0965                          'ROW_CLASS' => $row_class,
 0966                          'POSTER_NAME' => $poster,
 0967                          'POST_DATE' => $post_date,
 0968                          'POST_SUBJECT' => $post_subject,
 0969                          'MESSAGE' => $message,
 0970                          'POST_ID' => $post_id,
 0971                          
 0972                          'S_SPLIT_CHECKBOX' => $checkbox)
 0973                      );
 0974                  }
 0975   
 0976                  $template->pparse('split_body');
 0977              }
 0978          }
 0979          break;
 0980   
 0981      case 'ip':
 0982          $page_title = $lang['Mod_CP'];
 0983          include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 0984   
 0985          $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
 0986   
 0987          if ( !$post_id )
 0988          {
 0989              message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 0990          }
 0991   
 0992          //
 0993          // Set template files
 0994          //
 0995          $template->set_filenames(array(
 0996              'viewip' => 'modcp_viewip.tpl')
 0997          );
 0998   
 0999          // Look up relevent data for this post
 1000          $sql = "SELECT poster_ip, poster_id 
 1001              FROM " . POSTS_TABLE . " 
 1002              WHERE post_id = $post_id
 1003                  AND forum_id = $forum_id";
 1004          if ( !($result = $db->sql_query($sql)) )
 1005          {
 1006              message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
 1007          }
 1008          
 1009          if ( !($post_row = $db->sql_fetchrow($result)) )
 1010          {
 1011              message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 1012          }
 1013   
 1014          $ip_this_post = decode_ip($post_row['poster_ip']);
 1015          $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? htmlspecialchars(gethostbyaddr($ip_this_post)) : $ip_this_post;
 1016   
 1017          $poster_id = $post_row['poster_id'];
 1018   
 1019          $template->assign_vars(array(
 1020              'L_IP_INFO' => $lang['IP_info'],
 1021              'L_THIS_POST_IP' => $lang['This_posts_IP'],
 1022              'L_OTHER_IPS' => $lang['Other_IP_this_user'],
 1023              'L_OTHER_USERS' => $lang['Users_this_IP'],
 1024              'L_LOOKUP_IP' => $lang['Lookup_IP'], 
 1025              'L_SEARCH' => $lang['Search'],
 1026   
 1027              'SEARCH_IMG' => $images['icon_search'], 
 1028   
 1029              'IP' => $ip_this_post, 
 1030                  
 1031              'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=$ip_this_post&amp;p_sid=" . $userdata['priv_session_id']))
 1032          );
 1033   
 1034          //
 1035          // Get other IP's this user has posted under
 1036          //
 1037          $sql = "SELECT poster_ip, COUNT(*) AS postings 
 1038              FROM " . POSTS_TABLE . " 
 1039              WHERE poster_id = $poster_id 
 1040              GROUP BY poster_ip 
 1041              ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
 1042          if ( !($result = $db->sql_query($sql)) )
 1043          {
 1044              message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
 1045          }
 1046   
 1047          if ( $row = $db->sql_fetchrow($result) )
 1048          {
 1049              $i = 0;
 1050              do
 1051              {
 1052                  if ( $row['poster_ip'] == $post_row['poster_ip'] )
 1053                  {
 1054                      $template->assign_vars(array(
 1055                          'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
 1056                      );
 1057                      continue;
 1058                  }
 1059   
 1060                  $ip = decode_ip($row['poster_ip']);
 1061                  $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? htmlspecialchars(gethostbyaddr($ip)) : $ip;
 1062   
 1063                  $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
 1064                  $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 1065   
 1066                  $template->assign_block_vars('iprow', array(
 1067                      'ROW_COLOR' => '#' . $row_color, 
 1068                      'ROW_CLASS' => $row_class, 
 1069                      'IP' => $ip,
 1070                      'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
 1071   
 1072                      'U_LOOKUP_IP' => append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=$post_id&amp;" . POST_TOPIC_URL . "=$topic_id&amp;rdns=" . $row['poster_ip'] . "&amp;p_sid=" . $userdata['priv_session_id']))
 1073                  );
 1074   
 1075                  $i++; 
 1076              }
 1077              while ( $row = $db->sql_fetchrow($result) );
 1078          }
 1079   
 1080          //
 1081          // Get other users who've posted under this IP
 1082          //
 1083          $sql = "SELECT u.user_id, u.username, COUNT(*) as postings 
 1084              FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p 
 1085              WHERE p.poster_id = u.user_id 
 1086                  AND p.poster_ip = '" . $post_row['poster_ip'] . "'
 1087              GROUP BY u.user_id, u.username
 1088              ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
 1089          if ( !($result = $db->sql_query($sql)) )
 1090          {
 1091              message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
 1092          }
 1093   
 1094          if ( $row = $db->sql_fetchrow($result) )
 1095          {
 1096              $i = 0;
 1097              do
 1098              {
 1099                  $id = $row['user_id'];
 1100                  $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
 1101   
 1102                  $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
 1103                  $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 1104   
 1105                  $template->assign_block_vars('userrow', array(
 1106                      'ROW_COLOR' => '#' . $row_color, 
 1107                      'ROW_CLASS' => $row_class, 
 1108                      'USERNAME' => $username,
 1109                      'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
 1110                      'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username), 
 1111   
 1112                      'U_PROFILE' => ($id == ANONYMOUS) ? append_sid("modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $post_id . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;p_sid=" . $userdata['priv_session_id']) : append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
 1113                      'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . (($id == ANONYMOUS) ? 'Anonymous' : urlencode($username)) . "&amp;showresults=topics"))
 1114                  );
 1115   
 1116                  $i++; 
 1117              }
 1118              while ( $row = $db->sql_fetchrow($result) );
 1119          }
 1120   
 1121          $template->pparse('viewip');
 1122   
 1123          break;
 1124   
 1125      default:
 1126          $page_title = $lang['Mod_CP'];
 1127          include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 1128   
 1129          $template->assign_vars(array(
 1130              'FORUM_NAME' => $forum_name,
 1131   
 1132              'L_MOD_CP' => $lang['Mod_CP'],
 1133              'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
 1134              'L_SELECT' => $lang['Select'],
 1135              'L_DELETE' => $lang['Delete'],
 1136              'L_MOVE' => $lang['Move'],
 1137              'L_LOCK' => $lang['Lock'],
 1138              'L_UNLOCK' => $lang['Unlock'],
 1139              'L_TOPICS' => $lang['Topics'], 
 1140              'L_REPLIES' => $lang['Replies'], 
 1141              'L_LASTPOST' => $lang['Last_Post'], 
 1142              'L_SELECT' => $lang['Select'], 
 1143   
 1144              'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"), 
 1145              'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="p_sid" value="' . $userdata['priv_session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />',
 1146              'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
 1147          );
 1148   
 1149          $template->set_filenames(array(
 1150              'body' => 'modcp_body.tpl')
 1151          );
 1152          make_jumpbox('modcp.'.$phpEx);
 1153   
 1154          //
 1155          // Define censored word matches
 1156          //
 1157          $orig_word = array();
 1158          $replacement_word = array();
 1159          obtain_word_list($orig_word, $replacement_word);
 1160   
 1161          $sql = "SELECT t.*, u.username, u.user_id, p.post_time
 1162              FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
 1163              WHERE t.forum_id = $forum_id
 1164                  AND t.topic_poster = u.user_id
 1165                  AND p.post_id = t.topic_last_post_id
 1166              ORDER BY t.topic_type DESC, p.post_time DESC
 1167              LIMIT $start, " . $board_config['topics_per_page'];
 1168          if ( !($result = $db->sql_query($sql)) )
 1169          {
 1170                 message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
 1171          }
 1172   
 1173          while ( $row = $db->sql_fetchrow($result) )
 1174          {
 1175              $topic_title = '';
 1176   
 1177              if ( $row['topic_status'] == TOPIC_LOCKED )
 1178              {
 1179                  $folder_img = $images['folder_locked'];
 1180                  $folder_alt = $lang['Topic_locked'];
 1181              }
 1182              else
 1183              {
 1184                  if ( $row['topic_type'] == POST_ANNOUNCE )
 1185                  {
 1186                      $folder_img = $images['folder_announce'];
 1187                      $folder_alt = $lang['Topic_Announcement'];
 1188                  }
 1189                  else if ( $row['topic_type'] == POST_STICKY )
 1190                  {
 1191                      $folder_img = $images['folder_sticky'];
 1192                      $folder_alt = $lang['Topic_Sticky'];
 1193                  }
 1194                  else 
 1195                  {
 1196                      $folder_img = $images['folder'];
 1197                      $folder_alt = $lang['No_new_posts'];
 1198                  }
 1199              }
 1200   
 1201              $topic_id = $row['topic_id'];
 1202              $topic_type = $row['topic_type'];
 1203              $topic_status = $row['topic_status'];
 1204              
 1205              if ( $topic_type == POST_ANNOUNCE )
 1206              {
 1207                  $topic_type = $lang['Topic_Announcement'] . ' ';
 1208              }
 1209              else if ( $topic_type == POST_STICKY )
 1210              {
 1211                  $topic_type = $lang['Topic_Sticky'] . ' ';
 1212              }
 1213              else if ( $topic_status == TOPIC_MOVED )
 1214              {
 1215                  $topic_type = $lang['Topic_Moved'] . ' ';
 1216              }
 1217              else
 1218              {
 1219                  $topic_type = '';        
 1220              }
 1221      
 1222              if ( $row['topic_vote'] )
 1223              {
 1224                  $topic_type .= $lang['Topic_Poll'] . ' ';
 1225              }
 1226      
 1227              $topic_title = $row['topic_title'];
 1228              if ( count($orig_word) )
 1229              {
 1230                  $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
 1231              }
 1232   
 1233              $u_view_topic = append_sid("modcp.$phpEx?mode=split&amp;" . POST_TOPIC_URL . "=$topic_id&amp;p_sid=" . $userdata['priv_session_id']);
 1234              $topic_replies = $row['topic_replies'];
 1235   
 1236              $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
 1237   
 1238              $template->assign_block_vars('topicrow', array(
 1239                  'U_VIEW_TOPIC' => $u_view_topic,
 1240   
 1241                  'TOPIC_FOLDER_IMG' => $folder_img, 
 1242                  'TOPIC_TYPE' => $topic_type, 
 1243                  'TOPIC_TITLE' => $topic_title,
 1244                  'REPLIES' => $topic_replies,
 1245                  'LAST_POST_TIME' => $last_post_time,
 1246                  'TOPIC_ID' => $topic_id,
 1247                      
 1248                  'L_TOPIC_FOLDER_ALT' => $folder_alt)
 1249              );
 1250          }
 1251   
 1252          $template->assign_vars(array(
 1253              'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;p_sid=" . $userdata['priv_session_id'], $forum_topics, $board_config['topics_per_page'], $start),
 1254              'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )), 
 1255              'L_GOTO_PAGE' => $lang['Goto_page'])
 1256          );
 1257   
 1258          $template->pparse('body');
 1259   
 1260          break;
 1261  }
 1262   
 1263  include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
 1264   
 1265  ?>