[ Index ]
 

Code source de PHP NUKE 7.9

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/Forums/ -> 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.26 2005/06/26 12:03:46 acydburn 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  if ( !defined('MODULE_FILE') )
  31  {
  32      die("You can't access this file directly...");
  33  }
  34  $module_name = basename(dirname(__FILE__));
  35  require("modules/".$module_name."/nukebb.php");
  36  
  37  define('IN_PHPBB', true);
  38  include ($phpbb_root_path . 'extension.inc');
  39  include($phpbb_root_path . 'common.'.$phpEx);
  40  include ("includes/bbcode.php");
  41  include ("includes/functions_admin.php");
  42  
  43  //

  44  // Obtain initial var settings

  45  //

  46  if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
  47  {
  48          $forum_id = (isset($HTTP_POST_VARS[POST_FORUM_URL])) ? intval($HTTP_POST_VARS[POST_FORUM_URL]) : intval($HTTP_GET_VARS[POST_FORUM_URL]);
  49  }
  50  else
  51  {
  52          $forum_id = '';
  53  }
  54  
  55  if ( isset($HTTP_GET_VARS[POST_POST_URL]) || isset($HTTP_POST_VARS[POST_POST_URL]) )
  56  {
  57          $post_id = (isset($HTTP_POST_VARS[POST_POST_URL])) ? intval($HTTP_POST_VARS[POST_POST_URL]) : intval($HTTP_GET_VARS[POST_POST_URL]);
  58  }
  59  else
  60  {
  61          $post_id = '';
  62  }
  63  
  64  if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) || isset($HTTP_POST_VARS[POST_TOPIC_URL]) )
  65  {
  66          $topic_id = (isset($HTTP_POST_VARS[POST_TOPIC_URL])) ? intval($HTTP_POST_VARS[POST_TOPIC_URL]) : intval($HTTP_GET_VARS[POST_TOPIC_URL]);
  67  }
  68  else
  69  {
  70          $topic_id = '';
  71  }
  72  
  73  $confirm = ( $HTTP_POST_VARS['confirm'] ) ? TRUE : 0;
  74  
  75  //

  76  // Continue var definitions

  77  //

  78  $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  79  
  80  $delete = ( isset($HTTP_POST_VARS['delete']) ) ? TRUE : FALSE;
  81  $move = ( isset($HTTP_POST_VARS['move']) ) ? TRUE : FALSE;
  82  $lock = ( isset($HTTP_POST_VARS['lock']) ) ? TRUE : FALSE;
  83  $unlock = ( isset($HTTP_POST_VARS['unlock']) ) ? TRUE : FALSE;
  84  
  85  if ( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
  86  {
  87          $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
  88      $mode = htmlspecialchars($mode);
  89  }
  90  else
  91  {
  92          if ( $delete )
  93          {
  94                  $mode = 'delete';
  95          }
  96          else if ( $move )
  97          {
  98                  $mode = 'move';
  99          }
 100          else if ( $lock )
 101          {
 102                  $mode = 'lock';
 103          }
 104          else if ( $unlock )
 105          {
 106                  $mode = 'unlock';
 107          }
 108          else
 109          {
 110                  $mode = '';
 111          }
 112  }
 113  
 114  // session id check

 115  if (!empty($HTTP_POST_VARS['sid']) || !empty($HTTP_GET_VARS['sid']))
 116  {
 117          $sid = (!empty($HTTP_POST_VARS['sid'])) ? $HTTP_POST_VARS['sid'] : $HTTP_GET_VARS['sid'];
 118  }
 119  else
 120  {
 121          $sid = '';
 122  }
 123  
 124  //

 125  // Obtain relevant data

 126  //

 127  if ( !empty($topic_id) )
 128  {
 129          $sql = "SELECT f.forum_id, f.forum_name, f.forum_topics
 130                  FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f
 131                  WHERE t.topic_id = " . $topic_id . "
 132                          AND f.forum_id = t.forum_id";
 133          if ( !($result = $db->sql_query($sql)) )
 134          {
 135                  message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
 136          }
 137          $topic_row = $db->sql_fetchrow($result);
 138  
 139      if (!$topic_row)
 140      {
 141          message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
 142      }
 143  
 144          $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
 145          $forum_id = $topic_row['forum_id'];
 146          $forum_name = $topic_row['forum_name'];
 147  }
 148  else if ( !empty($forum_id) )
 149  {
 150          $sql = "SELECT forum_name, forum_topics
 151                  FROM " . FORUMS_TABLE . "
 152                  WHERE forum_id = " . $forum_id;
 153          if ( !($result = $db->sql_query($sql)) )
 154          {
 155                  message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 156          }
 157          $topic_row = $db->sql_fetchrow($result);
 158  
 159      if (!$topic_row)
 160      {
 161          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 162      }
 163  
 164          $forum_topics = ( $topic_row['forum_topics'] == 0 ) ? 1 : $topic_row['forum_topics'];
 165          $forum_name = $topic_row['forum_name'];
 166  }
 167  else
 168  {
 169          message_die(GENERAL_MESSAGE, 'Forum_not_exist');
 170  }
 171  
 172  //

 173  // Start session management

 174  //

 175  $userdata = session_pagestart($user_ip, $forum_id, $nukeuser);
 176  init_userprefs($userdata);
 177  //

 178  // End session management

 179  //

 180  
 181  // session id check

 182  //if (empty($sid) || $sid != $userdata['session_id'])

 183  //{

 184  //        message_die(GENERAL_ERROR, 'Invalid_session');

 185  //}

 186  
 187  //

 188  // Check if user did or did not confirm

 189  // If they did not, forward them to the last page they were on

 190  //

 191  if ( isset($HTTP_POST_VARS['cancel']) )
 192  {
 193          if ( $topic_id )
 194          {
 195                  $redirect = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id";
 196          }
 197          else if ( $forum_id )
 198          {
 199                  $redirect = "viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id";
 200          }
 201          else
 202          {
 203                  $redirect = "index.$phpEx";
 204          }
 205  
 206          $header_location = ( @preg_match('/Microsoft|WebSTAR|Xitami/', $_SERVER['SERVER_SOFTWARE']) ) ? 'Refresh: 0; URL=' : 'Location: ';
 207          header($header_location . append_sid($redirect, true));
 208          exit;
 209  }
 210  
 211  //

 212  // Start auth check

 213  //

 214  $is_auth = auth(AUTH_ALL, $forum_id, $userdata);
 215  
 216  if ( !$is_auth['auth_mod'] )
 217  {
 218          message_die(GENERAL_MESSAGE, $lang['Not_Moderator'], $lang['Not_Authorised']);
 219  }
 220  //

 221  // End Auth Check

 222  //

 223  
 224  //

 225  // Do major work ...

 226  //

 227  switch( $mode )
 228  {
 229          case 'delete':
 230                  if (!$is_auth['auth_delete'])
 231                  {
 232                          message_die(MESSAGE, sprintf($lang['Sorry_auth_delete'], $is_auth['auth_delete_type']));
 233                  }
 234  
 235                  $page_title = $lang['Mod_CP'];
 236                  include ("includes/page_header.php");
 237  
 238                  if ( $confirm )
 239                  {
 240                          include ("includes/functions_search.php");
 241  
 242                          $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 243  
 244                          $topic_id_sql = '';
 245                          for($i = 0; $i < count($topics); $i++)
 246                          {
 247                  $topic_id_sql .= ( ( !empty($topic_id_sql) ) ? ', ' : '' ) . intval($topics[$i]);
 248              }
 249  
 250              $sql = "SELECT topic_id 
 251                  FROM " . TOPICS_TABLE . "
 252                  WHERE topic_id IN ($topic_id_sql)
 253                      AND forum_id = '$forum_id'";
 254              if ( !($result = $db->sql_query($sql)) )
 255              {
 256                  message_die(GENERAL_ERROR, 'Could not get topic id information', '', __LINE__, __FILE__, $sql);
 257              }
 258              
 259              $topic_id_sql = '';
 260              while ($row = $db->sql_fetchrow($result))
 261              {
 262                  $topic_id_sql .= ((!empty($topic_id_sql)) ? ', ' : '') . intval($row['topic_id']);
 263              }
 264              $db->sql_freeresult($result);
 265  
 266                          $sql = "SELECT poster_id, COUNT(post_id) AS posts
 267                                  FROM " . POSTS_TABLE . "
 268                                  WHERE topic_id IN ($topic_id_sql)
 269                                  GROUP BY poster_id";
 270                          if ( !($result = $db->sql_query($sql)) )
 271                          {
 272                                  message_die(GENERAL_ERROR, 'Could not get poster id information', '', __LINE__, __FILE__, $sql);
 273                          }
 274  
 275                          $count_sql = array();
 276                          while ( $row = $db->sql_fetchrow($result) )
 277                          {
 278                                  $count_sql[] = "UPDATE " . USERS_TABLE . "
 279                                          SET user_posts = user_posts - " . $row['posts'] . "
 280                                          WHERE user_id = " . $row['poster_id'];
 281                          }
 282                          $db->sql_freeresult($result);
 283  
 284                          if ( sizeof($count_sql) )
 285                          {
 286                                  for($i = 0; $i < sizeof($count_sql); $i++)
 287                                  {
 288                                          if ( !$db->sql_query($count_sql[$i]) )
 289                                          {
 290                                                  message_die(GENERAL_ERROR, 'Could not update user post count information', '', __LINE__, __FILE__, $sql);
 291                                          }
 292                                  }
 293                          }
 294  
 295                          $sql = "SELECT post_id
 296                                  FROM " . POSTS_TABLE . "
 297                                  WHERE topic_id IN ($topic_id_sql)";
 298                          if ( !($result = $db->sql_query($sql)) )
 299                          {
 300                                  message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
 301                          }
 302  
 303                          $post_id_sql = '';
 304                          while ( $row = $db->sql_fetchrow($result) )
 305                          {
 306                                  $post_id_sql .= ( ( !empty($post_id_sql) ) ? ', ' : '' ) . intval($row['post_id']);
 307                          }
 308                          $db->sql_freeresult($result);
 309  
 310                          $sql = "SELECT vote_id
 311                                  FROM " . VOTE_DESC_TABLE . "
 312                                  WHERE topic_id IN ($topic_id_sql)";
 313                          if ( !($result = $db->sql_query($sql)) )
 314                          {
 315                                  message_die(GENERAL_ERROR, 'Could not get vote id information', '', __LINE__, __FILE__, $sql);
 316                          }
 317  
 318                          $vote_id_sql = '';
 319                          while ( $row = $db->sql_fetchrow($result) )
 320                          {
 321                                  $vote_id_sql .= ( ( !empty($vote_id_sql) ) ? ', ' : '' ) . $row['vote_id'];
 322                          }
 323                          $db->sql_freeresult($result);
 324  
 325                          //

 326                          // Got all required info so go ahead and start deleting everything

 327                          //

 328                          $sql = "DELETE
 329                                  FROM " . TOPICS_TABLE . "
 330                                  WHERE topic_id IN ($topic_id_sql)
 331                                          OR topic_moved_id IN ($topic_id_sql)";
 332                          if ( !$db->sql_query($sql, BEGIN_TRANSACTION) )
 333                          {
 334                                  message_die(GENERAL_ERROR, 'Could not delete topics', '', __LINE__, __FILE__, $sql);
 335                          }
 336  
 337                          if ( !empty($post_id_sql) )
 338                          {
 339                                  $sql = "DELETE
 340                                          FROM " . POSTS_TABLE . "
 341                                          WHERE post_id IN ($post_id_sql)";
 342                                  if ( !$db->sql_query($sql) )
 343                                  {
 344                                          message_die(GENERAL_ERROR, 'Could not delete posts', '', __LINE__, __FILE__, $sql);
 345                                  }
 346  
 347                                  $sql = "DELETE
 348                                          FROM " . POSTS_TEXT_TABLE . "
 349                                          WHERE post_id IN ($post_id_sql)";
 350                                  if ( !$db->sql_query($sql) )
 351                                  {
 352                                          message_die(GENERAL_ERROR, 'Could not delete posts text', '', __LINE__, __FILE__, $sql);
 353                                  }
 354  
 355                                  remove_search_post($post_id_sql);
 356                          }
 357  
 358                          if ( !empty($vote_id_sql) )
 359                          {
 360                                  $sql = "DELETE
 361                                          FROM " . VOTE_DESC_TABLE . "
 362                                          WHERE vote_id IN ($vote_id_sql)";
 363                                  if ( !$db->sql_query($sql) )
 364                                  {
 365                                          message_die(GENERAL_ERROR, 'Could not delete vote descriptions', '', __LINE__, __FILE__, $sql);
 366                                  }
 367  
 368                                  $sql = "DELETE
 369                                          FROM " . VOTE_RESULTS_TABLE . "
 370                                          WHERE vote_id IN ($vote_id_sql)";
 371                                  if ( !$db->sql_query($sql) )
 372                                  {
 373                                          message_die(GENERAL_ERROR, 'Could not delete vote results', '', __LINE__, __FILE__, $sql);
 374                                  }
 375  
 376                                  $sql = "DELETE
 377                                          FROM " . VOTE_USERS_TABLE . "
 378                                          WHERE vote_id IN ($vote_id_sql)";
 379                                  if ( !$db->sql_query($sql) )
 380                                  {
 381                                          message_die(GENERAL_ERROR, 'Could not delete vote users', '', __LINE__, __FILE__, $sql);
 382                                  }
 383                          }
 384  
 385                          $sql = "DELETE
 386                                  FROM " . TOPICS_WATCH_TABLE . "
 387                                  WHERE topic_id IN ($topic_id_sql)";
 388                          if ( !$db->sql_query($sql, END_TRANSACTION) )
 389                          {
 390                                  message_die(GENERAL_ERROR, 'Could not delete watched post list', '', __LINE__, __FILE__, $sql);
 391                          }
 392  
 393                          sync('forum', $forum_id);
 394  
 395                          if ( !empty($topic_id) )
 396                          {
 397                                  $redirect_page = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 398                                  $l_redirect = sprintf($lang['Click_return_forum'], '<a href="' . $redirect_page . '">', '</a>');
 399                          }
 400                          else
 401                          {
 402                                  $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 403                                  $l_redirect = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 404                          }
 405  
 406                          $template->assign_vars(array(
 407                                  'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 408                          );
 409  
 410                          message_die(GENERAL_MESSAGE, $lang['Topics_Removed'] . '<br /><br />' . $l_redirect);
 411                  }
 412                  else
 413                  {
 414                          // Not confirmed, show confirmation message

 415                          if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 416                          {
 417                                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 418                          }
 419  
 420                          $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 . '" />';
 421  
 422                          if ( isset($HTTP_POST_VARS['topic_id_list']) )
 423                          {
 424                                  $topics = $HTTP_POST_VARS['topic_id_list'];
 425                                  for($i = 0; $i < count($topics); $i++)
 426                                  {
 427                                          $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
 428                                  }
 429                          }
 430                          else
 431                          {
 432                                  $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
 433                          }
 434  
 435                          //

 436                          // Set template files

 437                          //

 438                          $template->set_filenames(array(
 439                                  'confirm' => 'confirm_body.tpl')
 440                          );
 441  
 442                          $template->assign_vars(array(
 443                                  'MESSAGE_TITLE' => $lang['Confirm'],
 444                                  'MESSAGE_TEXT' => $lang['Confirm_delete_topic'],
 445  
 446                                  'L_YES' => $lang['Yes'],
 447                                  'L_NO' => $lang['No'],
 448  
 449                                  'S_CONFIRM_ACTION' => append_sid("modcp.$phpEx"),
 450                                  'S_HIDDEN_FIELDS' => $hidden_fields)
 451                          );
 452  
 453                          $template->pparse('confirm');
 454  
 455                          include ("includes/page_tail.php");
 456                  }
 457                  break;
 458  
 459          case 'move':
 460                  $page_title = $lang['Mod_CP'];
 461                  include ("includes/page_header.php");
 462  
 463                  if ( $confirm )
 464                  {
 465                          if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 466                          {
 467                                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 468                          }
 469  
 470                          $new_forum_id = intval($HTTP_POST_VARS['new_forum']);
 471                          $old_forum_id = $forum_id;
 472  
 473                          $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
 474                             WHERE forum_id = ' . $new_forum_id;
 475                          if ( !($result = $db->sql_query($sql)) )
 476                          {
 477                             message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
 478                          }
 479  
 480                          if (!$db->sql_fetchrow($result))
 481                          {
 482                             message_die(GENERAL_MESSAGE, 'New forum does not exist');
 483                          }
 484  
 485                          $db->sql_freeresult($result);
 486                          if ( $new_forum_id != $old_forum_id )
 487                          {
 488                                  $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 489  
 490                                  $topic_list = '';
 491                                  for($i = 0; $i < count($topics); $i++)
 492                                  {
 493                                          $topic_list .= ( ( !empty($topic_list) ) ? ', ' : '' ) . intval($topics[$i]);
 494                                  }
 495  
 496                                  $sql = "SELECT *
 497                                          FROM " . TOPICS_TABLE . "
 498                                          WHERE topic_id IN ($topic_list)
 499                          AND forum_id = '$old_forum_id'
 500                                                  AND topic_status <> " . TOPIC_MOVED;
 501                                  if ( !($result = $db->sql_query($sql, BEGIN_TRANSACTION)) )
 502                                  {
 503                                          message_die(GENERAL_ERROR, 'Could not select from topic table', '', __LINE__, __FILE__, $sql);
 504                                  }
 505  
 506                                  $row = $db->sql_fetchrowset($result);
 507                                  $db->sql_freeresult($result);
 508  
 509                                  for($i = 0; $i < count($row); $i++)
 510                                  {
 511                                          $topic_id = $row[$i]['topic_id'];
 512  
 513                                          if ( isset($HTTP_POST_VARS['move_leave_shadow']) )
 514                                          {
 515                                                  // Insert topic in the old forum that indicates that the forum has moved.

 516                                                  $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)
 517                                                          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')";
 518                                                  if ( !$db->sql_query($sql) )
 519                                                  {
 520                                                          message_die(GENERAL_ERROR, 'Could not insert shadow topic', '', __LINE__, __FILE__, $sql);
 521                                                  }
 522                                          }
 523  
 524                                          $sql = "UPDATE " . TOPICS_TABLE . "
 525                                                  SET forum_id = '$new_forum_id'
 526                                                  WHERE topic_id = '$topic_id'";
 527                                          if ( !$db->sql_query($sql) )
 528                                          {
 529                                                  message_die(GENERAL_ERROR, 'Could not update old topic', '', __LINE__, __FILE__, $sql);
 530                                          }
 531  
 532                                          $sql = "UPDATE " . POSTS_TABLE . "
 533                                                  SET forum_id = '$new_forum_id'
 534                                                  WHERE topic_id = '$topic_id'";
 535                                          if ( !$db->sql_query($sql) )
 536                                          {
 537                                                  message_die(GENERAL_ERROR, 'Could not update post topic ids', '', __LINE__, __FILE__, $sql);
 538                                          }
 539                                  }
 540  
 541                                  // Sync the forum indexes

 542                                  sync('forum', $new_forum_id);
 543                                  sync('forum', $old_forum_id);
 544  
 545                                  $message = $lang['Topics_Moved'] . '<br /><br />';
 546  
 547                          }
 548                          else
 549                          {
 550                                  $message = $lang['No_Topics_Moved'] . '<br /><br />';
 551                          }
 552  
 553                          if ( !empty($topic_id) )
 554                          {
 555                                  $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 556                                  $message .= sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 557                          }
 558                          else
 559                          {
 560                                  $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 561                                  $message .= sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 562                          }
 563  
 564                          $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$old_forum_id") . '">', '</a>');
 565  
 566                          $template->assign_vars(array(
 567                                  'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 568                          );
 569  
 570                          message_die(GENERAL_MESSAGE, $message);
 571                  }
 572                  else
 573                  {
 574                          if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 575                          {
 576                                  message_die(GENERAL_MESSAGE, $lang['None_selected']);
 577                          }
 578  
 579                          $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 . '" />';
 580  
 581                          if ( isset($HTTP_POST_VARS['topic_id_list']) )
 582                          {
 583                                  $topics = $HTTP_POST_VARS['topic_id_list'];
 584  
 585                                  for($i = 0; $i < count($topics); $i++)
 586                                  {
 587                                          $hidden_fields .= '<input type="hidden" name="topic_id_list[]" value="' . intval($topics[$i]) . '" />';
 588                                  }
 589                          }
 590                          else
 591                          {
 592                                  $hidden_fields .= '<input type="hidden" name="' . POST_TOPIC_URL . '" value="' . $topic_id . '" />';
 593                          }
 594  
 595                          //

 596                          // Set template files

 597                          //

 598                          $template->set_filenames(array(
 599                                  'movetopic' => 'modcp_move.tpl')
 600                          );
 601  
 602                          $template->assign_vars(array(
 603                                  'MESSAGE_TITLE' => $lang['Confirm'],
 604                                  'MESSAGE_TEXT' => $lang['Confirm_move_topic'],
 605  
 606                                  'L_MOVE_TO_FORUM' => $lang['Move_to_forum'],
 607                                  'L_LEAVESHADOW' => $lang['Leave_shadow_topic'],
 608                                  'L_YES' => $lang['Yes'],
 609                                  'L_NO' => $lang['No'],
 610  
 611                                  'S_FORUM_SELECT' => make_forum_select('new_forum', $forum_id),
 612                                  'S_MODCP_ACTION' => append_sid("modcp.$phpEx"),
 613                                  'S_HIDDEN_FIELDS' => $hidden_fields)
 614                          );
 615  
 616                          $template->pparse('movetopic');
 617  
 618                          include ("includes/page_tail.php");
 619                  }
 620                  break;
 621  
 622          case 'lock':
 623                  if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 624                  {
 625                          message_die(GENERAL_MESSAGE, $lang['None_selected']);
 626                  }
 627  
 628                  $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 629  
 630                  $topic_id_sql = '';
 631                  for($i = 0; $i < count($topics); $i++)
 632                  {
 633              $topic_id_sql .= ( ( !empty($topic_id_sql) ) ? ', ' : '' ) . intval($topics[$i]);
 634          }
 635  
 636                  $sql = "UPDATE " . TOPICS_TABLE . "
 637                          SET topic_status = " . TOPIC_LOCKED . "
 638                          WHERE topic_id IN ($topic_id_sql)
 639                  AND forum_id = '$forum_id'
 640                                  AND topic_moved_id = '0'";
 641                  if ( !($result = $db->sql_query($sql)) )
 642                  {
 643                          message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
 644                  }
 645  
 646                  if ( !empty($topic_id) )
 647                  {
 648                          $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 649                          $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 650                  }
 651                  else
 652                  {
 653                          $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 654                          $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 655                  }
 656  
 657                  $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
 658  
 659                  $template->assign_vars(array(
 660                          'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 661                  );
 662  
 663                  message_die(GENERAL_MESSAGE, $lang['Topics_Locked'] . '<br /><br />' . $message);
 664  
 665                  break;
 666  
 667          case 'unlock':
 668                  if ( empty($HTTP_POST_VARS['topic_id_list']) && empty($topic_id) )
 669                  {
 670                          message_die(GENERAL_MESSAGE, $lang['None_selected']);
 671                  }
 672  
 673                  $topics = ( isset($HTTP_POST_VARS['topic_id_list']) ) ?  $HTTP_POST_VARS['topic_id_list'] : array($topic_id);
 674  
 675                  $topic_id_sql = '';
 676                  for($i = 0; $i < count($topics); $i++)
 677                  {
 678              $topic_id_sql .= ( ( !empty($topic_id_sql) ) ? ', ' : '' ) . intval($topics[$i]);
 679          }
 680  
 681                  $sql = "UPDATE " . TOPICS_TABLE . "
 682                          SET topic_status = " . TOPIC_UNLOCKED . "
 683                          WHERE topic_id IN ($topic_id_sql)
 684                  AND forum_id = '$forum_id'
 685                                  AND topic_moved_id = '0'";
 686                  if ( !($result = $db->sql_query($sql)) )
 687                  {
 688                          message_die(GENERAL_ERROR, 'Could not update topics table', '', __LINE__, __FILE__, $sql);
 689                  }
 690  
 691                  if ( !empty($topic_id) )
 692                  {
 693                          $redirect_page = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
 694                          $message = sprintf($lang['Click_return_topic'], '<a href="' . $redirect_page . '">', '</a>');
 695                  }
 696                  else
 697                  {
 698                          $redirect_page = append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 699                          $message = sprintf($lang['Click_return_modcp'], '<a href="' . $redirect_page . '">', '</a>');
 700                  }
 701  
 702                  $message = $message . '<br \><br \>' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
 703  
 704                  $template->assign_vars(array(
 705                          'META' => '<meta http-equiv="refresh" content="3;url=' . $redirect_page . '">')
 706                  );
 707  
 708                  message_die(GENERAL_MESSAGE, $lang['Topics_Unlocked'] . '<br /><br />' . $message);
 709  
 710                  break;
 711  
 712          case 'split':
 713                  $page_title = $lang['Mod_CP'];
 714                  include ("includes/page_header.php");
 715  
 716                  $post_id_sql = '';
 717  
 718                  if (isset($HTTP_POST_VARS['split_type_all']) || isset($HTTP_POST_VARS['split_type_beyond']))
 719                  {
 720                          $posts = $HTTP_POST_VARS['post_id_list'];
 721  
 722                          for ($i = 0; $i < count($posts); $i++)
 723                          {
 724                                  $post_id_sql .= ((!empty($post_id_sql)) ? ', ' : '') . intval($posts[$i]);
 725                          }
 726                  }
 727  
 728                  if (!empty($post_id_sql))
 729                  {
 730              $sql = "SELECT post_id 
 731                  FROM " . POSTS_TABLE . "
 732                  WHERE post_id IN ($post_id_sql)
 733                      AND forum_id = '$forum_id'";
 734              if ( !($result = $db->sql_query($sql)) )
 735              {
 736                  message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
 737              }
 738              
 739              $post_id_sql = '';
 740              while ($row = $db->sql_fetchrow($result))
 741              {
 742                  $post_id_sql .= ((!empty($post_id_sql)) ? ', ' : '') . intval($row['post_id']);
 743              }
 744              $db->sql_freeresult($result);
 745                          $sql = "SELECT post_id, poster_id, topic_id, post_time
 746                                  FROM " . POSTS_TABLE . "
 747                                  WHERE post_id IN ($post_id_sql)
 748                                  ORDER BY post_time ASC";
 749                          if (!($result = $db->sql_query($sql)))
 750                          {
 751                                  message_die(GENERAL_ERROR, 'Could not get post information', '', __LINE__, __FILE__, $sql);
 752                          }
 753  
 754                          if ($row = $db->sql_fetchrow($result))
 755                          {
 756                                  $first_poster = $row['poster_id'];
 757                                  $topic_id = $row['topic_id'];
 758                                  $post_time = $row['post_time'];
 759  
 760                                  $user_id_sql = '';
 761                                  $post_id_sql = '';
 762                                  do
 763                                  {
 764                                          $user_id_sql .= ((!empty($user_id_sql)) ? ', ' : '') . intval($row['poster_id']);
 765                                          $post_id_sql .= ((!empty($post_id_sql)) ? ', ' : '') . intval($row['post_id']);;
 766                                  }
 767                                  while ($row = $db->sql_fetchrow($result));
 768  
 769                                  $post_subject = trim(htmlspecialchars($HTTP_POST_VARS['subject']));
 770                                  if (empty($post_subject))
 771                                  {
 772                                          message_die(GENERAL_MESSAGE, $lang['Empty_subject']);
 773                                  }
 774  
 775                                  $new_forum_id = intval($HTTP_POST_VARS['new_forum_id']);
 776                                  $topic_time = time();
 777  
 778                                  $sql = 'SELECT forum_id FROM ' . FORUMS_TABLE . '
 779                                     WHERE forum_id = ' . $new_forum_id;
 780                                  if ( !($result = $db->sql_query($sql)) )
 781                                  {
 782                                     message_die(GENERAL_ERROR, 'Could not select from forums table', '', __LINE__, __FILE__, $sql);
 783                                  }
 784  
 785                                  if (!$db->sql_fetchrow($result))
 786                                  {
 787                                     message_die(GENERAL_MESSAGE, 'New forum does not exist');
 788                                  }
 789  
 790                                  $db->sql_freeresult($result);
 791                                  $sql  = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type)
 792                                          VALUES ('" . str_replace("\'", "''", $post_subject) . "', '$first_poster', " . $topic_time . ", '$new_forum_id', " . TOPIC_UNLOCKED . ", " . POST_NORMAL . ")";
 793                                  if (!($db->sql_query($sql, BEGIN_TRANSACTION)))
 794                                  {
 795                                          message_die(GENERAL_ERROR, 'Could not insert new topic', '', __LINE__, __FILE__, $sql);
 796                                  }
 797  
 798                                  $new_topic_id = $db->sql_nextid();
 799  
 800                                  // Update topic watch table, switch users whose posts

 801                                  // have moved, over to watching the new topic

 802                                  $sql = "UPDATE " . TOPICS_WATCH_TABLE . "
 803                                          SET topic_id = '$new_topic_id'
 804                                          WHERE topic_id = '$topic_id'
 805                                                  AND user_id IN ($user_id_sql)";
 806                                  if (!$db->sql_query($sql))
 807                                  {
 808                                          message_die(GENERAL_ERROR, 'Could not update topics watch table', '', __LINE__, __FILE__, $sql);
 809                                  }
 810  
 811                                  $sql_where = (!empty($HTTP_POST_VARS['split_type_beyond'])) ? " post_time >= '$post_time' AND topic_id = '$topic_id'" : "post_id IN ($post_id_sql)";
 812  
 813                                  $sql =         "UPDATE " . POSTS_TABLE . "
 814                                          SET topic_id = '$new_topic_id', forum_id = '$new_forum_id'
 815                                          WHERE $sql_where";
 816                                  if (!$db->sql_query($sql, END_TRANSACTION))
 817                                  {
 818                                          message_die(GENERAL_ERROR, 'Could not update posts table', '', __LINE__, __FILE__, $sql);
 819                                  }
 820  
 821                                  sync('topic', $new_topic_id);
 822                                  sync('topic', $topic_id);
 823                                  sync('forum', $new_forum_id);
 824                                  sync('forum', $forum_id);
 825  
 826                                  $template->assign_vars(array(
 827                                  'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">')
 828                                  );
 829  
 830                          $message = $lang['Topic_split'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id") . '">', '</a>');
 831                                  message_die(GENERAL_MESSAGE, $message);
 832                          }
 833                  }
 834                  else
 835                  {
 836                          //

 837                          // Set template files

 838                          //

 839                          $template->set_filenames(array(
 840                                  'split_body' => 'modcp_split.tpl')
 841                          );
 842  
 843                          $sql = "SELECT u.username, p.*, pt.post_text, pt.bbcode_uid, pt.post_subject, p.post_username
 844                                  FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
 845                                  WHERE p.topic_id = '$topic_id'
 846                                          AND p.poster_id = u.user_id
 847                                          AND p.post_id = pt.post_id
 848                                  ORDER BY p.post_time ASC";
 849                          if ( !($result = $db->sql_query($sql)) )
 850                          {
 851                                  message_die(GENERAL_ERROR, 'Could not get topic/post information', '', __LINE__, __FILE__, $sql);
 852                          }
 853  
 854                          $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" />';
 855  
 856                          if( ( $total_posts = $db->sql_numrows($result) ) > 0 )
 857                          {
 858                                  $postrow = $db->sql_fetchrowset($result);
 859  
 860                                  $template->assign_vars(array(
 861                                          'L_SPLIT_TOPIC' => $lang['Split_Topic'],
 862                                          'L_SPLIT_TOPIC_EXPLAIN' => $lang['Split_Topic_explain'],
 863                                          'L_AUTHOR' => $lang['Author'],
 864                                          'L_MESSAGE' => $lang['Message'],
 865                                          'L_SELECT' => $lang['Select'],
 866                                          'L_SPLIT_SUBJECT' => $lang['Split_title'],
 867                                          'L_SPLIT_FORUM' => $lang['Split_forum'],
 868                                          'L_POSTED' => $lang['Posted'],
 869                                          'L_SPLIT_POSTS' => $lang['Split_posts'],
 870                                          'L_SUBMIT' => $lang['Submit'],
 871                                          'L_SPLIT_AFTER' => $lang['Split_after'],
 872                                          'L_POST_SUBJECT' => $lang['Post_subject'],
 873                                          'L_MARK_ALL' => $lang['Mark_all'],
 874                                          'L_UNMARK_ALL' => $lang['Unmark_all'],
 875                                          'L_POST' => $lang['Post'],
 876  
 877                                          'FORUM_NAME' => $forum_name,
 878  
 879                                          'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
 880  
 881                                          'S_SPLIT_ACTION' => append_sid("modcp.$phpEx"),
 882                                          'S_HIDDEN_FIELDS' => $s_hidden_fields,
 883                                          'S_FORUM_SELECT' => make_forum_select("new_forum_id", false, $forum_id))
 884                                  );
 885                                          //

 886                                          // Define censored word matches

 887                                          //

 888                                          $orig_word = array();
 889                                          $replacement_word = array();
 890                                          obtain_word_list($orig_word, $replacement_word);
 891                                  for($i = 0; $i < $total_posts; $i++)
 892                                  {
 893                                          $post_id = $postrow[$i]['post_id'];
 894                                          $poster_id = $postrow[$i]['poster_id'];
 895                                          $poster = $postrow[$i]['username'];
 896  
 897                                          $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
 898  
 899                                          $bbcode_uid = $postrow[$i]['bbcode_uid'];
 900                                          $message = $postrow[$i]['post_text'];
 901                                          $post_subject = ( !empty($postrow[$i]['post_subject']) ) ? $postrow[$i]['post_subject'] : $topic_title;
 902  
 903                                          //

 904                                          // If the board has HTML off but the post has HTML

 905                                          // on then we process it, else leave it alone

 906                                          //

 907                                          if ( !$board_config['allow_html'] )
 908                                          {
 909                                                  if ( $postrow[$i]['enable_html'] )
 910                                                  {
 911                                                          $message = preg_replace('#(<)([\/]?.*?)(>)#is', '&lt;\\2&gt;', $message);
 912                                                  }
 913                                          }
 914  
 915                                          if ( !empty($bbcode_uid) )
 916                                          {
 917                                                  $message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
 918                                          }
 919  
 920                                          if ( count($orig_word) )
 921                                          {
 922                                                  $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
 923                                                  $message = preg_replace($orig_word, $replacement_word, $message);
 924                                          }
 925  
 926                                          $message = make_clickable($message);
 927  
 928                                          if ( $board_config['allow_smilies'] && $postrow[$i]['enable_smilies'] )
 929                                          {
 930                                                  $message = smilies_pass($message);
 931                                          }
 932  
 933                                          $message = str_replace("\n", '<br />', $message);
 934  
 935                                          $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
 936                                          $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
 937  
 938                                          $checkbox = ( $i > 0 ) ? '<input type="checkbox" name="post_id_list[]" value="' . $post_id . '" />' : '&nbsp;';
 939  
 940                                          $template->assign_block_vars('postrow', array(
 941                                                  'ROW_COLOR' => '#' . $row_color,
 942                                                  'ROW_CLASS' => $row_class,
 943                                                  'POSTER_NAME' => $poster,
 944                                                  'POST_DATE' => $post_date,
 945                                                  'POST_SUBJECT' => $post_subject,
 946                                                  'MESSAGE' => $message,
 947                                                  'POST_ID' => $post_id,
 948  
 949                                                  'S_SPLIT_CHECKBOX' => $checkbox)
 950                                          );
 951                                  }
 952  
 953                                  $template->pparse('split_body');
 954                          }
 955                  }
 956                  break;
 957  
 958          case 'ip':
 959                  $page_title = $lang['Mod_CP'];
 960                  include ("includes/page_header.php");
 961  
 962                  $rdns_ip_num = ( isset($HTTP_GET_VARS['rdns']) ) ? $HTTP_GET_VARS['rdns'] : "";
 963  
 964                  if ( !$post_id )
 965                  {
 966                          message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 967                  }
 968  
 969                  //

 970                  // Set template files

 971                  //

 972                  $template->set_filenames(array(
 973                          'viewip' => 'modcp_viewip.tpl')
 974                  );
 975  
 976                  // Look up relevent data for this post

 977                  $sql = "SELECT poster_ip, poster_id
 978                          FROM " . POSTS_TABLE . "
 979              WHERE post_id = '$post_id'
 980                  AND forum_id = '$forum_id'";
 981                  if ( !($result = $db->sql_query($sql)) )
 982                  {
 983                          message_die(GENERAL_ERROR, 'Could not get poster IP information', '', __LINE__, __FILE__, $sql);
 984                  }
 985  
 986                  if ( !($post_row = $db->sql_fetchrow($result)) )
 987                  {
 988                          message_die(GENERAL_MESSAGE, $lang['No_such_post']);
 989                  }
 990  
 991                  $ip_this_post = decode_ip($post_row['poster_ip']);
 992                  $ip_this_post = ( $rdns_ip_num == $ip_this_post ) ? gethostbyaddr($ip_this_post) : $ip_this_post;
 993  
 994                  $poster_id = $post_row['poster_id'];
 995  
 996                  $template->assign_vars(array(
 997                          'L_IP_INFO' => $lang['IP_info'],
 998                          'L_THIS_POST_IP' => $lang['This_posts_IP'],
 999                          'L_OTHER_IPS' => $lang['Other_IP_this_user'],
1000                          'L_OTHER_USERS' => $lang['Users_this_IP'],
1001                          'L_LOOKUP_IP' => $lang['Lookup_IP'],
1002                          'L_SEARCH' => $lang['Search'],
1003  
1004                          'SEARCH_IMG' => $images['icon_search'],
1005  
1006                          'IP' => $ip_this_post,
1007  
1008                          '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))
1009                  );
1010  
1011                  //

1012                  // Get other IP's this user has posted under

1013                  //

1014                  $sql = "SELECT poster_ip, COUNT(*) AS postings
1015                          FROM " . POSTS_TABLE . "
1016                          WHERE poster_id = '$poster_id'
1017                          GROUP BY poster_ip
1018                          ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
1019                  if ( !($result = $db->sql_query($sql)) )
1020                  {
1021                          message_die(GENERAL_ERROR, 'Could not get IP information for this user', '', __LINE__, __FILE__, $sql);
1022                  }
1023  
1024                  if ( $row = $db->sql_fetchrow($result) )
1025                  {
1026                          $i = 0;
1027                          do
1028                          {
1029                                  if ( $row['poster_ip'] == $post_row['poster_ip'] )
1030                                  {
1031                                          $template->assign_vars(array(
1032                                                  'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ))
1033                                          );
1034                                          continue;
1035                                  }
1036  
1037                                  $ip = decode_ip($row['poster_ip']);
1038                                  $ip = ( $rdns_ip_num == $row['poster_ip'] || $rdns_ip_num == 'all') ? gethostbyaddr($ip) : $ip;
1039  
1040                                  $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1041                                  $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1042  
1043                                  $template->assign_block_vars('iprow', array(
1044                                          'ROW_COLOR' => '#' . $row_color,
1045                                          'ROW_CLASS' => $row_class,
1046                                          'IP' => $ip,
1047                                          'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1048  
1049                                          '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']))
1050                                  );
1051  
1052                                  $i++;
1053                          }
1054                          while ( $row = $db->sql_fetchrow($result) );
1055                  }
1056  
1057                  //

1058                  // Get other users who've posted under this IP

1059                  //

1060                  $sql = "SELECT u.user_id, u.username, COUNT(*) as postings
1061                          FROM " . USERS_TABLE ." u, " . POSTS_TABLE . " p
1062                          WHERE p.poster_id = u.user_id
1063                                  AND p.poster_ip = '" . $post_row['poster_ip'] . "'
1064                          GROUP BY u.user_id, u.username
1065                          ORDER BY " . (( SQL_LAYER == 'msaccess' ) ? 'COUNT(*)' : 'postings' ) . " DESC";
1066                  if ( !($result = $db->sql_query($sql)) )
1067                  {
1068                          message_die(GENERAL_ERROR, 'Could not get posters information based on IP', '', __LINE__, __FILE__, $sql);
1069                  }
1070  
1071                  if ( $row = $db->sql_fetchrow($result) )
1072                  {
1073                          $i = 0;
1074                          do
1075                          {
1076                                  $id = $row['user_id'];
1077                                  $username = ( $id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
1078  
1079                                  $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1080                                  $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1081  
1082                                  $template->assign_block_vars('userrow', array(
1083                                          'ROW_COLOR' => '#' . $row_color,
1084                                          'ROW_CLASS' => $row_class,
1085                                          'USERNAME' => $username,
1086                                          'POSTS' => $row['postings'] . ' ' . ( ( $row['postings'] == 1 ) ? $lang['Post'] : $lang['Posts'] ),
1087                                          'L_SEARCH_POSTS' => sprintf($lang['Search_user_posts'], $username),
1088  
1089                                          'U_PROFILE' => append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$id"),
1090                                          'U_SEARCHPOSTS' => append_sid("search.$phpEx?search_author=" . urlencode($username) . "&amp;showresults=topics"))
1091                                  );
1092  
1093                                  $i++;
1094                          }
1095                          while ( $row = $db->sql_fetchrow($result) );
1096                  }
1097  
1098                  $template->pparse('viewip');
1099  
1100                  break;
1101  
1102          default:
1103                  $page_title = $lang['Mod_CP'];
1104                  include ("includes/page_header.php");
1105  
1106                  $template->assign_vars(array(
1107                          'FORUM_NAME' => $forum_name,
1108  
1109                          'L_MOD_CP' => $lang['Mod_CP'],
1110                          'L_MOD_CP_EXPLAIN' => $lang['Mod_CP_explain'],
1111                          'L_SELECT' => $lang['Select'],
1112                          'L_DELETE' => $lang['Delete'],
1113                          'L_MOVE' => $lang['Move'],
1114                          'L_LOCK' => $lang['Lock'],
1115                          'L_UNLOCK' => $lang['Unlock'],
1116                          'L_TOPICS' => $lang['Topics'],
1117                          'L_REPLIES' => $lang['Replies'],
1118                          'L_LASTPOST' => $lang['Last_Post'],
1119                          'L_SELECT' => $lang['Select'],
1120  
1121                          'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
1122                          'S_HIDDEN_FIELDS' => '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />',
1123                          'S_MODCP_ACTION' => append_sid("modcp.$phpEx"))
1124                  );
1125  
1126                  $template->set_filenames(array(
1127                          'body' => 'modcp_body.tpl')
1128                  );
1129                  make_jumpbox('modcp.'.$phpEx);
1130  
1131                  //

1132                  // Define censored word matches

1133                  //

1134                  $orig_word = array();
1135                  $replacement_word = array();
1136                  obtain_word_list($orig_word, $replacement_word);
1137  
1138                  $sql = "SELECT t.*, u.username, u.user_id, p.post_time
1139                          FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p
1140                          WHERE t.forum_id = '$forum_id'
1141                                  AND t.topic_poster = u.user_id
1142                                  AND p.post_id = t.topic_last_post_id
1143                          ORDER BY t.topic_type DESC, p.post_time DESC
1144                          LIMIT $start, " . $board_config['topics_per_page'];
1145                  if ( !($result = $db->sql_query($sql)) )
1146                  {
1147                             message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
1148                  }
1149  
1150                  while ( $row = $db->sql_fetchrow($result) )
1151                  {
1152                          $topic_title = '';
1153  
1154                          if ( $row['topic_status'] == TOPIC_LOCKED )
1155                          {
1156                                  $folder_img = $images['folder_locked'];
1157                                  $folder_alt = $lang['Topic_locked'];
1158                          }
1159                          else
1160                          {
1161                                  if ( $row['topic_type'] == POST_ANNOUNCE )
1162                                  {
1163                                          $folder_img = $images['folder_announce'];
1164                                          $folder_alt = $lang['Topic_Announcement'];
1165                                  }
1166                                  else if ( $row['topic_type'] == POST_STICKY )
1167                                  {
1168                                          $folder_img = $images['folder_sticky'];
1169                                          $folder_alt = $lang['Topic_Sticky'];
1170                                  }
1171                                  else
1172                                  {
1173                                          $folder_img = $images['folder'];
1174                                          $folder_alt = $lang['No_new_posts'];
1175                                  }
1176                          }
1177  
1178                          $topic_id = $row['topic_id'];
1179                          $topic_type = $row['topic_type'];
1180                          $topic_status = $row['topic_status'];
1181  
1182                          if ( $topic_type == POST_ANNOUNCE )
1183                          {
1184                                  $topic_type = $lang['Topic_Announcement'] . ' ';
1185                          }
1186                          else if ( $topic_type == POST_STICKY )
1187                          {
1188                                  $topic_type = $lang['Topic_Sticky'] . ' ';
1189                          }
1190                          else if ( $topic_status == TOPIC_MOVED )
1191                          {
1192                                  $topic_type = $lang['Topic_Moved'] . ' ';
1193                          }
1194                          else
1195                          {
1196                                  $topic_type = '';
1197                          }
1198  
1199                          if ( $row['topic_vote'] )
1200                          {
1201                                  $topic_type .= $lang['Topic_Poll'] . ' ';
1202                          }
1203  
1204                          $topic_title = $row['topic_title'];
1205                          if ( count($orig_word) )
1206                          {
1207                                  $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
1208                          }
1209  
1210                          $u_view_topic = append_sid("modcp.$phpEx?mode=split&amp;" . POST_TOPIC_URL . "=$topic_id");
1211                          $topic_replies = $row['topic_replies'];
1212  
1213                          $last_post_time = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
1214  
1215                          $template->assign_block_vars('topicrow', array(
1216                                  'U_VIEW_TOPIC' => $u_view_topic,
1217  
1218                                  'TOPIC_FOLDER_IMG' => $folder_img,
1219                                  'TOPIC_TYPE' => $topic_type,
1220                                  'TOPIC_TITLE' => $topic_title,
1221                                  'REPLIES' => $topic_replies,
1222                                  'LAST_POST_TIME' => $last_post_time,
1223                                  'TOPIC_ID' => $topic_id,
1224  
1225                                  'L_TOPIC_FOLDER_ALT' => $folder_alt)
1226                          );
1227                  }
1228  
1229                  $template->assign_vars(array(
1230                          'PAGINATION' => generate_pagination("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'], $forum_topics, $board_config['topics_per_page'], $start),
1231                          'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $forum_topics / $board_config['topics_per_page'] )),
1232                          'L_GOTO_PAGE' => $lang['Goto_page'])
1233                  );
1234  
1235                  $template->pparse('body');
1236  
1237                  break;
1238  }
1239  
1240  include ("includes/page_tail.php");
1241  
1242  ?>


Généré le : Sun Apr 1 11:11:59 2007 par Balluche grâce à PHPXref 0.7