[ABD] Profile Control Panel

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
260
60%
Very Good
81
19%
Good
43
10%
Fair
9
2%
Poor
41
9%
 
Total votes: 434

Jams44
Registered User
Posts: 31
Joined: Mon Feb 28, 2005 11:07 pm

Two Things

Post by Jams44 »

Two Things-

1. After Installing The PCP, I noticed in all the viewtopics, the Author/RAnk/Evrything Else Doesn't Appear. Here is a Link- http://xvisionz.net/forum/viewtopic.php?t=2

and here is the code-

Code: Select all

<?php
//-- mod : profile cp ------------------------------------------------------------------------------
/***************************************************************************
 *                               viewtopic.php
 *                            -------------------
 *   begin                : Saturday, Feb 13, 2001
 *   copyright            : (C) 2001 The phpBB Group
 *   email                : support@phpbb.com
 *
 *   $Id: viewtopic.php,v 1.186.2.42 2005/06/26 14:18:00 acydburn Exp $
 *
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);
include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
include($phpbb_root_path . 'profilcp/functions_profile.'.$phpEx);
//-- fin mod : profile cp --------------------------------------------------------------------------

//
// Start initial var setup
//
$topic_id = $post_id = 0;
if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
{
	$topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
}
else if ( isset($HTTP_GET_VARS['topic']) )
{
	$topic_id = intval($HTTP_GET_VARS['topic']);
}

if ( isset($HTTP_GET_VARS[POST_POST_URL]))
{
	$post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}


$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;

if ( !isset($topic_id) && !isset($post_id) )
{
	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}

//
// Find topic id if user requested a newer
// or older topic
//
if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{
	if ( $HTTP_GET_VARS['view'] == 'newest' )
	{
		if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
		{
			$session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];

			if (!preg_match('/^[A-Za-z0-9]*$/', $session_id)) 
			{
				$session_id = '';
			}

			if ( $session_id )
			{
				$sql = "SELECT p.post_id
					FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s,  " . USERS_TABLE . " u
					WHERE s.session_id = '$session_id'
						AND u.user_id = s.session_user_id
						AND p.topic_id = $topic_id
						AND p.post_time >= u.user_lastvisit
					ORDER BY p.post_time ASC
					LIMIT 1";
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
				}

				if ( !($row = $db->sql_fetchrow($result)) )
				{
					message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
				}

				$post_id = $row['post_id'];

				if (isset($HTTP_GET_VARS['sid']))
				{
					redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
				}
				else
				{
					redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
				}
			}
		}

		redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
	}
	else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
	{
		$sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<';
		$sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';

		$sql = "SELECT t.topic_id
			FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
			WHERE
				t2.topic_id = $topic_id
				AND t.forum_id = t2.forum_id
				AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
			ORDER BY t.topic_last_post_id $sql_ordering
			LIMIT 1";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
		}

		if ( $row = $db->sql_fetchrow($result) )
		{
			$topic_id = intval($row['topic_id']);
		}
		else
		{
			$message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
			message_die(GENERAL_MESSAGE, $message);
		}
	}
}

//
// This rather complex gaggle of code handles querying for topics but
// also allows for direct linking to a post (and the calculation of which
// page the post is on and the correct display of viewtopic)
//
$join_sql_table = ( empty($post_id) ) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = ( empty($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";
$count_sql = ( empty($post_id) ) ? '' : ", COUNT(p2.post_id) AS prev_posts";

$order_sql = ( empty($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";

$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 . "
	FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
	WHERE $join_sql
		AND f.forum_id = t.forum_id
		$order_sql";
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
}

if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
{
	message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}

$forum_id = intval($forum_topic_data['forum_id']);

//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
//
// End session management
//

//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);

if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
{
	if ( !$userdata['session_logged_in'] )
	{
		$redirect = ( isset($post_id) ) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
		$redirect .= ( isset($start) ) ? "&start=$start" : '';
		redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
	}

	$message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);

	message_die(GENERAL_MESSAGE, $message);
}
//
// End auth check
//

$forum_name = $forum_topic_data['forum_name'];
$topic_title = $forum_topic_data['topic_title'];
$topic_id = intval($forum_topic_data['topic_id']);
$topic_time = $forum_topic_data['topic_time'];

if ( !empty($post_id) )
{
	$start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
}

//
// Is user watching this thread?
//
if( $userdata['session_logged_in'] )
{
	$can_watch_topic = TRUE;

	$sql = "SELECT notify_status
		FROM " . TOPICS_WATCH_TABLE . "
		WHERE topic_id = $topic_id
			AND user_id = " . $userdata['user_id'];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql);
	}

	if ( $row = $db->sql_fetchrow($result) )
	{
		if ( isset($HTTP_GET_VARS['unwatch']) )
		{
			if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
			{
				$is_watching_topic = 0;

				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
				$sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . "
					WHERE topic_id = $topic_id
						AND user_id = " . $userdata['user_id'];
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql);
				}
			}

			$template->assign_vars(array(
				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">')
			);

			$message = $lang['No_longer_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		}
		else
		{
			$is_watching_topic = TRUE;

			if ( $row['notify_status'] )
			{
				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
				$sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . "
					SET notify_status = 0
					WHERE topic_id = $topic_id
						AND user_id = " . $userdata['user_id'];
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql);
				}
			}
		}
	}
	else
	{
		if ( isset($HTTP_GET_VARS['watch']) )
		{
			if ( $HTTP_GET_VARS['watch'] == 'topic' )
			{
				$is_watching_topic = TRUE;

				$sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
				$sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
					VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql);
				}
			}

			$template->assign_vars(array(
				'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">')
			);

			$message = $lang['You_are_watching'] . '<br /><br />' . sprintf($lang['Click_return_topic'], '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">', '</a>');
			message_die(GENERAL_MESSAGE, $message);
		}
		else
		{
			$is_watching_topic = 0;
		}
	}
}
else
{
	if ( isset($HTTP_GET_VARS['unwatch']) )
	{
		if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
		{
			redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
		}
	}
	else
	{
		$can_watch_topic = 0;
		$is_watching_topic = 0;
	}
}

//
// Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
// then get it's value, find the number of topics with dates newer than it (to properly
// handle pagination) and alter the main query
//
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
$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']);

if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
{
	$post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? intval($HTTP_POST_VARS['postdays']) : intval($HTTP_GET_VARS['postdays']);
	$min_post_time = time() - (intval($post_days) * 86400);

	$sql = "SELECT COUNT(p.post_id) AS num_posts
		FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
		WHERE t.topic_id = $topic_id
			AND p.topic_id = t.topic_id
			AND p.post_time >= $min_post_time";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql);
	}

	$total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0;

	$limit_posts_time = "AND p.post_time >= $min_post_time ";

	if ( !empty($HTTP_POST_VARS['postdays']))
	{
		$start = 0;
	}
}
else
{
	$total_replies = intval($forum_topic_data['topic_replies']) + 1;

	$limit_posts_time = '';
	$post_days = 0;
}

$select_post_days = '<select name="postdays">';
for($i = 0; $i < count($previous_days); $i++)
{
	$selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
	$select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
}
$select_post_days .= '</select>';

//
// Decide how to order the post display
//
if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) )
{
	$post_order = (!empty($HTTP_POST_VARS['postorder'])) ? htmlspecialchars($HTTP_POST_VARS['postorder']) : htmlspecialchars($HTTP_GET_VARS['postorder']);
	$post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
}
else
{
	$post_order = 'asc';
	$post_time_order = 'ASC';
}

$select_post_order = '<select name="postorder">';
if ( $post_time_order == 'ASC' )
{
	$select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>';
}
else
{
	$select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>';
}
$select_post_order .= '</select>';

//
// Go ahead and pull all data for this topic
//
//-- mod : profile cp ------------------------------------------------------------------------------
//-- delete
// $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
//-- add
$sql = "SELECT u.*, p.*,  pt.post_text, pt.post_subject, pt.bbcode_uid
	FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
	WHERE p.topic_id = $topic_id
		$limit_posts_time
		AND pt.post_id = p.post_id
		AND u.user_id = p.poster_id
	ORDER BY p.post_time $post_time_order
	LIMIT $start, ".$board_config['posts_per_page'];
	//-- fin mod : profile cp --------------------------------------------------------------------------
if ( !($result = $db->sql_query($sql)) )
{
	message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
}

//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
$user_ids = array();
//-- fin mod : profile cp --------------------------------------------------------------------------
$postrow = array();
if ($row = $db->sql_fetchrow($result))
{
	do
	{
		$postrow[] = $row;
		//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
		$user_ids[] = $row['user_id'];
//-- fin mod : profile cp --------------------------------------------------------------------------
	}
	while ($row = $db->sql_fetchrow($result));
	$db->sql_freeresult($result);

	$total_posts = count($postrow);
}
else 
{ 
   include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
   sync('topic', $topic_id); 

   message_die(GENERAL_MESSAGE, $lang['No_posts_topic']); 
} 

$resync = FALSE; 
if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow)) 
{ 
   $resync = TRUE; 
} 
elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies']) 
{ 
   $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']); 
   if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies']) 
   { 
      $resync = TRUE; 
   } 
} 
elseif (count($postrow) < $board_config['posts_per_page']) 
{ 
   $resync = TRUE; 
} 

if ($resync) 
{ 
   include($phpbb_root_path . 'includes/functions_admin.' . $phpEx); 
   sync('topic', $topic_id); 

   $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id); 
   $row = $db->sql_fetchrow($result); 
   $total_replies = $row['total']; 
}

//-- mod : profile cp ------------------------------------------------------------------------------
//-- delete
// $sql = "SELECT *
//	FROM " . RANKS_TABLE . "
//	ORDER BY rank_special, rank_min";
// if ( !($result = $db->sql_query($sql)) )
// {
//	message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
// }
//
// $ranksrow = array();
// while ( $row = $db->sql_fetchrow($result) )
// {
//	$ranksrow[] = $row;
// }
// $db->sql_freeresult($result);
//-- add
$buddys = array();
if (count($user_ids) > 0)
{
	$s_user_ids = implode(', ', $user_ids);

	// get base info
	$sql = "SELECT * FROM " . BUDDYS_TABLE . " WHERE user_id=" . $userdata['user_id'] . " and buddy_id in ($s_user_ids)";
	if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Could not obtain buddys information.", '', __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		$buddys[ $row['buddy_id'] ]['buddy_my_ignore'] = $row['buddy_ignore'];
		$buddys[ $row['buddy_id'] ]['buddy_my_friend'] = !$row['buddy_ignore'];
		$buddys[ $row['buddy_id'] ]['buddy_friend'] = false;
		$buddys[ $row['buddy_id'] ]['buddy_visible'] = false;
	}

	// check if in the topic author's friend list and "always visible" status he granted
	$sql = "SELECT * FROM " . BUDDYS_TABLE . " WHERE buddy_id=" . $userdata['user_id'] . " and user_id in ($s_user_ids)";
	if ( !($result = $db->sql_query($sql)) ) message_die(GENERAL_ERROR, "Could not obtain buddys information.", '', __LINE__, __FILE__, $sql);
	while ( $row = $db->sql_fetchrow($result) )
	{
		if ( !isset($buddys[ $row['user_id'] ]) ) $buddys[ $row['user_id'] ]['buddy_my_ignore'] = false;
		if ( !isset($buddys[ $row['user_id'] ]) ) $buddys[ $row['user_id'] ]['buddy_my_friend'] = false;
		$buddys[ $row['user_id'] ]['buddy_friend'] = !$row['buddy_ignore'];
		$buddys[ $row['user_id'] ]['buddy_visible'] = $row['buddy_visible'];
	}
}
//-- fin mod : profile cp --------------------------------------------------------------------------

//
// Define censored word matches
//
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);

//
// Censor topic title
//
if ( count($orig_word) )
{
	$topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
}

//
// Was a highlight request part of the URI?
//
$highlight_match = $highlight = '';
if (isset($HTTP_GET_VARS['highlight']))
{
	// Split words and phrases
	$words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));

	for($i = 0; $i < sizeof($words); $i++)
	{
		if (trim($words[$i]) != '')
		{
			$highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', phpbb_preg_quote($words[$i], '#'));
		}
	}
	unset($words);

	$highlight = urlencode($HTTP_GET_VARS['highlight']);
	$highlight_match = phpbb_rtrim($highlight_match, "\\");
}

//
// Post, reply and other URL generation for
// templating vars
//
$new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id");
$reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id");
$view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous");
$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next");

//
// Mozilla navigation bar
//
$nav_links['prev'] = array(
	'url' => $view_prev_topic_url,
	'title' => $lang['View_previous_topic']
);
$nav_links['next'] = array(
	'url' => $view_next_topic_url,
	'title' => $lang['View_next_topic']
);
$nav_links['up'] = array(
	'url' => $view_forum_url,
	'title' => $forum_name
);

$reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
$reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
$post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
$post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];

//
// Set a cookie for this topic
//
if ( $userdata['session_logged_in'] )
{
	$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
	$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();

	if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
	{
		$topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
	}
	else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
	{
		$topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
	}
	else
	{
		$topic_last_read = $userdata['user_lastvisit'];
	}

	if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
	{
		asort($tracking_topics);
		unset($tracking_topics[key($tracking_topics)]);
	}

	$tracking_topics[$topic_id] = time();

	setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
}

//
// Load templates
//
$template->set_filenames(array(
	'body' => 'viewtopic_body.tpl')
);
make_jumpbox('viewforum.'.$phpEx, $forum_id);

//
// Output page header
//
$page_title = $lang['View_topic'] .' - ' . $topic_title;
include($phpbb_root_path . 'includes/page_header.'.$phpEx);

//
// User authorisation levels output
//
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';

$topic_mod = '';

if ( $is_auth['auth_mod'] )
{
	$s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>');

	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a>&nbsp;';

	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a>&nbsp;';

	$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock&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&mode=unlock&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a>&nbsp;';

	$topic_mod .= "<a href=\"modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=split&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a>&nbsp;';
}

//
// Topic watch information
//
$s_watching_topic = '';
if ( $can_watch_topic )
{
	if ( $is_watching_topic )
	{
		$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start&sid=" . $userdata['session_id'] . '">' . $lang['Stop_watching_topic'] . '</a>';
		$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>' : '';
	}
	else
	{
		$s_watching_topic = "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start&sid=" . $userdata['session_id'] . '">' . $lang['Start_watching_topic'] . '</a>';
		$s_watching_topic_img = ( isset($images['Topic_watch']) ) ? "<a href=\"viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start&sid=" . $userdata['session_id'] . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Start_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>' : '';
	}
}

//
// If we've got a hightlight set pass it on to pagination,
// I get annoyed when I lose my highlight after the first page.
//
$pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);

//
// Send vars to template
//
$template->assign_vars(array(
	'FORUM_ID' => $forum_id,
    'FORUM_NAME' => $forum_name,
    'TOPIC_ID' => $topic_id,
    'TOPIC_TITLE' => $topic_title,
	'PAGINATION' => $pagination,
	'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),

	'POST_IMG' => $post_img,
	'REPLY_IMG' => $reply_img,

	'L_AUTHOR' => $lang['Author'],
	'L_MESSAGE' => $lang['Message'],
	'L_POSTED' => $lang['Posted'],
	'L_POST_SUBJECT' => $lang['Post_subject'],
	'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
	'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
	'L_POST_NEW_TOPIC' => $post_alt,
	'L_POST_REPLY_TOPIC' => $reply_alt,
	'L_BACK_TO_TOP' => $lang['Back_to_top'],
	'L_DISPLAY_POSTS' => $lang['Display_posts'],
	'L_LOCK_TOPIC' => $lang['Lock_topic'],
	'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
	'L_MOVE_TOPIC' => $lang['Move_topic'],
	'L_SPLIT_TOPIC' => $lang['Split_topic'],
	'L_DELETE_TOPIC' => $lang['Delete_topic'],
	'L_GOTO_PAGE' => $lang['Goto_page'],

	'S_TOPIC_LINK' => POST_TOPIC_URL,
	'S_SELECT_POST_DAYS' => $select_post_days,
	'S_SELECT_POST_ORDER' => $select_post_order,
	'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&start=$start"),
	'S_AUTH_LIST' => $s_auth_can,
	'S_TOPIC_ADMIN' => $topic_mod,
	'S_WATCH_TOPIC' => $s_watching_topic,
	'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,

	'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&highlight=$highlight"),
	'U_VIEW_FORUM' => $view_forum_url,
	'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
	'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
	'U_POST_NEW_TOPIC' => $new_topic_url,
	'U_POST_REPLY_TOPIC' => $reply_topic_url)
);

//
// Does this topic contain a poll?
//
if ( !empty($forum_topic_data['topic_vote']) )
{
	$s_hidden_fields = '';

	$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
		FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
		WHERE vd.topic_id = $topic_id
			AND vr.vote_id = vd.vote_id
		ORDER BY vr.vote_option_id ASC";
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
	}

	if ( $vote_info = $db->sql_fetchrowset($result) )
	{
		$db->sql_freeresult($result);
		$vote_options = count($vote_info);

		$vote_id = $vote_info[0]['vote_id'];
		$vote_title = $vote_info[0]['vote_text'];

		$sql = "SELECT vote_id
			FROM " . VOTE_USERS_TABLE . "
			WHERE vote_id = $vote_id
				AND vote_user_id = " . intval($userdata['user_id']);
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
		}

		$user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
		$db->sql_freeresult($result);

		if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
		{
			$view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
		}
		else
		{
			$view_result = 0;
		}

		$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;

		if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
		{
			$template->set_filenames(array(
				'pollbox' => 'viewtopic_poll_result.tpl')
			);

			$vote_results_sum = 0;

			for($i = 0; $i < $vote_options; $i++)
			{
				$vote_results_sum += $vote_info[$i]['vote_result'];
			}

			$vote_graphic = 0;
			$vote_graphic_max = count($images['voting_graphic']);

			for($i = 0; $i < $vote_options; $i++)
			{
				$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
				$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);

				$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
				$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;

				if ( count($orig_word) )
				{
					$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
				}

				$template->assign_block_vars("poll_option", array(
					'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
					'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
					'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),

					'POLL_OPTION_IMG' => $vote_graphic_img,
					'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
				);
			}

			$template->assign_vars(array(
				'L_TOTAL_VOTES' => $lang['Total_votes'],
				'TOTAL_VOTES' => $vote_results_sum)
			);

		}
		else
		{
			$template->set_filenames(array(
				'pollbox' => 'viewtopic_poll_ballot.tpl')
			);

			for($i = 0; $i < $vote_options; $i++)
			{
				if ( count($orig_word) )
				{
					$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
				}

				$template->assign_block_vars("poll_option", array(
					'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
					'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
				);
			}

			$template->assign_vars(array(
				'L_SUBMIT_VOTE' => $lang['Submit_vote'],
				'L_VIEW_RESULTS' => $lang['View_results'],

				'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult"))
			);

			$s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
		}

		if ( count($orig_word) )
		{
			$vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
		}

		$s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';

		$template->assign_vars(array(
			'POLL_QUESTION' => $vote_title,

			'S_HIDDEN_FIELDS' => $s_hidden_fields,
			'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&" . POST_TOPIC_URL . "=$topic_id"))
		);

		$template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
	}
}

//
// Update the topic view counter
//
$sql = "UPDATE " . TOPICS_TABLE . "
	SET topic_views = topic_views + 1
	WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}

//
// Okay, let's do the loop, yeah come on baby let's do the loop
// and it goes like this ...
//
for($i = 0; $i < $total_posts; $i++)
{
//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
	$author_panel = '';
	$postrow[$i]['user_friend']		= $buddys[ $postrow[$i]['user_id'] ]['buddy_friend'];
	$postrow[$i]['user_visible']	= $buddys[ $postrow[$i]['user_id'] ]['buddy_visible'];
	$postrow[$i]['user_my_friend']	= $buddys[ $postrow[$i]['user_id'] ]['buddy_my_friend'];
	$postrow[$i]['user_my_ignore']	= $buddys[ $postrow[$i]['user_id'] ]['buddy_my_ignore'];
	$postrow[$i]['user_online']		= ( $postrow[$i]['user_session_time'] >= (time()-300) );
	$postrow[$i]['user_pm'] = 1;

	// sig
	if (!$userdata['user_viewsig'] || !$postrow[$i]['user_allow_sig'])
	{
		$postrow[$i]['user_sig'] = '';
	}

	// get the panels
	$author_panel	= pcp_output_panel('PHPBB.viewtopic.left', $postrow[$i]);
	$buttons_panel	= pcp_output_panel('PHPBB.viewtopic.buttons', $postrow[$i]);
	$ignore_panel	= pcp_output_panel('PHPBB.viewtopic.left.ignore', $postrow[$i]);
	$ignore_buttons	= pcp_output_panel('PHPBB.viewtopic.buttons.ignore', $postrow[$i]);
//-- fin mod : profile cp --------------------------------------------------------------------------
	$poster_id = $postrow[$i]['user_id'];
	$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username'];

	$post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);

	//
	// Define the little post icon
	//
	if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
	{
		$mini_post_img = $images['icon_minipost_new'];
		$mini_post_alt = $lang['New_post'];
	}
	else
	{
		$mini_post_img = $images['icon_minipost'];
		$mini_post_alt = $lang['Post'];
	}

	$mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];

	$temp_url = append_sid("posting.$phpEx?mode=quote&" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
	$quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>';
	$quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>';

	$temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&showresults=posts");
	$search_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_search'] . '" alt="' . $lang['Search_user_posts'] . '" title="' . $lang['Search_user_posts'] . '" border="0" /></a>';
	$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';

	if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
	{
		$temp_url = append_sid("posting.$phpEx?mode=editpost&" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
		$edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
		$edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
	}
	else
	{
		$edit_img = '';
		$edit = '';
	}

	if ( $is_auth['auth_mod'] )
	{
		$temp_url = "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id'];
		$ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
		$ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>';

		$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
		$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
		$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
	}
	else
	{
		$ip_img = '';
		$ip = '';

		if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
		{
			$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
			$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
			$delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
		}
		else
		{
			$delpost_img = '';
			$delpost = '';
		}
	}

	$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';

	$message = $postrow[$i]['post_text'];
	$bbcode_uid = $postrow[$i]['bbcode_uid'];

	$user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
	$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
	$rabbitoshi_link = append_sid("rabbitoshi.$phpEx?" . POST_USERS_URL . "=" . $postrow[$i]['user_id']);

	//
	// Note! The order used for parsing the message _is_ important, moving things around could break any
	// output
	//

	//
	// If the board has HTML off but the post has HTML
	// on then we process it, else leave it alone
	//
	if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
	{
		if ( $user_sig != '' )
		{
			$user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
		}

		if ( $postrow[$i]['enable_html'] )
		{
			$message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message);
		}
	}

	//
	// Parse message and/or sig for BBCode if reqd
	//
	if ( $board_config['allow_bbcode'] )
	{
		if ( $user_sig != '' && $user_sig_bbcode_uid != '' )
		{
			$user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $user_sig);
		}

		if ( $bbcode_uid != '' )
		{
			$message = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
		}
	}

	if ( $user_sig != '' )
	{
		$user_sig = make_clickable($user_sig);
	}
	$message = make_clickable($message);

	//
	// Parse smilies
	//
	if ( $board_config['allow_smilies'] )
	{
		if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' )
		{
			$user_sig = smilies_pass($user_sig);
		}

		if ( $postrow[$i]['enable_smilies'] )
		{
			$message = smilies_pass($message);
		}
	}

	//
	// Highlight active words (primarily for search)
	//
	if ($highlight_match)
	{
		// This was shamelessly 'borrowed' from volker at multiartstudio dot de
		// via php.net's annotated manual
		$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
	}

	//
	// Replace naughty words
	//
	if (count($orig_word))
	{
		$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);

		if ($user_sig != '')
		{
			$user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
		}

		$message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
	}

	//
	// Replace newlines (we use this rather than nl2br because
	// till recently it wasn't XHTML compliant)
	//
	if ( $user_sig != '' )
	{
		$user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
	}

	$message = str_replace("\n", "\n<br />\n", $message);

	//
	// Editing information
	//
	if ( $postrow[$i]['post_edit_count'] )
	{
		$l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];

		$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']);
	}
	else
	{
		$l_edited_by = '';
	}

	//
	// Again this will be handled by the templating
	// code at some point
	//
	$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
	$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];

	$template->assign_block_vars('postrow', array(
	//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
		'POST_ID' => $postrow[$i]['post_id'],
		'AUTHOR_PANEL'	=> $postrow[$i]['user_my_ignore'] ? $ignore_panel : $author_panel,
		'BUTTONS_PANEL'	=> $buttons_panel,
		'IGNORE_IMG'	=> $ignore_buttons,
//-- fin mod : profile cp --------------------------------------------------------------------------
		'ROW_COLOR' => '#' . $row_color,
		'ROW_CLASS' => $row_class,
		'RABBITOSHI_LINK' => $rabbitoshi_link,
		'POST_DATE' => $post_date,
		'POST_SUBJECT' => $post_subject,
		'MESSAGE' => $message,
		'SIGNATURE' => $user_sig,
		'EDITED_MESSAGE' => $l_edited_by,

		'MINI_POST_IMG' => $mini_post_img,
		'EDIT_IMG' => $edit_img,
		'EDIT' => $edit,
		'QUOTE_IMG' => $quote_img,
		'QUOTE' => $quote,
		'IP_IMG' => $ip_img,
		'IP' => $ip,
		'DELETE_IMG' => $delpost_img,
		'DELETE' => $delpost,

		'L_MINI_POST_ALT' => $mini_post_alt,

		'U_MINI_POST' => $mini_post_url,
		'U_POST_ID' => $postrow[$i]['post_id'])
	);
	//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
	if ($postrow[$i]['user_my_ignore'])
	{
		$template->assign_block_vars('postrow.switch_buddy_ignore', array());
	}
	else
	{
		$template->assign_block_vars('postrow.switch_no_buddy_ignore', array());
	}
//-- fin mod : profile cp --------------------------------------------------------------------------
}

//-- mod : profile cp ------------------------------------------------------------------------------
//-- add
$template->assign_vars(array(
	'L_IGNORE_CHOOSEN' => $lang['Ignore_choosed'],
	)
);
//-- fin mod : profile cp --------------------------------------------------------------------------
$template->pparse('body');

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);

?>
2nd problem-

How do I incorporate the Cash Mod w/ the PCP mod?
User avatar
lwq
Registered User
Posts: 181
Joined: Tue Aug 12, 2003 1:43 pm

Post by lwq »

if i want to install this mod, but have installed category hierarchy mod, will it affect the performance?
lwq
Lady Serena
Registered User
Posts: 76
Joined: Thu May 26, 2005 12:31 am
Location: Smithsburg, MD
Contact:

Post by Lady Serena »

I actually tried using the CashMOD with the PCP, but the inconsistencies between the two was difficult to work with. Eventually, I uninstalled the CashMOD and started to develop my own cash system. Its actually very simple to create your own cash system, just make a new table with the user_id indexed, and one field for each form of currency you need. Then you can build the code in the scripts you need to have cash affected by. Things actually work out fairly easy this way, too.
Varus Online :: Discover Imagination
http://www.varusonline.com/
MrDSL
Registered User
Posts: 283
Joined: Thu Jul 15, 2004 1:52 am
Contact:

Post by MrDSL »

You can get the Cash Mod to work with PCP below

http://www.thehottub.net/phpBB2/dload.php
User avatar
AYHJA
Registered User
Posts: 60
Joined: Sun Jun 13, 2004 1:15 pm
Location: ayhja.com
Contact:

Topic Be Gone..

Post by AYHJA »

157 pages..???

I know I suck for this, but reading through all those posts probably takes longer than writing the MOD itself...

Here's my issue...

The mod works EXCELLENT in all other areas...I'm not getting any errors what so ever anywhere else...But, when I try to view topics, it's like I don't exist as a user...I don't know what I've done, and I've been over the viewtopic and the viewtopic_body like 4 times...I am sure that I have followed the instructions as close as possible...

http://www.ayhja.net/ADN/viewforum.php?f=2

When you try and click the topic, the information disappears...No error, I just can't view any topics...

I've taken that this is a database issue..? All my SQL commans processed just fine though...

No erros in the admincp, no errors anywhere...It's just seems like my topics have bit the dust...I appreciate any help someone can give me, despite my being lazy and not reading through all these pages..! :(
Search for it @ http://www.AYHJA.com/ - The 1337
Jams44
Registered User
Posts: 31
Joined: Mon Feb 28, 2005 11:07 pm

hey

Post by Jams44 »

That also happened to me, if you can use EAsyMod to install it, it works perfect!
ninosportif
Registered User
Posts: 220
Joined: Mon Apr 19, 2004 12:07 pm
Location: United Kingdom
Contact:

Post by ninosportif »

HI all,

I have a few problem with this, so i wonder if anyone has a fixed for this problem in buddylist...

I have been searching but i cant find a solution:
General Error

Could not update user options.

DEBUG MODE

SQL Error : 1054 Unknown column 'user_list_option' in 'field list'

UPDATE phpbb_users SET user_list_option = '0110000001110000000000000001' WHERE user_id = x

Line : 426
File : /var/www/html/phpbb/profilcp/profilcp_buddy.php

Code: Select all

here is the part of the script from 417-428

	// update the user option field
	if ($fields_choosen)
	{
		// store the result
		$sql = "UPDATE " . USERS_TABLE . " 
				SET user_list_option = '" .  $view_userdata['user_list_option'] . "' 
				WHERE user_id = " . $view_userdata['user_id'];
		if ( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not update user options.', '', __LINE__, __FILE__, $sql);
		}
	}
P.S. - Yes I have the user_list_option in my phpAdmin
All rights reserved to Gamers SportCast Network (2004). The site is poweredby Canaca.com.
Image
User avatar
AYHJA
Registered User
Posts: 60
Joined: Sun Jun 13, 2004 1:15 pm
Location: ayhja.com
Contact:

Go me..!

Post by AYHJA »

w00t...

I fixed the issue, now I have a slightly less annoying issue..But, the thing is, or that I could see, was the viewtopic_body.tpl has a bit of a conflict w/something else related to my new issue...

I don't want all that extra information under my User Name, Rank, and Avatar...All I want under that is the Unique user I.D. number and the post count...

Anybody have any idea how to do that...?
Search for it @ http://www.AYHJA.com/ - The 1337
User avatar
lwq
Registered User
Posts: 181
Joined: Tue Aug 12, 2003 1:43 pm

Post by lwq »

help help help!
I am installing this mod after the installation of CH mod and I can't find this line which reads:
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/index_body.tpl

#
#-----[ FIND ]------------------------------------------------
#
# this is a partial search : the full lines are longer
#
{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]


what should i do?
lwq
ninosportif
Registered User
Posts: 220
Joined: Mon Apr 19, 2004 12:07 pm
Location: United Kingdom
Contact:

Post by ninosportif »

IWQ

Try to aim to look for this words... one of them out of this three will do, as you will find the lines.
should be around line 40-75[ {L_WHOSONLINE_MOD} ]


I said around line 40-75, just because i have MODs already in there.

If for any reaon you can't find it, upload a link to it and i find it for ya for free... hehehe :P (I am not making business here, but rather, i would like to help...)
Last edited by ninosportif on Tue Jul 05, 2005 12:03 pm, edited 1 time in total.
All rights reserved to Gamers SportCast Network (2004). The site is poweredby Canaca.com.
Image
ninosportif
Registered User
Posts: 220
Joined: Mon Apr 19, 2004 12:07 pm
Location: United Kingdom
Contact:

Re: Two Things

Post by ninosportif »

Jams44 wrote: Two Things-

1. After Installing The PCP, I noticed in all the viewtopics, the Author/RAnk/Evrything Else Doesn't Appear. Here is a Link- http://xvisionz.net/forum/viewtopic.php?t=2

and here is the code- Read ***


Hi Jams

I have read your coding agains mine one and it looks fine.

There was no error or anything i can spot on.

I think you have to make sure you have every little php files in.
Can you check out your templates/yourtemplate*/

