[ Index ]

PHP Cross Reference of phpBB 2.0.21

title

Body

[close]

/ -> modcp.php (source)

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


Generated: Thu Jun 15 00:04:58 2006 Cross-referenced by PHPXref 0.6