sql_query($q);
$hof_data = $db->sql_fetchrowset($r);
}
// Activity - END
// Start initial var setup
$topic_id = $post_id = 0;
if ( isset($_GET[POST_TOPIC_URL]) )
{
$topic_id = intval($_GET[POST_TOPIC_URL]);
}
elseif ( isset($_GET['topic']) )
{
$topic_id = intval($_GET['topic']);
}
if ( isset($_GET[POST_POST_URL]))
{
$post_id = intval($_GET[POST_POST_URL]);
}
$kb_mode = false;
if ( isset($_GET['kb']) )
{
$kb_mode = ( $_GET['kb'] == true ) ? true : false;
}
elseif ( isset($_POST['kb']) )
{
$kb_mode = ( $_POST['kb'] == true ) ? true : false;
}
$start = ( isset($_GET['start']) ) ? intval($_GET['start']) : 0;
$start = ($start < 0) ? 0 : $start;
$download = ( isset($_GET['download']) ) ? $_GET['download'] : '';
if (!$topic_id && !$post_id)
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
// Find topic id if user requested a newer or older topic
if ( isset($_GET['view']) && empty($_GET[POST_POST_URL]) )
{
if ( $_GET['view'] == 'newest' )
{
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($_GET['sid']) )
{
$session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $_GET['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);
}
/* UPI2DB REPLACE
if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
}
*/
//
if ( !($row = $db->sql_fetchrow($result)) )
{
if ( $topic_id != 0 )
{
redirect(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id);
}
else
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
}
}
//
$post_id = $row['post_id'];
if (isset($_GET['sid']))
{
redirect(VIEWTOPIC_MG . '?sid=' . $session_id . '&' . POST_POST_URL . '=' . $post_id . '#p' . $post_id);
}
else
{
redirect(VIEWTOPIC_MG . '?' . POST_POST_URL . '=' . $post_id . '#p' . $post_id);
}
}
}
redirect(append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id, true));
}
elseif ( $_GET['view'] == 'next' || $_GET['view'] == 'previous' )
{
$sql_condition = ( $_GET['view'] == 'next' ) ? '>' : '<';
$sql_ordering = ( $_GET['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']);
redirect('./' . VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id);
}
else
{
$message = ( $_GET['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
message_die(GENERAL_MESSAGE, $message);
}
}
}
$board_config['topics_per_page'] = ( $userdata['user_topics_per_page'] == '' ) ? $board_config['topics_per_page'] : $userdata['user_topics_per_page'];
$board_config['posts_per_page'] = ( $userdata['user_posts_per_page'] == '' ) ? $board_config['posts_per_page'] : $userdata['user_posts_per_page'];
$board_config['hot_threshold'] = ( $userdata['user_hot_threshold'] == '' ) ? $board_config['hot_threshold'] : $userdata['user_hot_threshold'];
//
// 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";
$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.auth_ban, f.auth_greencard, f.auth_bluecard ORDER BY p.post_id ASC";
$sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, t.title_compl_infos, t.topic_first_post_id, t.topic_calendar_time, t.topic_calendar_duration, 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_rules, f.rules_display_title, f.rules_custom_title, f.rules_in_viewtopic, f.auth_ban, f.auth_greencard, f.auth_bluecard" . $count_sql . "
FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
WHERE $join_sql
AND f.forum_id = t.forum_id
$order_sql";
attach_setup_viewtopic_auth($order_sql, $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']);
$topic_id = intval($forum_topic_data['topic_id']);
// Thanks Mod - BEGIN
if ( $board_config['disable_thanks_topics'] == false )
{
// Check if the Thanks feature is active for this forum
$sql = "SELECT `thank`
FROM " . FORUMS_TABLE . "
WHERE `forum_id` = '" . $forum_id . "' ";
if ( !($result = $db->sql_query($sql, false, 'thanks_')) )
{
message_die(GENERAL_ERROR, "Could not obtain forum information", '', __LINE__, __FILE__, $sql);
}
if ( !($forum_thank_result = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'Forum "thanks" information doesn\'t exists');
}
$forum_thank_result = $forum_thank_result['thank'];
// Setting if feature is active or not
switch($forum_thank_result)
{
case '1':
$show_thanks = 1;
break;
default:
$show_thanks = 0;
break;
}
}
else
{
$show_thanks = 0;
}
// Thanks Mod - END
// Start session management
$userdata = session_pagestart($user_ip, $forum_id, $topic_id);
init_userprefs($userdata);
// End session management
//
// Set or remove bookmark
//
if ( isset($_GET['setbm']) || isset($_GET['removebm']) )
{
$redirect = VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&start=' . $start . '&postdays=' . $post_days . '&postorder=' . $post_order . '&highlight=' . $_GET['highlight'];
if ( $userdata['session_logged_in'] )
{
if (isset($_GET['setbm']) && $_GET['setbm'])
{
set_bookmark($topic_id);
}
elseif (isset($_GET['removebm']) && $_GET['removebm'])
{
remove_bookmark($topic_id);
}
}
else
{
if (isset($_GET['setbm']) && $_GET['setbm'])
{
$redirect .= '&setbm=true';
}
elseif (isset($_GET['removebm']) && $_GET['removebm'])
{
$redirect .= '&removebm=true';
}
redirect(append_sid(LOGIN_MG . '?redirect=' . $redirect, true));
}
redirect(append_sid($redirect, true));
}
$cms_page_id['viewt'] = CMS_PAGE_VIEWT;
$auth_level_req = $board_config['auth_view_viewt'];
if ($auth_level_req > AUTH_ALL)
{
if ( ($auth_level_req == AUTH_REG) && (!$userdata['session_logged_in']) )
{
message_die(GENERAL_MESSAGE, $lang['Not_Auth_View']);
}
if ($userdata['user_level'] != ADMIN)
{
if ( $auth_level_req == AUTH_ADMIN )
{
message_die(GENERAL_MESSAGE, $lang['Not_Auth_View']);
}
if ( ($auth_level_req == AUTH_MOD) && ($userdata['user_level'] != MOD) )
{
message_die(GENERAL_MESSAGE, $lang['Not_Auth_View']);
}
}
}
$importal_wide = ($board_config['wide_blocks_viewt'] == 1) ? true : false;
if ( $download )
{
$sql_download = ( $download != -1 ) ? " AND p.post_id = " . intval($download) . " " : '';
if (!$userdata['user_allowswearywords'])
{
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
}
$sql = "SELECT u.*, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
WHERE p.topic_id = $topic_id
$sql_download
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time ASC, p.post_id ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not create download stream for post.", '', __LINE__, __FILE__, $sql);
}
$download_file = '';
$is_auth_read = array();
$break = "\r\n";
$line = '-----------------------------------';
while ( $row = $db->sql_fetchrow($result) )
{
$is_auth_read = auth(AUTH_ALL, $row['forum_id'], $userdata);
$poster_id = $row['user_id'];
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $row['username'];
$post_date = create_date($board_config['default_dateformat'], $row['post_time'], $board_config['board_timezone']);
$post_subject = ( $row['post_subject'] != '' ) ? $row['post_subject'] : '';
$bbcode_uid = $row['bbcode_uid'];
$message = $row['post_text'];
$message = strip_tags($message);
$message = preg_replace("/\[.*?:$bbcode_uid:?.*?\]/si", '', $message);
$message = preg_replace('/\[url\]|\[\/url\]/si', '', $message);
$message = preg_replace('/\:[0-9a-z\:]+\]/si', ']', $message);
if($userdata['session_logged_in'])
{
$sql = "SELECT p.poster_id, p.topic_id
FROM " . POSTS_TABLE . " p
WHERE p.topic_id = $topic_id
AND p.poster_id = " . $userdata['user_id'];
$resultat = $db->sql_query($sql);
$show = $db->sql_numrows($resultat) ? true : false;
if ( ($userdata['user_level'] == ADMIN) || ($userdata['user_level'] == MOD))
{
$show = true;
}
}
if(!$show && preg_match('/\[hide/i', $message))
{
$search = array("/\[hide\](.*?)\[\/hide\]/");
$replace = array($lang['xs_bbc_hide_message']. ':' . $break . $lang['xs_bbc_hide_message_explain'] . $break);
$message = preg_replace($search, $replace, $message);
}
$message = unprepare_message($message);
$search = array('/(/', '/)/', '/:/', '/[/', '/]/', '/{/', '/}/');
$replace = array('(', ')', ':', '[', ']', '{', '}',);
$message = preg_replace($search, $replace, $message);
$message = bbcode_killer_mg($message, $bbcodeuid);
if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
$message = str_replace('\"', '"', substr(preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
}
$download_file .= $line . $break . $poster . $break . $post_date . $break . $break . $post_subject . $break . $line . $break . $message . $break . $break . $break;
}
$disp_folder = ( $download == -1 ) ? 'Topic_'. $topic_id : 'Post_' . $download;
if (!$is_auth_read['auth_read'])
{
$download_file = sprintf($lang['Sorry_auth_read'], $is_auth_read['auth_read_type']);
$disp_folder = 'Download';
}
$filename = $board_config['sitename']."_".$disp_folder."_".date("Ymd",time()).".txt";
header('Content-Type: text/x-delimtext; name="'.$filename.'"');
header('Content-Disposition: attachment;filename="'.$filename.'"');
header('Content-Transfer-Encoding: plain/text');
header('Content-Length: '.strlen($download_file));
print $download_file;
exit;
}
//Begin Lo-Fi Mod
if ($lofi)
{
$lang['Reply_with_quote'] = $lang['quote_lofi'] ;
$lang['Edit_delete_post'] = $lang['edit_lofi'];
$lang['View_IP'] = $lang['ip_lofi'];
$lang['Delete_post'] = $lang['del_lofi'];
$lang['Read_profile'] = $lang['profile_lofi'];
$lang['Send_private_message'] = $lang['pm_lofi'];
$lang['Send_email'] = $lang['email_lofi'];
$lang['Visit_website'] = $lang['website_lofi'];
$lang['ICQ'] = $lang['icq_lofi'];
$lang['AIM'] = $lang['aim_lofi'];
$lang['YIM'] = $lang['yim_lofi'];
$lang['MSNM'] = $lang['msnm_lofi'];
}
//End Lo-Fi Mod
// Force Topic Read - BEGIN
$active ='';
if ( $board_config['disable_ftr'] == false )
{
$check_viewed = GetUsersView($userdata['user_id']);
$install_time = time();
$bypass = '';
( !$_GET['mode'] ) ? $viewed_mode = $_GET['mode'] : $viewed_mode = $_GET['mode'];
$q = "SELECT active, effected, install_date
FROM " . FORCE_READ_TABLE;
$r = $db -> sql_query($q);
$row = $db -> sql_fetchrow($r);
$active = $row['active'];
$effected = $row['effected'];
$ins_date = $row['install_date'];
}
if ( ($active) && (strlen($ins_date) != 10) )
{
$q = "UPDATE " . FORCE_READ_TABLE . "
SET install_date = '". $install_time ."'";
$r = $db -> sql_query($q);
}
if ( strlen($ins_date) != 10 )
{
$ins_date = $install_time;
}
if ( $viewed_mode == 'reading' || $check_viewed != 'false')
{
$bypass = true;
}
if ( !$active )
{
$bypass = true;
}
elseif ( ($active) && ($check_viewed == 'false') && (!$bypass) )
{
if ( $viewed_mode == 'read_this' )
{
$q = "SELECT topic_number, message
FROM " . FORCE_READ_TABLE;
$r = $db -> sql_query($q);
$row = $db -> sql_fetchrow($r);
$topic = $row['topic_number'];
$msg = $row['message'];
InsertReadTopic($userdata['user_id']);
redirect(append_sid(VIEWTOPIC_MG .'?t=' . $topic . '&mode=reading'), true);
}
else
{
if ( ( ($check_viewed == 'false') && ($effected <> 1) && ($ins_date <= $userdata['user_regdate']) ) || ( ($check_viewed == 'false') && ($effected == '1') ) )
{
include_once($phpbb_root_path . 'includes/page_header.' . $phpEx);
$q = "SELECT *
FROM " . FORCE_READ_TABLE;
$r = $db -> sql_query($q);
$row = $db -> sql_fetchrow($r);
$topic = $row['topic_number'];
$msg = $row['message'];
$lng_msg = ' ' . sprintf($lang['Click_read_topic'], '', ' ');
message_die(GENERAL_ERROR, $msg . $lng_msg, 'Error');
include_once($phpbb_root_path . 'includes/page_tail.' . $phpEx);
}
else
{
$bypass = true;
}
}
}
// Force Topic Read - END
if ( $bypass )
{
if ( $board_config['similar_topics'] == 1)
{
$similar_forums_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
$similar_is_auth = $similar_forums_auth[$forum_id];
}
// Start auth check
$is_auth = array();
$is_auth = $tree['auth'][POST_FORUM_URL . $forum_id];
if ( !$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_MG . '?redirect=' . VIEWTOPIC_MG, '&' . $redirect, true));
}
$message = sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
message_die(GENERAL_MESSAGE, $message);
}
// End auth check
// Start add - Who viewed a topic MOD
if ( $board_config['disable_topic_view'] == false )
{
$user_id = $userdata['user_id'];
$sql='UPDATE ' . TOPIC_VIEW_TABLE . ' SET topic_id="' . $topic_id . '", view_time="' . time() . '", view_count=view_count+1 WHERE topic_id=' . $topic_id . ' AND user_id=' . $user_id;
if ( !$db->sql_query($sql) || !$db->sql_affectedrows() )
{
$sql = 'INSERT IGNORE INTO ' . TOPIC_VIEW_TABLE . ' (topic_id, user_id, view_time,view_count)
VALUES (' . $topic_id . ', "' . $user_id . '", "' . time() . '","1")';
if ( !($db->sql_query($sql)) )
{
message_die(CRITICAL_ERROR, 'Error create user view topic information ', '', __LINE__, __FILE__, $sql);
}
}
}
// End add - Who viewed a topic MOD
$forum_name = get_object_lang(POST_FORUM_URL . $forum_topic_data['forum_id'], 'name');
$topic_title = $forum_topic_data['topic_title'];
$topic_title = (empty($forum_topic_data['title_compl_infos'])) ? $topic_title : $forum_topic_data['title_compl_infos'] . ' ' . $topic_title;
$topic_id = intval($forum_topic_data['topic_id']);
$topic_time = $forum_topic_data['topic_time'];
$topic_first_post_id = intval($forum_topic_data['topic_first_post_id']);
$topic_calendar_time = intval($forum_topic_data['topic_calendar_time']);
$topic_calendar_duration = intval($forum_topic_data['topic_calendar_duration']);
$board_config['posts_per_page'] = ( $userdata['user_posts_per_page'] == '' ) ? $board_config['posts_per_page'] : $userdata['user_posts_per_page'];
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 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'] . "
LIMIT 1";
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($_GET['unwatch']) )
{
if ( $_GET['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' => ' '
)
);
$message = $lang['No_longer_watching'] . ' ' . sprintf($lang['Click_return_topic'], '', ' ');
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($_GET['watch']) )
{
if ( $_GET['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' => ' '
)
);
$message = $lang['You_are_watching'] . ' ' . sprintf($lang['Click_return_topic'], '', ' ');
message_die(GENERAL_MESSAGE, $message);
}
else
{
$is_watching_topic = 0;
}
}
}
else
{
if ( isset($_GET['unwatch']) )
{
if ( $_GET['unwatch'] == 'topic' )
{
redirect(append_sid(LOGIN_MG . '?redirect=' . VIEWTOPIC_MG . '&' . 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($_POST['postdays']) || !empty($_GET['postdays']) )
{
$post_days = ( !empty($_POST['postdays']) ) ? intval($_POST['postdays']) : intval($_GET['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($_POST['postdays']))
{
$start = 0;
}
}
else
{
$total_replies = intval($forum_topic_data['topic_replies']) + 1;
$limit_posts_time = '';
$post_days = 0;
}
$select_post_days = '';
for($i = 0; $i < count($previous_days); $i++)
{
$selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
$select_post_days .= '' . $previous_days_text[$i] . ' ';
}
$select_post_days .= ' ';
// Decide how to order the post display
if ( !empty($_POST['postorder']) || !empty($_GET['postorder']) )
{
$post_order = (!empty($_POST['postorder'])) ? htmlspecialchars($_POST['postorder']) : htmlspecialchars($_GET['postorder']);
$post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
}
else
{
$post_order = 'asc';
$post_time_order = 'ASC';
}
$select_post_order = '';
if ( $post_time_order == 'ASC' )
{
$select_post_order .= '' . $lang['Oldest_First'] . ' ' . $lang['Newest_First'] . ' ';
}
else
{
$select_post_order .= '' . $lang['Oldest_First'] . ' ' . $lang['Newest_First'] . ' ';
}
$select_post_order .= ' ';
$user_ids = array();
$user_ids2 = array();
if($userdata['session_logged_in'])
{
$user_ids[$userdata['user_id']] = $userdata['username'];
}
// Custom Profile Fields MOD
$profile_data = get_fields('WHERE view_in_topic = ' . VIEW_IN_TOPIC . ' AND users_can_view = ' . ALLOW_VIEW);
$profile_data_sql = get_udata_txt($profile_data, 'u.');
// END Custom Profile Fields MOD
// Similar Topics - BEGIN
$similar_topics_enabled = false;
if ( $board_config['similar_topics'] == 1)
{
if ( $board_config['similar_ignore_forums_ids'] )
{
$ignore_forums_ids = array_map('intval', explode("\n", trim($board_config['similar_ignore_forums_ids'])));
}
else
{
$ignore_forums_ids = array();
}
// Get forum auth information to insure privacy of hidden topics
$forums_auth_sql = '';
//foreach ($similar_forums_auth as $k=>$v)
//$similar_forums_auth = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata);
foreach ($similar_forums_auth as $k=>$v)
{
if ( count($ignore_forums_ids) && in_array($k, $ignore_forums_ids) )
{
continue;
}
if ( $v['auth_view'] && $v['auth_read'] )
{
$forums_auth_sql .= (( $forums_auth_sql == '' ) ? '': ', ') . $k;
}
}
if ($forums_auth_sql != '')
{
$forums_auth_sql = ' AND t.forum_id IN (' . $forums_auth_sql . ') ';
}
if ( $board_config['similar_stopwords'] )
{
// encoding match for workaround
$multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312';
// check against stopwords start
@include_once($phpbb_root_path . 'includes/functions_search.' . $phpEx);
$stopword_array = @file($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/search_stopwords.txt');
$synonym_array = array();
// check against stopwords end
$title_search = '';
$title_search_array = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ? split_words(clean_words('post', stripslashes($topic_title), $stopword_array, $synonym_array), 'search') : split(' ', $topic_title);
for ($i = 0; $i < count($title_search_array); $i++)
{
$title_search .= (( $title_search == '' ) ? '': ' ') . $title_search_array[$i];
}
}
else
{
$title_search = $topic_title;
}
/*
if ( !empty($forum_topic_data['topic_desc']) && $board_config['similar_topicdesc'] )
{
if ( $board_config['similar_stopwords'] )
{
$topicdesc = '';
$topic_desc_array = ( !strstr($multibyte_charset, $lang['ENCODING']) ) ? split_words(clean_words('post', stripslashes($forum_topic_data['topic_desc']), $stopword_array, $synonym_array), 'search') : split(' ', $forum_topic_data['topic_desc']);
for ($i = 0; $i < count($topic_desc_array); $i++)
{
$topicdesc .= (( $topicdesc == '' ) ? '': ' ') . $topic_desc_array[$i];
}
}
else
{
$topicdesc = $forum_topic_data['topic_desc'];
}
$sql_topic_desc = "+MATCH(t.topic_desc) AGAINST('" . addslashes($topicdesc) . "')";
}
$sql_match = "MATCH(t.topic_title) AGAINST('" . addslashes($title_search) . "')" . $sql_topic_desc;
*/
$sql_match = "MATCH(t.topic_title) AGAINST('" . addslashes($title_search) . "')";
if ( $board_config['similar_sort_type'] == 'time' )
{
$sql_sort = 'p.post_time';
}
else
{
$sql_sort = 'relevance';
}
//ORDER BY t.topic_type DESC, ' . $sql_sort . ' DESC LIMIT 0,' . intval($board_config['similar_max_topics']);
$sql = "SELECT t.*, u.user_id, u.username, u2.username as user2, u2.user_id as id2, f.forum_id, f.forum_name, p.post_time, p.post_username, $sql_match as relevance
FROM ". TOPICS_TABLE ." t, ". USERS_TABLE ." u, ". FORUMS_TABLE ." f, ". POSTS_TABLE ." p, " . USERS_TABLE . " u2
WHERE t.topic_id <> $topic_id $forums_auth_sql
AND $sql_match
AND t.forum_id = f.forum_id
AND p.poster_id = u2.user_id
AND p.post_id = t.topic_last_post_id
AND t.topic_poster = u.user_id
AND t.topic_status <> " . TOPIC_MOVED . '
GROUP BY t.topic_id
ORDER BY p.post_time DESC, ' . $sql_sort . ' DESC LIMIT 0,' . intval($board_config['similar_max_topics']);
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not get main information for similar topics", '', __LINE__, __FILE__, $sql);
}
$similar_topics = $db->sql_fetchrowset($result);
$db->sql_freeresult($result);
$count_similar = count($similar_topics);
if ( $count_similar > 0 )
{
$similar_topics_enabled = true;
}
}
// Similar Topics - END
if ( $board_config['switch_poster_info_topic'] == 1)
{
// Query Styles
$sql = "SELECT themes_id, style_name
FROM " . THEMES_TABLE . "
ORDER BY template_name, themes_id";
if ( !($result = $db->sql_query($sql, false, 'themes_')) )
{
message_die(GENERAL_ERROR, "Couldn't query themes table", "", __LINE__, __FILE__, $sql);
}
$styles_list_id = array();
$styles_list_name = array();
while ( $row = $db->sql_fetchrow($result) )
{
$styles_list_id[] = $row['themes_id'];
$styles_list_name[] = $row['style_name'];
}
$db->sql_freeresult($result);
}
// Activity - BEGIN
//if ( defined('ACTIVITY_MOD') && (ACTIVITY_MOD == true) )
if ( defined('ACTIVITY_MOD') )
{
$activity_sql = ', u.user_trophies, u.ina_char_name';
}
else
{
$activity_sql = '';
}
// Activity - END
// Go ahead and pull all data for this topic
$sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_from_flag, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_skype, 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_allow_viewonline, u.user_session_time, u.user_warnings, u.user_level, u.user_birthday, u.user_next_birthday_greeting, u.user_gender, u.user_personal_pics_count, u.user_style, u.user_lang" . $activity_sql . $profile_data_sql . ", u.ct_miserable_user, p.*, pt.post_text, pt.post_text_compiled, pt.post_subject, pt.bbcode_uid, pt.edit_notes, t.topic_poster, t.title_compl_infos
FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt, " . TOPICS_TABLE . " t
WHERE p.topic_id = $topic_id AND t.topic_id = p.topic_id
$limit_posts_time
AND pt.post_id = p.post_id
AND u.user_id = p.poster_id
ORDER BY p.post_time $post_time_order
LIMIT $start, ".$board_config['posts_per_page'];
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
{
if($row['user_id'] > 0)
{
$user_ids[$row['user_id']] = $row['username'];
}
if(defined('LOCAL_DEBUG'))
{
$row['post_text_compiled'] = '';
}
$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
if (!$userdata['user_allowswearywords'])
{
$orig_word = array();
$replacement_word = array();
obtain_word_list($orig_word, $replacement_word);
}
// Start Autolinks For phpBB Mod
$orig_autolink = array();
$replacement_autolink = array();
obtain_autolink_list($orig_autolink, $replacement_autolink, $forum_id);
// End Autolinks For phpBB Mod
// 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($_GET['highlight']))
{
$_GET['highlight'] = addslashes(preg_replace('#[][\\/%():><{}`]#',' ',$_GET['highlight']));
// Split words and phrases
$words = explode(' ', trim(htmlspecialchars($_GET['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($_GET['highlight']);
$highlight_match = phpbb_rtrim($highlight_match, "\\");
}
// Post, reply and other URL generation for templating vars
$new_topic_url = append_sid('posting.' . $phpEx . '?mode=newtopic&' . POST_FORUM_URL . '=' . $forum_id);
$reply_topic_url = append_sid('posting.' . $phpEx . '?mode=reply&' . POST_TOPIC_URL . '=' . $topic_id);
$view_forum_url = append_sid(VIEWFORUM_MG . '?' . POST_FORUM_URL . '=' . $forum_id);
$view_prev_topic_url = append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&view=previous');
$view_next_topic_url = append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&view=next');
// Begin Thanks Mod
$thank_topic_url = append_sid('posting.' . $phpEx . '?mode=thank&' . POST_TOPIC_URL . '=' . $topic_id);
// End Thanks Mod
// Mozilla navigation bar
//SEO TOOLKIT BEGIN
$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
);
/*
$nav_links['up'] = array(
'url' => append_sid(make_url_friendly($forum_name) . '-vf' . $forum_id . '.html'),
'title' => $forum_name
);
*/
//SEO TOOLKIT END
$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'];
// Begin Thanks Mod
$thank_img = $images['thanks'];
$thank_alt = $lang['thanks_alt'];
$thank_img = ( $show_thanks == 1 ) ? ' ' : '';
// End Thanks Mod
// 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];
}
elseif ( !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']);
}
//
if($userdata['upi2db_access'])
{
$unread_new_posts = 0;
$unread_edit_posts = 0;
for($i = 0; $i < $total_posts; $i++)
{
if (sizeof($unread[$topic_id]['new_posts']) && in_array($postrow[$i]['post_id'],$unread[$topic_id]['new_posts']))
{
++$unread_new_posts;
}
if (sizeof($unread[$topic_id]['edit_posts']) && in_array($postrow[$i]['post_id'],$unread[$topic_id]['edit_posts']))
{
++$unread_edit_posts;
}
}
}
//
// Load templates
if ($kb_mode == true)
{
$template->set_filenames(array('body' => 'viewtopic_kb_body.tpl'));
}
else
{
$template->set_filenames(array('body' => 'viewtopic_body.tpl'));
}
make_jumpbox(VIEWFORUM_MG, $forum_id);
// Output page header
define('SHOW_ONLINE', true);
$page_title = $topic_title;
include($phpbb_root_path . 'includes/page_header.' . $phpEx);
if ($similar_topics_enabled == true)
{
include($phpbb_root_path . 'includes/similar_topics.' . $phpEx);
}
// User authorisation levels output
$s_auth_can = ( $is_auth['auth_post'] ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_reply'] ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_edit'] ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_delete'] ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_vote'] ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . ' ';
if (intval($attach_config['disable_mod']) == 0)
{
$s_auth_can .= ( $is_auth['auth_attachments'] ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_download'] ? $lang['Rules_download_can'] : $lang['Rules_download_cannot'] ) . ' ';
}
$s_auth_can .= ( $is_auth['auth_cal'] ? $lang['Rules_calendar_can'] : $lang['Rules_calendar_cannot'] ) . ' ';
$s_auth_can .= ( $is_auth['auth_ban'] ? $lang['Rules_ban_can'] . ' ' : '' );
$s_auth_can .= ( $is_auth['auth_greencard'] ? $lang['Rules_greencard_can'] . ' ' : '' );
$s_auth_can .= ( $is_auth['auth_bluecard'] ? $lang['Rules_bluecard_can'] . ' ' : '' );
//attach_build_auth_levels($is_auth, $s_auth_can);
$topic_mod = '';
if ( $is_auth['auth_mod'] )
{
$s_auth_can .= sprintf($lang['Rules_moderate'], '', ' ');
if ($lofi)
{
$topic_mod .= '' . $lang['Delete_topic'] . ' :: ';
$topic_mod .= '' . $lang['Move_topic'] . ' ';
$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? '' . $lang['Lock_topic'] . ' :: ' : '' . $lang['Unlock_topic'] . ' :: ';
$topic_mod .= '' . $lang['Split_topic'] . ' ';
$topic_mod .= '' . $lang['Merge_topic'] . ' ';
if ( $board_config['bin_forum'] != false )
{
$topic_mod .= '' . $lang['Move_bin'] . ' ';
}
}
else
{
if ( $board_config['bin_forum'] != false )
{
$topic_mod .= ' ';
}
$topic_mod .= ' ';
$topic_mod .= ' ';
$topic_mod .= ( $forum_topic_data['topic_status'] == TOPIC_UNLOCKED ) ? ' ' : ' ';
$topic_mod .= ' ';
$topic_mod .= ' ';
$normal_button = ' ';
$sticky_button = ( $is_auth['auth_sticky'] ) ? ' ' : "";
$announce_button = ( $is_auth['auth_announce'] ) ? ' ' : "";
$global_button = ( $is_auth['auth_globalannounce'] ) ? ' ' : "";
switch( $forum_topic_data['topic_type'] )
{
case POST_NORMAL:
$topic_mod .= $global_button . $announce_button . $sticky_button;
break;
case POST_STICKY:
$topic_mod .= $global_button . $announce_button . $normal_button;
break;
case POST_ANNOUNCE:
$topic_mod .= $global_button . $sticky_button . $normal_button;
break;
case POST_GLOBAL_ANNOUNCE:
$topic_mod .= $announce_button . $sticky_button . $normal_button;
break;
}
}
}
// Topic watch information
if ( !( ($userdata['user_level'] == 0) && ($userdata['user_id'] != $row['topic_poster']) ) )
{
$sql = "SELECT * FROM " . TITLE_INFOS_TABLE . " ORDER BY title_info ASC";
if ( !($result = $db->sql_query($sql, false, 'topics_prefixes_')) )
{
message_die(GENERAL_MESSAGE, 'Unable to query Quick Title Addon informations.');
}
$select_title = '
';
$topic_mod .= $select_title;
}
$s_watching_topic = '';
if ( $can_watch_topic )
{
if ( $is_watching_topic )
{
$s_watching_topic_url = append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&unwatch=topic&start=' . $start);
$s_watching_topic = '' . $lang['Stop_watching_topic'] . ' ';
$s_watching_topic_img = ( isset($images['topic_un_watch']) ) ? ' ' : '';
}
else
{
$s_watching_topic_url = append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&watch=topic&start=' . $start);
$s_watching_topic = '' . $lang['Start_watching_topic'] . ' ';
$s_watching_topic_img = ( isset($images['topic_watch']) ) ? ' ' : '';
}
}
// Bookmark information
if ( $userdata['session_logged_in'] )
{
$template->assign_block_vars('bookmark_state', array());
// Send vars to template
if (is_bookmark_set($topic_id))
{
$bookmark_img = $images['bookmark_remove'];
$bm_action = '&removebm=true';
$set_rem_bookmark = $lang['Remove_Bookmark'];
}
else
{
$bookmark_img = $images['bookmark_add'];
$bm_action = '&setbm=true';
$set_rem_bookmark = $lang['Set_Bookmark'];
}
$template->assign_vars(array(
'L_BOOKMARK_ACTION' => $set_rem_bookmark,
'IMG_BOOKMARK' => $bookmark_img,
'U_BOOKMARK_ACTION' => append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&start=' . $start . '&postdays=' . $post_days . '&postorder=' . $post_order . '&highlight=' . $_GET['highlight'] . $bm_action)
)
);
}
//
if($userdata['upi2db_access'])
{
$mark_always_read = mark_always_read($forum_topic_data['topic_type'], $topic_id, $forum_id, 'viewforum', 'txt', $unread);
}
else
{
$mark_always_read = '';
}
//
// If we've got a hightlight set pass it on to pagination,
// I get annoyed when I lose my highlight after the first page.
$pagination = ( $highlight != '' ) ? generate_pagination(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&postdays=' . $post_days . '&postorder=' . $post_order . '&highlight=' . $highlight, $total_replies, $board_config['posts_per_page'], $start) : generate_pagination(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&postdays=' . $post_days . '&postorder=' . $post_order, $total_replies, $board_config['posts_per_page'], $start);
$current_page = get_page($total_replies, $board_config['posts_per_page'], $start);
$watch_topic_url = 'topic_view_users.' . $phpEx . '?' . POST_TOPIC_URL . '=' . $topic_id;
if ( $forum_topic_data['rules_in_viewtopic'] )
{
$template->assign_block_vars('switch_forum_rules', array() );
// display a title on top of the box??
if ( $forum_topic_data['rules_display_title'] )
{
$template->assign_block_vars('switch_forum_rules.switch_display_title', array() );
}
}
// Send vars to template
//BBcode Parsing for Olympus rules Start
$rules_bbcode = $forum_topic_data['forum_rules'];
$bbcode->allow_html = true;
$bbcode->allow_bbcode = true;
$bbcode->allow_smilies = true;
$rules_bbcode = $bbcode->parse($rules_bbcode, $bbcode_uid);
//BBcode Parsing for Olympus rules Start
if ( $board_config['show_icons'] == true )
{
$template->assign_block_vars('switch_show_icons', array());
if ( $userdata['session_logged_in'] )
{
$template->assign_block_vars('switch_show_icons.switch_user_logged_in', array());
}
}
else
{
$template->assign_block_vars('switch_show_links', array());
}
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
'FORUM_NAME' => $forum_name,
'FORUM_RULES' => $rules_bbcode,
'TOPIC_ID' => $topic_id,
'TOPIC_TITLE' => $topic_title,
'PAGINATION' => $pagination,
'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),
'POST_IMG' => $post_img,
'REPLY_IMG' => $reply_img,
'THANK_IMG' => $thank_img,
'L_DOWNLOAD_POST' => $lang['Download_post'],
'L_DOWNLOAD_TOPIC' => $lang['Download_topic'],
'DOWNLOAD_TOPIC' => append_sid(VIEWTOPIC_MG . '?download=-1&' . POST_TOPIC_URL . '=' . $topic_id),
//'TELL_LINK' => append_sid('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?topic_id=' . $topic_id, true),
'U_TELL' => append_sid('tellafriend.' . $phpEx . '?topic=' . str_replace(array(' ', '?', '&'), array('%20', '%3F', '%26'), $topic_title) . '&link=http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?topic_id=' . $topic_id),
//'U_TELL' => append_sid('tellafriend.' . $phpEx . '?topic=' . htmlspecialchars($topic_title) . '&link='),
'L_PRINT' => $lang['Print_View'],
'U_PRINT' => append_sid('printview.' . $phpEx . '?' . POST_TOPIC_URL . '=' . $topic_id . '&start=' . $start),
'L_REPLY_NEWS' => $lang['News_Reply'],
'L_PRINT_NEWS' => $lang['News_Print'],
'L_EMAIL_NEWS' => $lang['News_Email'],
'MINIPOST_IMG' => $images['icon_minipost'],
'IMG_FLOPPY' => $images['floppy2'],
'IMG_REPLY' => $images['news_reply'],
'IMG_PRINT' => $images['printer_topic'],
'IMG_EMAIL' => $images['email_topic'],
'IMG_LEFT' => $images['icon_previous'],
'IMG_RIGHT' => $images['icon_next'],
'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_QUICK_QUOTE' => $lang['QuickQuote'],
'L_OFFTOPIC' => $lang['OffTopic'],
'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'],
'L_FORUM_RULES' => ( empty($forum_topic_data['rules_custom_title']) ) ? $lang['Forum_Rules'] : $forum_topic_data['rules_custom_title'],
'L_PERMISSIONS_LIST' => $lang['Permissions_List'],
'L_TELL' => $lang['Tell_Friend'],
'L_SMILEYS' => $lang['Emoticons'],
'L_SMILEYS_MORE' => $lang['More_emoticons'],
'U_SMILEYS_MORE' => append_sid('posting.' . $phpEx . '?mode=smilies'),
'IMG_QUICK_QUOTE' => $images['icon_quick_quote'],
'IMG_QUICK_QUOTE_RED' => $images['icon_quick_quote_red'],
'IMG_OFFTOPIC' => $images['icon_offtopic'],
'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_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&start=' . $start),
'S_AUTH_LIST' => $s_auth_can,
'S_TOPIC_ADMIN' => $topic_mod,
'S_WATCH_TOPIC' => $s_watching_topic,
'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
'U_VIEW_TOPIC' => append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&start=' . $start . '&postdays=' . $post_days . '&postorder=' . $post_order . '&highlight=' . $highlight . (($kb_mode == true) ? '&kb=true' : '')),
//
'U_MARK_ALWAYS_READ' => $mark_always_read,
//
'U_VIEW_FORUM' => $view_forum_url,
'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
'U_POST_NEW_TOPIC' => $new_topic_url,
'U_POST_REPLY_TOPIC' => $reply_topic_url
)
);
// Does this topic contain a poll?
if ( !empty($forum_topic_data['topic_vote']) )
{
$s_hidden_fields = '';
$sql = "SELECT vd.vote_id, vd.vote_text, vd.vote_start, vd.vote_length, vr.vote_option_id, vr.vote_option_text, vr.vote_result
FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
WHERE vd.topic_id = $topic_id
AND vr.vote_id = vd.vote_id
ORDER BY vr.vote_option_id ASC";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
}
if ( $vote_info = $db->sql_fetchrowset($result) )
{
$db->sql_freeresult($result);
$vote_options = count($vote_info);
$vote_id = $vote_info[0]['vote_id'];
$vote_title = $vote_info[0]['vote_text'];
$sql = "SELECT vote_id
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . intval($userdata['user_id']);
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
}
$user_voted = ( $row = $db->sql_fetchrow($result) ) ? true : 0;
$db->sql_freeresult($result);
if ( isset($_GET['vote']) || isset($_POST['vote']) )
{
$view_result = ( ( ( isset($_GET['vote']) ) ? $_GET['vote'] : $_POST['vote'] ) == 'viewresult' ) ? true : 0;
}
else
{
$view_result = 0;
}
$poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? true : 0 ) : 0;
if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
{
$template->set_filenames(array('pollbox' => 'viewtopic_poll_result.tpl'));
$vote_results_sum = 0;
for($i = 0; $i < $vote_options; $i++)
{
$vote_results_sum += $vote_info[$i]['vote_result'];
}
$vote_graphic = 0;
$vote_graphic_max = count($images['voting_graphic']);
for($i = 0; $i < $vote_options; $i++)
{
$vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
// [Begin] XS Poll Color - Edited by MG
if ( $vote_percent <= 0.3 )
{
$vote_color = 'red';
}
elseif ( ($vote_percent > 0.3) && ($vote_percent <= 0.6) )
{
$vote_color = 'blue';
}
elseif ( $vote_percent > 0.6 )
{
$vote_color = 'green';
}
// [End] XS Poll Color - Edited by MG
$vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
$voting_bar = 'voting_graphic_' . $vote_color;
$voting_bar_body = 'voting_graphic_' . $vote_color . '_body';
$voting_bar_left = 'voting_graphic_' . $vote_color . '_left';
$voting_bar_right = 'voting_graphic_' . $vote_color . '_right';
$voting_bar_img = $images[$voting_bar];
$voting_bar_body_img = $images[$voting_bar_body];
$voting_bar_left_img = $images[$voting_bar_left];
$voting_bar_right_img = $images[$voting_bar_right];
$vote_graphic_img = $images['voting_graphic'][$vote_graphic];
$vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
if ( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars('poll_option', array(
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
'POLL_GRAPHIC' => $voting_bar_img,
'POLL_GRAPHIC_BODY' => $voting_bar_body_img,
'POLL_GRAPHIC_LEFT' => $voting_bar_left_img,
'POLL_GRAPHIC_RIGHT' => $voting_bar_right_img,
'POLL_OPTION_COLOR' => $vote_color,
'POLL_OPTION_IMG' => $vote_graphic_img,
'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length
)
);
}
$template->assign_vars(array(
'L_TOTAL_VOTES' => $lang['Total_votes'],
'TOTAL_VOTES' => $vote_results_sum
)
);
}
else
{
$template->set_filenames(array('pollbox' => 'viewtopic_poll_ballot.tpl'));
for($i = 0; $i < $vote_options; $i++)
{
if ( count($orig_word) )
{
$vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
}
$template->assign_block_vars('poll_option', array(
'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
);
}
$template->assign_vars(array(
'L_SUBMIT_VOTE' => $lang['Submit_vote'],
'L_VIEW_RESULTS' => $lang['View_results'],
'U_VIEW_RESULTS' => append_sid(VIEWTOPIC_MG . '?' . POST_TOPIC_URL . '=' . $topic_id . '&postdays=' . $post_days . '&postorder=' . $post_order . '&vote=viewresult')
)
);
$s_hidden_fields = ' ';
}
if ( count($orig_word) )
{
$vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
}
$s_hidden_fields .= ' ';
$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');
}
}
init_display_post_attachments($forum_topic_data['topic_attachment']);
// Don't update the topic view counter if viewer is poster
if (!($postrow[0]['user_id'] == $userdata['user_id']))
{
// Update the topic view counter
$sql = "UPDATE " . TOPICS_TABLE . "
SET topic_views = topic_views + 1
WHERE topic_id = $topic_id";
if ( !$db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
}
}
// Begin Thanks Mod
// Get topic thanks
if ($show_thanks == FORUM_THANKABLE)
{
// Select Format for the date
$timeformat = "d F";
$sql = "SELECT u.user_id, t.thanks_time
FROM " . THANKS_TABLE . " t, " . USERS_TABLE . " u
WHERE topic_id = $topic_id
AND t.user_id = u.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain thanks information", '', __LINE__, __FILE__, $sql);
}
$total_thank = $db->sql_numrows($result);
$thanksrow = array();
if ($fil = $db->sql_fetchrow($result))
{
do
{
$thanksrow[] = $fil;
}
while ($fil = $db->sql_fetchrow($result));
}
for($i = 0; $i < $total_thank; $i++)
{
$topic_thanks = $db->sql_fetchrow($result);
$thanker_id[$i] = $thanksrow[$i]['user_id'];
$thanks_date[$i] = $thanksrow[$i]['thanks_time'];
// Get thanks date
$thanks_date[$i] = create_date_thanks($timeformat, $thanks_date[$i], $board_config['board_timezone']);
// Make thanker profile link
$thanks .= color_group_colorize_name($thanker_id[$i]) . ' (' . $thanks_date[$i] . '), ';
}
$sql = "SELECT u.topic_poster, t.user_id, t.username
FROM " . TOPICS_TABLE . " u, " . USERS_TABLE . " t
WHERE topic_id = $topic_id
AND u.topic_poster = t.user_id";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain user information", '', __LINE__, __FILE__, $sql);
}
$autor = array();
if ($fil = $db->sql_fetchrow($result))
{
do
{
$autor[] = $fil;
}
while ($fil = $db->sql_fetchrow($result));
}
for($i = 0; $i < 1; $i++)
{
$autor_name = $autor[0]['username'];
}
$thanks2 .= $lang['thanks_to'] . ' ' . $autor_name . ' ' . $lang['thanks_end'];
}
// End Thanks Mod
if ( $board_config['enable_quick_quote'] == 1 )
{
$template->assign_block_vars('switch_quick_quote', array());
}
// Okay, let's do the loop, yeah come on baby let's do the loop and it goes like this ...
$sig_cache = array();
$delnote = isset($_GET['delnote']) ? explode('.', $_GET['delnote']) : array();
$this_year = create_date('Y', time(), $board_config['board_timezone']);
$this_date = create_date('md', time(), $board_config['board_timezone']);
for($i = 0; $i < $total_posts; $i++)
{
$poster_id = $postrow[$i]['user_id'];
$post_id = $postrow[$i]['post_id'];
$user_pic_count = $postrow[$i]['user_personal_pics_count'];
global $bot_name;
if ( $bot_name != false )
{
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : color_group_colorize_name($postrow[$i]['user_id'], true);
}
else
{
$poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : color_group_colorize_name($postrow[$i]['user_id']);
}
$poster_qq = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username'];
// Start add - Birthday MOD
$poster_age = '';
if ( $board_config['birthday_viewtopic'] == 1)
{
if ( $postrow[$i]['user_birthday'] != 999999 )
{
$poster_birthdate = realdate('md', $postrow[$i]['user_birthday']);
$poster_age = $this_year - realdate ('Y',$postrow[$i]['user_birthday']);
if ($this_date < $poster_birthdate)
{
$poster_age--;
}
$poster_age = $lang['Age'] . ': ' . $poster_age . ' ';
}
else
{
$poster_age = '';
$poster_birthdate = '';
}
if ($this_date == $poster_birthdate)
{
$gebbild = ' ';
}
else
{
$gebbild = ' ';
}
}
// End add - Birthday MOD
$post_date = create_date2($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
$poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : '';
$poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
$poster_from_flag = ( $postrow[$i]['user_from_flag'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? ' ' : '';
$poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['JOINED_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'] ) ? ' ' : '';
break;
case USER_AVATAR_REMOTE:
$poster_avatar = resize_avatar($postrow[$i]['user_avatar']);
break;
case USER_AVATAR_GALLERY:
$poster_avatar = ( $board_config['allow_avatar_local'] ) ? ' ' : '';
break;
case USER_GRAVATAR:
$poster_avatar = ( $board_config['enable_gravatars'] ) ? ' ' : '';
break;
}
}
if ($poster_avatar == '')
{
$poster_avatar = get_default_avatar($poster_id);
}
// Define the little post icon
//
if( !$userdata['upi2db_access'])
{
//
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'];
}
//
}
else
{
viewtopic_calc_unread($unread, $topic_id, $postrow[$i]['post_id'], $forum_id, $mini_post_img, $mini_post_alt, $unread_color, $read_posts);
}
//
//$mini_post_url = append_sid(VIEWTOPIC_MG . '?' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#p' . $postrow[$i]['post_id'];
if ( ($board_config['url_rw'] == '1') || ( ($board_config['url_rw_guests'] == '1') && ($userdata['user_id'] == ANONYMOUS) ) )
{
$mini_post_url = str_replace ('--', '-', make_url_friendly($postrow[$i]['post_subject']) . '-vp' . $postrow[$i]['post_id'] . '.html#p' . $postrow[$i]['post_id']);
}
else
{
$mini_post_url = append_sid(VIEWTOPIC_MG . '?' . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#p' . $postrow[$i]['post_id'];
}
// Mighty Gorgon - Multiple Ranks - BEGIN
$user_ranks = generate_ranks($postrow[$i], $ranks_sql);
$user_rank_01 = ($user_ranks['rank_01'] == '') ? '' : ($user_ranks['rank_01'] . ' ');
$user_rank_01_img = ($user_ranks['rank_01_img'] == '') ? '' : ($user_ranks['rank_01_img'] . ' ');
$user_rank_02 = ($user_ranks['rank_02'] == '') ? '' : ($user_ranks['rank_02'] . ' ');
$user_rank_02_img = ($user_ranks['rank_02_img'] == '') ? '' : ($user_ranks['rank_02_img'] . ' ');
$user_rank_03 = ($user_ranks['rank_03'] == '') ? '' : ($user_ranks['rank_03'] . ' ');
$user_rank_03_img = ($user_ranks['rank_03_img'] == '') ? '' : ($user_ranks['rank_03_img'] . ' ');
$user_rank_04 = ($user_ranks['rank_04'] == '') ? '' : ($user_ranks['rank_04'] . ' ');
$user_rank_04_img = ($user_ranks['rank_04_img'] == '') ? '' : ($user_ranks['rank_04_img'] . ' ');
$user_rank_05 = ($user_ranks['rank_05'] == '') ? '' : ($user_ranks['rank_05'] . ' ');
$user_rank_05_img = ($user_ranks['rank_05_img'] == '') ? '' : ($user_ranks['rank_05_img'] . ' ');
if ( ($user_rank_01 == '') && ($user_rank_01_img == '') && ($user_rank_02 == '') && ($user_rank_02_img == '') && ($user_rank_03 == '') && ($user_rank_03_img == '') && ($user_rank_04 == '') && ($user_rank_04_img == '') && ($user_rank_05 == '') && ($user_rank_05_img == ''))
{
$user_rank_01 = ' ';
}
// Mighty Gorgon - Multiple Ranks - END
//
// Handle anon users posting with usernames
//
if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' )
{
$poster = $postrow[$i]['post_username'];
$poster_qq = $postrow[$i]['post_username'];
$user_rank_01 = $lang['Guest'] . ' ';
}
if ( $poster_id != ANONYMOUS )
{
$temp_url = append_sid(PROFILE_MG . '?mode=viewprofile&' . POST_USERS_URL . '=' . $poster_id);
$profile_img = ' ';
$profile = '' . $lang['Profile'] . ' ';
$temp_url = append_sid('privmsg.' . $phpEx . '?mode=post&' . POST_USERS_URL . '=' . $poster_id);
$pm_img = ' ';
$pm = '' . $lang['PM'] . ' ';
// Start add - Gender MOD
switch ($postrow[$i]['user_gender'])
{
case 1:
$gender_image = ' ';
break;
case 2:
$gender_image = ' ';
break;
default:
$gender_image = '';
}
// End add - Gender MOD
if ( empty($userdata['user_id']) || ($userdata['user_id'] == ANONYMOUS) )
{
if ( !empty($postrow[$i]['user_viewemail']) )
{
$email_img = ' ';
}
else
{
$email_img = ' ';
}
$email = ' ';
}
elseif ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
{
$email_uri = ( $board_config['board_email_form'] ) ? append_sid(PROFILE_MG . '?mode=email&' . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
$email_img = ' ';
$email = '' . $lang['Email'] . ' ';
}
else
{
$email_img = '';
$email = '';
}
$www_img = ( $postrow[$i]['user_website'] ) ? ' ' : '';
$www = ( $postrow[$i]['user_website'] ) ? '' . $lang['Website'] . ' ' : '';
if ( !empty($postrow[$i]['user_icq']) )
{
$icq_status_img = ' ';
$icq_img = ' ';
$icq = '' . $lang['ICQ'] . ' ';
}
else
{
$icq_status_img = '';
$icq_img = '';
$icq = '';
}
$aim_img = ( $postrow[$i]['user_aim'] ) ? ' ' : '';
$aim = ( $postrow[$i]['user_aim'] ) ? '' . $lang['AIM'] . ' ' : '';
$temp_url = append_sid(PROFILE_MG . '?mode=viewprofile&' . POST_USERS_URL . '=' . $poster_id);
$msn_img = ( $postrow[$i]['user_msnm'] ) ? ' ' : '';
$msn = ( $postrow[$i]['user_msnm'] ) ? '' . $lang['MSNM'] . ' ' : '';
$yim_img = ( $postrow[$i]['user_yim'] ) ? ' ' : '';
$yim = ( $postrow[$i]['user_yim'] ) ? '' . $lang['YIM'] . ' ' : '';
$skype_img = ( $postrow[$i]['user_skype'] ) ? ' ' : '';
$skype = ( $postrow[$i]['user_skype'] ) ? '' . $lang['SKYPE'] . ' ' : '';
// --- Smart Album Button BEGIN ----------------
if ( $postrow[$i]['user_personal_pics_count'] > 0 )
{
$album_img = ( $postrow[$i]['user_personal_pics_count'] ) ? ' ' : '';
$album = ( $postrow[$i]['user_personal_pics_count'] ) ? '' . $lang['Show_Personal_Gallery'] . ' ' : '';
}
else
{
$album_img = '';
$album = '';
}
// --- Smart Album Button END ----------------
// Start add - Online/Offline/Hidden Mod
if ( $postrow[$i]['user_session_time'] >= (time()-$board_config['online_time']) )
{
if ( $postrow[$i]['user_allow_viewonline'] )
{
$online_status_img = ' ';
// $online_status = ' ' . $lang['Online_status'] . ': ' . $lang['Online'] . ' ';
}
elseif ( $is_auth['auth_mod'] || $userdata['user_id'] == $poster_id )
{
$online_status_img = ' ';
// $online_status = ' ' . $lang['Online_status'] . ': ' . $lang['Hidden'] . ' ';
}
else
{
$online_status_img = ' ';
}
}
else
{
$online_status_img = ' ';
}
// End add - Online/Offline/Hidden Mod
}
else
{
$gender_image = '';
$poster_from_flag = '';
$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 = '';
$skype_img = '';
$skype = '';
$album_img = '';
$album = '';
$online_status_img = '';
$online_status = '';
}
$temp_url = append_sid('posting.' . $phpEx . '?mode=quote&' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
$quote_img = ' ';
$quote = '' . $lang['Reply_with_quote'] . ' ';
$temp_url = append_sid(SEARCH_MG . '?search_author=' . urlencode($postrow[$i]['username']) . '&showresults=posts');
$search_img = ' ';
$search = '' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . ' ';
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 = ' ';
$edit = '' . $lang['Edit_delete_post'] . ' ';
}
else
{
$edit_img = '';
$edit = '';
}
if ( $board_config['disable_topic_view'] == false )
{
$topic_view_img = ($userdata['session_logged_in']) ? ' ' : '';
}
else
{
$topic_view_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'];
// Start Advanced IP Tools Pack MOD
$ip_img = ' ';
// End Advanced IP Tools Pack MOD
$ip = '' . $lang['View_IP'] . ' ';
$temp_url = 'posting.' . $phpEx . '?mode=delete&' . POST_POST_URL . '=' . $postrow[$i]['post_id'] . '&sid=' . $userdata['session_id'];
$delpost_img = ' ';
$delpost = '' . $lang['Delete_post'] . ' ';
}
else
{
$ip_img = '';
$ip = '';
if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
{
$temp_url = 'posting.' . $phpEx . '?mode=delete&' . POST_POST_URL . '=' . $postrow[$i]['post_id'] . '&sid=' . $userdata['session_id'];
$delpost_img = ' ';
$delpost = '' . $lang['Delete_post'] . ' ';
}
else
{
$delpost_img = '';
$delpost = '';
}
}
// Start Yellow Card Changes for phpBB Styles
$style_used = explode('/', $template->files['body']);
$allowed_styles = array(
'ca_aphrodite',
//'mg_themes',
);
if( in_array($style_used[2], $allowed_styles) && (!empty($template->xs_version)) )
{
$phpbb_styles = true;
}
else
{
$phpbb_styles = false;
}
if( ($poster_id != ANONYMOUS) && ($postrow[$i]['user_level'] != ADMIN) )
{
$current_user = str_replace("'", "\'", $postrow[$i]['username']);
if ($is_auth['auth_greencard'])
{
$grn_card_img = ' ';
$grn_card_action = 'return confirm(\''.sprintf($lang['Green_card_warning'],$current_user).'\')';
$temp_url = 'card.' . $phpEx . '?mode=unban&post_id=' . $postrow[$i]['post_id'] . '&user_id=' . $userdata['user_id'] . '&sid=' . $userdata['session_id'];
$g_card_img = '' . $grn_card_img . ' ';
if( $phpbb_styles == true )
{
$g_card_img = '' . $g_card_img . ' ';
}
}
else
{
$g_card_img = '';
}
$user_warnings = $postrow[$i]['user_warnings'];
$card_img = '';
$is_banned = false;
if ($user_warnings == 0)
{
$card_img = '';
}
else
{
for($n = 0; $n < count($ranks_sql['bannedrow']); $n++)
{
if ( $ranks_sql['bannedrow'][$n]['ban_userid'] == $poster_id )
{
$is_banned = true;
break;
}
}
if ( ($user_warnings > $board_config['max_user_bancard']) || ($is_banned == true) )
{
$card_img = ' ';
}
else
{
for ($n = 0; $n < $user_warnings; $n++)
{
$card_img .= ' ';
}
}
}
if ( ($user_warnings <= $board_config['max_user_bancard']) && $is_auth['auth_ban'] )
{
$yel_card_img = ' ';
$yel_card_action = 'return confirm(\'' . sprintf($lang['Yellow_card_warning'], $current_user) . '\')';
$temp_url = 'card.' . $phpEx . '?mode=warn&post_id=' . $postrow[$i]['post_id'] . '&user_id=' . $userdata['user_id'] . '&sid=' . $userdata['session_id'];
$y_card_img = '' . $yel_card_img . ' ';
$red_card_img = ' ';
$red_card_action = 'return confirm(\''.sprintf($lang['Red_card_warning'], $current_user).'\')';
$temp_url = 'card.' . $phpEx . '?mode=ban&post_id=' . $postrow[$i]['post_id'] . '&user_id=' . $userdata['user_id'] . '&sid=' . $userdata['session_id'];
$r_card_img = '' . $red_card_img . ' ';
if( $phpbb_styles == true )
{
$y_card_img = '' . $y_card_img . ' ';
$r_card_img = '' . $r_card_img . ' ';
}
}
else
{
$y_card_img = '';
$r_card_img = '';
}
}
else
{
$card_img = '';
$g_card_img = '';
$y_card_img = '';
$r_card_img = '';
}
if ($is_auth['auth_bluecard'])
{
if ($is_auth['auth_mod'])
{
$blue_card_img = (($postrow[$i]['post_bluecard'])) ? ' ' : ' ';
$blue_card_action = ($postrow[$i]['post_bluecard']) ? 'return confirm(\'' . $lang['Clear_blue_card_warning'] . '\')' : 'return confirm(\'' . $lang['Blue_card_warning'] . '\')';
$temp_url = 'card.' . $phpEx . '?mode=' . (($postrow[$i]['post_bluecard']) ? 'report_reset' : 'report') . '&post_id=' . $postrow[$i]['post_id'] . '&user_id=' . $userdata['user_id'] . '&sid=' . $userdata['session_id'];
$b_card_img = '' . $blue_card_img . ' ';
if( $phpbb_styles == true)
{
$b_card_img = '' . $b_card_img . ' ';
}
}
else
{
$blue_card_img = ' ';
$blue_card_action = 'return confirm(\''.$lang['Blue_card_warning'].'\')';
$temp_url = 'card.' . $phpEx . '?mode=report&post_id=' . $postrow[$i]['post_id'] . '&user_id=' . $userdata['user_id'] . '&sid=' . $userdata['session_id'];
$b_card_img = '' . $blue_card_img . ' ';
if( $phpbb_styles == true )
{
$b_card_img = '' . $b_card_img . ' ';
}
}
}
else
{
$b_card_img = '';
}
// parse hidden fields if cards visible
$card_hidden = ($g_card_img || $r_card_img || $y_card_img || $b_card_img) ? ' ' : '';
// End Changes for Yellow Card Mod
if ( $board_config['switch_poster_info_topic'] == true )
{
if( array_search($postrow[$i]['user_style'], $styles_list_id) )
{
$poster_style = $lang['Change_Style'] . ': ' . $styles_list_name[array_search($postrow[$i]['user_style'], $styles_list_id)] . ' ';
}
else
{
$poster_style = '';
}
if ( !$postrow[$i]['user_lang'] == '' )
{
$poster_lang = $lang['Change_Lang'] . ': ' . ucfirst(strtolower($postrow[$i]['user_lang'])) . ' ';
}
else
{
$poster_lang = '';
}
}
else
{
$poster_style = '';
$poster_lang = '';
}
$post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
// Mighty Gorgon - Quick Quote - BEGIN
if ( $board_config['enable_quick_quote'] == 1 )
{
$look_up_array = array(
"<",
">",
"\n",
chr(13),
);
$replacement_array = array(
"<_mg;",
">_mg;",
"\\n",
"",
);
$plain_message = $postrow[$i]['post_text'];
$plain_message = strtr($plain_message, array_flip(get_html_translation_table(HTML_ENTITIES)));
//Hide MOD
if( preg_match('/\[hide/i', $plain_message) )
{
$search = array("/\[hide\](.*?)\[\/hide\]/");
$replace = array('[hide]' . $lang['xs_bbc_hide_quote_message'] . '[/hide]');
$plain_message = preg_replace($search, $replace, $plain_message);
}
//Hide MOD
if ( !empty($orig_word) )
{
$plain_message = ( !empty($plain_message) ) ? preg_replace($orig_word, $replacement_word, $plain_message) : '';
}
$plain_message = addslashes($plain_message);
$plain_message = str_replace($look_up_array, $replacement_array, $plain_message);
}
// Mighty Gorgon - Quick Quote - END
// Mighty Gorgon - New BBCode Functions - BEGIN
// Please, do not change anything here, if you're not confident with what you're doing!!!
//$message = $postrow[$i]['post_text'];
// CrackerTracker v5.x
$is_miserable = false;
if ( ($postrow[$i]['ct_miserable_user'] == 1) && ($postrow[$i]['user_id'] != $userdata['user_id']) && ($userdata['user_level'] == 0) )
{
//$message = $lang['ctracker_message_dialog_title'] . ' ' . $lang['ctracker_ipb_deleted'];
$message = $lang['ctracker_message_dialog_title'] . "\n\n" . $lang['ctracker_ipb_deleted'];
$is_miserable = true;
}
else
{
$message = $postrow[$i]['post_text'];
if ( ($postrow[$i]['ct_miserable_user'] == 1) && ($userdata['user_level'] == ADMIN) )
{
//$message .= ' ' . $lang['ctracker_mu_success_bbc'];
$message .= "\n\n" . $lang['ctracker_mu_success_bbc'];
$is_miserable = true;
}
}
// CrackerTracker v5.x
$message_compiled = empty($postrow[$i]['post_text_compiled']) ? false : $postrow[$i]['post_text_compiled'];
if ($is_miserable == true )
{
$message_compiled = false;
}
$bbcode_uid = $postrow[$i]['bbcode_uid'];
// BEGIN CMX News Mod
// Strip out the delimiter.
$delim = htmlspecialchars('');
$pos = strpos($message, $delim);
if( ($pos !== false) && ($pos < strlen( $message )) )
{
$message = substr_replace( $message, html_entity_decode($delim), $pos, strlen($delim) );
}
// END CMX News Mod
$user_sig = ( $postrow[$i]['enable_sig'] && (trim($postrow[$i]['user_sig']) != '') && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
$user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
// Replace Naughty Words - BEGIN
if (count($orig_word))
{
$post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
//$poster = ( !empty($poster) ) ? preg_replace($orig_word, $replacement_word, $poster) : '';
//$poster_qq = ( !empty($poster_qq) ) ? preg_replace($orig_word, $replacement_word, $poster_qq) : '';
//$user_sig = ( !empty($user_sig) ) ? preg_replace($orig_word, $replacement_word, $user_sig) : '';
//$message = ( !empty($message) ) ? preg_replace($orig_word, $replacement_word, $message) : '';
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 Naughty Words - END
// BBCode Parsing
if($user_sig && empty($sig_cache[$postrow[$i]['user_id']]))
{
$bbcode->allow_bbcode = $board_config['allow_bbcode'] && $userdata['user_allowbbcode'];
//$bbcode->allow_smilies = true;
//$bbcode->allow_html = true;
$bbcode->allow_smilies = $board_config['allow_smilies'] && !$lofi;
$bbcode->allow_html = $board_config['allow_html'] && $userdata['user_allowhtml'];
$bbcode->is_sig = ( $board_config['allow_all_bbcode'] == 0 ) ? true : false;
$user_sig = $bbcode->parse($user_sig, $user_sig_bbcode_uid);
$bbcode->is_sig = false;
$sig_cache[$postrow[$i]['user_id']] = $user_sig;
}
elseif($user_sig)
{
$user_sig = $sig_cache[$postrow[$i]['user_id']];
}
$bbcode->allow_html = $board_config['allow_html'] && $userdata['user_allowhtml'] && $postrow[$i]['enable_html'];
$bbcode->allow_bbcode = $board_config['allow_bbcode'] && $userdata['user_allowbbcode'] && $postrow[$i]['enable_bbcode'];
$bbcode->allow_smilies = $board_config['allow_smilies'] && !$lofi && $postrow[$i]['enable_smilies'];
if( preg_match('/\[code/i', $message))
{
$bbcode->allow_html = false;
}
if( preg_match('/\[hide/i', $message) || preg_match('/\[xs/i', $message) || preg_match('/\[upgrade/i', $message))
{
$message_compiled = false;
}
else
{
$message_compiled = empty($postrow[$i]['post_text_compiled']) ? false : $postrow[$i]['post_text_compiled'];
}
if ($lofi)
{
$message = $bbcode->parse($message, $bbcode_uid);
}
elseif($board_config['posts_precompiled'] == '0')
{
if($message_compiled == false)
{
// $bbcode->allow_smilies = $board_config['allow_smilies'] && $postrow[$i]['user_allowsmile'] ? true : false;
$GLOBALS['code_post_id'] = $postrow[$i]['post_id'];
$message = $bbcode->parse($message, $bbcode_uid);
if ( $bbcode->allow_bbcode == false)
{
$message = str_replace("\n", " ", preg_replace("/\r\n/", "\n", $message));
}
$GLOBALS['code_post_id'] = 0;
// update database
$sql = "UPDATE " . POSTS_TEXT_TABLE . " SET post_text_compiled='" . addslashes($message) . "' WHERE post_id='" . $postrow[$i]['post_id'] . "'";
$db->sql_query($sql);
}
else
{
$message = $message_compiled;
}
}
else
{
$GLOBALS['code_post_id'] = $postrow[$i]['post_id'];
$message = $bbcode->parse($message, $bbcode_uid);
if ( $bbcode->allow_bbcode == false)
{
$message = str_replace("\n", " ", preg_replace("/\r\n/", "\n", $message));
}
$GLOBALS['code_post_id'] = 0;
}
// Mighty Gorgon - New BBCode Functions - END
//Acronyms, AutoLinks, Wrap - BEGIN
if ($postrow[$i]['enable_autolinks_acronyms'] == true)
{
if( function_exists('acronym_pass') )
{
$message = acronym_pass($message);
}
if( count($orig_autolink) )
{
$message = autolink_transform($message, $orig_autolink, $replacement_autolink);
}
//$message = kb_word_wrap_pass ($message);
if ( count($orig_word) && !$postrow[$i]['user_allowswearywords'])
{
$message = preg_replace($orig_word, $replacement_word, $message);
}
}
//Acronyms, AutoLinks, Wrap -END
// Highlight active words (primarily for search)
if ($highlight_match)
{
// This has been back-ported from 3.0 CVS
$message = preg_replace('#(?!<.*)(?]*>)#i', '\1 ', $message);
}
// Replace newlines (we use this rather than nl2br because till recently it wasn't XHTML compliant)
if ( $user_sig != '' )
{
$user_sig = ' ' . $board_config['sig_line'] . ' ' . $user_sig;
}
// Mighty Gorgon - ???
// $message = str_replace("\n", "\n \n", $message);
// Mighty Gorgon - ???
// Editing information
if ($board_config['edit_notes'] == 1)
{
$notes_list = strlen($postrow[$i]['edit_notes']) ? unserialize($postrow[$i]['edit_notes']) : array();
if($is_auth['auth_mod'] && count($delnote) == 2 && $delnote[0] == $postrow[$i]['post_id'])
{
$new_list = array();
$num = intval($delnote[1]);
for($n=0; $nsql_query($sql);
}
}
else
{
$notes_list = '';
}
if ( $postrow[$i]['post_edit_count'] && !$notes_list )
{
$l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
$l_edited_by = ' ' . sprintf($l_edit_time_total, $poster, create_date2($board_config['default_dateformat'], $postrow[$i]['post_edit_time'], $board_config['board_timezone']), $postrow[$i]['post_edit_count']);
}
else
{
$l_edited_by = ' ';
}
if (!empty($topic_calendar_time) && ($postrow[$i]['post_id'] == $topic_first_post_id))
{
$post_subject .= get_calendar_title($topic_calendar_time, $topic_calendar_duration);
}
if ( ($board_config['smilies_topic_title'] == '1') && !$lofi)
{
//Start BBCode Parsing for title
$bbcode->allow_html = false ;
$bbcode->allow_bbcode = false ;
$bbcode->allow_smilies = ( $board_config['allow_smilies'] ? true : false );
$post_subject = ( $bbcode ? $topic_title = $bbcode->parse($post_subject, $bbcode_uid, true) : $post_subject );
//End BBCode Parsing for title
}
//
if($userdata['upi2db_access'])
{
$post_edit_max = ($postrow[$i]['post_time'] >= $postrow[$i]['post_edit_time']) ? $postrow[$i]['post_time'] : $postrow[$i]['post_edit_time'];
$post_time_max = (empty($board_config['upi2db_edit_as_new'])) ? $postrow[$i]['post_time'] : $post_edit_max;
$post_id = $postrow[$i]['post_id'];
$mark_topic_unread = mark_post_viewtopic($post_time_max, $unread, $topic_id, $forum_id, $post_id, $except_time, $forum_topic_data['topic_type']);
}
else
{
$mark_topic_unread = '';
}
//
//-- mod : post icon -------------------------------------------------------------------------------
//-- add
$post_subject = get_icon_title($postrow[$i]['post_icon']) . ' ' . $post_subject;
//-- fin mod : post icon ---------------------------------------------------------------------------
// Again this will be handled by the templating code at some point
$row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
$row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
/* Begin HP/MP/EXP Mod
*
* Note: all new variables used created in this mod
* are prefixed with level_ to be sure of not overwriting
* other variables.
*
*/
/* Calculate Level
* A user's level is determined by their total number of posts.
* A nice mathmatical formula is used to translate their post count
* into an intager level.
*
* Note: A user with zero (0) posts is considered level 0, however
* making one (1) post, raises them to level 1.
*
*/
if($postrow[$i]['user_posts'] < 1)
{
$level_level = 0;
}
else
{
$level_level = floor( pow( log10( $postrow[$i]['user_posts'] ), 3 ) ) + 1;
}
/* Determine Hit Points (HP)
*
* Hp is based on user activity.
* Max HP is based on the user's level, and will generally
* be the same for all users of the same level.
*
* A user's current HP is based on the user's posts per day.
* A higher post per day (ppd), the more HP they will have. A
* user with an average PPD (set below) will have 50% of their
* max HP. As a user goes over the average PPD, they will have
* more HP, but the gains will decrease as the user's PPD increases.
* This makes achieving 100% hp difficult, but not impossible.
*
* For users with under the average PPD, they will have HP equal
* to 1/2 the percentage their ppd is of the average.
* ie- a user with 2.5 ppd, and an average ppd of 5 will have
* 25% of their max HP. This is because 2.5 is 50% of 5, and 1/2
* of that, is 25%.
*
* Users who manage to post so far above the average that they have
* more HP than their max will recieve a bonus to their max HP.
*
* Note that users at level 0 will always have 0 / 0 hp.
*
*/
/*
* This value determines the 'average' posts per day.
* The admin may redefine this variable as he wishes.
* Higher values will generally decrease users' HP, and
* lower values will generally increase users' HP.
*
* Note: Do NOT set this value to zero (0).
* This -may- be set to a fractional value (eg, 5.1, 3.1415)
*
*/
$level_avg_ppd = 5;
/*
* this value sets how hard it is to achieve 100%
* hp. The higher you set it, the harder it is to
* get full hp.
*
* to judge how high to set it, a user must have
* posts per day equal to the $level_avg_ppd plus
* the number set below.
*
* This should NOT be zero.
*/
$level_bonus_redux = 5;
/*
* We need to actually calculate the user's posts per day
* because unlike in the profile, it's not done for us.
*
*/
$level_user_ppd = ($postrow[$i]['user_posts'] / max(1, round( ( time() - $postrow[$i]['user_regdate'] ) / 86400 )));
if($level_level < 1)
{
$level_hp = "0 / 0";
$level_hp_percent = 0;
}
else
{
$level_max_hp = floor( (pow( $level_level, (1/4) ) ) * (pow( 10, pow( $level_level+2, (1/3) ) ) ) / (1.5) );
if($level_user_ppd >= $level_avg_ppd)
{
$level_hp_percent = floor( (.5 + (($level_user_ppd - $level_avg_ppd) / ($level_bonus_redux * 2)) ) * 100);
}
else
{
$level_hp_percent = floor( $level_user_ppd / ($level_avg_ppd / 50) );
}
if($level_hp_percent > 100)
{
//Give the user a bonus to max HP for greater than 100% hp.
$level_max_hp += floor( ($level_hp_percent - 100) * pi() );
$level_hp_percent = 100;
}
else
{
$level_hp_percent = max(0, $level_hp_percent);
}
$level_cur_hp = floor($level_max_hp * ($level_hp_percent / 100) );
//Be sure a user has no more than max, and no less than zero hp.
$level_cur_hp = max(0, $level_cur_hp);
$level_cur_hp = min($level_max_hp, $level_cur_hp);
$level_hp = $level_cur_hp . ' / ' . $level_max_hp;
}
/* Determine MP
*
* MP is calculated by how long the user has been around
* and how often they post.
*
* Max MP is based on level, and increases with level
* Each post a user makes costs them mp,
* and a user regenerates mp proportional to how
* many days they have been registered
*
*/
//Number of days the user has been at the forums.
$level_user_days = max(1, round( ( time() - $postrow[$i]['user_regdate'] ) / 86400 ));
/* The mp cost for one post.
* Raising this value will generally decrease the current
* mp for most posters.
* This may be set to a decimal value (eg, 2, 2.1, 3.141596)
* This should NOT be set to 0
*/
$level_post_mp_cost = 2.5;
/* This determines how much mp a user regenerates per day
* Raising this value will generally increase the current
* mp for most posters.
* This may be set to a decimal value (eg, 3, 3.5, 2.71828)
* This should NOT be set to 0
*/
$level_mp_regen_per_day = 4;
if($level_level < 1)
{
$level_mp = '0 / 0';
$level_mp_percent = 0;
}
else
{
$level_max_mp = floor( (pow( $level_level, (1/4) ) ) * (pow( 10, pow( $level_level+2, (1/3) ) ) ) / (pi()) );
$level_mp_cost = $postrow[$i]['user_posts'] * $level_post_mp_cost;
$level_mp_regen = max(1, $level_user_days * $level_mp_regen_per_day);
$level_cur_mp = floor($level_max_mp - $level_mp_cost + $level_mp_regen);
$level_cur_mp = max(0, $level_cur_mp);
$level_cur_mp = min($level_max_mp, $level_cur_mp);
$level_mp = $level_cur_mp . ' / ' . $level_max_mp;
$level_mp_percent = floor($level_cur_mp / $level_max_mp * 100 );
}
/* Determine EXP percentage
*
* Experience is determined by how far the user is away
* from the next level. This is expressed as a percentage.
*
* Note, a user of level 0 has 100% experience. Making one post
* will put them at level 1. Also, a user that is shown to have 100%
* experience, will go up a level on their next post.
*
*/
if($level_level == 0)
{
$level_exp = "0 / 0";
$level_exp_percent = 100;
}
else
{
$level_posts_for_next = floor( pow( 10, pow( $level_level, (1/3) ) ) );
$level_posts_for_this = max(1, floor( pow( 10, pow( ($level_level - 1), (1/3) ) ) ) );
$level_exp = ($postrow[$i]['user_posts'] - $level_posts_for_this) . " / " . ($level_posts_for_next - $level_posts_for_this);
$level_exp_percent = floor( ( ($postrow[$i]['user_posts'] - $level_posts_for_this) / max( 1, ($level_posts_for_next - $level_posts_for_this ) ) ) * 100);
}
/* END HP/MP/EXP MOD */
$post_id = $postrow[$i]['post_id'];
$poster_number = ( $postrow[$i]['poster_id'] == ANONYMOUS ) ? '' : $lang['User_Number'] . ': ' . $postrow[$i]['poster_id'];
$post_edit_link = append_sid('edit_post_time.' . $phpEx . '?' . POST_TOPIC_URL . '=' . $topic_id . '&' . POST_POST_URL . '=' . $postrow[$i]['post_id']);
$post_edit_string = ( !$userdata['user_id'] == ADMIN ) ? '' : '' . $lang['Edit_post_time_xs']. ' ';
//$post_edit_string = (!$userdata['user_level'] == MOD || !$userdata['user_id'] == ADMIN ) ? '' : '' . $lang['Edit_post_time_xs']. ' ';
$single_post = '#' . ( $i + 1 + $start ) . ' ';
//Single Post on the same window
//$single_post = '#'.( $i + 1 + $start ) . ' ';
$template->assign_block_vars('postrow', array(
'ROW_COLOR' => '#' . $row_color,
'ROW_CLASS' => $row_class,
'POSTER_NAME' => $poster,
'POSTER_NAME_QQ' => $poster_qq,
'POSTER_NAME_QR' => str_replace(array(' ', '?', '&'), array('%20', '%3F', '%26'), $poster_qq),
'POSTER_AGE' => $poster_age,
'GEB_BILD' => $gebbild,
'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,
'POSTER_GENDER' => $gender_image,
'POSTER_JOINED' => $poster_joined,
'POSTER_POSTS' => $poster_posts,
'POSTER_FROM' => $poster_from,
'POSTER_FROM_FLAG' => $poster_from_flag,
'POSTER_AVATAR' => $poster_avatar,
'POSTER_ONLINE_STATUS_IMG' => $online_status_img,
'POSTER_ONLINE_STATUS' => $online_status,
'POST_DATE' => $post_date,
'POST_EDIT_STRING' => $post_edit_string,
//'POST_EDIT_LINK' => $post_edit_link,
'POST_SUBJECT' => $post_subject,
'MESSAGE' => $message,
'PLAIN_MESSAGE' => $plain_message,
'SIGNATURE' => $user_sig,
'EDITED_MESSAGE' => $l_edited_by,
'POSTER_STYLE' => $poster_style,
'POSTER_LANG' => $poster_lang,
// Activity - BEGIN
'POSTER_TROPHY' => ( defined('ACTIVITY_MOD') && (ACTIVITY_MOD == true) ) ? Amod_Build_Topics($hof_data, $postrow[$i]['user_id'], $postrow[$i]['user_trophies'], $postrow[$i]['username'], $postrow[$i]['ina_char_name']) : '',
// Activity - END
'MINI_POST_IMG' => $mini_post_img,
'PROFILE_IMG' => $profile_img,
'PROFILE' => $profile,
'SEARCH_IMG' => $search_img,
'SEARCH' => $search,
'PM_IMG' => $pm_img,
'PM' => $pm,
'EMAIL_IMG' => ( !$userdata['session_logged_in'] )? '' : $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,
'SKYPE_IMG' => $skype_img,
'SKYPE' => $skype,
'DOWNLOAD_IMG' => $images['icon_download2'],
'ALBUM_IMG' => $album_img,
'ALBUM' => $album,
'EDIT_IMG' => $edit_img,
'EDIT' => $edit,
'QUOTE_IMG' => $quote_img,
'QUOTE' => $quote,
'IP_IMG' => $ip_img,
'TOPIC_VIEW_IMG' => $topic_view_img,
'L_MINI_POST_ALT' => $mini_post_alt,
/* BEGIN LEVEL MOD */
"POSTER_HP" => $level_hp,
"POSTER_HP_WIDTH" => $level_hp_percent,
"POSTER_HP_EMPTY" => ( 100 - $level_hp_percent ),
"POSTER_MP" => $level_mp,
"POSTER_MP_WIDTH" => $level_mp_percent,
"POSTER_MP_EMPTY" => ( 100 - $level_mp_percent ),
"POSTER_EXP" => $level_exp,
"POSTER_EXP_WIDTH" => $level_exp_percent,
"POSTER_EXP_EMPTY" => ( 100 - $level_exp_percent ),
"POSTER_LEVEL" => $level_level,
/* END LEVEL MOD */
'NOTES_COUNT' => count($notes_list),
'NOTES_DATA' => $postrow[$i]['edit_notes'],
'DOWNLOAD_POST' => append_sid(VIEWTOPIC_MG . '?download=' . $postrow[$i]['post_id'] . '&' . POST_TOPIC_URL . '=' . $topic_id),
'SINGLE_POST' => $single_post,
'POSTER_NO' => $poster_number,
//'POSTER_NO' => $postrow[$i]['poster_id'],
'IP' => $ip,
'DELETE_IMG' => $delpost_img,
'DELETE' => $delpost,
'USER_WARNINGS' => $user_warnings,
'CARD_IMG' => $card_img,
'CARD_HIDDEN_FIELDS' => $card_hidden,
'CARD_EXTRA_SPACE' => ($r_card_img || $y_card_img || $g_card_img || $b_card_img) ? ' ' : '',
'U_MINI_POST' => $mini_post_url,
//
'UNREAD_IMG' => $mark_topic_unread,
'UNREAD_COLOR' => $unread_color,
//
'U_G_CARD' => $g_card_img,
'U_Y_CARD' => $y_card_img,
'U_R_CARD' => $r_card_img,
'U_B_CARD' => $b_card_img,
'S_CARD' => ( $phpbb_styles ) ? $card_action : append_sid('card.' . $phpEx),
'U_POST_ID' => $postrow[$i]['post_id']
)
);
//
// Custom Profile Fields MOD
//
if ( ($poster_id != ANONYMOUS) && ($profile_data_sql != '') )
{
$language = $board_config['default_lang'];
if ( !file_exists($phpbb_root_path . 'language/lang_' . $language . '/lang_profile_fields.' . $phpEx) )
{
$language = 'english';
}
include($phpbb_root_path . 'language/lang_' . $language . '/lang_profile_fields.' . $phpEx);
$cp_data = array();
$cp_data = get_topic_udata($postrow[$i], $profile_data);
if ( $cp_data['aboves'] )
foreach($cp_data['aboves'] as $above_val)
{
$template->assign_block_vars('postrow.above_sig', array('ABOVE_VAL' => $above_val));
}
if ( $cp_data['belows'] )
{
foreach($cp_data['belows'] as $below_val)
{
$template->assign_block_vars('postrow.below_sig', array('BELOW_VAL' => $below_val));
}
}
if ( $cp_data['author'] )
{
foreach($cp_data['author'] as $author_val)
{
$template->assign_block_vars('postrow.author_profile', array('AUTHOR_VAL' => $author_val));
}
}
}
//
// END Custom Profile Fields MOD
//
if ( $board_config['switch_poster_info_topic'] == 1)
{
$template->assign_block_vars('postrow.switch_poster_info', array());
}
if ($userdata['user_showavatars'])
{
$template->assign_block_vars('postrow.switch_showavatars', array());
}
if ($userdata['user_showsignatures'])
{
$template->assign_block_vars('postrow.switch_showsignatures', array());
}
if ( ($userdata['user_level'] == ADMIN) || ($userdata['user_level'] == MOD) )
{
$template->assign_block_vars('postrow.switch_user_admin_or_mod', array(
'POST_EDIT_STRING' => $post_edit_string,
)
);
}
display_post_attachments($postrow[$i]['post_id'], $postrow[$i]['post_attachment']);
if( ($show_thanks == FORUM_THANKABLE) && ($i == 0) && ($current_page == 1) && ($thanks <> '') )
{
$template->assign_block_vars('postrow.thanks', array(
'THANKS' => $thanks,
'THANKFUL' => $lang['thankful'],
'THANKS2' => $lang ['thanks2'],
'THANKS3' => $thanks2
)
);
}
//if ( (!$forum_topic_data['forum_status'] == FORUM_LOCKED) && (!$forum_topic_data['topic_status'] == TOPIC_LOCKED) && ($is_auth['auth_reply']) && ($userdata['session_logged_in']) )
if ( (!$forum_topic_data['forum_status'] == FORUM_LOCKED) && (!$forum_topic_data['topic_status'] == TOPIC_LOCKED) && ($is_auth['auth_reply']) && ($board_config['enable_quick_quote'] == 1) )
{
$template->assign_block_vars('postrow.switch_quick_quote', array());
}
if ( ($i == 0) && ($board_config['switch_viewtopic_banner'] == 1) )
{
$template->assign_block_vars('postrow.switch_viewtopic_banner', array());
}
if ( $board_config['edit_notes'] == 1 )
{
for($n=0; $n_tpldata['postrow.'][$i]['NOTES_DATA']))
{
$item = &$template->_tpldata['postrow.'][$i];
$item['notes.'] = array();
$list = unserialize($item['NOTES_DATA']);
for($j=0; $j $lang['Edited_by'],
'POSTER_NAME' => color_group_colorize_name($list[$j]['poster']),
'POSTER_PROFILE' => append_sid(PROFILE_MG . '?mode=viewprofile&' . POST_USERS_URL . '=' . $list[$j]['poster']),
'TEXT' => htmlspecialchars($list[$j]['text']),
'TIME' => create_date2($board_config['default_dateformat'], $list[$j]['time'], $board_config['board_timezone']),
'L_DELETE_NOTE' => $lang['Delete_note'],
'U_DELETE' => $is_auth['auth_mod'] ? ($template->vars['U_VIEW_TOPIC'] . '&delnote=' . $item['U_POST_ID'] . '.' . $j) : '',
);
}
unset($item);
}
}
}
ratings_view_topic();
//
if($userdata['upi2db_access'])
{
delete_read_posts($read_posts);
}
//
generate_smilies_row();
$template->pparse('body');
include($phpbb_root_path . 'includes/page_tail.' . $phpEx);
if ( $active )
{
}
}
?>