:arrow: index_body.tpl
:arrow: viewtopic_body.tpl
:arrow: viewforum.tpl

I wonder if you have mistaken to put the coding in one of them (check agains the MOD PCP instructions) or if there is any coding, (pls pls, make it in a zip file and upload the link, where we can read it, rather than posting a huge txt, like above.

I have a read again for ya and see...


P.S. Have you make a backup b4 you did this, thats include the database backup and also the board itself?
All rights reserved to Gamers SportCast Network (2004). The site is poweredby Canaca.com.
Image
ninosportif
Registered User
Posts: 220
Joined: Mon Apr 19, 2004 12:07 pm
Location: United Kingdom
Contact:

[Fixed] Buddy list Error

Post by ninosportif »

ninosportif wrote: HI all,

I have a few problem with this, so i wonder if anyone has a fixed for this problem in buddylist...

I have been searching but i cant find a solution:
General Error

Could not update user options.

DEBUG MODE

SQL Error : 1054 Unknown column 'user_list_option' in 'field list'

UPDATE phpbb_users SET user_list_option = '0110000001110000000000000001' WHERE user_id = x

Line : 426
File : /var/www/html/phpbb/profilcp/profilcp_buddy.php

Code: Select all

here is the part of the script from 417-428

	// update the user option field
	if ($fields_choosen)
	{
		// store the result
		$sql = "UPDATE " . USERS_TABLE . " 
				SET user_list_option = '" .  $view_userdata['user_list_option'] . "' 
				WHERE user_id = " . $view_userdata['user_id'];
		if ( !$result = $db->sql_query($sql) )
		{
			message_die(GENERAL_ERROR, 'Could not update user options.', '', __LINE__, __FILE__, $sql);
		}
	}
P.S. - Yes I have the user_list_option in my phpAdmin


Hurray!!! I have fixed my problem today, after a nice gud sleep.

So how did i fixed this?
I menthion that i have the user_list_option in my phpAdmin, but after i did a check (after a good sleep) I found out that i have it in the wrong folder

For example (myphpAdmin) have a phpbb_users & a users database.
I have put the SQL queries in the users database -> That was the wrong database
So after i spotted/ found this section...

I have drop all this queries, and did the sql again in the phpbb_users database, and now my forum works like a charm.

So, those having parse error or anything else, should make a double/triple/ quadriple check in all folders, as well as the SQL database.

Summary

Common Mistake:
:arrow: Forgot to upload certain files in the root or required folder
For example:

Code: Select all

#-----[ COPY ]------------------------------------------------
# 
# -- mod-lang_settings --
#
// This is only part of the line, the full line is longer
copy mod-lang_settings/admin_lang_extend.php to admin/admin_lang_extend.php
copy mod-lang_settings/lang_extend_mac.php to includes/lang_extend_mac.php
:arrow: Forgot to upload certain SQL/ database in the correct folder

Code: Select all

#-----[ SQL ]-------------------------------------------------
#
// This is only part of the SQL/ database, the full SQL is longer
ALTER TABLE phpbb_users ADD user_realname VARCHAR(25) NOT NULL;
ALTER TABLE phpbb_users ADD user_gender TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_birthday VARCHAR(8) DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_last_birthday INT(11) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_home_phone VARCHAR(20);
ALTER TABLE phpbb_users ADD user_home_fax VARCHAR(20);
:arrow: Forgot to CHMOD the following folders

Code: Select all

##	_________________________________________________________________________________________
##
##
##	  / \
##	 / ! \	The next CHMODs are required to allow the editing of the mentioned files by the ACP tools
##	/_____\
##
##
##	CHMOD 666 to apply :
##
##		profilcp/def/def_userfields.php
##		profilcp/def/def_usermaps.php
##
##	COPY to each of your language installed directories (ie: languages/lang_english/) and
##	CHMOD 666 those files :
##		COPY mod-lang_settings/lang_extend.php TO language/lang_*/lang_extend.php
##
:arrow: Did not read the instructions properly
Important Do read the instructions of any MODs you do before you start with it. Using Nuttzys EasyMod x.x.x; can facilitate your used, but sometimes, you will need to check your boards and make some amendments needed to it, as errors/ critical errors/ parse errors/ 'board does not exist or no forum or topics does not exist'

I hope this clarifies every one common mistakes and problems.
All rights reserved to Gamers SportCast Network (2004). The site is poweredby Canaca.com.
Image
ninosportif
Registered User
Posts: 220
Joined: Mon Apr 19, 2004 12:07 pm
Location: United Kingdom
Contact:

Re: Topic Be Gone..

Post by ninosportif »

AYHJA wrote: 157 pages..???

I know I suck for this, but reading through all those posts probably takes longer than writing the MOD itself...

Here's my issue...

The mod works EXCELLENT in all other areas...I'm not getting any errors what so ever anywhere else...But, when I try to view topics, it's like I don't exist as a user...I don't know what I've done, and I've been over the viewtopic and the viewtopic_body like 4 times...I am sure that I have followed the instructions as close as possible...

http://www.ayhja.net/ADN/viewforum.php?f=2

When you try and click the topic, the information disappears...No error, I just can't view any topics...

I've taken that this is a database issue..? All my SQL commans processed just fine though...

No erros in the admincp, no errors anywhere...It's just seems like my topics have bit the dust...I appreciate any help someone can give me, despite my being lazy and not reading through all these pages..! :(


Well definately this is a database issue.

First i would like you to check the following:
ACP -> Forum Admin -> Configurations -> Enable Pruning -> Off

(i wonder if you have Pruning On, before you start?
How long have you run your board for?)
.:. I see you have ard 31 articles made, so those seems disappear, maybe coz of pruning (I can't help ya with this issue, but i can tell ya, if you have Pruning on (auto) or had pruning done before, the issue is your posted topics are all gone now (all you can do is do a back up of the database (if you have, but dont bother, unless those post are very important. Personally I lost +1000 coz I was playing with pruning)

Ok back to the issue...

Check your databases agains the following:
phpbb_users (not users)
phpbb_ranks (not ranks)
phpbb_buddy

This is where most people have made mistakes on (including me)

:arrow: An issue, may raise here is check the phpbb_topic (but I dont know how, unless you can find a moderator in phpbb who is expert in it, cant help on this - as this may explain why you lost your topics - including 'Announcements')

Let me know how you getting on, so I can assist you further.
All rights reserved to Gamers SportCast Network (2004). The site is poweredby Canaca.com.
Image
User avatar
AYHJA
Registered User
Posts: 60
Joined: Sun Jun 13, 2004 1:15 pm
Location: ayhja.com
Contact:

Post by AYHJA »

Issue fixed M8..! Thanks for your tips..!

As I mentioned in my previous post though, now my issue is something else, I don't want all that informaiton underneath my avatar...All I want is the unique user I.D. and the Post count...But, editing that line in the veiwtopic_body.tpl will screw everything else back up again...
Search for it @ http://www.AYHJA.com/ - The 1337
tlavery
Registered User
Posts: 59
Joined: Wed Jun 01, 2005 8:25 pm

Post by tlavery »

tlavery wrote: Ok I Installed with easymod and got these errors:

SQL PROCESSING ERROR:
No SQL alterations will be performed. However, you may skip SQL processing, continue installing the MOD, and deal with the SQL manually

The following error occured:

FATAL ERROR: Unable to parse SQL statement;


ALTER TABLE phpbb_ranks CHANGE rank_title rank_title VARCHAR(255) NOT NULL


Then after processing the rest of the installation while skipping the SQL processing when I was done I got this error on the main MB page:

General Error

Could not obtain buddys information.

DEBUG MODE

SQL Error : 1146 Table 'dishinstallers_net_-_phpbb3.buddy' doesn't exist

SELECT * FROM buddy WHERE user_id=3 and buddy_id in (3)
Line : 216
File : page_header.php

Then I went into phpmyadmin and here are the errors that I got:

(I don't know if I tried to do the edits correctly so that may have been my problem.)

Code: Select all

ALTER TABLE phpbb_users ADD user_realname VARCHAR(25) NOT NULL;
ALTER TABLE phpbb_users ADD user_gender TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_birthday VARCHAR(8) DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_last_birthday INT(11) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_home_phone VARCHAR(20);
ALTER TABLE phpbb_users ADD user_home_fax VARCHAR(20);
ALTER TABLE phpbb_users ADD user_work_phone VARCHAR(20);
ALTER TABLE phpbb_users ADD user_work_fax VARCHAR(20);
ALTER TABLE phpbb_users ADD user_cellular VARCHAR(20);
ALTER TABLE phpbb_users ADD user_pager VARCHAR(20);
ALTER TABLE phpbb_users ADD user_summer_time TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL;
ALTER TABLE phpbb_users ADD user_list_option VARCHAR(255);
ALTER TABLE phpbb_users ADD user_allow_email TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_allow_website TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_allow_messanger TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_allow_real TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_allow_sig TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewpm TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewwebsite TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewmessanger TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewreal TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewavatar TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewsig TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_viewimg TINYINT(1) DEFAULT '1' NOT NULL;
ALTER TABLE phpbb_users ADD user_buddy_friend_display TINYINT(1) DEFAULT '1';
ALTER TABLE phpbb_users ADD user_buddy_ignore_display TINYINT(1) DEFAULT '1';
ALTER TABLE phpbb_users ADD user_buddy_friend_of_display TINYINT(1) DEFAULT '1';
ALTER TABLE phpbb_users ADD user_buddy_ignored_by_display TINYINT(1) DEFAULT '1';
ALTER TABLE phpbb_users ADD user_watched_topics_per_page SMALLINT(3) DEFAULT '15';
ALTER TABLE phpbb_users ADD user_privmsgs_per_page SMALLINT(3) DEFAULT '5';
I copied and pasted all that into phpmyadmin and tried to apply it.....this is the error I got:

SQL-query:

ALTER TABLE phpbb_users ADD user_realname VARCHAR( 25 ) NOT NULL
MySQL said:

#1146 - Table 'dishinstallers_net_-_phpbb3.phpbb_users' doesn't exist


Then I copied and pasted this into phpmyadmin:

Code: Select all

ALTER TABLE phpbb_sessions ADD session_robot VARCHAR(32);
And here is my error:

SQL-query:

ALTER TABLE phpbb_sessions ADD session_robot VARCHAR( 32 )
MySQL said:

#1146 - Table 'dishinstallers_net_-_phpbb3.phpbb_sessions' doesn't exist

Then I copied and pasted this to phpmyadmin:

Code: Select all

ALTER TABLE phpbb_ranks CHANGE rank_title rank_title VARCHAR(255) NOT NULL;
ALTER TABLE phpbb_ranks ADD rank_max MEDIUMINT(8) NOT NULL AFTER rank_min; 
And this is my error:

SQL-query:

ALTER TABLE phpbb_ranks CHANGE rank_title rank_title VARCHAR( 255 ) NOT NULL
MySQL said:

#1146 - Table 'dishinstallers_net_-_phpbb3.phpbb_ranks' doesn't exist


Then I copied and pasted this to phpmyadmin:

Code: Select all

CREATE TABLE phpbb_buddy (
  user_id mediumint(8) NOT NULL default '0',
  buddy_id mediumint(8) NOT NULL default '0',
  buddy_ignore tinyint(1) NOT NULL default '0',
  buddy_visible tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (user_id, buddy_id)
) TYPE=MyISAM;
And that one was successful!

After I tried to run the SQL I still get this error on the main MB page :

General Error

Could not obtain buddys information.

DEBUG MODE

SQL Error : 1146 Table 'dishinstallers_net_-_phpbb3.buddy' doesn't exist

SELECT * FROM buddy WHERE user_id=-1 and buddy_id in (3)

Line : 216
File : page_header.php

I did not get any errors from easymod about not being able to find any certain codes when it does it's initial check before performing the install, so maybe all the errors are related to SQL. I am not real familure with how to manually do the SQL changes, so maybe I totally screwed it up. If someone can give me some pointers I would appreciate it immensly! If I was supposed to do one line at a time I would appreciate knowing that :)

Thanks a MILLION guys!!


Just thought I would bump this since there seems to be some help here now. Thanks!!
Locked

Return to “[2.0.x] MODs in Development”