2 /***************************************************************************
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
9 * $Id: viewtopic.php,v 1.186.2.45 2005/10/05 17:42:04 grahamje Exp $
12 ***************************************************************************/
14 /***************************************************************************
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 ***************************************************************************/
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
27 include($phpbb_root_path . 'includes/bbcode.'.$phpEx);
30 // Start initial var setup
32 $topic_id = $post_id = 0;
33 if ( isset($HTTP_GET_VARS[POST_TOPIC_URL]) )
35 $topic_id = intval($HTTP_GET_VARS[POST_TOPIC_URL]);
37 else if ( isset($HTTP_GET_VARS['topic']) )
39 $topic_id = intval($HTTP_GET_VARS['topic']);
42 if ( isset($HTTP_GET_VARS[POST_POST_URL]))
44 $post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
48 $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
50 if (!$topic_id && !$post_id)
52 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
56 // Find topic id if user requested a newer
59 if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
61 if ( $HTTP_GET_VARS['view'] == 'newest' )
63 if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
65 $session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];
67 if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
74 $sql = "SELECT p.post_id
75 FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
76 WHERE s.session_id = '$session_id'
77 AND u.user_id = s.session_user_id
78 AND p.topic_id = $topic_id
79 AND p.post_time >= u.user_lastvisit
80 ORDER BY p.post_time ASC
82 if ( !($result = $db->sql_query($sql)) )
84 message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
87 if ( !($row = $db->sql_fetchrow($result)) )
89 message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
92 $post_id = $row['post_id'];
94 if (isset($HTTP_GET_VARS['sid']))
96 redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
100 redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
105 redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
107 else if ( $HTTP_GET_VARS['view'] == 'next' || $HTTP_GET_VARS['view'] == 'previous' )
109 $sql_condition = ( $HTTP_GET_VARS['view'] == 'next' ) ? '>' : '<';
110 $sql_ordering = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'ASC' : 'DESC';
112 $sql = "SELECT t.topic_id
113 FROM " . TOPICS_TABLE . " t, " . TOPICS_TABLE . " t2
115 t2.topic_id = $topic_id
116 AND t.forum_id = t2.forum_id
117 AND t.topic_moved_id = 0
118 AND t.topic_last_post_id $sql_condition t2.topic_last_post_id
119 ORDER BY t.topic_last_post_id $sql_ordering
121 if ( !($result = $db->sql_query($sql)) )
123 message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
126 if ( $row = $db->sql_fetchrow($result) )
128 $topic_id = intval($row['topic_id']);
132 $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
133 message_die(GENERAL_MESSAGE, $message);
139 // This rather complex gaggle of code handles querying for topics but
140 // also allows for direct linking to a post (and the calculation of which
141 // page the post is on and the correct display of viewtopic)
143 $join_sql_table = (!$post_id) ? '' : ", " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2 ";
144 $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";
145 $count_sql = (!$post_id) ? '' : ", COUNT(p2.post_id) AS prev_posts";
147 $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 ORDER BY p.post_id ASC";
149 $sql = "SELECT t.topic_id, t.topic_title, t.topic_status, t.topic_replies, t.topic_time, t.topic_type, t.topic_vote, t.topic_last_post_id, f.forum_name, f.forum_status, f.forum_id, f.auth_view, f.auth_read, f.auth_post, f.auth_reply, f.auth_edit, f.auth_delete, f.auth_sticky, f.auth_announce, f.auth_pollcreate, f.auth_vote, f.auth_attachments" . $count_sql . "
150 FROM " . TOPICS_TABLE . " t, " . FORUMS_TABLE . " f" . $join_sql_table . "
152 AND f.forum_id = t.forum_id
154 if ( !($result = $db->sql_query($sql)) )
156 message_die(GENERAL_ERROR, "Could not obtain topic information", '', __LINE__, __FILE__, $sql);
159 if ( !($forum_topic_data = $db->sql_fetchrow($result)) )
161 message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
164 $forum_id = intval($forum_topic_data['forum_id']);
167 // Start session management
169 $userdata = session_pagestart($user_ip, $forum_id);
170 init_userprefs($userdata);
172 // End session management
179 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_topic_data);
181 if( !$is_auth['auth_view'] || !$is_auth['auth_read'] )
183 if ( !$userdata['session_logged_in'] )
185 $redirect = ($post_id) ? POST_POST_URL . "=$post_id" : POST_TOPIC_URL . "=$topic_id";
186 $redirect .= ($start) ? "&start=$start" : '';
187 redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&$redirect", true));
190 $message = ( !$is_auth['auth_view'] ) ? $lang['Topic_post_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
192 message_die(GENERAL_MESSAGE, $message);
198 $forum_name = $forum_topic_data['forum_name'];
199 $topic_title = $forum_topic_data['topic_title'];
200 $topic_id = intval($forum_topic_data['topic_id']);
201 $topic_time = $forum_topic_data['topic_time'];
205 $start = floor(($forum_topic_data['prev_posts'] - 1) / intval($board_config['posts_per_page'])) * intval($board_config['posts_per_page']);
209 // Is user watching this thread?
211 if( $userdata['session_logged_in'] )
213 $can_watch_topic = TRUE;
215 $sql = "SELECT notify_status
216 FROM " . TOPICS_WATCH_TABLE . "
217 WHERE topic_id = $topic_id
218 AND user_id = " . $userdata['user_id'];
219 if ( !($result = $db->sql_query($sql)) )
221 message_die(GENERAL_ERROR, "Could not obtain topic watch information", '', __LINE__, __FILE__, $sql);
224 if ( $row = $db->sql_fetchrow($result) )
226 if ( isset($HTTP_GET_VARS['unwatch']) )
228 if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
230 $is_watching_topic = 0;
232 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
233 $sql = "DELETE $sql_priority FROM " . TOPICS_WATCH_TABLE . "
234 WHERE topic_id = $topic_id
235 AND user_id = " . $userdata['user_id'];
236 if ( !($result = $db->sql_query($sql)) )
238 message_die(GENERAL_ERROR, "Could not delete topic watch information", '', __LINE__, __FILE__, $sql);
242 $template->assign_vars(array(
243 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">')
246 $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>');
247 message_die(GENERAL_MESSAGE, $message);
251 $is_watching_topic = TRUE;
253 if ( $row['notify_status'] )
255 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
256 $sql = "UPDATE $sql_priority " . TOPICS_WATCH_TABLE . "
257 SET notify_status = 0
258 WHERE topic_id = $topic_id
259 AND user_id = " . $userdata['user_id'];
260 if ( !($result = $db->sql_query($sql)) )
262 message_die(GENERAL_ERROR, "Could not update topic watch information", '', __LINE__, __FILE__, $sql);
269 if ( isset($HTTP_GET_VARS['watch']) )
271 if ( $HTTP_GET_VARS['watch'] == 'topic' )
273 $is_watching_topic = TRUE;
275 $sql_priority = (SQL_LAYER == "mysql") ? "LOW_PRIORITY" : '';
276 $sql = "INSERT $sql_priority INTO " . TOPICS_WATCH_TABLE . " (user_id, topic_id, notify_status)
277 VALUES (" . $userdata['user_id'] . ", $topic_id, 0)";
278 if ( !($result = $db->sql_query($sql)) )
280 message_die(GENERAL_ERROR, "Could not insert topic watch information", '', __LINE__, __FILE__, $sql);
284 $template->assign_vars(array(
285 'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start") . '">')
288 $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>');
289 message_die(GENERAL_MESSAGE, $message);
293 $is_watching_topic = 0;
299 if ( isset($HTTP_GET_VARS['unwatch']) )
301 if ( $HTTP_GET_VARS['unwatch'] == 'topic' )
303 redirect(append_sid("login.$phpEx?redirect=viewtopic.$phpEx&" . POST_TOPIC_URL . "=$topic_id&unwatch=topic", true));
308 $can_watch_topic = 0;
309 $is_watching_topic = 0;
314 // Generate a 'Show posts in previous x days' select box. If the postdays var is POSTed
315 // then get it's value, find the number of topics with dates newer than it (to properly
316 // handle pagination) and alter the main query
318 $previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
319 $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']);
321 if( !empty($HTTP_POST_VARS['postdays']) || !empty($HTTP_GET_VARS['postdays']) )
323 $post_days = ( !empty($HTTP_POST_VARS['postdays']) ) ? intval($HTTP_POST_VARS['postdays']) : intval($HTTP_GET_VARS['postdays']);
324 $min_post_time = time() - (intval($post_days) * 86400);
326 $sql = "SELECT COUNT(p.post_id) AS num_posts
327 FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
328 WHERE t.topic_id = $topic_id
329 AND p.topic_id = t.topic_id
330 AND p.post_time >= $min_post_time";
331 if ( !($result = $db->sql_query($sql)) )
333 message_die(GENERAL_ERROR, "Could not obtain limited topics count information", '', __LINE__, __FILE__, $sql);
336 $total_replies = ( $row = $db->sql_fetchrow($result) ) ? intval($row['num_posts']) : 0;
338 $limit_posts_time = "AND p.post_time >= $min_post_time ";
340 if ( !empty($HTTP_POST_VARS['postdays']))
347 $total_replies = intval($forum_topic_data['topic_replies']) + 1;
349 $limit_posts_time = '';
353 $select_post_days = '<select name="postdays">';
354 for($i = 0; $i < count($previous_days); $i++)
356 $selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : '';
357 $select_post_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
359 $select_post_days .= '</select>';
362 // Decide how to order the post display
364 if ( !empty($HTTP_POST_VARS['postorder']) || !empty($HTTP_GET_VARS['postorder']) )
366 $post_order = (!empty($HTTP_POST_VARS['postorder'])) ? htmlspecialchars($HTTP_POST_VARS['postorder']) : htmlspecialchars($HTTP_GET_VARS['postorder']);
367 $post_time_order = ($post_order == "asc") ? "ASC" : "DESC";
372 $post_time_order = 'ASC';
375 $select_post_order = '<select name="postorder">';
376 if ( $post_time_order == 'ASC' )
378 $select_post_order .= '<option value="asc" selected="selected">' . $lang['Oldest_First'] . '</option><option value="desc">' . $lang['Newest_First'] . '</option>';
382 $select_post_order .= '<option value="asc">' . $lang['Oldest_First'] . '</option><option value="desc" selected="selected">' . $lang['Newest_First'] . '</option>';
384 $select_post_order .= '</select>';
387 // Go ahead and pull all data for this topic
389 $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid
390 FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt
391 WHERE p.topic_id = $topic_id
393 AND pt.post_id = p.post_id
394 AND u.user_id = p.poster_id
395 ORDER BY p.post_time $post_time_order
396 LIMIT $start, ".$board_config['posts_per_page'];
397 if ( !($result = $db->sql_query($sql)) )
399 message_die(GENERAL_ERROR, "Could not obtain post/user information.", '', __LINE__, __FILE__, $sql);
403 if ($row = $db->sql_fetchrow($result))
409 while ($row = $db->sql_fetchrow($result));
410 $db->sql_freeresult($result);
412 $total_posts = count($postrow);
416 include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
417 sync('topic', $topic_id);
419 message_die(GENERAL_MESSAGE, $lang['No_posts_topic']);
423 if ($forum_topic_data['topic_replies'] + 1 < $start + count($postrow))
427 elseif ($start + $board_config['posts_per_page'] > $forum_topic_data['topic_replies'])
429 $row_id = intval($forum_topic_data['topic_replies']) % intval($board_config['posts_per_page']);
430 if ($postrow[$row_id]['post_id'] != $forum_topic_data['topic_last_post_id'] || $start + count($postrow) < $forum_topic_data['topic_replies'])
435 elseif (count($postrow) < $board_config['posts_per_page'])
442 include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
443 sync('topic', $topic_id);
445 $result = $db->sql_query('SELECT COUNT(post_id) AS total FROM ' . POSTS_TABLE . ' WHERE topic_id = ' . $topic_id);
446 $row = $db->sql_fetchrow($result);
447 $total_replies = $row['total'];
451 FROM " . RANKS_TABLE . "
452 ORDER BY rank_special, rank_min";
453 if ( !($result = $db->sql_query($sql)) )
455 message_die(GENERAL_ERROR, "Could not obtain ranks information.", '', __LINE__, __FILE__, $sql);
459 while ( $row = $db->sql_fetchrow($result) )
463 $db->sql_freeresult($result);
466 // Define censored word matches
468 $orig_word = array();
469 $replacement_word = array();
470 obtain_word_list($orig_word, $replacement_word);
473 // Censor topic title
475 if ( count($orig_word) )
477 $topic_title = preg_replace($orig_word, $replacement_word, $topic_title);
481 // Was a highlight request part of the URI?
483 $highlight_match = $highlight = '';
484 if (isset($HTTP_GET_VARS['highlight']))
486 // Split words and phrases
487 $words = explode(' ', trim(htmlspecialchars($HTTP_GET_VARS['highlight'])));
489 for($i = 0; $i < sizeof($words); $i++)
491 if (trim($words[$i]) != '')
493 $highlight_match .= (($highlight_match != '') ? '|' : '') . str_replace('*', '\w*', preg_quote($words[$i], '#'));
498 $highlight = urlencode($HTTP_GET_VARS['highlight']);
499 $highlight_match = phpbb_rtrim($highlight_match, "\\");
503 // Post, reply and other URL generation for
506 $new_topic_url = append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id");
507 $reply_topic_url = append_sid("posting.$phpEx?mode=reply&" . POST_TOPIC_URL . "=$topic_id");
508 $view_forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id");
509 $view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous");
510 $view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next");
513 // Mozilla navigation bar
515 $nav_links['prev'] = array(
516 'url' => $view_prev_topic_url,
517 'title' => $lang['View_previous_topic']
519 $nav_links['next'] = array(
520 'url' => $view_next_topic_url,
521 'title' => $lang['View_next_topic']
523 $nav_links['up'] = array(
524 'url' => $view_forum_url,
525 'title' => $forum_name
528 $reply_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $images['reply_locked'] : $images['reply_new'];
529 $reply_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED || $forum_topic_data['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['Reply_to_topic'];
530 $post_img = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'];
531 $post_alt = ( $forum_topic_data['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'];
534 // Set a cookie for this topic
536 if ( $userdata['session_logged_in'] )
538 $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
539 $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
541 if ( !empty($tracking_topics[$topic_id]) && !empty($tracking_forums[$forum_id]) )
543 $topic_last_read = ( $tracking_topics[$topic_id] > $tracking_forums[$forum_id] ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
545 else if ( !empty($tracking_topics[$topic_id]) || !empty($tracking_forums[$forum_id]) )
547 $topic_last_read = ( !empty($tracking_topics[$topic_id]) ) ? $tracking_topics[$topic_id] : $tracking_forums[$forum_id];
551 $topic_last_read = $userdata['user_lastvisit'];
554 if ( count($tracking_topics) >= 150 && empty($tracking_topics[$topic_id]) )
556 asort($tracking_topics);
557 unset($tracking_topics[key($tracking_topics)]);
560 $tracking_topics[$topic_id] = time();
562 setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
568 $template->set_filenames(array(
569 'body' => 'viewtopic_body.tpl')
571 make_jumpbox('viewforum.'.$phpEx, $forum_id);
574 // Output page header
576 $page_title = $lang['View_topic'] .' - ' . $topic_title;
577 include($phpbb_root_path . 'includes/page_header.'.$phpEx);
580 // User authorisation levels output
582 $s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
583 $s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
584 $s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
585 $s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
586 $s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
590 if ( $is_auth['auth_mod'] )
592 $s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>');
594 $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> ';
596 $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> ';
598 $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> ' : "<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> ';
600 $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> ';
604 // Topic watch information
606 $s_watching_topic = '';
607 if ( $can_watch_topic )
609 if ( $is_watching_topic )
611 $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>';
612 $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>' : '';
616 $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>';
617 $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>' : '';
622 // If we've got a hightlight set pass it on to pagination,
623 // I get annoyed when I lose my highlight after the first page.
625 $pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
628 // Send vars to template
630 $template->assign_vars(array(
631 'FORUM_ID' => $forum_id,
632 'FORUM_NAME' => $forum_name,
633 'TOPIC_ID' => $topic_id,
634 'TOPIC_TITLE' => $topic_title,
635 'PAGINATION' => $pagination,
636 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / intval($board_config['posts_per_page']) ) + 1 ), ceil( $total_replies / intval($board_config['posts_per_page']) )),
638 'POST_IMG' => $post_img,
639 'REPLY_IMG' => $reply_img,
641 'L_AUTHOR' => $lang['Author'],
642 'L_MESSAGE' => $lang['Message'],
643 'L_POSTED' => $lang['Posted'],
644 'L_POST_SUBJECT' => $lang['Post_subject'],
645 'L_VIEW_NEXT_TOPIC' => $lang['View_next_topic'],
646 'L_VIEW_PREVIOUS_TOPIC' => $lang['View_previous_topic'],
647 'L_POST_NEW_TOPIC' => $post_alt,
648 'L_POST_REPLY_TOPIC' => $reply_alt,
649 'L_BACK_TO_TOP' => $lang['Back_to_top'],
650 'L_DISPLAY_POSTS' => $lang['Display_posts'],
651 'L_LOCK_TOPIC' => $lang['Lock_topic'],
652 'L_UNLOCK_TOPIC' => $lang['Unlock_topic'],
653 'L_MOVE_TOPIC' => $lang['Move_topic'],
654 'L_SPLIT_TOPIC' => $lang['Split_topic'],
655 'L_DELETE_TOPIC' => $lang['Delete_topic'],
656 'L_GOTO_PAGE' => $lang['Goto_page'],
658 'S_TOPIC_LINK' => POST_TOPIC_URL,
659 'S_SELECT_POST_DAYS' => $select_post_days,
660 'S_SELECT_POST_ORDER' => $select_post_order,
661 'S_POST_DAYS_ACTION' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . '=' . $topic_id . "&start=$start"),
662 'S_AUTH_LIST' => $s_auth_can,
663 'S_TOPIC_ADMIN' => $topic_mod,
664 'S_WATCH_TOPIC' => $s_watching_topic,
665 'S_WATCH_TOPIC_IMG' => $s_watching_topic_img,
667 'U_VIEW_TOPIC' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&postdays=$post_days&postorder=$post_order&highlight=$highlight"),
668 'U_VIEW_FORUM' => $view_forum_url,
669 'U_VIEW_OLDER_TOPIC' => $view_prev_topic_url,
670 'U_VIEW_NEWER_TOPIC' => $view_next_topic_url,
671 'U_POST_NEW_TOPIC' => $new_topic_url,
672 'U_POST_REPLY_TOPIC' => $reply_topic_url)
676 // Does this topic contain a poll?
678 if ( !empty($forum_topic_data['topic_vote']) )
680 $s_hidden_fields = '';
682 $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
683 FROM " . VOTE_DESC_TABLE . " vd, " . VOTE_RESULTS_TABLE . " vr
684 WHERE vd.topic_id = $topic_id
685 AND vr.vote_id = vd.vote_id
686 ORDER BY vr.vote_option_id ASC";
687 if ( !($result = $db->sql_query($sql)) )
689 message_die(GENERAL_ERROR, "Could not obtain vote data for this topic", '', __LINE__, __FILE__, $sql);
692 if ( $vote_info = $db->sql_fetchrowset($result) )
694 $db->sql_freeresult($result);
695 $vote_options = count($vote_info);
697 $vote_id = $vote_info[0]['vote_id'];
698 $vote_title = $vote_info[0]['vote_text'];
700 $sql = "SELECT vote_id
701 FROM " . VOTE_USERS_TABLE . "
702 WHERE vote_id = $vote_id
703 AND vote_user_id = " . intval($userdata['user_id']);
704 if ( !($result = $db->sql_query($sql)) )
706 message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
709 $user_voted = ( $row = $db->sql_fetchrow($result) ) ? TRUE : 0;
710 $db->sql_freeresult($result);
712 if ( isset($HTTP_GET_VARS['vote']) || isset($HTTP_POST_VARS['vote']) )
714 $view_result = ( ( ( isset($HTTP_GET_VARS['vote']) ) ? $HTTP_GET_VARS['vote'] : $HTTP_POST_VARS['vote'] ) == 'viewresult' ) ? TRUE : 0;
721 $poll_expired = ( $vote_info[0]['vote_length'] ) ? ( ( $vote_info[0]['vote_start'] + $vote_info[0]['vote_length'] < time() ) ? TRUE : 0 ) : 0;
723 if ( $user_voted || $view_result || $poll_expired || !$is_auth['auth_vote'] || $forum_topic_data['topic_status'] == TOPIC_LOCKED )
725 $template->set_filenames(array(
726 'pollbox' => 'viewtopic_poll_result.tpl')
729 $vote_results_sum = 0;
731 for($i = 0; $i < $vote_options; $i++)
733 $vote_results_sum += $vote_info[$i]['vote_result'];
737 $vote_graphic_max = count($images['voting_graphic']);
739 for($i = 0; $i < $vote_options; $i++)
741 $vote_percent = ( $vote_results_sum > 0 ) ? $vote_info[$i]['vote_result'] / $vote_results_sum : 0;
742 $vote_graphic_length = round($vote_percent * $board_config['vote_graphic_length']);
744 $vote_graphic_img = $images['voting_graphic'][$vote_graphic];
745 $vote_graphic = ($vote_graphic < $vote_graphic_max - 1) ? $vote_graphic + 1 : 0;
747 if ( count($orig_word) )
749 $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
752 $template->assign_block_vars("poll_option", array(
753 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'],
754 'POLL_OPTION_RESULT' => $vote_info[$i]['vote_result'],
755 'POLL_OPTION_PERCENT' => sprintf("%.1d%%", ($vote_percent * 100)),
757 'POLL_OPTION_IMG' => $vote_graphic_img,
758 'POLL_OPTION_IMG_WIDTH' => $vote_graphic_length)
762 $template->assign_vars(array(
763 'L_TOTAL_VOTES' => $lang['Total_votes'],
764 'TOTAL_VOTES' => $vote_results_sum)
770 $template->set_filenames(array(
771 'pollbox' => 'viewtopic_poll_ballot.tpl')
774 for($i = 0; $i < $vote_options; $i++)
776 if ( count($orig_word) )
778 $vote_info[$i]['vote_option_text'] = preg_replace($orig_word, $replacement_word, $vote_info[$i]['vote_option_text']);
781 $template->assign_block_vars("poll_option", array(
782 'POLL_OPTION_ID' => $vote_info[$i]['vote_option_id'],
783 'POLL_OPTION_CAPTION' => $vote_info[$i]['vote_option_text'])
787 $template->assign_vars(array(
788 'L_SUBMIT_VOTE' => $lang['Submit_vote'],
789 'L_VIEW_RESULTS' => $lang['View_results'],
791 'U_VIEW_RESULTS' => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&vote=viewresult"))
794 $s_hidden_fields = '<input type="hidden" name="topic_id" value="' . $topic_id . '" /><input type="hidden" name="mode" value="vote" />';
797 if ( count($orig_word) )
799 $vote_title = preg_replace($orig_word, $replacement_word, $vote_title);
802 $s_hidden_fields .= '<input type="hidden" name="sid" value="' . $userdata['session_id'] . '" />';
804 $template->assign_vars(array(
805 'POLL_QUESTION' => $vote_title,
807 'S_HIDDEN_FIELDS' => $s_hidden_fields,
808 'S_POLL_ACTION' => append_sid("posting.$phpEx?mode=vote&" . POST_TOPIC_URL . "=$topic_id"))
811 $template->assign_var_from_handle('POLL_DISPLAY', 'pollbox');
816 // Update the topic view counter
818 $sql = "UPDATE " . TOPICS_TABLE . "
819 SET topic_views = topic_views + 1
820 WHERE topic_id = $topic_id";
821 if ( !$db->sql_query($sql) )
823 message_die(GENERAL_ERROR, "Could not update topic views.", '', __LINE__, __FILE__, $sql);
827 // Okay, let's do the loop, yeah come on baby let's do the loop
828 // and it goes like this ...
830 for($i = 0; $i < $total_posts; $i++)
832 $poster_id = $postrow[$i]['user_id'];
833 $poster = ( $poster_id == ANONYMOUS ) ? $lang['Guest'] : $postrow[$i]['username'];
835 $post_date = create_date($board_config['default_dateformat'], $postrow[$i]['post_time'], $board_config['board_timezone']);
837 $poster_posts = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Posts'] . ': ' . $postrow[$i]['user_posts'] : '';
839 $poster_from = ( $postrow[$i]['user_from'] && $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Location'] . ': ' . $postrow[$i]['user_from'] : '';
841 $poster_joined = ( $postrow[$i]['user_id'] != ANONYMOUS ) ? $lang['Joined'] . ': ' . create_date($lang['DATE_FORMAT'], $postrow[$i]['user_regdate'], $board_config['board_timezone']) : '';
844 if ( $postrow[$i]['user_avatar_type'] && $poster_id != ANONYMOUS && $postrow[$i]['user_allowavatar'] )
846 switch( $postrow[$i]['user_avatar_type'] )
848 case USER_AVATAR_UPLOAD:
849 $poster_avatar = ( $board_config['allow_avatar_upload'] ) ? '<img src="' . $board_config['avatar_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
851 case USER_AVATAR_REMOTE:
852 $poster_avatar = ( $board_config['allow_avatar_remote'] ) ? '<img src="' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
854 case USER_AVATAR_GALLERY:
855 $poster_avatar = ( $board_config['allow_avatar_local'] ) ? '<img src="' . $board_config['avatar_gallery_path'] . '/' . $postrow[$i]['user_avatar'] . '" alt="" border="0" />' : '';
861 // Define the little post icon
863 if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
865 $mini_post_img = $images['icon_minipost_new'];
866 $mini_post_alt = $lang['New_post'];
870 $mini_post_img = $images['icon_minipost'];
871 $mini_post_alt = $lang['Post'];
874 $mini_post_url = append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $postrow[$i]['post_id']) . '#' . $postrow[$i]['post_id'];
877 // Generate ranks, set them to empty string initially.
881 if ( $postrow[$i]['user_id'] == ANONYMOUS )
884 else if ( $postrow[$i]['user_rank'] )
886 for($j = 0; $j < count($ranksrow); $j++)
888 if ( $postrow[$i]['user_rank'] == $ranksrow[$j]['rank_id'] && $ranksrow[$j]['rank_special'] )
890 $poster_rank = $ranksrow[$j]['rank_title'];
891 $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
897 for($j = 0; $j < count($ranksrow); $j++)
899 if ( $postrow[$i]['user_posts'] >= $ranksrow[$j]['rank_min'] && !$ranksrow[$j]['rank_special'] )
901 $poster_rank = $ranksrow[$j]['rank_title'];
902 $rank_image = ( $ranksrow[$j]['rank_image'] ) ? '<img src="' . $ranksrow[$j]['rank_image'] . '" alt="' . $poster_rank . '" title="' . $poster_rank . '" border="0" /><br />' : '';
908 // Handle anon users posting with usernames
910 if ( $poster_id == ANONYMOUS && $postrow[$i]['post_username'] != '' )
912 $poster = $postrow[$i]['post_username'];
913 $poster_rank = $lang['Guest'];
918 if ( $poster_id != ANONYMOUS )
920 $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
921 $profile_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_profile'] . '" alt="' . $lang['Read_profile'] . '" title="' . $lang['Read_profile'] . '" border="0" /></a>';
922 $profile = '<a href="' . $temp_url . '">' . $lang['Read_profile'] . '</a>';
924 $temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=$poster_id");
925 $pm_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_pm'] . '" alt="' . $lang['Send_private_message'] . '" title="' . $lang['Send_private_message'] . '" border="0" /></a>';
926 $pm = '<a href="' . $temp_url . '">' . $lang['Send_private_message'] . '</a>';
928 if ( !empty($postrow[$i]['user_viewemail']) || $is_auth['auth_mod'] )
930 $email_uri = ( $board_config['board_email_form'] ) ? append_sid("profile.$phpEx?mode=email&" . POST_USERS_URL .'=' . $poster_id) : 'mailto:' . $postrow[$i]['user_email'];
932 $email_img = '<a href="' . $email_uri . '"><img src="' . $images['icon_email'] . '" alt="' . $lang['Send_email'] . '" title="' . $lang['Send_email'] . '" border="0" /></a>';
933 $email = '<a href="' . $email_uri . '">' . $lang['Send_email'] . '</a>';
941 $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>' : '';
942 $www = ( $postrow[$i]['user_website'] ) ? '<a href="' . $postrow[$i]['user_website'] . '" target="_userwww">' . $lang['Visit_website'] . '</a>' : '';
944 if ( !empty($postrow[$i]['user_icq']) )
946 $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>';
947 $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>';
948 $icq = '<a href="http://wwp.icq.com/scripts/search.dll?to=' . $postrow[$i]['user_icq'] . '">' . $lang['ICQ'] . '</a>';
952 $icq_status_img = '';
957 $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>' : '';
958 $aim = ( $postrow[$i]['user_aim'] ) ? '<a href="aim:goim?screenname=' . $postrow[$i]['user_aim'] . '&message=Hello+Are+you+there?">' . $lang['AIM'] . '</a>' : '';
960 $temp_url = append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=$poster_id");
961 $msn_img = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '"><img src="' . $images['icon_msnm'] . '" alt="' . $lang['MSNM'] . '" title="' . $lang['MSNM'] . '" border="0" /></a>' : '';
962 $msn = ( $postrow[$i]['user_msnm'] ) ? '<a href="' . $temp_url . '">' . $lang['MSNM'] . '</a>' : '';
964 $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>' : '';
965 $yim = ( $postrow[$i]['user_yim'] ) ? '<a href="http://edit.yahoo.com/config/send_webmesg?.target=' . $postrow[$i]['user_yim'] . '&.src=pg">' . $lang['YIM'] . '</a>' : '';
977 $icq_status_img = '';
988 $temp_url = append_sid("posting.$phpEx?mode=quote&" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
989 $quote_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_quote'] . '" alt="' . $lang['Reply_with_quote'] . '" title="' . $lang['Reply_with_quote'] . '" border="0" /></a>';
990 $quote = '<a href="' . $temp_url . '">' . $lang['Reply_with_quote'] . '</a>';
992 $temp_url = append_sid("search.$phpEx?search_author=" . urlencode($postrow[$i]['username']) . "&showresults=posts");
993 $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>';
994 $search = '<a href="' . $temp_url . '">' . sprintf($lang['Search_user_posts'], $postrow[$i]['username']) . '</a>';
996 if ( ( $userdata['user_id'] == $poster_id && $is_auth['auth_edit'] ) || $is_auth['auth_mod'] )
998 $temp_url = append_sid("posting.$phpEx?mode=editpost&" . POST_POST_URL . "=" . $postrow[$i]['post_id']);
999 $edit_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_edit'] . '" alt="' . $lang['Edit_delete_post'] . '" title="' . $lang['Edit_delete_post'] . '" border="0" /></a>';
1000 $edit = '<a href="' . $temp_url . '">' . $lang['Edit_delete_post'] . '</a>';
1008 if ( $is_auth['auth_mod'] )
1010 $temp_url = "modcp.$phpEx?mode=ip&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&" . POST_TOPIC_URL . "=" . $topic_id . "&sid=" . $userdata['session_id'];
1011 $ip_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_ip'] . '" alt="' . $lang['View_IP'] . '" title="' . $lang['View_IP'] . '" border="0" /></a>';
1012 $ip = '<a href="' . $temp_url . '">' . $lang['View_IP'] . '</a>';
1014 $temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
1015 $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
1016 $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
1023 if ( $userdata['user_id'] == $poster_id && $is_auth['auth_delete'] && $forum_topic_data['topic_last_post_id'] == $postrow[$i]['post_id'] )
1025 $temp_url = "posting.$phpEx?mode=delete&" . POST_POST_URL . "=" . $postrow[$i]['post_id'] . "&sid=" . $userdata['session_id'];
1026 $delpost_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_delpost'] . '" alt="' . $lang['Delete_post'] . '" title="' . $lang['Delete_post'] . '" border="0" /></a>';
1027 $delpost = '<a href="' . $temp_url . '">' . $lang['Delete_post'] . '</a>';
1036 $post_subject = ( $postrow[$i]['post_subject'] != '' ) ? $postrow[$i]['post_subject'] : '';
1038 $message = $postrow[$i]['post_text'];
1039 $bbcode_uid = $postrow[$i]['bbcode_uid'];
1041 $user_sig = ( $postrow[$i]['enable_sig'] && $postrow[$i]['user_sig'] != '' && $board_config['allow_sig'] ) ? $postrow[$i]['user_sig'] : '';
1042 $user_sig_bbcode_uid = $postrow[$i]['user_sig_bbcode_uid'];
1045 // Note! The order used for parsing the message _is_ important, moving things around could break any
1050 // If the board has HTML off but the post has HTML
1051 // on then we process it, else leave it alone
1053 if ( !$board_config['allow_html'] || !$userdata['user_allowhtml'])
1055 if ( $user_sig != '' )
1057 $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig);
1060 if ( $postrow[$i]['enable_html'] )
1062 $message = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $message);
1067 // Parse message and/or sig for BBCode if reqd
1069 if ($user_sig != '' && $user_sig_bbcode_uid != '')
1071 $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig);
1074 if ($bbcode_uid != '')
1076 $message = ($board_config['allow_bbcode']) ? bbencode_second_pass($message, $bbcode_uid) : preg_replace("/\:$bbcode_uid/si", '', $message);
1079 if ( $user_sig != '' )
1081 $user_sig = make_clickable($user_sig);
1083 $message = make_clickable($message);
1088 if ( $board_config['allow_smilies'] )
1090 if ( $postrow[$i]['user_allowsmile'] && $user_sig != '' )
1092 $user_sig = smilies_pass($user_sig);
1095 if ( $postrow[$i]['enable_smilies'] )
1097 $message = smilies_pass($message);
1102 // Highlight active words (primarily for search)
1104 if ($highlight_match)
1106 // This was shamelessly 'borrowed' from volker at multiartstudio dot de
1107 // via php.net's annotated manual
1108 $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace('#\b(" . str_replace('\\', '\\\\', addslashes($highlight_match)) . ")\b#i', '<span style=\"color:#" . $theme['fontcolor3'] . "\"><b>\\\\1</b></span>', '\\0')", '>' . $message . '<'), 1, -1));
1112 // Replace naughty words
1114 if (count($orig_word))
1116 $post_subject = preg_replace($orig_word, $replacement_word, $post_subject);
1118 if ($user_sig != '')
1120 $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1));
1123 $message = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $message . '<'), 1, -1));
1127 // Replace newlines (we use this rather than nl2br because
1128 // till recently it wasn't XHTML compliant)
1130 if ( $user_sig != '' )
1132 $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig);
1135 $message = str_replace("\n", "\n<br />\n", $message);
1138 // Editing information
1140 if ( $postrow[$i]['post_edit_count'] )
1142 $l_edit_time_total = ( $postrow[$i]['post_edit_count'] == 1 ) ? $lang['Edited_time_total'] : $lang['Edited_times_total'];
1144 $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']);
1152 // Again this will be handled by the templating
1153 // code at some point
1155 $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
1156 $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
1158 $template->assign_block_vars('postrow', array(
1159 'ROW_COLOR' => '#' . $row_color,
1160 'ROW_CLASS' => $row_class,
1161 'POSTER_NAME' => $poster,
1162 'POSTER_RANK' => $poster_rank,
1163 'RANK_IMAGE' => $rank_image,
1164 'POSTER_JOINED' => $poster_joined,
1165 'POSTER_POSTS' => $poster_posts,
1166 'POSTER_FROM' => $poster_from,
1167 'POSTER_AVATAR' => $poster_avatar,
1168 'POST_DATE' => $post_date,
1169 'POST_SUBJECT' => $post_subject,
1170 'MESSAGE' => $message,
1171 'SIGNATURE' => $user_sig,
1172 'EDITED_MESSAGE' => $l_edited_by,
1174 'MINI_POST_IMG' => $mini_post_img,
1175 'PROFILE_IMG' => $profile_img,
1176 'PROFILE' => $profile,
1177 'SEARCH_IMG' => $search_img,
1178 'SEARCH' => $search,
1179 'PM_IMG' => $pm_img,
1181 'EMAIL_IMG' => $email_img,
1183 'WWW_IMG' => $www_img,
1185 'ICQ_STATUS_IMG' => $icq_status_img,
1186 'ICQ_IMG' => $icq_img,
1188 'AIM_IMG' => $aim_img,
1190 'MSN_IMG' => $msn_img,
1192 'YIM_IMG' => $yim_img,
1194 'EDIT_IMG' => $edit_img,
1196 'QUOTE_IMG' => $quote_img,
1198 'IP_IMG' => $ip_img,
1200 'DELETE_IMG' => $delpost_img,
1201 'DELETE' => $delpost,
1203 'L_MINI_POST_ALT' => $mini_post_alt,
1205 'U_MINI_POST' => $mini_post_url,
1206 'U_POST_ID' => $postrow[$i]['post_id'])
1210 $template->pparse('body');
1212 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);