[BETA] Post Points

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.
Avatar de Io
Registered User
Posts: 6
Joined: Mon May 15, 2006 5:37 am
Location: Perú
Contact:

Re: [BETA] Post Points

Post by Avatar de Io » Fri Oct 26, 2007 3:22 am

I'll try to Mod my phpBB Plus 1.53a based in phpBB 2.0.22 and the instructions to insert in viewtopic are imposible to put or adapt (and phpBB plus use the CH mod as far as I know).

I checked your [BETA] Topic and Post Rating Mod and his instructions seems more compatible with phpBB plus.

Do you plan to makes a revision over [BETA] Post Points to the phpBB Plus?

Many thanks!
Image

User avatar
freejoe76
Registered User
Posts: 34
Joined: Sat Feb 08, 2003 3:41 am
Location: Denver
Contact:

Re: [BETA] Post Points

Post by freejoe76 » Tue Dec 11, 2007 2:04 am

Here's a modification I added. It shows the total number of votes a post has gotten.

First, I added a field (MEDIUMINT) called post_points_total to the phpbb_posts table.
Second, I ran this query to get the field up to speed:

Code: Select all

UPDATE 
	phpbb_posts 
	SET post_points_total = 
		(
		SELECT COUNT(post_id) 
		FROM phpbb_postpoints_results 
		WHERE phpbb_posts.post_id = phpbb_postpoints_results.post_id 
		GROUP BY phpbb_postpoints_results.post_id
		)
Third, I updated the vote query to look like this:

Code: Select all

		$sql = 'UPDATE ' . POSTS_TABLE . '
				SET 
					post_points = post_points ' . $vote_crement . $abs_vote_points . ', 
					post_points_total = post_points_total + 1
				WHERE post_id = ' . intval($post_id);
Fourth, I added a line and a variable to handle the new field (check the second line, that's the new one).

Code: Select all

	$postvotepoints = ( $postrow[$i]['post_points'] != 0 ) ? '<b>' . $postrow[$i]['post_points'] . ' points<b>' : '0';
	$postvotetotal = ( $postrow[$i]['post_points_total'] != 0 ) ? ' (' . $postrow[$i]['post_points_total'] . ' total votes)' : '';
Then I output it to the template in the post item loop. See it in action here: http://neighbors.denverpost.com/viewtop ... &start=120

Avatar de Io
Registered User
Posts: 6
Joined: Mon May 15, 2006 5:37 am
Location: Perú
Contact:

Re: [BETA] Post Points

Post by Avatar de Io » Sat Dec 15, 2007 5:49 pm

After checking the script, I discover that you use Categories Hierarchy Mod and phpBB plus not, so, this is the reason to not find some files like:

includes/CH_functions_post.php
includes/class_posts.php

Could be a possibility of adapt this wonderful work to phpBB Plus?

Many thanks!
Image

User avatar
SpilltheBeans
Registered User
Posts: 53
Joined: Wed Dec 21, 2005 6:21 am
Contact:

Re: [BETA] Post Points

Post by SpilltheBeans » Wed Dec 19, 2007 4:44 pm

Avatar de Io wrote:After checking the script, I discover that you use Categories Hierarchy Mod and phpBB plus not
This mod is for phpBB 2.022. My suggestion is to use the phpBB 2.022 version of the mod and ask someone at phpBB plus to do the conversion.

Also, thanks freejoe76 for the added feature.

I'm planning to do one more thing with this mod and that is to allow admins to specify which forums can use post voting. After that, unless there are bugs in the mod, I think it's pretty complete.
A site for people interested in personal electronics - MP3 players, digital cameras, camcorders
All my mods found at TripStir.com/forum/

User avatar
freejoe76
Registered User
Posts: 34
Joined: Sat Feb 08, 2003 3:41 am
Location: Denver
Contact:

Re: [BETA] Post Points

Post by freejoe76 » Thu Feb 14, 2008 7:28 pm

Hi,

I just got the first draft of the (heavily edited) Post Points working in phpbb3.0 -- is anybody interested in the code?

-Joe

ColdSun98
Registered User
Posts: 1
Joined: Wed Mar 05, 2008 12:57 am

Re: [BETA] Post Points

Post by ColdSun98 » Wed Mar 05, 2008 12:59 am

I am definately interested in the version for phpbb3 =)

UpL0ad3R
Registered User
Posts: 9
Joined: Sun Apr 13, 2008 4:32 pm

Re: [BETA] Post Points

Post by UpL0ad3R » Sun Apr 20, 2008 3:17 am

ColdSun98 wrote:I am definately interested in the version for phpbb3 =)
Yeah man, I've been searching for this for like 4 hours!! ... But i gor sooo disappointed when i found out that its not for phpBB3 :(

User avatar
Zaid
Registered User
Posts: 590
Joined: Thu Nov 08, 2007 2:06 pm
Location: South Pacific Ocean

Re: [BETA] Post Points

Post by Zaid » Sun Jun 01, 2008 9:09 am

i'll give it a try in my forum :D

User avatar
Zaid
Registered User
Posts: 590
Joined: Thu Nov 08, 2007 2:06 pm
Location: South Pacific Ocean

Re: [BETA] Post Points

Post by Zaid » Sun Jun 15, 2008 11:06 am

still works?

User avatar
Zaid
Registered User
Posts: 590
Joined: Thu Nov 08, 2007 2:06 pm
Location: South Pacific Ocean

Re: [BETA] Post Points

Post by Zaid » Mon Jun 16, 2008 11:17 am

HI, I came across a error in this mod


I get the following error when trying to view a topic , can any one please have a look.. :)

Parse error: syntax error, unexpected $end in /home/tmgngr/public_html/forums/viewtopic.php on line 2668


here is my viewtopic.php
<?php
//-- mod : post points

//-- mod: sf

//-- mod : post icon -------------------------------------------------------------------------------




/***************************************************************************
* viewtopic.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: viewtopic.php,v 1.186.2.47 2006/12/16 13:11:25 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 : post icon -------------------------------------------------------------------------------
//-- add
include($phpbb_root_path . 'includes/def_icons.'. $phpEx);
//-- fin mod : post icon ---------------------------------------------------------------------------


include($phpbb_root_path . 'reputation_common.'.$phpEx);
include($phpbb_root_path . 'includes/functions_reputation.'.$phpEx);

// BEGIN PostOptions by Wicher
include($phpbb_root_path . 'includes/functions_post.'.$phpEx);
include($phpbb_root_path . 'includes/posts_options_modmess_functions.'.$phpEx);
// END PostOptions by Wicher

#======================================================================= |
#==== Start: == Activity Mod Plus ====================================== |
#==== v1.1.0 =========================================================== |
#====
include_once($phpbb_root_path .'includes/functions_amod_plus.'. $phpEx);
$q = "SELECT *
FROM ". INA_HOF ."";
$r = $db->sql_query($q);
$hof_data = $db->sql_fetchrowset($r);
#====
#==== Author: aUsTiN [austin@phpbb-amod.com] [http://phpbb-amod.com] === |
#==== End: ==== Activity Mod Plus ====================================== |
#======================================================================= |

//
// 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($HTTP_GET_VARS['printertopic']))
{
$start = ( isset($HTTP_GET_VARS['start_rel']) ) && ( isset($HTTP_GET_VARS['printertopic']) ) ? intval($HTTP_GET_VARS['start_rel']) - 1 : $start;
// $finish when positive indicates last message; when negative it indicates range; can't be 0
if(isset($HTTP_GET_VARS['finish_rel']))
{
$finish = intval($HTTP_GET_VARS['finish_rel']);
}
if(($finish >= 0) && (($finish - $start) <=0))
{
unset($finish);
}
}

$start = ($start < 0) ? 0 : $start;

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


//mod -- post points
$no_increase_views = (isset($HTTP_GET_VARS['no_increase_views'])) ? 1 : 0;
if ( isset($HTTP_GET_VARS['postvote']))
{
$postvote = $HTTP_GET_VARS['postvote'];
}

$postvoteorder = '';
if ( isset($HTTP_GET_VARS['postvoteorder']))
$postvoteorder = $HTTP_GET_VARS['postvoteorder'];




//
// 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_moved_id = 0
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 = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
$join_sql = (!$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 = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";
$count_sql .= ", f.forum_approve, t.topic_approve, t.topic_poster"; // approval mod
// sql modified by approval mod
$order_sql = (!$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, f.forum_approve, t.topic_approve, t.topic_poster ORDER BY p.post_id ASC";

//mod -- post points
//$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_first_post_id, 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, f.thanks_enabled" . $count_sql . "



$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, t.topic_first_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']);

$thanks_forum_enabled = intval($forum_topic_data['thanks_enabled']);

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


/* vBulletin Navigation MOD :: START */
if ($userdata['user_id'] != '-1')
{
$name_link = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&u=" . $userdata['user_id']) . '">' . $userdata['username'] . '</a>';
}
/* vBulletin Navigation MOD :: END */


//-- mod: sf
include($phpbb_root_path . 'includes/functions_sf.'.$phpEx);
_sf_display_nav($forum_id);
//-- mod: sf - end




