(file) Return to modcp.php CVS log (file) (dir) Up to [RizwankCVS] / geekymedia_web / phpBB2

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

Rizwan Kassim
Powered by
ViewCVS 0.9.2