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

   1 rizwank 1.1 <?php
   2             /***************************************************************************
   3              *                               viewtopic.php
   4              *                            -------------------
   5              *   begin                : Saturday, Feb 13, 2001
   6              *   copyright            : (C) 2001 The phpBB Group
   7              *   email                : support@phpbb.com
   8              *
   9              *   $Id: viewtopic.php,v 1.186.2.23 2003/01/14 13:39:49 psotfx Exp $
  10              *
  11              *
  12              ***************************************************************************/
  13             
  14             /***************************************************************************
  15              *
  16              *   This program is free software; you can redistribute it and/or modify
  17              *   it under the terms of the GNU General Public License as published by
  18              *   the Free Software Foundation; either version 2 of the License, or
  19              *   (at your option) any later version.
  20              *
  21              ***************************************************************************/
  22 rizwank 1.1 
  23             define('IN_PHPBB', true);
  24             $phpbb_root_path = './';
  25             include($phpbb_root_path . 'extension.inc');
  26             include($phpbb_root_path . 'common.'.$phpEx);
  27             include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
  28             
  29             //
  30             // Start initial var setup
  31             //
  32             if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
  33             {
  34             	$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
  35             }
  36             else if ( isset($HTTP_GET_VARS['topic']) )
  37             {
  38             	$topic_id = intval($HTTP_GET_VARS['topic']);
  39             }
  40             
  41             if ( isset($HTTP_GET_VARS[POST_POST_URL]))
  42             {
  43 rizwank 1.1 	$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
  44             }
  45             
  46             $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
  47             
  48             if ( !isset($topic_id) && !isset($post_id) )
  49             {
  50             	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
  51             }
  52             
  53             //
  54             // Find topic id if user requested a newer
  55             // or older topic
  56             //
  57             if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
  58             {
  59             	if ( $HTTP_GET_VARS['view'] == 'newest' )
  60             	{
  61             		if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
  62             		{
  63             			$session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];
  64 rizwank 1.1 
  65             			if ( $session_id )
  66             			{
  67             				$sql = "SELECT p.post_id
  68             					FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s,  " . USERS_TABLE . " u
  69             					WHERE s.session_id = '$session_id'
  70             						AND u.user_id = s.session_user_id
  71             						AND p.topic_id = $topic_id
  72             						AND p.post_time >= u.user_lastvisit
  73             					ORDER BY p.post_time ASC
  74             					LIMIT 1";
  75             				if ( !($result = $db->sql_query($sql)) )
  76             				{
  77             					message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
  78             				}
  79             
  80             				if ( !($row = $db->sql_fetchrow($result)) )
  81             				{
  82             					message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
  83             				}
  84             
  85 rizwank 1.1 				$post_id = $row['post_id'];
  86             
  87             				if (isset($HTTP_GET_VARS['sid']))
  88             				{
  89             					redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
  90             				}
  91             				else
  92             				{
  93             					redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
  94             				}
  95             			}
  96             		}
  97             
  98             		redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
  99             	}
 100             	else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
 101             	{
 102             		$sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<';
 103             		$sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';
 104             
 105             		$sql = "SELECT t.topic_id
 106 rizwank 1.1 			FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2
 107             			WHERE t2.topic_id = $topic_id
 108             				AND p2.post_id = t2.topic_last_post_id
 109             				AND t.forum_id = t2.forum_id
 110             				AND p.post_id = t.topic_last_post_id
 111             				AND p.post_time $sql_condition p2.post_time
 112             				AND p.topic_id = t.topic_id
 113             			ORDER BY p.post_time $sql_ordering
 114             			LIMIT 1";
 115             		if ( !($result = $db->sql_query($sql)) )
 116             		{
 117             			message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
 118             		}
 119             
 120             		if ( $row = $db->sql_fetchrow($result) )
 121             		{
 122             			$topic_id = intval($row['topic_id']);
 123             		}
 124             		else
 125             		{
 126             			$message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
 127 rizwank 1.1 			message_die(GENERAL_MESSAGE, $message);
 128             		}
 129             	}
 130             }
 131             
 132             //
 133             // This rather complex gaggle of code handles querying for topics but
 134             // also allows for direct linking to a post (and the calculation of which
 135             // page the post is on and the correct display of viewtopic)
 136             //
 137             $join_sql_table = ( !isset($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
 138             $join_sql = ( !isset($post_id) ) ? "t.topic_id = $topic_id" : "p.post_id = $post_id AND t.topic_id = p.topic_id AND p2.topic_id = p.topic_id AND p2.post_id <= $post_id";
 139             $count_sql = ( !isset($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";
 140             
 141             $order_sql = ( !isset($post_id) ) ? '' : "GROUP BY p.post_id, t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments ORDER BY p.post_id ASC";
 142             
 143             $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
 144             	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
 145             	WHERE $join_sql
 146             		AND f.forum_id = t.forum_id
 147             		$order_sql";
 148 rizwank 1.1 if ( !($result = $db->sql_query($sql)) )
 149             {
 150             	message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
 151             }
 152             
 153             if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
 154             {
 155             	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
 156             }
 157             
 158             $forum_id = intval($forum_topic_data['forum_id']);
 159             
 160             //
 161             // Start session management
 162             //
 163             $userdata = session_pagestart($user_ip, $forum_id);
 164             init_userprefs($userdata);
 165             //
 166             // End session management
 167             //
 168             
 169 rizwank 1.1 //
 170             // Start auth check
 171             //
 172             $is_auth = array();
 173             $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
 174             
 175             if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
 176             {
 177             	if ( !$userdata['session_logged_in'] )
 178             	{
 179             		$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
 180             		$redirect .= ( isset($start) ) ? "&start=$start" : '';
 181             		redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
 182             	}
 183             
 184             	$message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
 185             
 186             	message_die(GENERAL_MESSAGE, $message);
 187             }
 188             //
 189             // End auth check
 190 rizwank 1.1 //
 191             
 192             $forum_name = $forum_topic_data['forum_name'];
 193             $topic_title = $forum_topic_data['topic_title'];
 194             $topic_id = intval($forum_topic_data['topic_id']);
 195             $topic_time = $forum_topic_data['topic_time'];
 196             
 197             if ( !empty($post_id) )
 198             {
 199             	$start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
 200             }
 201             
 202             //
 203             // Is user watching this thread?
 204             //
 205             if( $userdata['session_logged_in'] )
 206             {
 207             	$can_watch_topic = TRUE;
 208             
 209             	$sql = "SELECT notify_status
 210             		FROM " . TOPICS_WATCH_TABLE . "
 211 rizwank 1.1 		WHERE topic_id = $topic_id
 212             			AND user_id = " . $userdata['user_id'];
 213             	if ( !($result = $db->sql_query($sql)) )
 214             	{
 215             		message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql);
 216             	}
 217             
 218             	if ( $row = $db->sql_fetchrow($result) )
 219             	{
 220             		if ( isset($HTTP_GET_VARS['unwatch']) )
 221             		{
 222             			if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
 223             			{
 224             				$is_watching_topic = 0;
 225             
 226             				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
 227             				$sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . "
 228             					WHERE topic_id = $topic_id
 229             						AND user_id = " . $userdata['user_id'];
 230             				if ( !($result = $db->sql_query($sql)) )
 231             				{
 232 rizwank 1.1 					message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql);
 233             				}
 234             			}
 235             
 236             			$template->assign_vars(array(
 237             				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
 238             			);
 239             
 240             			$message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
 241             			message_die(GENERAL_MESSAGE, $message);
 242             		}
 243             		else
 244             		{
 245             			$is_watching_topic = TRUE;
 246             
 247             			if ( $row['notify_status'] )
 248             			{
 249             				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
 250             				$sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . "
 251             					SET notify_status = 0
 252             					WHERE topic_id = $topic_id
 253 rizwank 1.1 						AND user_id = " . $userdata['user_id'];
 254             				if ( !($result = $db->sql_query($sql)) )
 255             				{
 256             					message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql);
 257             				}
 258             			}
 259             		}
 260             	}
 261             	else
 262             	{
 263             		if ( isset($HTTP_GET_VARS['watch']) )
 264             		{
 265             			if ( $HTTP_GET_VARS['watch'] == 'topic' )
 266             			{
 267             				$is_watching_topic = TRUE;
 268             
 269             				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
 270             				$sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
 271             					VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
 272             				if ( !($result = $db->sql_query($sql)) )
 273             				{
 274 rizwank 1.1 					message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql);
 275             				}
 276             			}
 277             
 278             			$template->assign_vars(array(
 279             				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">')
 280             			);
 281             
 282             			$message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start") . '">', '</a>');
 283             			message_die(GENERAL_MESSAGE, $message);
 284             		}
 285             		else
 286             		{
 287             			$is_watching_topic = 0;
 288             		}
 289             	}
 290             }
 291             else
 292             {
 293             	if ( isset($HTTP_GET_VARS['unwatch']) )
 294             	{
 295 rizwank 1.1 		if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
 296             		{
 297             			redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
 298             		}
 299             	}
 300             	else
 301             	{
 302             		$can_watch_topic = 0;
 303             		$is_watching_topic = 0;
 304             	}
 305             }
 306             
 307             //
 308             // Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
 309             // then get it's value, find the number of topics with dates newer than it (to properly
 310             // handle pagination) and alter the main query
 311             //
 312             $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
 313             $previous_days_text = array($lang['All_Posts'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
 314             
 315             if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
 316 rizwank 1.1 {
 317             	$post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? $HTTP_POST_VARS['postdays'] : $HTTP_GET_VARS['postdays'];
 318             	$min_post_time = time() - (intval($post_days) * 86400);
 319             
 320             	$sql = "SELECT COUNT(p.post_id) AS num_posts
 321             		FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
 322             		WHERE t.topic_id = $topic_id
 323             			AND p.topic_id = t.topic_id
 324             			AND p.post_time >= $min_post_time";
 325             	if ( !($result = $db->sql_query($sql)) )
 326             	{
 327             		message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql);
 328             	}
 329             
 330             	$total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0;
 331             
 332             	$limit_posts_time = "AND p.post_time >= $min_post_time ";
 333             
 334             	if ( !empty($HTTP_POST_VARS['postdays']))
 335             	{
 336             		$start = 0;
 337 rizwank 1.1 	}
 338             }
 339             else
 340             {
 341             	$total_replies = intval($forum_topic_data['topic_replies']) + 1;
 342             
 343             	$limit_posts_time = '';
 344             	$post_days = 0;
 345             }
 346             
 347             $select_post_days = '<select name="postdays">';
 348             for($i = 0; $i < count($previous_days); $i++)
 349             {
 350             	$selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
 351             	$select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
 352             }
 353             $select_post_days .= '</select>';
 354             
 355             //
 356             // Decide how to order the post display
 357             //
 358 rizwank 1.1 if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) )
 359             {
 360             	$post_order = (!empty($HTTP_POST_VARS['postorder'])) ? $HTTP_POST_VARS['postorder'] : $HTTP_GET_VARS['postorder'];
 361             	$post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
 362             }
 363             else
 364             {
 365             	$post_order = 'asc';
 366             	$post_time_order = 'ASC';
 367             }
 368             
 369             $select_post_order = '<select name="postorder">';
 370             if ( $post_time_order == 'ASC' )
 371             {
 372             	$select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>';
 373             }
 374             else
 375             {
 376             	$select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>';
 377             }
 378             $select_post_order .= '</select>';
 379 rizwank 1.1 
 380             //
 381             // Go ahead and pull all data for this topic
 382             //
 383             $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
 384             	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
 385             	WHERE p.topic_id = $topic_id
 386             		$limit_posts_time
 387             		AND pt.post_id = p.post_id
 388             		AND u.user_id = p.poster_id
 389             	ORDER BY p.post_time $post_time_order
 390             	LIMIT $start, ".$board_config['posts_per_page'];
 391             if ( !($result = $db->sql_query($sql)) )
 392             {
 393             	message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
 394             }
 395             
 396             $postrow = array();
 397             if ($row = $db->sql_fetchrow($result))
 398             {
 399             	do
 400 rizwank 1.1 	{
 401             		$postrow[] = $row;
 402             	}
 403             	while ($row = $db->sql_fetchrow($result));
 404             	$db->sql_freeresult($result);
 405             
 406             	$total_posts = count($postrow);
 407             }
 408             else 
 409             { 
 410                include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
 411                sync('topic', $topic_id); 
 412             
 413                message_die(GENERAL_MESSAGE, $lang['No_posts_topic']); 
 414             } 
 415             
 416             $resync = FALSE; 
 417             if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow)) 
 418             { 
 419                $resync = TRUE; 
 420             } 
 421 rizwank 1.1 elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies']) 
 422             { 
 423                $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']); 
 424                if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies']) 
 425                { 
 426                   $resync = TRUE; 
 427                } 
 428             } 
 429             elseif (count($postrow) < $board_config['posts_per_page']) 
 430             { 
 431                $resync = TRUE; 
 432             } 
 433             
 434             if ($resync) 
 435             { 
 436                include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
 437                sync('topic', $topic_id); 
 438             
 439                $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id); 
 440                $row = $db->sql_fetchrow($result); 
 441                $total_replies = $row['total']; 
 442 rizwank 1.1 }
 443             
 444             $sql = "SELECT *
 445             	FROM " . RANKS_TABLE . "
 446             	ORDER BY rank_special, rank_min";
 447             if ( !($result = $db->sql_query($sql)) )
 448             {
 449             	message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
 450             }
 451             
 452             $ranksrow = array();
 453             while ( $row = $db->sql_fetchrow($result) )
 454             {
 455             	$ranksrow[] = $row;
 456             }
 457             $db->sql_freeresult($result);
 458             
 459             //
 460             // Define censored word matches
 461             //
 462             $orig_word = array();
 463 rizwank 1.1 $replacement_word = array();
 464             obtain_word_list($orig_word, $replacement_word);
 465             
 466             //
 467             // Censor topic title
 468             //
 469             if ( count($orig_word) )
 470             {
 471             	$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
 472             }
 473             
 474             //
 475             // Was a highlight request part of the URI?
 476             //
 477             $highlight_match = $highlight = '';
 478             if (isset($HTTP_GET_VARS['highlight']))
 479             {
 480             	// Split words and phrases
 481             	$words = explode(' ', trim(htmlspecialchars(urldecode($HTTP_GET_VARS['highlight']))));
 482             
 483             	for($i = 0; $i < sizeof($words); $i++)
 484 rizwank 1.1 	{
 485             		if (trim($words[$i]) != '')
 486             		{
 487             			$highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
 488             		}
 489             	}
 490             	unset($words);
 491             
 492             	$highlight = urlencode($HTTP_GET_VARS['highlight']);
 493             }
 494             
 495             //
 496             // Post, reply and other URL generation for
 497             // templating vars
 498             //
 499             $new_topic_url = append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id");
 500             $reply_topic_url = append_sid("posting.$phpEx?mode=reply&amp;" . POST_TOPIC_URL . "=$topic_id");
 501             $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
 502             $view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=previous");
 503             $view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=next");
 504             
 505 rizwank 1.1 //
 506             // Mozilla navigation bar
 507             //
 508             $nav_links['prev'] = array(
 509             	'url' => $view_prev_topic_url,
 510             	'title' => $lang['View_previous_topic']
 511             );
 512             $nav_links['next'] = array(
 513             	'url' => $view_next_topic_url,
 514             	'title' => $lang['View_next_topic']
 515             );
 516             $nav_links['up'] = array(
 517             	'url' => $view_forum_url,
 518             	'title' => $forum_name
 519             );
 520             
 521             $reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
 522             $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
 523             $post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
 524             $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
 525             
 526 rizwank 1.1 //
 527             // Set a cookie for this topic
 528             //
 529             if ( $userdata['session_logged_in'] )
 530             {
 531             	$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
 532             	$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
 533             
 534             	if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
 535             	{
 536             		$topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
 537             	}
 538             	else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
 539             	{
 540             		$topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
 541             	}
 542             	else
 543             	{
 544             		$topic_last_read = $userdata['user_lastvisit'];
 545             	}
 546             
 547 rizwank 1.1 	if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
 548             	{
 549             		asort($tracking_topics);
 550             		unset($tracking_topics[key($tracking_topics)]);
 551             	}
 552             
 553             	$tracking_topics[$topic_id] = time();
 554             
 555             	setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
 556             }
 557             
 558             //
 559             // Load templates
 560             //
 561             $template->set_filenames(array(
 562             	'body' => 'viewtopic_body.tpl')
 563             );
 564             make_jumpbox('viewforum.'.$phpEx, $forum_id);
 565             
 566             //
 567             // Output page header
 568 rizwank 1.1 //
 569             $page_title = $lang['View_topic'] .' - ' . $topic_title;
 570             include($phpbb_root_path . 'includes/page_header.'.$phpEx);
 571             
 572             //
 573             // User authorisation levels output
 574             //
 575             $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
 576             $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
 577             $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
 578             $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
 579             $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
 580             
 581             $topic_mod = '';
 582             
 583             if ( $is_auth['auth_mod'] )
 584             {
 585             	$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;sid=" . $userdata['session_id'] . '">', '</a>');
 586             
 587             	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=delete&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a>&nbsp;';
 588             
 589 rizwank 1.1 	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=move&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a>&nbsp;';
 590             
 591             	$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=lock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a>&nbsp;' : "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=unlock&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a>&nbsp;';
 592             
 593             	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;mode=split&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a>&nbsp;';
 594             }
 595             
 596             //
 597             // Topic watch information
 598             //
 599             $s_watching_topic = '';
 600             if ( $can_watch_topic )
 601             {
 602             	if ( $is_watching_topic )
 603             	{
 604             		$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['Stop_watching_topic'] . '</a>';
 605             		$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;unwatch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>' : '';
 606             	}
 607             	else
 608             	{
 609             		$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '">' . $lang['Start_watching_topic'] . '</a>';
 610 rizwank 1.1 		$s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;watch=topic&amp;start=$start&amp;sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Start_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>' : '';
 611             	}
 612             }
 613             
 614             //
 615             // If we've got a hightlight set pass it on to pagination,
 616             // I get annoyed when I lose my highlight after the first page.
 617             //
 618             $pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
 619             
 620             //
 621             // Send vars to template
 622             //
 623             $template->assign_vars(array(
 624             	'FORUM_ID' => $forum_id,
 625                 'FORUM_NAME' => $forum_name,
 626                 'TOPIC_ID' => $topic_id,
 627                 'TOPIC_TITLE' => $topic_title,
 628             	'PAGINATION' => $pagination,
 629             	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),
 630             
 631 rizwank 1.1 	'POST_IMG' => $post_img,
 632             	'REPLY_IMG' => $reply_img,
 633             
 634             	'L_AUTHOR' => $lang['Author'],
 635             	'L_MESSAGE' => $lang['Message'],
 636             	'L_POSTED' => $lang['Posted'],
 637             	'L_POST_SUBJECT' => $lang['Post_subject'],
 638             	'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
 639             	'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
 640             	'L_POST_NEW_TOPIC' => $post_alt,
 641             	'L_POST_REPLY_TOPIC' => $reply_alt,
 642             	'L_BACK_TO_TOP' => $lang['Back_to_top'],
 643             	'L_DISPLAY_POSTS' => $lang['Display_posts'],
 644             	'L_LOCK_TOPIC' => $lang['Lock_topic'],
 645             	'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
 646             	'L_MOVE_TOPIC' => $lang['Move_topic'],
 647             	'L_SPLIT_TOPIC' => $lang['Split_topic'],
 648             	'L_DELETE_TOPIC' => $lang['Delete_topic'],
 649             	'L_GOTO_PAGE' => $lang['Goto_page'],
 650             
 651             	'S_TOPIC_LINK' => POST_TOPIC_URL,
 652 rizwank 1.1 	'S_SELECT_POST_DAYS' => $select_post_days,
 653             	'S_SELECT_POST_ORDER' => $select_post_order,
 654             	'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&amp;start=$start"),
 655             	'S_AUTH_LIST' => $s_auth_can,
 656             	'S_TOPIC_ADMIN' => $topic_mod,
 657             	'S_WATCH_TOPIC' => $s_watching_topic,
 658             	'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
 659             
 660             	'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;start=$start&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight"),
 661             	'U_VIEW_FORUM' => $view_forum_url,
 662             	'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
 663             	'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
 664             	'U_POST_NEW_TOPIC' => $new_topic_url,
 665             	'U_POST_REPLY_TOPIC' => $reply_topic_url)
 666             );
 667             
 668             //
 669             // Does this topic contain a poll?
 670             //
 671             if ( !empty($forum_topic_data['topic_vote']) )
 672             {
 673 rizwank 1.1 	$s_hidden_fields = '';
 674             
 675             	$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
 676             		FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
 677             		WHERE vd.topic_id = $topic_id
 678             			AND vr.vote_id = vd.vote_id
 679             		ORDER BY vr.vote_option_id ASC";
 680             	if ( !($result = $db->sql_query($sql)) )
 681             	{
 682             		message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
 683             	}
 684             
 685             	if ( $vote_info = $db->sql_fetchrowset($result) )
 686             	{
 687             		$db->sql_freeresult($result);
 688             		$vote_options = count($vote_info);
 689             
 690             		$vote_id = $vote_info[0]['vote_id'];
 691             		$vote_title = $vote_info[0]['vote_text'];
 692             
 693             		$sql = "SELECT vote_id
 694 rizwank 1.1 			FROM " . VOTE_USERS_TABLE . "
 695             			WHERE vote_id = $vote_id
 696             				AND vote_user_id = " . $userdata['user_id'];
 697             		if ( !($result = $db->sql_query($sql)) )
 698             		{
 699             			message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
 700             		}
 701             
 702             		$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
 703             		$db->sql_freeresult($result);
 704             
 705             		if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
 706             		{
 707             			$view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
 708             		}
 709             		else
 710             		{
 711             			$view_result = 0;
 712             		}
 713             
 714             		$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
 715 rizwank 1.1 
 716             		if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
 717             		{
 718             			$template->set_filenames(array(
 719             				'pollbox' => 'viewtopic_poll_result.tpl')
 720             			);
 721             
 722             			$vote_results_sum = 0;
 723             
 724             			for($i = 0; $i < $vote_options; $i++)
 725             			{
 726             				$vote_results_sum += $vote_info[$i]['vote_result'];
 727             			}
 728             
 729             			$vote_graphic = 0;
 730             			$vote_graphic_max = count($images['voting_graphic']);
 731             
 732             			for($i = 0; $i < $vote_options; $i++)
 733             			{
 734             				$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
 735             				$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
 736 rizwank 1.1 
 737             				$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
 738             				$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
 739             
 740             				if ( count($orig_word) )
 741             				{
 742             					$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
 743             				}
 744             
 745             				$template->assign_block_vars("poll_option", array(
 746             					'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
 747             					'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
 748             					'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
 749             
 750             					'POLL_OPTION_IMG' => $vote_graphic_img,
 751             					'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
 752             				);
 753             			}
 754             
 755             			$template->assign_vars(array(
 756             				'L_TOTAL_VOTES' => $lang['Total_votes'],
 757 rizwank 1.1 				'TOTAL_VOTES' => $vote_results_sum)
 758             			);
 759             
 760             		}
 761             		else
 762             		{
 763             			$template->set_filenames(array(
 764             				'pollbox' => 'viewtopic_poll_ballot.tpl')
 765             			);
 766             
 767             			for($i = 0; $i < $vote_options; $i++)
 768             			{
 769             				if ( count($orig_word) )
 770             				{
 771             					$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
 772             				}
 773             
 774             				$template->assign_block_vars("poll_option", array(
 775             					'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
 776             					'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
 777             				);
 778 rizwank 1.1 			}
 779             
 780             			$template->assign_vars(array(
 781             				'L_SUBMIT_VOTE' => $lang['Submit_vote'],
 782             				'L_VIEW_RESULTS' => $lang['View_results'],
 783             
 784             				'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;vote=viewresult"))
 785             			);
 786             
 787             			$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
 788             		}
 789             
 790             		if ( count($orig_word) )
 791             		{
 792             			$vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
 793             		}
 794             
 795             		$s_hidden_fields = '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
 796             
 797             		$template->assign_vars(array(
 798             			'POLL_QUESTION' => $vote_title,
 799 rizwank 1.1 
 800             			'S_HIDDEN_FIELDS' => $s_hidden_fields,
 801             			'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&amp;" . POST_TOPIC_URL . "=$topic_id"))
 802             		);
 803             
 804             		$template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
 805             	}
 806             }
 807             
 808             //
 809             // Update the topic view counter
 810             //
 811             $sql = "UPDATE " . TOPICS_TABLE . "
 812             	SET topic_views = topic_views + 1
 813             	WHERE topic_id = $topic_id";
 814             if ( !$db->sql_query($sql) )
 815             {
 816             	message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
 817             }
 818             
 819             //
 820 rizwank 1.1 // Okay, let's do the loop, yeah come on baby let's do the loop
 821             // and it goes like this ...
 822             //
 823             for($i = 0; $i < $total_posts; $i++)
 824             {
 825             	$poster_id = $postrow[$i]['user_id'];
 826             	$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username'];
 827             
 828             	$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
 829             
 830             	$poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : '';
 831             
 832             	$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
 833             
 834             	$poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) : '';
 835             
 836             	$poster_avatar = '';
 837             	if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
 838             	{
 839             		switch( $postrow[$i]['user_avatar_type'] )
 840             		{
 841 rizwank 1.1 			case USER_AVATAR_UPLOAD:
 842             				$poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
 843             				break;
 844             			case USER_AVATAR_REMOTE:
 845             				$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
 846             				break;
 847             			case USER_AVATAR_GALLERY:
 848             				$poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
 849             				break;
 850             		}
 851             	}
 852             
 853             	//
 854             	// Define the little post icon
 855             	//
 856             	if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
 857             	{
 858             		$mini_post_img = $images['icon_minipost_new'];
 859             		$mini_post_alt = $lang['New_post'];
 860             	}
 861             	else
 862 rizwank 1.1 	{
 863             		$mini_post_img = $images['icon_minipost'];
 864             		$mini_post_alt = $lang['Post'];
 865             	}
 866             
 867             	$mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];
 868             
 869             	//
 870             	// Generate ranks, set them to empty string initially.
 871             	//
 872             	$poster_rank = '';
 873             	$rank_image = '';
 874             	if ( $postrow[$i]['user_id'] == ANONYMOUS )
 875             	{
 876             	}
 877             	else if ( $postrow[$i]['user_rank'] )
 878             	{
 879             		for($j = 0; $j < count($ranksrow); $j++)
 880             		{
 881             			if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
 882             			{
 883 rizwank 1.1 				$poster_rank = $ranksrow[$j]['rank_title'];
 884             				$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
 885             			}
 886             		}
 887             	}
 888             	else
 889             	{
 890             		for($j = 0; $j < count($ranksrow); $j++)
 891             		{
 892             			if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
 893             			{
 894             				$poster_rank = $ranksrow[$j]['rank_title'];
 895             				$rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
 896             			}
 897             		}
 898             	}
 899             
 900             	//
 901             	// Handle anon users posting with usernames
 902             	//
 903             	if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' )
 904 rizwank 1.1 	{
 905             		$poster = $postrow[$i]['post_username'];
 906             		$poster_rank = $lang['Guest'];
 907             	}
 908             
 909             	$temp_url = '';
 910             
 911             	if ( $poster_id != ANONYMOUS )
 912             	{
 913             		$temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
 914             		$profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
 915             		$profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';
 916             
 917             		$temp_url = append_sid("privmsg.$phpEx?mode=post&amp;" . POST_USERS_URL . "=$poster_id");
 918             		$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
 919             		$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
 920             
 921             		if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
 922             		{
 923             			$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&amp;" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
 924             
 925 rizwank 1.1 			$email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
 926             			$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
 927             		}
 928             		else
 929             		{
 930             			$email_img = '';
 931             			$email = '';
 932             		}
 933             
 934             		$www_img = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww"><img src="' . $images['icon_www'] . '" alt="' . $lang['Visit_website'] . '" title="' . $lang['Visit_website'] . '" border="0" /></a>' : '';
 935             		$www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
 936             
 937             		if ( !empty($postrow[$i]['user_icq']) )
 938             		{
 939             			$icq_status_img = '<a href="http://wwp.icq.com/' . $postrow[$i]['user_icq'] . '#pager"><img src="http://web.icq.com/whitepages/online?icq=' . $postrow[$i]['user_icq'] . '&img=5" width="18" height="18" border="0" /></a>';
 940             			$icq_img = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '"><img src="' . $images['icon_icq'] . '" alt="' . $lang['ICQ'] . '" title="' . $lang['ICQ'] . '" border="0" /></a>';
 941             			$icq =  '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . $lang['ICQ'] . '</a>';
 942             		}
 943             		else
 944             		{
 945             			$icq_status_img = '';
 946 rizwank 1.1 			$icq_img = '';
 947             			$icq = '';
 948             		}
 949             
 950             		$aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
 951             		$aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&amp;message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
 952             
 953             		$temp_url = append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=$poster_id");
 954             		$msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
 955             		$msn = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
 956             
 957             		$yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
 958             		$yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&amp;.src=pg">' . $lang['YIM'] . '</a>' : '';
 959             	}
 960             	else
 961             	{
 962             		$profile_img = '';
 963             		$profile = '';
 964             		$pm_img = '';
 965             		$pm = '';
 966             		$email_img = '';
 967 rizwank 1.1 		$email = '';
 968             		$www_img = '';
 969             		$www = '';
 970             		$icq_status_img = '';
 971             		$icq_img = '';
 972             		$icq = '';
 973             		$aim_img = '';
 974             		$aim = '';
 975             		$msn_img = '';
 976             		$msn = '';
 977             		$yim_img = '';
 978             		$yim = '';
 979             	}
 980             
 981             	$temp_url = append_sid("posting.$phpEx?mode=quote&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
 982             	$quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>';
 983             	$quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>';
 984             
 985             	$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&amp;showresults=posts");
 986             	$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
 987             	$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
 988 rizwank 1.1 
 989             	if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
 990             	{
 991             		$temp_url = append_sid("posting.$phpEx?mode=editpost&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
 992             		$edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
 993             		$edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
 994             	}
 995             	else
 996             	{
 997             		$edit_img = '';
 998             		$edit = '';
 999             	}
1000             
1001             	if ( $is_auth['auth_mod'] )
1002             	{
1003             		$temp_url = "modcp.$phpEx?mode=ip&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;" . POST_TOPIC_URL . "=" . $topic_id . "&amp;sid=" . $userdata['session_id'];
1004             		$ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
1005             		$ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>';
1006             
1007             		$temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
1008             		$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
1009 rizwank 1.1 		$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
1010             	}
1011             	else
1012             	{
1013             		$ip_img = '';
1014             		$ip = '';
1015             
1016             		if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
1017             		{
1018             			$temp_url = "posting.$phpEx?mode=delete&amp;" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&amp;sid=" . $userdata['session_id'];
1019             			$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
1020             			$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
1021             		}
1022             		else
1023             		{
1024             			$delpost_img = '';
1025             			$delpost = '';
1026             		}
1027             	}
1028             
1029             	$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
1030 rizwank 1.1 
1031             	$message = $postrow[$i]['post_text'];
1032             	$bbcode_uid = $postrow[$i]['bbcode_uid'];
1033             
1034             	$user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
1035             	$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
1036             
1037             	//
1038             	// Note! The order used for parsing the message _is_ important, moving things around could break any
1039             	// output
1040             	//
1041             
1042             	//
1043             	// If the board has HTML off but the post has HTML
1044             	// on then we process it, else leave it alone
1045             	//
1046             	if ( !$board_config['allow_html'] )
1047             	{
1048             		if ( $user_sig != '' && $userdata['user_allowhtml'] )
1049             		{
1050             			$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $user_sig);
1051 rizwank 1.1 		}
1052             
1053             		if ( $postrow[$i]['enable_html'] )
1054             		{
1055             			$message = preg_replace('#(<)([\/]?.*?)(>)#is', "&lt;\\2&gt;", $message);
1056             		}
1057             	}
1058             
1059             	//
1060             	// Parse message and/or sig for BBCode if reqd
1061             	//
1062             	if ( $board_config['allow_bbcode'] )
1063             	{
1064             		if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
1065             		{
1066             			$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
1067             		}
1068             
1069             		if ( $bbcode_uid != '' )
1070             		{
1071             			$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
1072 rizwank 1.1 		}
1073             	}
1074             
1075             	if ( $user_sig != '' )
1076             	{
1077             		$user_sig = make_clickable($user_sig);
1078             	}
1079             	$message = make_clickable($message);
1080             
1081             	//
1082             	// Parse smilies
1083             	//
1084             	if ( $board_config['allow_smilies'] )
1085             	{
1086             		if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' )
1087             		{
1088             			$user_sig = smilies_pass($user_sig);
1089             		}
1090             
1091             		if ( $postrow[$i]['enable_smilies'] )
1092             		{
1093 rizwank 1.1 			$message = smilies_pass($message);
1094             		}
1095             	}
1096             
1097             	//
1098             	// Highlight active words (primarily for search)
1099             	//
1100             	if ($highlight_match)
1101             	{
1102             		// This was shamelessly 'borrowed' from volker at multiartstudio dot de
1103             		// via php.net's annotated manual
1104             		$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace('#\b(" . $highlight_match . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
1105             	}
1106             
1107             	//
1108             	// Replace naughty words
1109             	//
1110             	if (count($orig_word))
1111             	{
1112             		$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
1113             
1114 rizwank 1.1 		if ($user_sig != '')
1115             		{
1116             			$user_sig = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
1117             		}
1118             
1119             		$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
1120             	}
1121             
1122             	//
1123             	// Replace newlines (we use this rather than nl2br because
1124             	// till recently it wasn't XHTML compliant)
1125             	//
1126             	if ( $user_sig != '' )
1127             	{
1128             		$user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
1129             	}
1130             
1131             	$message = str_replace("\n", "\n<br />\n", $message);
1132             
1133             	//
1134             	// Editing information
1135 rizwank 1.1 	//
1136             	if ( $postrow[$i]['post_edit_count'] )
1137             	{
1138             		$l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
1139             
1140             		$l_edited_by = '<br /><br />' . sprintf($l_edit_time_total, $poster, create_date($board_config['default_dateformat'], $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']);
1141             	}
1142             	else
1143             	{
1144             		$l_edited_by = '';
1145             	}
1146             
1147             	//
1148             	// Again this will be handled by the templating
1149             	// code at some point
1150             	//
1151             	$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1152             	$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1153             
1154             	$template->assign_block_vars('postrow', array(
1155             		'ROW_COLOR' => '#' . $row_color,
1156 rizwank 1.1 		'ROW_CLASS' => $row_class,
1157             		'POSTER_NAME' => $poster,
1158             		'POSTER_RANK' => $poster_rank,
1159             		'RANK_IMAGE' => $rank_image,
1160             		'POSTER_JOINED' => $poster_joined,
1161             		'POSTER_POSTS' => $poster_posts,
1162             		'POSTER_FROM' => $poster_from,
1163             		'POSTER_AVATAR' => $poster_avatar,
1164             		'POST_DATE' => $post_date,
1165             		'POST_SUBJECT' => $post_subject,
1166             		'MESSAGE' => $message,
1167             		'SIGNATURE' => $user_sig,
1168             		'EDITED_MESSAGE' => $l_edited_by,
1169             
1170             		'MINI_POST_IMG' => $mini_post_img,
1171             		'PROFILE_IMG' => $profile_img,
1172             		'PROFILE' => $profile,
1173             		'SEARCH_IMG' => $search_img,
1174             		'SEARCH' => $search,
1175             		'PM_IMG' => $pm_img,
1176             		'PM' => $pm,
1177 rizwank 1.1 		'EMAIL_IMG' => $email_img,
1178             		'EMAIL' => $email,
1179             		'WWW_IMG' => $www_img,
1180             		'WWW' => $www,
1181             		'ICQ_STATUS_IMG' => $icq_status_img,
1182             		'ICQ_IMG' => $icq_img,
1183             		'ICQ' => $icq,
1184             		'AIM_IMG' => $aim_img,
1185             		'AIM' => $aim,
1186             		'MSN_IMG' => $msn_img,
1187             		'MSN' => $msn,
1188             		'YIM_IMG' => $yim_img,
1189             		'YIM' => $yim,
1190             		'EDIT_IMG' => $edit_img,
1191             		'EDIT' => $edit,
1192             		'QUOTE_IMG' => $quote_img,
1193             		'QUOTE' => $quote,
1194             		'IP_IMG' => $ip_img,
1195             		'IP' => $ip,
1196             		'DELETE_IMG' => $delpost_img,
1197             		'DELETE' => $delpost,
1198 rizwank 1.1 
1199             		'L_MINI_POST_ALT' => $mini_post_alt,
1200             
1201             		'U_MINI_POST' => $mini_post_url,
1202             		'U_POST_ID' => $postrow[$i]['post_id'])
1203             	);
1204             }
1205             
1206             $template->pparse('body');
1207             
1208             include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
1209             
1210             ?>

Rizwan Kassim
Powered by
ViewCVS 0.9.2