if(!file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_printertopic.'.$phpEx)))
{
include($phpbb_root_path . 'language/lang_english/lang_printertopic.' . $phpEx);
} else
{
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_printertopic.' . $phpEx);
}









//
// Start auth check
//
$is_auth = array();
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
// approval block start
$allowed_to_approve = ( $is_auth['auth_mod'] || $is_auth['auth_approve'] == APPROVAL_MOD_CAN_DO ) ? TRUE : FALSE;
$can_approve_msg = $allowed_to_approve ? $lang['Rules_approve_forum'] : '';
if ( ($forum_topic_data['forum_approve'] & APPROVAL_TOPIC_STARTER) == APPROVAL_TOPIC_STARTER &&
!$allowed_to_approve && $forum_topic_data['topic_poster'] != ANONYMOUS &&
!$forum_topic_data['topic_approve'] && $forum_topic_data['topic_poster'] == $userdata['user_id']
)
{
$can_approve_msg = $lang['Rules_approve_topic'];
$allowed_to_approve = TRUE;
}
$approve_hide = ( ($forum_topic_data['forum_approve'] & APPROVAL_HIDE) == APPROVAL_HIDE && !$allowed_to_approve ) ? TRUE : FALSE;
if ( $approve_hide && $forum_topic_data['topic_approve'] )
{
$is_auth['auth_view'] = FALSE;
$lang['Topic_post_not_exist'] = $lang['Sorry_approve_read'];
}
// approval block end
if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
{
if ( !$userdata['session_logged_in'] )
{
$redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
$redirect .= ($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'];

//mod -- post points
$first_post_id = $forum_topic_data['topic_first_post_id'];

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






//
// Is user subscribed to this topic?
//
if( $userdata['session_logged_in'] )
{
$topic_subscription_sql='SELECT topic_id FROM ' . USER_SUBSCRIPTIONS_TABLE . ' WHERE user_id = ' . $userdata['user_id'] . ' AND topic_id=' . $topic_id . '';
if ( !($topic_subscription = $db->sql_query($topic_subscription_sql)) )
{
message_die(GENERAL_ERROR, 'Could not query user subscription information', '', __LINE__, __FILE__, $topic_subscription_sql);
}

if ( $db->sql_numrows($topic_subscription) != 0 )
{
$s_subscribed_topic = '';
}
else
{
$temp_url = append_sid("subscp.$phpEx?" . POST_TOPIC_URL ."=$topic_id&mode=add_t");
$s_subscribed_topic = '<a href="' . $temp_url . '">' . $lang['sub_to_topic'] . '</a>';
}
$db->sql_freeresult($topic_subscription);
}
else
{
$s_subscribed_topic = '';
}
//
// End user subscription
//




//
// 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;
}
$limit_posts_time .= $approve_hide ? " AND p.post_approve = 0" : ''; // approval mod
$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>';







if ($postvote && $is_auth['auth_reply'] && ($post_id != $first_post_id)) //--to do : use it's own auth
{
//to do - make sure they have permissions?

$do_vote = true;
$abs_vote_points = 1;

//if logged in, check if user has voted already
if ($userdata['session_logged_in'])
{
$sql = 'SELECT vote_result
FROM '. POSTPOINTS_RESULTS_TABLE . '
WHERE post_id = ' . intval($post_id);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
if ($row = $db->sql_fetchrow($result))
{
//cannot do postvote
$do_vote = false;
}
$db->sql_freeresult($result);
}

if ($postvote == 'up')
{
$vote_points = $abs_vote_points;
$vote_crement = '+';
}
else if ($postvote == 'down')
{
$vote_points = (-1)*$abs_vote_points;
$vote_crement = '-';
}
else
{
$vote_points = $abs_vote_points;
$vote_crement = '+';
}

$sql = 'SELECT post_points, poster_id
FROM ' . POSTS_TABLE . '
WHERE post_id = ' . intval($post_id);
$result = $db->sql_query($sql, false, __LINE__, __FILE__);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

$post_points = $row['post_points'];
$poster_id = $row['poster_id'];

if ($post_points >= $board_config['max_post_points'] && $vote_crement == '+')
$do_vote = false;
if ($post_points <= 0 && $vote_crement == '-')
$do_vote = false;

if ($do_vote)
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET post_points = post_points ' . $vote_crement . $abs_vote_points . '
WHERE post_id = ' . intval($post_id);
$db->sql_query($sql, false, __LINE__, __FILE__);

//update the post points table except for unregistered users
if ($userdata['session_logged_in'])
{
$sql = "INSERT INTO " . POSTPOINTS_RESULTS_TABLE .
"(user_id, topic_id, post_id, vote_result, vote_time) VALUES(" . $userdata['user_id'] . "," . intval($topic_id) . "," . intval($post_id) . "," .intval($vote_points) . "," . time() . ")";
$db->sql_query($sql, false, __LINE__, __FILE__);
}

$sql = 'UPDATE ' . USERS_TABLE . '
SET user_points = user_points ' . $vote_crement . $abs_vote_points . '
WHERE user_id = ' . intval($poster_id);
$db->sql_query($sql, false, __LINE__, __FILE__);
}
}





//
// 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>';


//mod - post points
$sortorder = 'p.post_time';
if ($postvoteorder != '') //only view by descending order - ascending order doesn't make sense here
{
$sortorder = 'p.post_points';
$post_time_order = 'DESC';


//
// Go ahead and pull all data for this topic
//
$sql = "SELECT u.user_trophies, u.ina_char_name, u.username, u.user_id, u.user_level, u.user_nopost_time, u.user_posts, u.user_topics, u.user_custom_title, 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_rank2, u.user_rank3, u.user_rank4, u.user_rank5, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile,u.user_points, u.user_level, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid, p.post_points, u.user_reputation

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, ".(isset($finish)? ((($finish - $start) > 0)? ($finish - $start): -$finish): $board_config['posts_per_page']);
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
}

$postrow = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$postrow[] = $row;
}
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'];
}

// Mighty Gorgon - Multiple Ranks - BEGIN
require_once($phpbb_root_path . 'includes/functions_mg_ranks.'.$phpEx);
$ranks_sql = query_ranks();
// Mighty Gorgon - Multiple Ranks - END

//
// 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*', 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

//


$printer_topic_url = append_sid("viewtopic.$phpEx?printertopic=1&" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&vote=viewresult");



$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'];

$printer_img = $images['printer'];
$printer_alt = $lang['printertopic_button'];





//
// 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
//
if(isset($HTTP_GET_VARS['printertopic']))
{


$template->set_filenames(array(
'body' => 'printertopic_body.tpl')
);
} else
{
$template->set_filenames(array(
'body' => 'viewtopic_body.tpl')
);
}

// approval block start
if ( $forum_topic_data['topic_approve'] && !$allowed_to_approve && ($userdata['user_id'] != $forum_topic_data['topic_poster'] || $userdata['user_id'] == ANONYMOUS) )
{
$topic_title = $lang['Approval_unapproved_topic'];
}
$lang['Rules_vote_can' . ($is_auth['auth_vote'] ? '' : 'not') ] .= $allowed_to_approve ? '<br />' . $can_approve_msg : '';
// approval block end
make_jumpbox('viewforum.'.$phpEx, $forum_id);



/* vBulletin Navigation MOD :: START */
$sql = "SELECT f.cat_id, f.forum_id, c.cat_id, c.cat_title
FROM " . FORUMS_TABLE . " f, " . CATEGORIES_TABLE ." c
WHERE f.forum_id = $forum_id
AND f.cat_id = c.cat_id";
if( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not query categories list', '', __LINE__, __FILE__, $sql);
}

$row = $db->sql_fetchrow($result);
$cat_id = $row['cat_id'];
$show_cat = $row['cat_title'];
/* vBulletin Navigation MOD :: END */


//
// Output page header
//
$page_title = $lang['View_topic'] .' - ' . $topic_title;
if(isset($HTTP_GET_VARS['printertopic']))
{
include($phpbb_root_path . 'includes/page_header_printer.'.$phpEx);
} else
{
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>');

// BEGIN PostOptions by Wicher
if ($board_config['move_deleted_to_trash'] && $board_config['postoptions_trash_id'] != $forum_id)
{
$trashforum_id = $board_config['postoptions_trash_id'];
$topic_mod .= "<a href=\"modcp.$phpEx?mode=move&postoptions_topicmove=true&" . POST_TOPIC_URL . "=$topic_id&" . POST_FORUM_URL . "=" . $forum_id . "&new_forum=" . $trashforum_id . "&sid=" . $userdata['session_id'] . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Move_topic_trashforum'] . '" title="' . $lang['Move_topic_trashforum'] . '" border="0" /></a>&nbsp;';
}
else
{
$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;';
}
// END PostOptions by Wicher

$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.
//
if(isset($HTTP_GET_VARS['printertopic']))
{
$pagination_printertopic = "printertopic=1&";
}
if($highlight != '')
{
$pagination_highlight = "highlight=$highlight&";
}
$pagination_ppp = $board_config['posts_per_page'];
if(isset($finish))
{
$pagination_ppp = ($finish < 0)? -$finish: ($finish - $start);
$pagination_finish_rel = "finish_rel=". -$pagination_ppp. "&amp";
}

$pagination = generate_pagination("viewtopic.$phpEx?". $pagination_printertopic . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&". $pagination_highlight . $pagination_finish_rel, $total_replies, $pagination_ppp, $start);
if($pagination != '' && isset($pagination_printertopic))
{
$pagination .= " &nbsp;<a href=\"viewtopic.$phpEx?". $pagination_printertopic. POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&". $pagination_highlight. "start=0&finish_rel=-10000\" title=\"" . $lang['printertopic_cancel_pagination_desc'] . "\">:|&nbsp;|:</a>";


//
// Start Thank Post by User Mod
//

// Set to 1 if you wish to use pop-ups instead of using the same window
$popup_enabled = 0;

if ($popup_enabled == 1) {

$thanks_javascript ='<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, \'" + id + "\', \'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=400,height=225\');");
}
// End -->
</script>';
}

//
// End Thank Post by User Mod
//


}








//
// Send vars to template
//
$template->assign_vars(array(


'START_REL' => ($start + 1),
'FINISH_REL' => (isset($HTTP_GET_VARS['finish_rel'])? intval($HTTP_GET_VARS['finish_rel']) : ($board_config['posts_per_page'] - $start)),




'THANKS_JAVASCRIPT' => $thanks_javascript,

'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_name,
'TOPIC_ID' => $topic_id,
'TOPIC_TITLE' => ucfirst($topic_title),
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $pagination_ppp ) + 1 ), ceil( $total_replies / $pagination_ppp )),

'POST_IMG' => $post_img,
'REPLY_IMG' => $reply_img,
'PRINTER_IMG' => $printer_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_PRINTER_TOPIC' => $printer_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'],


//mod -- post points
'L_POSTVOTE_UP' => $lang['Postpoints_Up'],
'L_POSTVOTE_DOWN' => $lang['Postpoints_Down'],


// BEGIN PostOptions by Wicher
'L_PERMANENT' => $lang['permanent'],
'L_CLOSE' => $lang['close'],
'L_REPORTED' => $lang['Post_reported'],
// END PostOptions by Wicher

'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,

/* vBulletin Navigation MOD :: START */
'L_DARE_WELCOME' => $lang['DARE_WELCOME'],
'L_DARE_NAVIGATION' => $lang['DARE_NAVIGATION'],
'L_DARE_LOGIN' => $lang['DARE_LOGIN'],
'L_DARE_USERNAME' => $lang['DARE_USERNAME'],
'L_DARE_PASSWORD' => $lang['DARE_PASSWORD'],
'L_DARE_LOGIN_EXPLAIN' => $lang['DARE_LOGIN_EXPLAIN'],
'L_SHOW_CAT' => $show_cat,
'U_SHOW_CAT' => append_sid("index.$phpEx?c=$cat_id"),
'U_NAME_LINK' => $name_link,
/* vBulletin Navigation MOD :: END */

'S_SUBSCRIBED_TOPIC' => $s_subscribed_topic,

'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_PRINTER_TOPIC' => $printer_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']);


// Begin Color_Poll Mod
$ii = "0";
require_once("./color_poll.php");
// End Color_Poll Mod

for($i = 0; $i < $vote_options; $i++)
{
// Begin Color_Poll Mod
if ($ii <= (count($Color_Poll_Colors) - 1)) {
$Color_Poll = $Color_Poll_Colors[$ii];
}
else
{
$ii = "0";
$Color_Poll = $Color_Poll_Colors[$ii];
}
$ii++;
// End Color_Poll Mod

$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_lcap_img = Get_Dir_From_String($vote_graphic_img) . "color_poll/" . $Color_Poll . "/voting_lcap" . $Color_Poll_File_EXT;
$vote_graphic_rcap_img = Get_Dir_From_String($vote_graphic_img) . "color_poll/" . $Color_Poll . "/voting_rcap" . $Color_Poll_File_EXT;
$vote_graphic_img = Get_Dir_From_String($vote_graphic_img) . "color_poll/" . $Color_Poll . "/voting_bar" . $Color_Poll_File_EXT;
$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_LCAP_IMG' => $vote_graphic_lcap_img,
'POLL_OPTION_RCAP_IMG' => $vote_graphic_rcap_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
//



//mod - post points
if (!$no_increase_views)
{

$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++)
{
$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_created'], $board_config['board_timezone']);

$poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : '';




// Topics a user has started MOD, By Manipe (Begin)
$poster_topics = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Topics'] . ': ' . (( $postrow[$i]['user_topics'] ) ? $postrow[$i]['user_topics'] : '0') : '';
// Topics a user has started MOD, By Manipe (End)



$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';

$poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) : '';

$poster_avatar = '';
if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
{
switch( $postrow[$i]['user_avatar_type'] )
{
case USER_AVATAR_UPLOAD:
$poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_REMOTE:
$poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
break;
case USER_AVATAR_GALLERY:
$poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
break;
}
}

//
// 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'];

// Mighty Gorgon - Multiple Ranks - BEGIN
$user_ranks = generate_ranks($postrow[$i], $ranks_sql);
$custom_title = '';
$user_rank_01 = ($user_ranks['rank_01'] == '') ? '' : ($user_ranks['rank_01'] . '<br />');
$user_rank_01_img = ($user_ranks['rank_01_img'] == '') ? '' : ($user_ranks['rank_01_img'] . '<br />');
$user_rank_02 = ($user_ranks['rank_02'] == '') ? '' : ($user_ranks['rank_02'] . '<br />');
$user_rank_02_img = ($user_ranks['rank_02_img'] == '') ? '' : ($user_ranks['rank_02_img'] . '<br />');
$user_rank_03 = ($user_ranks['rank_03'] == '') ? '' : ($user_ranks['rank_03'] . '<br />');
$user_rank_03_img = ($user_ranks['rank_03_img'] == '') ? '' : ($user_ranks['rank_03_img'] . '<br />');
$user_rank_04 = ($user_ranks['rank_04'] == '') ? '' : ($user_ranks['rank_04'] . '<br />');
$user_rank_04_img = ($user_ranks['rank_04_img'] == '') ? '' : ($user_ranks['rank_04_img'] . '<br />');
$user_rank_05 = ($user_ranks['rank_05'] == '') ? '' : ($user_ranks['rank_05'] . '<br />');
$user_rank_05_img = ($user_ranks['rank_05_img'] == '') ? '' : ($user_ranks['rank_05_img'] . '<br />');
// Mighty Gorgon - Multiple Ranks - END










if ( !empty($postrow[$i]['user_custom_title']) )
{
switch( $board_config['custom_title_mode'] )
{
case CUSTOM_TITLE_MODE_INDEPENDENT:
$custom_title = $postrow[$i]['user_custom_title'] . '<br />';
break;
case CUSTOM_TITLE_MODE_REPLACE_RANK:
$poster_rank = $postrow[$i]['user_custom_title'];
break;
case CUSTOM_TITLE_MODE_REPLACE_BOTH:
$poster_rank = $postrow[$i]['user_custom_title'];
$rank_image = '';
break;
default:
break;
}
}








//
// Handle anon users posting with usernames
//
if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' )
{
$poster = $postrow[$i]['post_username'];
$user_rank_01 = $lang['Guest'] . '<br />';
}

$temp_url = '';

if ( $poster_id != ANONYMOUS )
{





if ( $userdata['user_id'] == $poster_id )
{
$buddy_img = '';
}
else
{
$buddy_check_sql='SELECT buddy_id FROM ' . USER_BUDDYS_TABLE . ' WHERE user_id = ' . $userdata['user_id'] . ' AND buddy_id=' . $poster_id . '';
if ( !($buddy_check = $db->sql_query($buddy_check_sql)) )
{
message_die(GENERAL_ERROR, 'Could not query user buddy information', '', __LINE__, __FILE__, $buddy_check_sql);
}

if ( $db->sql_numrows($buddy_check) != 0 )
{
$buddy_img = '';
}
else
{
$temp_url = append_sid("buddycp.$phpEx?mode=add&t=".$topic_id."&u=".$poster_id."");
$buddy_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_buddy'] . '" alt="' . $lang['Add_to_BuddyList'] . '" title="' . $lang['Add_to_BuddyList'] . '" border="0" /></a>';
}
$db->sql_freeresult($buddy_check);
}







$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
$profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
$profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';

$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id");
$pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
$pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';








$temp_url_profile = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
$vb_menu_profile = '<a class="vbm" href="' . $temp_url_profile . '">&nbsp;<img src="' . $images['vb_menu_profile'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_profile'] . '</a>';
$temp_url_menu = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id");
$vb_menu_pm = '<a class="vbm" href="' . $temp_url_menu . '">&nbsp;<img src="' . $images['vb_menu_pm'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_pm'] . '&nbsp;' . $postrow[$i]['username'] . '&nbsp;</a>';
$vb_menu_search = '<a class="vbm" href="search.php?show_results=posts&search_author=' . $poster . '">&nbsp;<img src="' . $images['vb_menu_search'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_search'] . '&nbsp;' . $postrow[$i]['username'] . '</a>';
$vb_menu_www = ( $postrow[$i]['user_website'] ) ? '<a class="vbm" href="' . $postrow[$i]['user_website'] . '" target="_userwww">&nbsp;<img src="' . $images['vb_menu_www'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_www1'] . '&nbsp;' . $postrow[$i]['username'] . '`s&nbsp;' . $lang['vb_menu_l_www2'] . '!</a>' : '';
//$vb_menu_album = '<a class="vbm" href="album.php?user_id=' . $poster_id . '&mode=list">&nbsp;<img src="' . $images['vb_menu_album'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_album'] . '&nbsp;' . $postrow[$i]['username'] . '</a>';
$vb_menu_id = $poster_id;






if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
{
$email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];

$email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
$email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';


$vb_menu_email = '<a class="vbm" href="' . $email_uri . '">&nbsp;<img src="' . $images['vb_menu_email'] . '" border="0" />&nbsp;' . $lang['vb_menu_l_email'] . '&nbsp;' . $postrow[$i]['username'] . '</a>';







}
else
{
$email_img = '';
$email = '';
$vb_menu_email = '';

}

$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>' : '';
$www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';

if ( !empty($postrow[$i]['user_icq']) )
{
$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>';
$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>';
$icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . $lang['ICQ'] . '</a>';
}
else
{
$icq_status_img = '';
$icq_img = '';
$icq = '';
}

$aim_img = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&message=Hello+Are+you+there?"><img src="' . $images['icon_aim'] . '" alt="' . $lang['AIM'] . '" title="' . $lang['AIM'] . '" border="0" /></a>' : '';
$aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';

$temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
$msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
$msn = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';

$yim_img = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&.src=pg"><img src="' . $images['icon_yim'] . '" alt="' . $lang['YIM'] . '" title="' . $lang['YIM'] . '" border="0" /></a>' : '';
$yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
}
else
{





$buddy_img = '';


$profile_img = '';
$profile = '';
$pm_img = '';
$pm = '';
$email_img = '';
$email = '';
$www_img = '';
$www = '';
$icq_status_img = '';
$icq_img = '';
$icq = '';
$aim_img = '';
$aim = '';
$msn_img = '';
$msn = '';
$yim_img = '';
$yim = '';
$vb_menu_profile = '';
$vb_menu_pm = '';
$vb_menu_search = '';
$vb_menu_email = '';
$vb_menu_www = '';
//$vb_menu_album = '';


}

if (!$postrow[$i]['censor'])
{
$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>';
}
else
{
$quote_img = '';
$quote = '';
}

$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="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" title="' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '" border="0" /></a>';
$search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '</a>';



//
// Start Thank Post by User Mod
//

$thanks_img = '';

// If the user is logged in, the user is not the poster, the poster is not anonymous and thanks is enabled on this fourm
if ( ($userdata['session_logged_in']) && ($userdata['user_id'] != $poster_id) && ($poster_id != ANONYMOUS) && ($thanks_forum_enabled == 1) ) {

// Posts SQL
$sql = "SELECT thanks_by
FROM phpbb_thanksmod
WHERE post_id = '" . $postrow[$i]['post_id'] . "'
AND thanks_by = '" . $userdata['user_id'] . "'";

if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}

$post_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

// If the user hasn't thanked this post
if (!$post_row) {
$temp_url = append_sid("thanks.$phpEx?p=" . $postrow[$i]['post_id']);
if ($popup_enabled == 1) {
$thanks_img = '<a href="javascript:popUp(\'' . $temp_url . '\')"><img src="' . $images['icon_thank'] . '" alt="' . $lang['Thanks_text'] . '" title="' . $lang['Thanks_text'] . '" border="0" /></a>';
}
else {
$thanks_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_thank'] . '" alt="' . $lang['Thanks_text'] . '" title="' . $lang['Thanks_text'] . '" border="0" /></a>';
}
}
}

//
// End Thank Post by User Mod
//





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 = '';
}







//mod - post points
$is_first_post = ($first_post_id == $postrow[$i]['post_id']) ? true : false;
if ( $is_auth['auth_reply'] && !$is_first_post) //-- to do : set its own auth to be able to vote
{
$temp_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&postvote=up&no_increase_views=1&postvoteorder=1");
$postvote_up_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_postpointsup']. '" alt="' . $lang['Postpoints_Up'] . '" title="' . $lang['Postpoints_Up'] . '" border="0" /></a>';
$temp_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&postvote=down&no_increase_views=1&postvoteorder=1");
$postvote_down_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_postpointsdown']. '" alt="' . $lang['Postpoints_Down'] . '" title="' . $lang['Postpoints_Down'] . '" border="0" /></a>';
}
else
{
$postvote_up_img = '';
$postvote_down_img = '';
}




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'];
// BEGIN PostOptions by Wicher
// Check if PostOptionsBox is needed
if ( ($board_config['modviewip']) || ($board_config['mod_ban']) || ($board_config['moddelposts']) || ($board_config['modmovetotrash']) || ($board_config['modcensor']) || ($userdata['user_level'] == ADMIN) )
{
$ip_img = '<img src="' . $images['icon_options'] . '" alt="' . $lang['PostOptions'] . '" title="' . $lang['PostOptions'] . '" border="0" />';
}
if ( ($board_config['modviewip']) || ($userdata['user_level'] == ADMIN) )
{
$ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a><br />';
}

if (($board_config['moddelposts']) || ($postrow[$i]['poster_id'] == $userdata['user_id'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id']) || ($userdata['user_level'] == ADMIN) )
{
$trashforum_id = $board_config['postoptions_trash_id'];
if ($board_config['move_deleted_to_trash'] && $trashforum_id != $forum_id)
{
$topic_title = str_replace($lang['New_topic_title_post_move_prefix'], '', $topic_title);
$temp_url = "modcp.$phpEx?mode=postoptions_split&postoptions_postmove=true&" . POST_TOPIC_URL . "=" . $topic_id . "&split_type_all=" . $postrow[$i]['post_id'] . "&new_forum_id=" . $trashforum_id . "&subject=" . $lang['New_topic_title_post_move_prefix'] . $topic_title . "&sid=" . $userdata['session_id'];
$alttext = $lang['Move_thispost_trashforum'];
}
else
{
$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
$alttext = $lang['Delete_post'];
}
$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>';

$postoptions_delpost = '<b>*</b><a href="' . $temp_url . '" alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_post'] . '</a><br />';
}

if ( ($board_config['modcensor']) || ($userdata['user_level'] == ADMIN) )
{
$script_path = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

for ($a = 1; $a < 7; $a++)
{
$alt = str_replace('%YOURBOARD%', $server_protocol.$server_name.$server_port.$script_path, trim($board_config['censor'.$a]));
$alt = str_replace('%TEMPLATE%', $theme['template_name'], $alt);
$alt = ($userdata['user_id'] != ANONYMOUS) ? str_replace('%LANGUAGE%', 'lang_'.$userdata['user_lang'], $alt) : str_replace('%LANGUAGE%', 'lang_'.$board_config['default_lang'], $alt);
// taking out strange characters which break javascript
$trans = get_html_translation_table(HTML_ENTITIES);
$pre_modmess_chars = strtr($alt, $trans);
$pre_modmess_chars = str_replace(array("\n", "\r"), array('\n', '\r'), $pre_modmess_chars);
$pre_modmess[] = str_replace("'", "\'", $pre_modmess_chars);
// proceeding with normal things
$html_on = true;
$bbcode_on = true;
$smilies_on = true;
$bbcode_uid = make_bbcode_uid();
$alt = prepare_message(trim($alt), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$alt = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $alt);
$alt = bbencode_second_pass($alt, $bbcode_uid);
$alt = smilies_pass($alt);
$alt = str_replace(array('"', '\''), array('"', '\''), $alt);
$alt = preg_replace("/\[.+\]/iU",'',$alt);
$alt_title[] = $alt;
}

$u_censormm1 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[0].'\')" alt="'.$alt_title[0].'" title="'.$alt_title[0].'">1</a>]&nbsp;';
$u_censormm2 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[1].'\')" alt="'.$alt_title[1].'" title="'.$alt_title[1].'">2</a>]&nbsp;';
$u_censormm3 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[2].'\')" alt="'.$alt_title[2].'" title="'.$alt_title[2].'">3</a>]&nbsp;';
$u_censormm4 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[3].'\')" alt="'.$alt_title[3].'" title="'.$alt_title[3].'">4</a>]&nbsp;';
$u_censormm5 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[4].'\')" alt="'.$alt_title[4].'" title="'.$alt_title[4].'">5</a>]&nbsp;';
$u_censormm6 = '[<a href="javascript:predefined_censor(\''.$pre_modmess[5].'\')" alt="'.$alt_title[5].'" title="'.$alt_title[5].'">6</a>]&nbsp;';

if ($postrow[$i]['censor'] == 0)
{
$u_uncensor = '';
$l_censor = $lang['Censor_post'].': ';

$u_censor1 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=1&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[0].'" title="'.$alt_title[0].'">1</a>]&nbsp;';
$u_censor2 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=2&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[1].'" title="'.$alt_title[1].'">2</a>]&nbsp;';
$u_censor3 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=3&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[2].'" title="'.$alt_title[2].'">3</a>]&nbsp;';
$u_censor4 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=4&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[3].'" title="'.$alt_title[3].'">4</a>]&nbsp;';
$u_censor5 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=5&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[4].'" title="'.$alt_title[4].'">5</a>]&nbsp;';
$u_censor6 = '[<a href="'.append_sid("posts_options_userban.$phpEx?censor=".$postrow[$i]['post_id']).'&censortype=6&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$alt_title[5].'" title="'.$alt_title[5].'">6</a>]<br />';
$u_censor7 = '<a href="'.append_sid("viewtopic.$phpEx?".POST_POST_URL."=".$postrow[$i]['post_id']."&censortype=7").'#'.$postrow[$i]['post_id'].'" alt="'.$lang['modmess_alt'].'" title="'.$lang['modmess_alt'].'">'.$lang['add_to'].'</a>';
if ($postrow[$i]['mod_censor_mess'])
{
$u_censor7del = '[<a href="'.append_sid("posts_options_userban.$phpEx?modmessdel=".$postrow[$i]['post_id']).'&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'" alt="'.$lang['del_modmess'].'" title="'.$lang['del_modmess'].'">X</a>]<br />';
}
else
{
$u_censor7del = '<br />';
}
}
else
{
$l_censor = '';
$u_censor1 = '';
$u_censor2 = '';
$u_censor3 = '';
$u_censor4 = '';
$u_censor5 = '';
$u_censor6 = '';
$u_uncensor = '<br /><a href="'.append_sid("posts_options_userban.$phpEx?uncensor=".$postrow[$i]['post_id']).'&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'">' . $lang['UNCensor_post'] . '</a><br />';
$u_censor7 = '<a href="'.append_sid("viewtopic.$phpEx?".POST_POST_URL."=".$postrow[$i]['post_id']."&censortype=7").'#'.$postrow[$i]['post_id'].'" alt="'.$lang['modmess_alt'].'" title="'.$lang['modmess_alt'].'">'.$lang['add_to'].'</a>';
if ($postrow[$i]['mod_censor_mess'])
{
$u_censor7del = '[<a href="'.append_sid("posts_options_userban.$phpEx?modmessdeluncen=".$postrow[$i]['post_id']).'&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'" alt="'.$lang['del_modmess_unc'].'" title="'.$lang['del_modmess_unc'].'">X</a>]<br />';
}
else
{
$u_censor7del = '';
}
}
}

if ($postrow[$i]['user_nopost_time'])
{
$u_resettimeframe = '<a href="'.append_sid("posts_options_userban.$phpEx?reset_timeframe=true"). '&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&'.POST_FORUM_URL.'='.$forum_id.'&'.POST_USERS_URL.'='.$postrow[$i]['user_id'].'" alt="'.$lang['reset_explain'].'" title="'.$lang['reset_explain'].'">' . $lang['reset_thisusers_timeframe'] . '</a><br />';
}
else
{
$u_resettimeframe = '';
}

$trashforum_id = $board_config['postoptions_trash_id'];
if ( ($trashforum_id != $forum_id && $trashforum_id != 0 && $board_config['modmovetotrash']) || ($trashforum_id != $forum_id && $trashforum_id != 0 && $userdata['user_level'] == ADMIN) )
{
if (!$trashforum_id)
{
message_die(GENERAL_MESSAGE, $lang['trasforum_not_set']);
}
$temp_url = "modcp.$phpEx?mode=move&postoptions_topicmove=true&" . POST_TOPIC_URL . "=" . $topic_id . "&" . POST_FORUM_URL . "=" . $forum_id . "&new_forum=" . $trashforum_id . "&sid=" . $userdata['session_id'];
$move_topic_to_trash = '<a href="' . $temp_url . '">' . $lang['Move_topic_trashforum'] . '</a><br />';

$sql = "SELECT post_id
FROM " . POSTS_TABLE . "
WHERE poster_id = " . $postrow[$i]['poster_id'] . "
AND topic_id = $topic_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not get post id information', '', __LINE__, __FILE__, $sql);
}

$post_id_sql = '';
while ($row = $db->sql_fetchrow($result))
{
$post_id_sql .= (($post_id_sql != '') ? '^' : '') . intval($row['post_id']);
}
$db->sql_freeresult($result);
if ($forum_topic_data['topic_first_post_id'] != $post_id_sql && $forum_topic_data['topic_last_post_id'] != $post_id_sql)
{
$temp_url = "modcp.$phpEx?mode=postoptions_split&postoptions_postmove=true&" . POST_TOPIC_URL . "=" . $topic_id . "&split_type_all=" . $post_id_sql . "&new_forum_id=" . $trashforum_id . "&subject=" . $lang['New_topic_title_post_move_prefix'] . $topic_title . "&sid=" . $userdata['session_id'];
$move_posts_to_trash = '<a href="' . $temp_url . '">' . $lang['Move_allpost_trashforum'] . '</a><br />';

$temp_url = "modcp.$phpEx?mode=postoptions_split&postoptions_postmove=true&" . POST_TOPIC_URL . "=" . $topic_id . "&split_type_all=" . $postrow[$i]['post_id'] . "&new_forum_id=" . $trashforum_id . "&subject=" . $lang['New_topic_title_post_move_prefix'] . $topic_title . "&sid=" . $userdata['session_id'];
$move_post_to_trash = '<a href="' . $temp_url . '">' . $lang['Move_thispost_trashforum'] . '</a><br />';
}
}
else if ( ($trashforum_id != 0 && $board_config['modmovetotrash']) || ($trashforum_id != 0 && $userdata['user_level'] == ADMIN) )
{
if (!$trashforum_id)
{
message_die(GENERAL_MESSAGE, $lang['trasforum_not_set']);
}
$sql2 = "SELECT topic_id, old_forum_id
FROM " . TRASH_TOPICS_TABLE . "
WHERE topic_id = $topic_id";
$result2 = $db->sql_query($sql2);
$row = $db->sql_fetchrow($result2);
$db->sql_freeresult($result2);
if ($row['topic_id'] == $topic_id)
{
$putback_forum_id = intval($row['old_forum_id']);
$temp_url = "modcp.$phpEx?mode=move&postoptions_topicmove=1&" . POST_TOPIC_URL . "=" . $topic_id . "&" . POST_FORUM_URL . "=" . $forum_id . "&new_forum=" . $putback_forum_id . "&sid=" . $userdata['session_id'];
$move_topic_from_trash = '<a href="' . $temp_url . '">' . $lang['Move_topic_from_trash'] . '</a><br />';
}
$sql2 = "SELECT topic_id
FROM " . TRASH_POSTS_TABLE . "
WHERE topic_id = $topic_id";
$result2 = $db->sql_query($sql2);
$row = $db->sql_fetchrow($result2);
if ($row['topic_id'] == $topic_id)
{
$putback_topic_id = intval($row['old_topic_id']);
$temp_url = "modcp.$phpEx?mode=mergeback&" . POST_TOPIC_URL . "=" . $topic_id . "&" . POST_FORUM_URL . "=" . $forum_id . "&sid=" . $userdata['session_id'];
$move_posts_from_trash = '<a href="' . $temp_url . '">' . $lang['Move_posts_from_trash'] . '</a><br />';
}
$move_post_to_trash = '';
$move_posts_to_trash = '';
}

if ( ($board_config['moddelposts']) || ($userdata['user_level'] == ADMIN) )
{
$temp_url = "posting.$phpEx?mode=delete&delete_all_posts_topic=1&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $postrow[$i]['topic_id'] . "&poster_id=" . $postrow[$i]['poster_id'] . "&sid=" . $userdata['session_id'];
$delallposttopic = '<b>*</b><a href="' . $temp_url . ' alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_all_post_topic'] . '</a><br />';

if ($forum_topic_data['topic_first_post_id'] != $postrow[$i]['post_id'])
{
$temp_url = "posting.$phpEx?mode=delete&delete_all_from_post=1&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $postrow[$i]['topic_id'] . "&poster_id=" . $postrow[$i]['poster_id'] . "&sid=" . $userdata['session_id'];
$delallpostfromreply = '<b>*</b><a href="' . $temp_url . ' alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_all_post_from_reply'] . '</a><br />';
}

if ( ($board_config['moddelall_boardwide'] == true) || ($userdata['user_level'] == ADMIN) )
{
$temp_url = "posting.$phpEx?mode=delete&delete_all_posts_board=1&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $postrow[$i]['topic_id'] . "&poster_id=" . $postrow[$i]['poster_id'] . "&sid=" . $userdata['session_id'];
$delallpostboard = '<b>*</b><a href="' . $temp_url . ' alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_all_post_board'] . '</a><br />';

$temp_url = "posting.$phpEx?mode=delete&delete_all_posts_board=1&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $postrow[$i]['topic_id'] . "&del_u=true&poster_id=" . $postrow[$i]['poster_id'] . "&".POST_FORUM_URL."=". $forum_id ."&sid=" . $userdata['session_id'];
$deluser_allpostboard = '<b>*</b><a href="' . $temp_url . ' alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_User_And_All_Posts'] . '</a><br />';
}
}
// END PostOptions by Wicher
}
else
{
$ip_img = '';
$ip = '';

// BEGIN PostOptions by Wicher
if ($board_config['postoptions_report_system'] && $board_config['reg_can_report'] && $userdata['session_logged_in'])
{
$temp_url = 'posts_options_reports.'.$phpEx.'?regreport=true&user='.$poster_id.'&'.POST_FORUM_URL.'=' . $forum_id . '&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$postrow[$i]['post_id'].'&sid=' . $userdata['session_id'];
$report_img = '<img src="' . $images['icon_report'] . '" alt="' . $lang['Report_this'] . '" title="' . $lang['Report_this'] . '" border="0" />';
$report = '<a href="' . $temp_url . '">' . $report_img . '</a>';
}
else
{
$report_img = '';
$report = '';
}
// END PostOptions by Wicher

if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] || $allowed_to_approve && $postrow[$i]['post_approve'] )
{
// BEGIN PostOptions by Wicher
if ($board_config['move_deleted_to_trash'])
{
$topic_title = str_replace($lang['New_topic_title_post_move_prefix'], '', $topic_title);
$temp_url = "modcp.$phpEx?mode=postoptions_split&postoptions_postmove=true&" . POST_TOPIC_URL . "=" . $topic_id . "&split_type_all=" . $postrow[$i]['post_id'] . "&new_forum_id=" . $trashforum_id . "&subject=" . $lang['New_topic_title_post_move_prefix'] . $topic_title . "&sid=" . $userdata['session_id'];
$alttext = $lang['Move_thispost_trashforum'];
}
else
{
$temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
$alttext = $lang['Delete_post'];
}
$delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $alttext . '" title="' . $alttext . '" border="0" /></a>';
$delpost = '<a href="' . $temp_url . '">' . $alttext . '</a>';
// END PostOptions by Wicher
}
else
{
$delpost_img = '';
$delpost = '';
}
}

// BEGIN PostOptions by Wicher
if (!$postrow[$i]['censor'])
{
$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';



//mod - post points
$postvotepoints = ( $postrow[$i]['post_points'] != '' ) ? $postrow[$i]['post_points'] : '0';
$post_vote_points_text = $lang['Postpoints_Points'] . ': ';
if ($is_first_post == 1)
{
$postvotepoints = '';
$post_vote_points_text = '';
}
$poster_points = ( $postrow[$i]['user_points'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Postpoints_poster_points'] . ': ' . $postrow[$i]['user_points'] : '';





}
else
{
$post_subject = $lang['subject_censored'];
}

if ( ($postrow[$i]['censor'] != 0) && ($postrow[$i]['censor'] != 7) && ($postrow[$i]['censor'] != 8) )
{
$script_path = preg_replace('/^\/?(.*?)\/?$/', "\\1", trim($board_config['script_path']));
$server_name = trim($board_config['server_name']);
$server_protocol = ( $board_config['cookie_secure'] ) ? 'https://' : 'http://';
$server_port = ( $board_config['server_port'] <> 80 ) ? ':' . trim($board_config['server_port']) . '/' : '/';

$message = str_replace('%YOURBOARD%', $server_protocol.$server_name.$server_port.$script_path, trim($board_config['censor'.$postrow[$i]['censor']]));
$message = str_replace('%TEMPLATE%', $theme['template_name'], $message);
$message = ($userdata['user_id'] != ANONYMOUS) ? str_replace('%LANGUAGE%', 'lang_'.$userdata['user_lang'], $message) : str_replace('%LANGUAGE%', 'lang_'.$board_config['default_lang'], $message);
$html_on = true;
$bbcode_on = true;
$smilies_on = true;
$bbcode_uid = make_bbcode_uid();
$message = prepare_message(trim($message), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$modmess = $postrow[$i]['mod_censor_mess'];
$modmess = prepare_message(trim($modmess), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$message .= $modmess;
}
else
{
$message = $postrow[$i]['post_text'];
$modmess = $postrow[$i]['mod_censor_mess'];
$html_on = true;
$bbcode_on = true;
$smilies_on = true;
$bbcode_uid = $postrow[$i]['bbcode_uid'];
$modmess = prepare_message(trim($modmess), $html_on, $bbcode_on, $smilies_on, $bbcode_uid);
$message .= $modmess;
if (($postrow[$i]['censor'] == 8))
{
$message = $modmess;
}
}

if (!$postrow[$i]['censor'])
{
$user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
}
else
{
$user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $lang['sig_censored'] : '';
}
// END PostOptions by Wicher
$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];

//
// 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 ($user_sig != '' && $user_sig_bbcode_uid != '')
{
$user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
}

if ($bbcode_uid != '')
{
$message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/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 has been back-ported from 3.0 CVS
$message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*>)#i', '<b style="color:#'.$theme['fontcolor3'].'">\1</b>', $message);
}

//
// 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 = '';
}

// START ADD Reputation Mod v.1.0.0
$reputation = '';
if ($postrow[$i]['user_id'] != ANONYMOUS)
{
if ($rep_config['rep_disable'] == 0)
{
if ($postrow[$i]['user_reputation'] == 0)
{
$reputation = $lang['Zero_reputation'];
} else
{
if ($rep_config['graphic_version'] == 0)
{
// Text version
$reputation = $lang['Reputation'] . ": ";
if ($postrow[$i]['user_reputation'] > 0)
{
$reputation .= "<strong><font color=\"green\">" . round($postrow[$i]['user_reputation'],1) . "</font></strong>";
} else {
$reputation .= "<strong><font color=\"red\">" . round($postrow[$i]['user_reputation'],1) . "</font></strong>";
}
$reputation_add = '';
} else {
// Graphic version
get_reputation_medals($postrow[$i]['user_reputation']);
}
}
$reputation .= " <a href=\"" . append_sid("reputation.$phpEx?a=add&" . POST_USERS_URL . "=" . $postrow[$i]['user_id']) . "&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&c=" . substr(md5($bbcode_uid),0,8) . "\" target=\"_blank\" onClick=\"popupWin = window.open(this.href, '" . $lang['Reputation'] . "', 'location,width=700,height=400,top=0,scrollbars=yes'); popupWin.focus(); return false;\"><p></p><img src=\"images/reputationaddplusag9.gif\" alt=\"\" border=\"0\"></a>";
$sql = "SELECT COUNT(user_id) AS count_reps
FROM " . REPUTATION_TABLE . " AS r
WHERE r.user_id = " . $postrow[$i]['user_id'] . "
GROUP BY user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain reputation stats for this user", '', __LINE__, __FILE__, $sql);
}
$row_rep = $db->sql_fetchrow($result);
if ($row_rep)
{
$reputation .= "<br /><a href=\"" . append_sid("reputation.$phpEx?a=stats&" . POST_USERS_URL . "=" . $postrow[$i]['user_id']) . "\" target=\"_blank\" onClick=\"popupWin = window.open(this.href, '" . $lang['Reputation'] . "', 'location,width=700,height=400,top=0,scrollbars=yes'); popupWin.focus(); return false;\">" . $lang['Votes'] . "</a>: " . $row_rep['count_reps'];
}
}
}
// END ADD Reputation Mod v.1.0.0



//-- mod : post icon -------------------------------------------------------------------------------
//-- add
$post_subject = get_icon_title($postrow[$i]['post_icon']) . '&nbsp;' . $post_subject;
//-- fin mod : post icon ---------------------------------------------------------------------------





if ( $poster_id != ANONYMOUS )
{
$style_color = ($user_color = color_groups_user($poster_id)) ? ' style="font-weight:bold;color: #' . $user_color . '"' : '';
$poster = '<span' . $style_color . '>' . $poster . '</span>';
}

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

if ( $postrow[$i]['user_level'] == ADMIN )
{
$poster_color = ' style="color: #' . $theme['fontcolor3'] . '"';
}
else if ( $postrow[$i]['user_level'] == MOD )
{
$poster_color = ' style="color: #' . $theme['fontcolor2'] . '"';
}
else
{
$poster_color = '';
}
// approval block start
if ( $postrow[$i]['post_approve'] )
{
if ( ($userdata['user_id'] == $poster_id && $userdata['user_id'] != ANONYMOUS) || $allowed_to_approve )
{
$post_subject = $post_subject . ' <span class="topicUnapproved">' . $lang['Approval_unapproved_subject'] . '</span>';
}
else
{
$post_subject = '<span class="topicUnapproved">' . $lang['Approval_unapproved_subject'] . '</span>';
}
}

if ( $postrow[$i]['post_approve'] && !$allowed_to_approve && ($userdata['user_id'] != $poster_id || $userdata['user_id'] == ANONYMOUS) )
{
$message = $lang['Approval_unapproved_text'];
$quote_img = '';
$quote = '';
}

if ( $forum_topic_data['topic_approve'] )
{
$quote_img = '';
$quote = '';
}

if ( $postrow[$i]['post_approve'] && $allowed_to_approve )
{
$temp_url = "posting.$phpEx?mode=approve&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
$approve_mod_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_approve'] . '" alt="' . $lang['Approval_approve_this'] . '" title="' . $lang['Approval_approve_this'] . '" border="0" /></a>';
$approve = '<a href="' . $temp_url . '">' . $lang['Approval_approve_this'] . '</a>';
}
else
{
$approve_mod_img = '';
$approve = '';
}
// approval block end

// BEGIN PostOptions by Wicher
$post_id = $postrow[$i]['post_id'];
if ($poster_id != ANONYMOUS && $postrow[$i]['user_level'] != ADMIN && $postrow[$i]['user_level'] != MOD)
{
$poster_ip = $postrow[$i]['poster_ip'];
$poster_email = $postrow[$i]['user_email'];
if ( ($board_config['mod_ban']) || ($userdata['user_level'] == ADMIN) )
{
include($phpbb_root_path . 'includes/posts_options_include.' . $phpEx);
}
if ( ($board_config['mod_del_user']) || ($userdata['user_level'] == ADMIN) )
{
$u_delete_user = '<b>*</b><a href="'.append_sid("posts_options_userdel.$phpEx?deleteuser=".$poster_id).'&'.POST_FORUM_URL.'=' . $forum_id . '&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$post_id.'" alt="' . $lang['be_carefull'] . '" title="' . $lang['be_carefull'] . '">' . $lang['Delete_user'] . '</a><br />';
}
}
else
{
$u_posterban = '';
if ($poster_id != ANONYMOUS)
{
$u_ipban = '';
}
$u_emailban = '';
$u_total_userban = '';
$u_total_userunban = '';
$u_delete_user = '';
$delallposttopic = '';
$delallpostfromreply = '';
$delallpostboard = '';
$deluser_allpostboard = '';
}
if ($board_config['postoptions_report_system'])
{
$u_report = '<a href="'.append_sid("posts_options_reports.$phpEx?user=".$poster_id).'&'.POST_FORUM_URL.'=' . $forum_id . '&'.POST_TOPIC_URL.'='.$topic_id.'&'.POST_POST_URL.'='.$post_id.'">' . $lang['Report_this'] . '</a><br />';
}
// END PostOptions by Wicher

//
// Start Thank Post by User Mod
//

// If the user isn't anonymous then show the user's thanks given and thanks received
if ($postrow[$i]['user_id'] != ANONYMOUS) {

// Thanks by
$sql = "SELECT COUNT(thanks_by) AS thanks_by
FROM phpbb_thanksmod
WHERE thanks_by = " . $postrow[$i]['user_id'];

if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}

$thanks_by_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

// Thanked user
$sql = "SELECT post_id, thanked_user
FROM phpbb_thanksmod
WHERE thanked_user = '" . $postrow[$i]['user_id'] . "'
ORDER BY post_id";

if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}

// Calculate the user's thanks given and thanks received
$thanked_count = 0;
$thanked_posts = 0;
$old_post_id = 0;
while ($row = mysql_fetch_array($result)) {
if ($row['post_id'] != $old_post_id) {
$thanked_posts++;
}
$old_post_id = $row['post_id'];
$thanked_count++;
}

$thanks_given = $lang['Thanks_thanks'] . ': ' . $thanks_by_row['thanks_by'];
$thanks_received = $lang['Thanks_thanked_1'] . ' ' . $thanked_count . ' ' . $lang['Thanks_thanked_2'] . ' ' . $thanked_posts . ' ' . $lang['Thanks_thanked_3'];

}
else {
$thanks_given = '';
$thanks_received = '';
}

//
// End Thank Post by User Mod
//

$template->assign_block_vars('postrow', array(
// Start Online/Offline Status Images MOD
'STATUS_IMG' => display_online_offline($poster_id, $online_array),
// End Online/Offline Status Images MOD
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => ( $postrow[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $poster_id) . '" class="name"' . $poster_color . '>' . $poster . '</a>' : $poster,

'CUSTOM_TITLE' => $custom_title,

// Mighty Gorgon - Multiple Ranks - BEGIN
'USER_RANK_01' => $user_rank_01,
'USER_RANK_01_IMG' => $user_rank_01_img,
'USER_RANK_02' => $user_rank_02,
'USER_RANK_02_IMG' => $user_rank_02_img,
'USER_RANK_03' => $user_rank_03,
'USER_RANK_03_IMG' => $user_rank_03_img,
'USER_RANK_04' => $user_rank_04,
'USER_RANK_04_IMG' => $user_rank_04_img,
'USER_RANK_05' => $user_rank_05,
'USER_RANK_05_IMG' => $user_rank_05_img,
// Mighty Gorgon - Multiple Ranks - END
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,


// Topics a user has started MOD, By Manipe (Begin)
'POSTER_TOPICS' => $poster_topics,
// Topics a user has started MOD, By Manipe (End)

'POSTER_FROM' => $poster_from,

'POSTER_THANKS_GIVEN' => $thanks_given,
'POSTER_THANKS_RECEIVED' => $thanks_received,


// START ADD Reputation Mod v.1.0.0
'REPUTATION_ADD' => $reputation_add,
'REPUTATION' => $reputation,
// END ADD Reputation Mod v.1.0.0

'POSTER_AVATAR' => $poster_avatar,
#======================================================================= |
#==== Start: == Activity Mod Plus ====================================== |
#==== v1.1.0 =========================================================== |
#====
'POSTER_TROPHY' => Amod_Build_Topics($hof_data, $postrow[$i]['user_id'], $postrow [$i]['user_trophies'], $postrow[$i]['username'], $postrow[$i]['ina_char_name']),
#====
#==== Author: aUsTiN [austin@phpbb-amod.com] [http://phpbb-amod.com] === |
#==== End: ==== Activity Mod Plus ====================================== |
#======================================================================= |
'POST_NUMBER' => ($i + $start + 1),

'POST_DATE' => $post_date,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'SIGNATURE' => $user_sig,
'EDITED_MESSAGE' => $l_edited_by,


//mod - post points
'POSTVOTE_POINTS' => $postvotepoints,

'VB_MENU_PROFILE' => $vb_menu_profile,
'VB_MENU_EMAIL' => $vb_menu_email,
'VB_MENU_PM' => $vb_menu_pm,
'VB_MENU_WWW' => $vb_menu_www,
'VB_MENU_SEARCH' => $vb_menu_search,
//'VB_MENU_ALBUM' => $vb_menu_album,
'VB_MENU_ID' => $vb_menu_id,
'VB_MENU_L_PROFILE' => $vb_menu_l_profile,
'VB_MENU_L_EMAIL' => $vb_menu_l_email,
'VB_MENU_L_PM' => $vb_menu_l_pm,
'VB_MENU_L_WWW1' => $vb_menu_l_www1,
'VB_MENU_L_WWW2' => $vb_menu_l_www2,
'VB_MENU_L_SEARCH' => $vb_menu_l_search,
//'VB_MENU_L_ALBUM' => $vb_menu_l_album,


'MINI_POST_IMG' => $mini_post_img,

'BUDDY_IMG' => $buddy_img,

'PROFILE_IMG' => $profile_img,
'PROFILE' => $profile,
'SEARCH_IMG' => $search_img,
'SEARCH' => $search,
'PM_IMG' => $pm_img,
'PM' => $pm,
'EMAIL_IMG' => $email_img,
'EMAIL' => $email,
'WWW_IMG' => $www_img,
'WWW' => $www,
'ICQ_STATUS_IMG' => $icq_status_img,
'ICQ_IMG' => $icq_img,
'ICQ' => $icq,
'AIM_IMG' => $aim_img,
'AIM' => $aim,
'MSN_IMG' => $msn_img,
'MSN' => $msn,
'YIM_IMG' => $yim_img,
'YIM' => $yim,
'EDIT_IMG' => $edit_img,
'EDIT' => $edit,
'THANKS_IMG' => $thanks_img,
'QUOTE_IMG' => $quote_img,
'QUOTE' => $quote,
'IP_IMG' => $ip_img,
'IP' => $ip,
'DELETE_IMG' => $delpost_img,
'DELETE' => $delpost,

//mod - post points
'I_POSTVOTE_UP' => $postvote_up_img,
'I_POSTVOTE_DOWN' => $postvote_down_img,

// BEGIN PostOptions by Wicher
'TD' => (isset($HTTP_GET_VARS['censortype'])) ? '<td>' : '',
'REPORT' => $report,
'U_POSTOPTIONS_DELETE' => $postoptions_delpost,
'U_POSTER_BAN' => $u_posterban,
'U_POSTER_IP_BAN' => $u_ipban,
'U_POSTER_EMAIL_BAN' => $u_emailban,
'U_TOTAL_BAN' => $u_total_userban,
'U_TOTAL_UNBAN' => $u_total_userunban,
'L_CENSOR' => $l_censor,
'U_CENSOR1' => $u_censor1,
'U_CENSOR2' => $u_censor2,
'U_CENSOR3' => $u_censor3,
'U_CENSOR4' => $u_censor4,
'U_CENSOR5' => $u_censor5,
'U_CENSOR6' => $u_censor6,
'U_CENSOR7' => $u_censor7,
'U_UNCENSOR' => $u_uncensor,
'U_DEL_MODMESS'=> $u_censor7del,
'U_RESET_TIMEFRAME' => $u_resettimeframe,
'U_DELETE_USER' => $u_delete_user,
'U_DELETE_ALL_POSTS_TOPIC' => $delallposttopic,
'U_DELETE_ALL_POSTS_FROM_REPLY' => $delallpostfromreply,
'U_DELETE_ALL_POSTS_BOARD' => $delallpostboard,
'U_DEL_USER_AND_ALL_POSTS' => $deluser_allpostboard,
'U_MOVE_TOPIC_TO_TRASH' => $move_topic_to_trash,
'U_MOVE_TOPIC_FROM_TRASH' => $move_topic_from_trash,
'U_MOVE_POST_TO_TRASH' => $move_post_to_trash,
'U_MOVE_POSTS_TO_TRASH' => $move_posts_to_trash,
'U_MOVE_POSTS_FROM_TRASH' => $move_posts_from_trash,
'U_REPORT_THIS_POST' => $u_report,
// END PostOptions by Wicher
// approval block start
'APPROVE_MOD_IMG' => $approve_mod_img,
'APPROVE' => $approve,
// approval block end
'L_MINI_POST_ALT' => $mini_post_alt,

//mod - post points
'L_POSTVOTE_POINTS' => $post_vote_points_text,

'U_MINI_POST' => $mini_post_url,
'U_POST_ID' => $postrow[$i]['post_id'])
);

//
// Start Thank Post by User Mod
//

// If the user isn't anonymous and thanks on this fourm is enabled
if ($postrow[$i]['user_id'] != ANONYMOUS && $thanks_forum_enabled == 1) {

$thanked_by = '';

// Thanked post
$sql = "SELECT thanks_by
FROM phpbb_thanksmod
WHERE post_id = '" . $postrow[$i]['post_id'] . "'
ORDER BY thanked_time ASC";

if ( !($result = $db->sql_query($sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}

$x = 0;
while ($row = mysql_fetch_array($result)) {

// Users SQL
$users_sql = "SELECT user_id, username
FROM " . USERS_TABLE . "
WHERE user_id = '" . $row['thanks_by'] . "'";

if ( !($users_result = $db->sql_query($users_sql)) ) {
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $users_sql);
}

$user_row = $db->sql_fetchrow($users_result);
$db->sql_freeresult($users_result);

if ($x >= 1) { $thanked_by .= ", "; }

// Add user to thanked by list
$temp_url = "profile.$phpEx?mode=viewprofile&u=" . $user_row['user_id'];
$thanked_by .= '<a href="' . $temp_url . '">' . $user_row['username'] . '</a>';

$x++;
}

if ($thanked_by) {
$template->assign_block_vars('postrow.thanks', array(
'L_THANKS_TEXT' => $lang['Thanks_thanked_by'],
'THANKS_USERS' => $thanked_by)
);
}
}

//
// End Thank Post by User Mod
//



if($i == $ad_after)
{
$row_color = ( !($num % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($num % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
$num ++;

$mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#ad';
$template->assign_block_vars('postrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POST_DATE' => $post_date,
'POST_SUBJECT' => 'Please Click the Ads to Support Us',
'MINI_POST_IMG' => $mini_post_img,
'POSTER_NAME' => 'ADVERTISEMENT ',
'POSTER_RANK' => 'AdSense',
'POSTER_AVATAR' => '<A HREF="" target="blank"><IMG SRC="images/adsvtar.jpg" Border=0></A>',
'MESSAGE' => '<div align="center"><SPAN class="gensmall">
<script type="text/javascript"><!--
google_ad_client = "pub-2723335651581214";
/* Pimpd space 300x250 */
google_ad_slot = "4036385906";
google_ad_width = 300;
google_ad_height = 250;
google_cpa_choice = ""; // on file
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>


</SPAN></div>',
'L_MINI_POST_ALT' => $mini_post_alt,
'U_MINI_POST' => $mini_post_url,
'U_POST_ID' => 'ad')
);
}






// BEGIN PostOptions by Wicher
if ($postrow[$i]['reported'] && $postrow[$i]['reported_mess'] && $board_config['ReportSystem_user_view_message'])
{
$template->assign_block_vars('postrow.switch_reported', array(
'L_REPORTED' => $lang['Post_reported']
));
}
if (isset($HTTP_GET_VARS['censortype']))
{
$p_id = intval($HTTP_GET_VARS[POST_POST_URL]);
if (intval($HTTP_GET_VARS['censortype']) == 7)
{
$mod_post_mess = $postrow[$i]['mod_censor_mess'];
$predefined = $u_censormm1.$u_censormm2.$u_censormm3.$u_censormm4.$u_censormm5.$u_censormm6;
display_modmessbox($post_id, $p_id, $predefined, $mod_post_mess, $topic_id, $forum_id, $poster);
}
}
// END PostOptions by Wicher

}


//
// Quick Reply and Actions Mod
//
if ( ((!$is_auth['auth_reply']) or ($forum_topic_data['forum_status'] == FORUM_LOCKED) or ($forum_topic_data['topic_status'] == TOPIC_LOCKED)) and ($userdata['user_level'] != ADMIN) )
{
$quick_reply_form = "";
}
else
{
if ( $can_watch_topic && $is_watching_topic )
{
$notify = 1;
}
else
{
$notify = $userdata['user_notify'];
}
$bbcode_uid = $postrow[$total_posts - 1]['bbcode_uid'];
$last_poster = $postrow[$total_posts - 1]['username'];
$last_msg = $postrow[$total_posts - 1]['post_text'];
$last_msg = str_replace(":1:$bbcode_uid", "", $last_msg);
$last_msg = str_replace(":u:$bbcode_uid", "", $last_msg);
$last_msg = str_replace(":o:$bbcode_uid", "", $last_msg);
$last_msg = str_replace(":$bbcode_uid", "", $last_msg);
$last_msg = str_replace("'", "'", $last_msg);
$last_msg = "
\"$last_poster\" wrote:" . $last_msg . "
";
$quick_reply_form = "
<script language='JavaScript' type='text/javascript'>
function checkForm() {
formErrors = false;
document.post.message.value = '';
if (document.post.input.value.length < 2) {
formErrors = '" . $lang['Empty_message'] . "';
}
if (formErrors) {
alert(formErrors);
return false;
} else {
if (document.post.quick_quote.checked) {
document.post.message.value = document.post.last_msg.value;
}
document.post.message.value += document.post.input.value;
return true;
}
}
</script>
<form action='".append_sid("posting.$phpEx")."' method='post' name='post' onsubmit='return checkForm(this)'>
<span class='genmed'><b>".$lang["Quick_Reply"].":</b><br />";

if (!$userdata['session_logged_in'])
{
$quick_reply_form .= $lang['Username'] . ":&nbsp;<input class='post' type='text' name='username' size='25' maxlength='25' value='' /><br />";
}

$quick_reply_form .= "<textarea name='input' rows='6' style='width: 98%;' wrap='virtual' class='post''></textarea><br />
<input type='checkbox' name='quick_quote' />".$lang["Quick_quote"]."<br />
<input type='checkbox' name='attach_sig' checked='checked' />".$lang["Attach_signature"]."<br />
<input type='hidden' name='mode' value='reply' />
<input type='hidden' name='sid' value='" . $userdata['session_id'] . "' />
<input type='hidden' name='t' value='" . $topic_id . "' />
<input type='hidden' name='message' value='' />
<input type='hidden' name='notify' value=" . $notify . " />
<input type='hidden' name='last_msg' value='" . $last_msg . "' />
<input type='submit' name='preview' class='liteoption' value='".$lang['Preview']."' />&nbsp;
<input type='submit' name='post' class='mainoption' value='".$lang["Submit"]."' />
</form></span>";
}

$template->assign_vars(array(
'QUICK_REPLY_FORM' => $quick_reply_form)
);
//
// END Quick Reply and Actions Mod
//


$template->pparse('body');

if(isset($HTTP_GET_VARS['printertopic']))
{
$gen_simple_header = 1;
}



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

?>

User avatar
Zaid
Registered User
Posts: 590
Joined: Thu Nov 08, 2007 2:06 pm
Location: South Pacific Ocean

Re: [BETA] Post Points

Post by Zaid » Tue Jun 17, 2008 2:13 pm

NEED SOME HELP HERE DAMN!

leo.niu
Registered User
Posts: 6
Joined: Thu Jun 19, 2008 3:22 pm

Re: [BETA] Post Points

Post by leo.niu » Thu Jun 19, 2008 3:30 pm

freejoe76 wrote:Hi,

I just got the first draft of the (heavily edited) Post Points working in phpbb3.0 -- is anybody interested in the code?

-Joe
May I have the draft also? I am really crazy with it. Thanks a lot!

Leo

leo.niu
Registered User
Posts: 6
Joined: Thu Jun 19, 2008 3:22 pm

Re: [BETA] Post Points

Post by leo.niu » Thu Jun 19, 2008 3:33 pm

SpilltheBeans wrote: I still need to package it to mod format, but I wanted to put it out there first to see if there is any demand. Also, I'd like to work on a phpBB3 version of this, so I may not do too much more for the phpBB2 version. Is anyone intersted in this type of mod?
hi SpilltheBeans,

Are you still working on the phpbb3 version for this mod? Hope you can figure it out soon, or do you have part of changes done already?

User avatar
Zaid
Registered User
Posts: 590
Joined: Thu Nov 08, 2007 2:06 pm
Location: South Pacific Ocean

Re: [BETA] Post Points

Post by Zaid » Fri Jun 20, 2008 9:35 am

u gona help me or what!

Avatar de Io
Registered User
Posts: 6
Joined: Mon May 15, 2006 5:37 am
Location: Perú
Contact:

Re: [BETA] Post Points

Post by Avatar de Io » Fri Jun 20, 2008 2:05 pm

AcidRain wrote:u gona help me or what!
Hey dude, first of all, you must know a few things before ask for help.

When someone needs help, never must expect a sooner answer. The help comes or not, and it comes if the community is interested in the theme, but since phpBB declared officially that they never more will give support for phpBB2, I suppose that the creator of this mod and all people around are at this time more worried about the possibility of migrate to phpBB3, than check in old and near dead topics inside phpBB2.

Second, and concerning your trouble, I'm never installed it in my forum, because a hard trouble of compatibility, and this is another reason to leave the idea of put this mod in your site. Since we see a lot of mods here, we cannot have a 100% security that all of this works like a charming. If one mod does'nt run, then leave and continue your effort with another, as simple as that.

Regularly people that have more skills in php or related programming languages can tweak the difficult or malformed codes and use this in his sites, but in the other hand, if you don't own this skills, the most reasonable is ask for help in a good way or pay for help (the last one never fails).

As i said lines above, I'm never try this mod, but, since I have certain experience with phpBB2 and phpBB plus, I can recommend three possible solutions:

1.- Check the last line of your viewtopic.php and delete the blank space in the end of the code.

I never understand why, but in my life using phpBB and other scripts, sometimes a white space appears at the end of a script and generate errors like yours.

This blank could exist after the php closing ?>

Simply check for this blank space and delete it, then replace your viewtopic.php and see if it works.

2.- A closing curly bracket } need to be placed in the script to close properly a sentence.

Since the debug of phpBB2 declared that the error line is the 2668, then you must put the } in this line, and you must see something like this in the last 3 lines:

Code: Select all

include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
?>
3.- Sometimes your server doesn't accept the short open of php and it must be <?php instead of <? (Sincerely I don't think so that this is the trouble, because you use the file before the mod with no trouble, so leave this change to the last).

Let me know If you can resolve this. If negative, You can hire me :wink:
Image

Post Reply

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