marge
[phpbb.git] / phpBB / viewtopic.php
blobb7139bd7246ba3488c0552bc8c7218c0ebd2299d
1 <?php
2 /**
4 * @package phpBB3
5 * @version $Id$
6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
9 */
11 /**
12 * @ignore
14 define('IN_PHPBB', true);
15 if (!defined('PHPBB_ROOT_PATH')) define('PHPBB_ROOT_PATH', './');
16 if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1));
17 include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT);
18 include(PHPBB_ROOT_PATH . 'includes/functions_display.' . PHP_EXT);
19 include(PHPBB_ROOT_PATH . 'includes/bbcode.' . PHP_EXT);
21 // Start session management
22 $user->session_begin();
23 $auth->acl($user->data);
25 // Initial var setup
26 $forum_id = request_var('f', 0);
27 $topic_id = request_var('t', 0);
28 $post_id = request_var('p', 0);
29 $voted_id = request_var('vote_id', array('' => 0));
31 $start = request_var('start', 0);
32 $view = request_var('view', '');
34 $sort_days = request_var('st', ((!empty($user->data['user_post_show_days'])) ? $user->data['user_post_show_days'] : 0));
35 $sort_key = request_var('sk', ((!empty($user->data['user_post_sortby_type'])) ? $user->data['user_post_sortby_type'] : 't'));
36 $sort_dir = request_var('sd', ((!empty($user->data['user_post_sortby_dir'])) ? $user->data['user_post_sortby_dir'] : 'a'));
38 $update = request_var('update', false);
40 /**
41 * @todo normalize?
43 $hilit_words = request_var('hilit', '', true);
45 // Do we have a topic or post id?
46 if (!$topic_id && !$post_id)
48 trigger_error('NO_TOPIC');
51 // Find topic id if user requested a newer or older topic
52 if ($view && !$post_id)
54 if (!$forum_id)
56 $sql = 'SELECT forum_id
57 FROM ' . TOPICS_TABLE . "
58 WHERE topic_id = $topic_id";
59 $result = $db->sql_query($sql);
60 $forum_id = (int) $db->sql_fetchfield('forum_id');
61 $db->sql_freeresult($result);
63 if (!$forum_id)
65 trigger_error('NO_TOPIC');
69 if ($view == 'unread')
71 // Get topic tracking info
72 $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
74 $topic_last_read = (isset($topic_tracking_info[$topic_id])) ? $topic_tracking_info[$topic_id] : 0;
76 $sql = 'SELECT post_id, topic_id, forum_id
77 FROM ' . POSTS_TABLE . "
78 WHERE topic_id = $topic_id
79 " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1') . "
80 AND post_time > $topic_last_read
81 ORDER BY post_time ASC";
82 $result = $db->sql_query_limit($sql, 1);
83 $row = $db->sql_fetchrow($result);
84 $db->sql_freeresult($result);
86 if (!$row)
88 $sql = 'SELECT topic_last_post_id as post_id, topic_id, forum_id
89 FROM ' . TOPICS_TABLE . '
90 WHERE topic_id = ' . $topic_id;
91 $result = $db->sql_query($sql);
92 $row = $db->sql_fetchrow($result);
93 $db->sql_freeresult($result);
96 if (!$row)
98 // Setup user environment so we can process lang string
99 $user->setup('viewtopic');
101 trigger_error('NO_TOPIC');
104 $post_id = $row['post_id'];
105 $topic_id = $row['topic_id'];
107 else if ($view == 'next' || $view == 'previous')
109 $sql_condition = ($view == 'next') ? '>' : '<';
110 $sql_ordering = ($view == 'next') ? 'ASC' : 'DESC';
112 $sql = 'SELECT forum_id, topic_last_post_time
113 FROM ' . TOPICS_TABLE . '
114 WHERE topic_id = ' . $topic_id;
115 $result = $db->sql_query($sql);
116 $row = $db->sql_fetchrow($result);
117 $db->sql_freeresult($result);
119 if (!$row)
121 $user->setup('viewtopic');
122 // OK, the topic doesn't exist. This error message is not helpful, but technically correct.
123 trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
125 else
127 $sql = 'SELECT topic_id, forum_id
128 FROM ' . TOPICS_TABLE . '
129 WHERE forum_id = ' . $row['forum_id'] . "
130 AND topic_moved_id = 0
131 AND topic_last_post_time $sql_condition {$row['topic_last_post_time']}
132 " . (($auth->acl_get('m_approve', $row['forum_id'])) ? '' : 'AND topic_approved = 1') . "
133 ORDER BY topic_last_post_time $sql_ordering";
134 $result = $db->sql_query_limit($sql, 1);
135 $row = $db->sql_fetchrow($result);
136 $db->sql_freeresult($result);
138 if (!$row)
140 $user->setup('viewtopic');
141 trigger_error(($view == 'next') ? 'NO_NEWER_TOPICS' : 'NO_OLDER_TOPICS');
143 else
145 $topic_id = $row['topic_id'];
147 // Check for global announcement correctness?
148 if (!$row['forum_id'] && !$forum_id)
150 trigger_error('NO_TOPIC');
152 else if ($row['forum_id'])
154 $forum_id = $row['forum_id'];
160 // Check for global announcement correctness?
161 if ((!isset($row) || !$row['forum_id']) && !$forum_id)
163 trigger_error('NO_TOPIC');
165 else if (isset($row) && $row['forum_id'])
167 $forum_id = $row['forum_id'];
171 // This rather complex gaggle of code handles querying for topics but
172 // also allows for direct linking to a post (and the calculation of which
173 // page the post is on and the correct display of viewtopic)
174 $sql_array = array(
175 'SELECT' => 't.*, f.*',
177 'FROM' => array(
178 FORUMS_TABLE => 'f',
179 TOPICS_TABLE => 't',
183 if ($user->data['is_registered'])
185 $sql_array['SELECT'] .= ', tw.notify_status';
186 $sql_array['LEFT_JOIN'] = array();
188 $sql_array['LEFT_JOIN'][] = array(
189 'FROM' => array(TOPICS_WATCH_TABLE => 'tw'),
190 'ON' => 'tw.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tw.topic_id'
193 if ($config['allow_bookmarks'])
195 $sql_array['SELECT'] .= ', bm.topic_id as bookmarked';
196 $sql_array['LEFT_JOIN'][] = array(
197 'FROM' => array(BOOKMARKS_TABLE => 'bm'),
198 'ON' => 'bm.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = bm.topic_id'
202 if ($config['load_db_lastread'])
204 $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
206 $sql_array['LEFT_JOIN'][] = array(
207 'FROM' => array(TOPICS_TRACK_TABLE => 'tt'),
208 'ON' => 'tt.user_id = ' . $user->data['user_id'] . ' AND t.topic_id = tt.topic_id'
211 $sql_array['LEFT_JOIN'][] = array(
212 'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
213 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND t.forum_id = ft.forum_id'
218 if (!$post_id)
220 $sql_array['WHERE'] = "t.topic_id = $topic_id";
222 else
224 $sql_array['WHERE'] = "p.post_id = $post_id AND t.topic_id = p.topic_id" . ((!$auth->acl_get('m_approve', $forum_id)) ? ' AND p.post_approved = 1' : '');
225 $sql_array['FROM'][POSTS_TABLE] = 'p';
228 $sql_array['WHERE'] .= ' AND (f.forum_id = t.forum_id';
230 if (!$forum_id)
232 // If it is a global announcement make sure to set the forum id to a postable forum
233 $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . '
234 AND f.forum_type = ' . FORUM_POST . ')';
236 else
238 $sql_array['WHERE'] .= ' OR (t.topic_type = ' . POST_GLOBAL . "
239 AND f.forum_id = $forum_id)";
242 $sql_array['WHERE'] .= ')';
244 // Join to forum table on topic forum_id unless topic forum_id is zero
245 // whereupon we join on the forum_id passed as a parameter ... this
246 // is done so navigation, forum name, etc. remain consistent with where
247 // user clicked to view a global topic
248 $sql = $db->sql_build_query('SELECT', $sql_array);
249 $result = $db->sql_query($sql);
250 $topic_data = $db->sql_fetchrow($result);
251 $db->sql_freeresult($result);
253 if (!$topic_data)
255 // If post_id was submitted, we try at least to display the topic as a last resort...
256 if ($post_id && $forum_id && $topic_id)
258 redirect(append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id"));
261 trigger_error('NO_TOPIC');
264 // This is for determining where we are (page)
265 if ($post_id)
267 if ($post_id == $topic_data['topic_first_post_id'] || $post_id == $topic_data['topic_last_post_id'])
269 $check_sort = ($post_id == $topic_data['topic_first_post_id']) ? 'd' : 'a';
271 if ($sort_dir == $check_sort)
273 $topic_data['prev_posts'] = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
275 else
277 $topic_data['prev_posts'] = 0;
280 else
282 $sql = 'SELECT COUNT(p1.post_id) AS prev_posts
283 FROM ' . POSTS_TABLE . ' p1, ' . POSTS_TABLE . " p2
284 WHERE p1.topic_id = {$topic_data['topic_id']}
285 AND p2.post_id = {$post_id}
286 " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p1.post_approved = 1' : '') . '
287 AND ' . (($sort_dir == 'd') ? 'p1.post_time >= p2.post_time' : 'p1.post_time <= p2.post_time');
289 $result = $db->sql_query($sql);
290 $row = $db->sql_fetchrow($result);
291 $db->sql_freeresult($result);
293 $topic_data['prev_posts'] = $row['prev_posts'] - 1;
297 $forum_id = (int) $topic_data['forum_id'];
298 $topic_id = (int) $topic_data['topic_id'];
301 $topic_replies = ($auth->acl_get('m_approve', $forum_id)) ? $topic_data['topic_replies_real'] : $topic_data['topic_replies'];
303 // Check sticky/announcement time limit
304 if (($topic_data['topic_type'] == POST_STICKY || $topic_data['topic_type'] == POST_ANNOUNCE) && $topic_data['topic_time_limit'] && ($topic_data['topic_time'] + $topic_data['topic_time_limit']) < time())
306 $sql = 'UPDATE ' . TOPICS_TABLE . '
307 SET topic_type = ' . POST_NORMAL . ', topic_time_limit = 0
308 WHERE topic_id = ' . $topic_id;
309 $db->sql_query($sql);
311 $topic_data['topic_type'] = POST_NORMAL;
312 $topic_data['topic_time_limit'] = 0;
315 // Setup look and feel
316 $user->setup('viewtopic', $topic_data['forum_style']);
318 if (!$topic_data['topic_approved'] && !$auth->acl_get('m_approve', $forum_id))
320 trigger_error('NO_TOPIC');
323 // Start auth check
324 if (!$auth->acl_get('f_read', $forum_id))
326 if ($user->data['user_id'] != ANONYMOUS)
328 trigger_error('SORRY_AUTH_READ');
331 login_box('', $user->lang['LOGIN_VIEWFORUM']);
334 // Forum is passworded ... check whether access has been granted to this
335 // user this session, if not show login box
336 if ($topic_data['forum_password'])
338 login_forum_box($topic_data);
341 // Redirect to login or to the correct post upon emailed notification links
342 if (isset($_GET['e']))
344 $jump_to = request_var('e', 0);
346 $redirect_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id");
348 if ($user->data['user_id'] == ANONYMOUS)
350 login_box($redirect_url . "&amp;p=$post_id&amp;e=$jump_to", $user->lang['LOGIN_NOTIFY_TOPIC']);
353 if ($jump_to > 0)
355 // We direct the already logged in user to the correct post...
356 redirect($redirect_url . ((!$post_id) ? "&amp;p=$jump_to" : "&amp;p=$post_id") . "#p$jump_to");
360 // What is start equal to?
361 if ($post_id)
363 $start = floor(($topic_data['prev_posts']) / $config['posts_per_page']) * $config['posts_per_page'];
366 // Get topic tracking info
367 if (!isset($topic_tracking_info))
369 $topic_tracking_info = array();
371 // Get topic tracking info
372 if ($config['load_db_lastread'] && $user->data['is_registered'])
374 $tmp_topic_data = array($topic_id => $topic_data);
375 $topic_tracking_info = get_topic_tracking($forum_id, $topic_id, $tmp_topic_data, array($forum_id => $topic_data['forum_mark_time']));
376 unset($tmp_topic_data);
378 else if ($config['load_anon_lastread'] || $user->data['is_registered'])
380 $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id);
384 // Post ordering options
385 $limit_days = array(0 => $user->lang['ALL_POSTS'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
387 $sort_by_text = array('a' => $user->lang['AUTHOR'], 't' => $user->lang['POST_TIME'], 's' => $user->lang['SUBJECT']);
388 $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
390 $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
391 gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
393 // Obtain correct post count and ordering SQL if user has
394 // requested anything different
395 if ($sort_days)
397 $min_post_time = time() - ($sort_days * 86400);
399 $sql = 'SELECT COUNT(post_id) AS num_posts
400 FROM ' . POSTS_TABLE . "
401 WHERE topic_id = $topic_id
402 AND post_time >= $min_post_time
403 " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND post_approved = 1');
404 $result = $db->sql_query($sql);
405 $total_posts = (int) $db->sql_fetchfield('num_posts');
406 $db->sql_freeresult($result);
408 $limit_posts_time = "AND p.post_time >= $min_post_time ";
410 if (isset($_POST['sort']))
412 $start = 0;
415 else
417 $total_posts = $topic_replies + 1;
418 $limit_posts_time = '';
421 // Was a highlight request part of the URI?
422 $highlight_match = $highlight = '';
423 if ($hilit_words)
425 foreach (explode(' ', trim($hilit_words)) as $word)
427 if (trim($word))
429 $word = str_replace('\*', '\w+?', preg_quote($word, '#'));
430 $word = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $word);
431 $highlight_match .= (($highlight_match != '') ? '|' : '') . $word;
435 $highlight = urlencode($hilit_words);
438 // Make sure $start is set to the last page if it exceeds the amount
439 if ($start < 0 || $start > $total_posts)
441 $start = ($start < 0) ? 0 : floor(($total_posts - 1) / $config['posts_per_page']) * $config['posts_per_page'];
444 // General Viewtopic URL for return links
445 $viewtopic_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start&amp;$u_sort_param" . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
447 // Are we watching this topic?
448 $s_watching_topic = array(
449 'link' => '',
450 'title' => '',
451 'is_watching' => false,
454 if (($config['email_enable'] || $config['jab_enable']) && $config['allow_topic_notify'] && $user->data['is_registered'])
456 watch_topic_forum('topic', $s_watching_topic, $user->data['user_id'], $forum_id, $topic_id, $topic_data['notify_status'], $start);
458 // Reset forum notification if forum notify is set
459 if ($config['allow_forum_notify'] && $auth->acl_get('f_subscribe', $forum_id))
461 $s_watching_forum = $s_watching_topic;
462 watch_topic_forum('forum', $s_watching_forum, $user->data['user_id'], $forum_id, 0);
466 // Bookmarks
467 if ($config['allow_bookmarks'] && $user->data['is_registered'] && request_var('bookmark', 0))
469 if (!$topic_data['bookmarked'])
471 $sql = 'INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
472 'user_id' => $user->data['user_id'],
473 'topic_id' => $topic_id,
475 $db->sql_query($sql);
477 else
479 $sql = 'DELETE FROM ' . BOOKMARKS_TABLE . "
480 WHERE user_id = {$user->data['user_id']}
481 AND topic_id = $topic_id";
482 $db->sql_query($sql);
485 meta_refresh(3, $viewtopic_url);
487 $message = (($topic_data['bookmarked']) ? $user->lang['BOOKMARK_REMOVED'] : $user->lang['BOOKMARK_ADDED']) . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $viewtopic_url . '">', '</a>');
488 trigger_error($message);
491 // Grab ranks
492 $ranks = cache::obtain_ranks();
494 // Grab icons
495 $icons = cache::obtain_icons();
497 // Grab extensions
498 $extensions = array();
499 if ($topic_data['topic_attachment'])
501 $extensions = cache::obtain_attach_extensions($forum_id);
504 // Forum rules listing
505 $s_forum_rules = '';
506 gen_forum_auth_level('topic', $forum_id, $topic_data['forum_status']);
508 // Quick mod tools
509 $allow_change_type = ($auth->acl_get('m_', $forum_id) || ($user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'])) ? true : false;
511 $topic_mod = '';
512 $topic_mod .= ($auth->acl_get('m_lock', $forum_id) || ($auth->acl_get('f_user_lock', $forum_id) && $user->data['is_registered'] && $user->data['user_id'] == $topic_data['topic_poster'] && $topic_data['topic_status'] == ITEM_UNLOCKED)) ? (($topic_data['topic_status'] == ITEM_UNLOCKED) ? '<option value="lock">' . $user->lang['LOCK_TOPIC'] . '</option>' : '<option value="unlock">' . $user->lang['UNLOCK_TOPIC'] . '</option>') : '';
513 $topic_mod .= ($auth->acl_get('m_delete', $forum_id)) ? '<option value="delete_topic">' . $user->lang['DELETE_TOPIC'] . '</option>' : '';
514 $topic_mod .= ($auth->acl_get('m_move', $forum_id) && $topic_data['topic_status'] != ITEM_MOVED) ? '<option value="move">' . $user->lang['MOVE_TOPIC'] . '</option>' : '';
515 $topic_mod .= ($auth->acl_get('m_split', $forum_id)) ? '<option value="split">' . $user->lang['SPLIT_TOPIC'] . '</option>' : '';
516 $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge">' . $user->lang['MERGE_POSTS'] . '</option>' : '';
517 $topic_mod .= ($auth->acl_get('m_merge', $forum_id)) ? '<option value="merge_topic">' . $user->lang['MERGE_TOPIC'] . '</option>' : '';
518 $topic_mod .= ($auth->acl_get('m_move', $forum_id)) ? '<option value="fork">' . $user->lang['FORK_TOPIC'] . '</option>' : '';
519 $topic_mod .= ($allow_change_type && $auth->acl_gets('f_sticky', 'f_announce', $forum_id) && $topic_data['topic_type'] != POST_NORMAL) ? '<option value="make_normal">' . $user->lang['MAKE_NORMAL'] . '</option>' : '';
520 $topic_mod .= ($allow_change_type && $auth->acl_get('f_sticky', $forum_id) && $topic_data['topic_type'] != POST_STICKY) ? '<option value="make_sticky">' . $user->lang['MAKE_STICKY'] . '</option>' : '';
521 $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_ANNOUNCE) ? '<option value="make_announce">' . $user->lang['MAKE_ANNOUNCE'] . '</option>' : '';
522 $topic_mod .= ($allow_change_type && $auth->acl_get('f_announce', $forum_id) && $topic_data['topic_type'] != POST_GLOBAL) ? '<option value="make_global">' . $user->lang['MAKE_GLOBAL'] . '</option>' : '';
523 $topic_mod .= ($auth->acl_get('m_', $forum_id)) ? '<option value="topic_logs">' . $user->lang['VIEW_TOPIC_LOGS'] . '</option>' : '';
525 // If we've got a hightlight set pass it on to pagination.
526 $pagination = generate_pagination(append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;$u_sort_param" . (($highlight_match) ? "&amp;hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
528 // Navigation links
529 generate_forum_nav($topic_data);
531 // Forum Rules
532 generate_forum_rules($topic_data);
534 // Moderators
535 $forum_moderators = array();
536 get_moderators($forum_moderators, $forum_id);
538 // This is only used for print view so ...
539 $server_path = (!$view) ? PHPBB_ROOT_PATH : generate_board_url() . '/';
541 // Replace naughty words in title
542 $topic_data['topic_title'] = censor_text($topic_data['topic_title']);
544 // Send vars to template
545 $template->assign_vars(array(
546 'FORUM_ID' => $forum_id,
547 'FORUM_NAME' => $topic_data['forum_name'],
548 'FORUM_DESC' => generate_text_for_display($topic_data['forum_desc'], $topic_data['forum_desc_uid'], $topic_data['forum_desc_bitfield'], $topic_data['forum_desc_options']),
549 'TOPIC_ID' => $topic_id,
550 'TOPIC_TITLE' => $topic_data['topic_title'],
551 'TOPIC_POSTER' => $topic_data['topic_poster'],
553 'TOPIC_AUTHOR_FULL' => get_username_string('full', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
554 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
555 'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
557 'PAGINATION' => $pagination,
558 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start),
559 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts),
560 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid('mcp', "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id&amp;start=$start&amp;$u_sort_param", true, $user->session_id) : '',
561 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
563 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
564 'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
565 'REPLY_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED || $topic_data['topic_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'TOPIC_LOCKED') : $user->img('button_topic_reply', 'REPLY_TO_TOPIC'),
566 'EDIT_IMG' => $user->img('icon_post_edit', 'EDIT_POST'),
567 'DELETE_IMG' => $user->img('icon_post_delete', 'DELETE_POST'),
568 'INFO_IMG' => $user->img('icon_post_info', 'VIEW_INFO'),
569 'PROFILE_IMG' => $user->img('icon_user_profile', 'READ_PROFILE'),
570 'SEARCH_IMG' => $user->img('icon_user_search', 'SEARCH_USER_POSTS'),
571 'PM_IMG' => $user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
572 'EMAIL_IMG' => $user->img('icon_contact_email', 'SEND_EMAIL'),
573 'WWW_IMG' => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
574 'ICQ_IMG' => $user->img('icon_contact_icq', 'ICQ'),
575 'AIM_IMG' => $user->img('icon_contact_aim', 'AIM'),
576 'MSN_IMG' => $user->img('icon_contact_msnm', 'MSNM'),
577 'YIM_IMG' => $user->img('icon_contact_yahoo', 'YIM'),
578 'JABBER_IMG' => $user->img('icon_contact_jabber', 'JABBER') ,
579 'REPORT_IMG' => $user->img('icon_post_report', 'REPORT_POST'),
580 'REPORTED_IMG' => $user->img('icon_topic_reported', 'POST_REPORTED'),
581 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'POST_UNAPPROVED'),
582 'WARN_IMG' => $user->img('icon_user_warn', 'WARN_USER'),
584 'S_IS_LOCKED' =>($topic_data['topic_status'] == ITEM_UNLOCKED) ? false : true,
585 'S_SELECT_SORT_DIR' => $s_sort_dir,
586 'S_SELECT_SORT_KEY' => $s_sort_key,
587 'S_SELECT_SORT_DAYS' => $s_limit_days,
588 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true,
589 'S_TOPIC_ACTION' => append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start"),
590 'S_TOPIC_MOD' => ($topic_mod != '') ? '<select name="action" id="quick-mod-select">' . $topic_mod . '</select>' : '',
591 'S_MOD_ACTION' => append_sid('mcp', "f=$forum_id&amp;t=$topic_id&amp;quickmod=1&amp;redirect=" . urlencode(str_replace('&amp;', '&', $viewtopic_url)), true, $user->session_id),
593 'S_VIEWTOPIC' => true,
594 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false,
595 'S_SEARCHBOX_ACTION' => append_sid('search', 't=' . $topic_id),
597 'S_DISPLAY_POST_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
598 'S_DISPLAY_REPLY_INFO' => ($topic_data['forum_type'] == FORUM_POST && ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS)) ? true : false,
600 'U_TOPIC' => "{$server_path}viewtopic." . PHP_EXT . "?f=$forum_id&amp;t=$topic_id",
601 'U_FORUM' => $server_path,
602 'U_VIEW_TOPIC' => $viewtopic_url,
603 'U_VIEW_FORUM' => append_sid('viewforum', 'f=' . $forum_id),
604 'U_VIEW_OLDER_TOPIC' => append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;view=previous"),
605 'U_VIEW_NEWER_TOPIC' => append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;view=next"),
606 'U_PRINT_TOPIC' => ($auth->acl_get('f_print', $forum_id)) ? $viewtopic_url . '&amp;view=print' : '',
607 'U_EMAIL_TOPIC' => ($auth->acl_get('f_email', $forum_id) && $config['email_enable']) ? append_sid('memberlist', "mode=email&amp;t=$topic_id") : '',
609 'U_WATCH_TOPIC' => $s_watching_topic['link'],
610 'L_WATCH_TOPIC' => $s_watching_topic['title'],
611 'S_WATCHING_TOPIC' => $s_watching_topic['is_watching'],
613 'U_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks']) ? $viewtopic_url . '&amp;bookmark=1' : '',
614 'L_BOOKMARK_TOPIC' => ($user->data['is_registered'] && $config['allow_bookmarks'] && $topic_data['bookmarked']) ? $user->lang['BOOKMARK_TOPIC_REMOVE'] : $user->lang['BOOKMARK_TOPIC'],
616 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid('posting', "mode=post&amp;f=$forum_id") : '',
617 'U_POST_REPLY_TOPIC' => ($auth->acl_get('f_reply', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid('posting', "mode=reply&amp;f=$forum_id&amp;t=$topic_id") : '',
618 'U_BUMP_TOPIC' => (bump_topic_allowed($forum_id, $topic_data['topic_bumped'], $topic_data['topic_last_post_time'], $topic_data['topic_poster'], $topic_data['topic_last_poster_id'])) ? append_sid('posting', "mode=bump&amp;f=$forum_id&amp;t=$topic_id") : '')
621 // Does this topic contain a poll?
622 if (!empty($topic_data['poll_start']))
624 $sql = 'SELECT o.*, p.bbcode_bitfield, p.bbcode_uid
625 FROM ' . POLL_OPTIONS_TABLE . ' o, ' . POSTS_TABLE . " p
626 WHERE o.topic_id = $topic_id
627 AND p.post_id = {$topic_data['topic_first_post_id']}
628 AND p.topic_id = o.topic_id
629 ORDER BY o.poll_option_id";
630 $result = $db->sql_query($sql);
632 $poll_info = array();
633 while ($row = $db->sql_fetchrow($result))
635 $poll_info[] = $row;
637 $db->sql_freeresult($result);
639 $cur_voted_id = array();
640 if ($user->data['is_registered'])
642 $sql = 'SELECT poll_option_id
643 FROM ' . POLL_VOTES_TABLE . '
644 WHERE topic_id = ' . $topic_id . '
645 AND vote_user_id = ' . $user->data['user_id'];
646 $result = $db->sql_query($sql);
648 while ($row = $db->sql_fetchrow($result))
650 $cur_voted_id[] = $row['poll_option_id'];
652 $db->sql_freeresult($result);
654 else
656 // Cookie based guest tracking ... I don't like this but hum ho
657 // it's oft requested. This relies on "nice" users who don't feel
658 // the need to delete cookies to mess with results.
659 if (isset($_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]))
661 $cur_voted_id = explode(',', $_COOKIE[$config['cookie_name'] . '_poll_' . $topic_id]);
662 $cur_voted_id = array_map('intval', $cur_voted_id);
666 $s_can_vote = (((!sizeof($cur_voted_id) && $auth->acl_get('f_vote', $forum_id)) ||
667 ($auth->acl_get('f_votechg', $forum_id) && $topic_data['poll_vote_change'])) &&
668 (($topic_data['poll_length'] != 0 && $topic_data['poll_start'] + $topic_data['poll_length'] > time()) || $topic_data['poll_length'] == 0) &&
669 $topic_data['topic_status'] != ITEM_LOCKED &&
670 $topic_data['forum_status'] != ITEM_LOCKED) ? true : false;
671 $s_display_results = (!$s_can_vote || ($s_can_vote && sizeof($cur_voted_id)) || $view == 'viewpoll') ? true : false;
673 if ($update && $s_can_vote)
676 if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
678 $redirect_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start");
680 meta_refresh(5, $redirect_url);
681 if (!sizeof($voted_id))
683 $message = 'NO_VOTE_OPTION';
685 else if (sizeof($voted_id) > $topic_data['poll_max_options'])
687 $message = 'TOO_MANY_VOTE_OPTIONS';
689 else
691 $message = 'VOTE_CONVERTED';
694 $message = $user->lang[$message] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>');
695 trigger_error($message);
698 foreach ($voted_id as $option)
700 if (in_array($option, $cur_voted_id))
702 continue;
705 $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
706 SET poll_option_total = poll_option_total + 1
707 WHERE poll_option_id = ' . (int) $option . '
708 AND topic_id = ' . (int) $topic_id;
709 $db->sql_query($sql);
711 if ($user->data['is_registered'])
713 $sql_ary = array(
714 'topic_id' => (int) $topic_id,
715 'poll_option_id' => (int) $option,
716 'vote_user_id' => (int) $user->data['user_id'],
717 'vote_user_ip' => (string) $user->ip,
720 $sql = 'INSERT INTO ' . POLL_VOTES_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
721 $db->sql_query($sql);
725 foreach ($cur_voted_id as $option)
727 if (!in_array($option, $voted_id))
729 $sql = 'UPDATE ' . POLL_OPTIONS_TABLE . '
730 SET poll_option_total = poll_option_total - 1
731 WHERE poll_option_id = ' . (int) $option . '
732 AND topic_id = ' . (int) $topic_id;
733 $db->sql_query($sql);
735 if ($user->data['is_registered'])
737 $sql = 'DELETE FROM ' . POLL_VOTES_TABLE . '
738 WHERE topic_id = ' . (int) $topic_id . '
739 AND poll_option_id = ' . (int) $option . '
740 AND vote_user_id = ' . (int) $user->data['user_id'];
741 $db->sql_query($sql);
746 if ($user->data['user_id'] == ANONYMOUS && !$user->data['is_bot'])
748 $user->set_cookie('poll_' . $topic_id, implode(',', $voted_id), time() + 31536000);
751 $sql = 'UPDATE ' . TOPICS_TABLE . '
752 SET poll_last_vote = ' . time() . "
753 WHERE topic_id = $topic_id";
754 //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now
755 $db->sql_query($sql);
757 $redirect_url = append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;start=$start");
759 meta_refresh(5, $redirect_url);
760 trigger_error($user->lang['VOTE_SUBMITTED'] . '<br /><br />' . sprintf($user->lang['RETURN_TOPIC'], '<a href="' . $redirect_url . '">', '</a>'));
763 $poll_total = 0;
764 foreach ($poll_info as $poll_option)
766 $poll_total += $poll_option['poll_option_total'];
769 if ($poll_info[0]['bbcode_bitfield'])
771 $poll_bbcode = new bbcode();
773 else
775 $poll_bbcode = false;
778 for ($i = 0, $size = sizeof($poll_info); $i < $size; $i++)
780 $poll_info[$i]['poll_option_text'] = censor_text($poll_info[$i]['poll_option_text']);
782 if ($poll_bbcode !== false)
784 $poll_bbcode->bbcode_second_pass($poll_info[$i]['poll_option_text'], $poll_info[$i]['bbcode_uid'], $poll_option['bbcode_bitfield']);
787 $poll_info[$i]['poll_option_text'] = bbcode_nl2br($poll_info[$i]['poll_option_text']);
788 $poll_info[$i]['poll_option_text'] = smiley_text($poll_info[$i]['poll_option_text']);
791 $topic_data['poll_title'] = censor_text($topic_data['poll_title']);
793 if ($poll_bbcode !== false)
795 $poll_bbcode->bbcode_second_pass($topic_data['poll_title'], $poll_info[0]['bbcode_uid'], $poll_info[0]['bbcode_bitfield']);
798 $topic_data['poll_title'] = bbcode_nl2br($topic_data['poll_title']);
799 $topic_data['poll_title'] = smiley_text($topic_data['poll_title']);
801 unset($poll_bbcode);
803 foreach ($poll_info as $poll_option)
805 $option_pct = ($poll_total > 0) ? $poll_option['poll_option_total'] / $poll_total : 0;
806 $option_pct_txt = sprintf("%.1d%%", ($option_pct * 100));
808 $template->assign_block_vars('poll_option', array(
809 'POLL_OPTION_ID' => $poll_option['poll_option_id'],
810 'POLL_OPTION_CAPTION' => $poll_option['poll_option_text'],
811 'POLL_OPTION_RESULT' => $poll_option['poll_option_total'],
812 'POLL_OPTION_PERCENT' => $option_pct_txt,
813 'POLL_OPTION_PCT' => round($option_pct * 100),
814 'POLL_OPTION_IMG' => $user->img('poll_center', $option_pct_txt, round($option_pct * 250)),
815 'POLL_OPTION_VOTED' => (in_array($poll_option['poll_option_id'], $cur_voted_id)) ? true : false)
819 $poll_end = $topic_data['poll_length'] + $topic_data['poll_start'];
821 $template->assign_vars(array(
822 'POLL_QUESTION' => $topic_data['poll_title'],
823 'TOTAL_VOTES' => $poll_total,
824 'POLL_LEFT_CAP_IMG' => $user->img('poll_left'),
825 'POLL_RIGHT_CAP_IMG'=> $user->img('poll_right'),
827 'L_MAX_VOTES' => ($topic_data['poll_max_options'] == 1) ? $user->lang['MAX_OPTION_SELECT'] : sprintf($user->lang['MAX_OPTIONS_SELECT'], $topic_data['poll_max_options']),
828 'L_POLL_LENGTH' => ($topic_data['poll_length']) ? sprintf($user->lang[($poll_end > time()) ? 'POLL_RUN_TILL' : 'POLL_ENDED_AT'], $user->format_date($poll_end)) : '',
830 'S_HAS_POLL' => true,
831 'S_CAN_VOTE' => $s_can_vote,
832 'S_DISPLAY_RESULTS' => $s_display_results,
833 'S_IS_MULTI_CHOICE' => ($topic_data['poll_max_options'] > 1) ? true : false,
834 'S_POLL_ACTION' => $viewtopic_url,
836 'U_VIEW_RESULTS' => $viewtopic_url . '&amp;view=viewpoll')
839 unset($poll_end, $poll_info, $voted_id);
842 // If the user is trying to reach the second half of the topic, fetch it starting from the end
843 $store_reverse = false;
844 $sql_limit = $config['posts_per_page'];
846 if ($start > $total_posts / 2)
848 $store_reverse = true;
850 if ($start + $config['posts_per_page'] > $total_posts)
852 $sql_limit = min($config['posts_per_page'], max(1, $total_posts - $start));
855 // Select the sort order
856 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'ASC' : 'DESC');
857 $sql_start = max(0, $total_posts - $sql_limit - $start);
859 else
861 // Select the sort order
862 $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
863 $sql_start = $start;
866 // Container for user details, only process once
867 $post_list = $user_cache = $id_cache = $attachments = $attach_list = $rowset = $update_count = $post_edit_list = array();
868 $has_attachments = $display_notice = false;
869 $bbcode_bitfield = '';
870 $i = $i_total = 0;
872 // Go ahead and pull all data for this topic
873 $sql = 'SELECT p.post_id
874 FROM ' . POSTS_TABLE . ' p' . (($sort_by_sql[$sort_key][0] == 'u') ? ', ' . USERS_TABLE . ' u': '') . "
875 WHERE p.topic_id = $topic_id
876 " . ((!$auth->acl_get('m_approve', $forum_id)) ? 'AND p.post_approved = 1' : '') . "
877 " . (($sort_by_sql[$sort_key][0] == 'u') ? 'AND u.user_id = p.poster_id': '') . "
878 $limit_posts_time
879 ORDER BY $sql_sort_order";
880 $result = $db->sql_query_limit($sql, $sql_limit, $sql_start);
882 $i = ($store_reverse) ? $sql_limit - 1 : 0;
883 while ($row = $db->sql_fetchrow($result))
885 $post_list[$i] = $row['post_id'];
886 ($store_reverse) ? $i-- : $i++;
888 $db->sql_freeresult($result);
890 if (!sizeof($post_list))
892 if ($sort_days)
894 trigger_error('NO_POSTS_TIME_FRAME');
896 else
898 trigger_error('NO_TOPIC');
902 // Holding maximum post time for marking topic read
903 // We need to grab it because we do reverse ordering sometimes
904 $max_post_time = 0;
906 $sql = $db->sql_build_query('SELECT', array(
907 'SELECT' => 'u.*, z.friend, z.foe, p.*',
909 'FROM' => array(
910 USERS_TABLE => 'u',
911 POSTS_TABLE => 'p',
914 'LEFT_JOIN' => array(
915 array(
916 'FROM' => array(ZEBRA_TABLE => 'z'),
917 'ON' => 'z.user_id = ' . $user->data['user_id'] . ' AND z.zebra_id = p.poster_id'
921 'WHERE' => $db->sql_in_set('p.post_id', $post_list) . '
922 AND u.user_id = p.poster_id'
925 $result = $db->sql_query($sql);
927 $now = getdate(time() + $user->timezone + $user->dst - date('Z'));
929 // Posts are stored in the $rowset array while $attach_list, $user_cache
930 // and the global bbcode_bitfield are built
931 while ($row = $db->sql_fetchrow($result))
933 // Set max_post_time
934 if ($row['post_time'] > $max_post_time)
936 $max_post_time = $row['post_time'];
939 $poster_id = $row['poster_id'];
941 // Does post have an attachment? If so, add it to the list
942 if ($row['post_attachment'] && $config['allow_attachments'])
944 $attach_list[] = $row['post_id'];
946 if ($row['post_approved'])
948 $has_attachments = true;
952 $rowset[$row['post_id']] = array(
953 'hide_post' => ($row['foe'] && ($view != 'show' || $post_id != $row['post_id'])) ? true : false,
955 'post_id' => $row['post_id'],
956 'post_time' => $row['post_time'],
957 'user_id' => $row['user_id'],
958 'username' => $row['username'],
959 'user_colour' => $row['user_colour'],
960 'topic_id' => $row['topic_id'],
961 'forum_id' => $row['forum_id'],
962 'post_subject' => $row['post_subject'],
963 'post_edit_count' => $row['post_edit_count'],
964 'post_edit_time' => $row['post_edit_time'],
965 'post_edit_reason' => $row['post_edit_reason'],
966 'post_edit_user' => $row['post_edit_user'],
968 // Make sure the icon actually exists
969 'icon_id' => (isset($icons[$row['icon_id']]['img'], $icons[$row['icon_id']]['height'], $icons[$row['icon_id']]['width'])) ? $row['icon_id'] : 0,
970 'post_attachment' => $row['post_attachment'],
971 'post_approved' => $row['post_approved'],
972 'post_reported' => $row['post_reported'],
973 'post_username' => $row['post_username'],
974 'post_text' => $row['post_text'],
975 'bbcode_uid' => $row['bbcode_uid'],
976 'bbcode_bitfield' => $row['bbcode_bitfield'],
977 'enable_smilies' => $row['enable_smilies'],
978 'enable_sig' => $row['enable_sig'],
979 'friend' => $row['friend'],
980 'foe' => $row['foe'],
983 // Define the global bbcode bitfield, will be used to load bbcodes
984 $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['bbcode_bitfield']);
986 // Is a signature attached? Are we going to display it?
987 if ($row['enable_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
989 $bbcode_bitfield = $bbcode_bitfield | base64_decode($row['user_sig_bbcode_bitfield']);
992 // Cache various user specific data ... so we don't have to recompute
993 // this each time the same user appears on this page
994 if (!isset($user_cache[$poster_id]))
996 if ($poster_id == ANONYMOUS)
998 $user_cache[$poster_id] = array(
999 'joined' => '',
1000 'posts' => '',
1001 'from' => '',
1003 'sig' => '',
1004 'sig_bbcode_uid' => '',
1005 'sig_bbcode_bitfield' => '',
1007 'online' => false,
1008 'avatar' => '',
1009 'rank_title' => '',
1010 'rank_image' => '',
1011 'rank_image_src' => '',
1012 'sig' => '',
1013 'profile' => '',
1014 'pm' => '',
1015 'email' => '',
1016 'www' => '',
1017 'icq_status_img' => '',
1018 'icq' => '',
1019 'aim' => '',
1020 'msn' => '',
1021 'yim' => '',
1022 'jabber' => '',
1023 'search' => '',
1024 'age' => '',
1026 'username' => $row['username'],
1027 'user_colour' => $row['user_colour'],
1029 'warnings' => 0,
1030 'allow_pm' => 0,
1033 else
1035 $user_sig = '';
1037 // We add the signature to every posters entry because enable_sig is post dependant
1038 if ($row['user_sig'] && $config['allow_sig'] && $user->optionget('viewsigs'))
1040 $user_sig = $row['user_sig'];
1043 $id_cache[] = $poster_id;
1045 $user_cache[$poster_id] = array(
1046 'joined' => $user->format_date($row['user_regdate']),
1047 'posts' => $row['user_posts'],
1048 'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
1049 'from' => (!empty($row['user_from'])) ? $row['user_from'] : '',
1051 'sig' => $user_sig,
1052 'sig_bbcode_uid' => (!empty($row['user_sig_bbcode_uid'])) ? $row['user_sig_bbcode_uid'] : '',
1053 'sig_bbcode_bitfield' => (!empty($row['user_sig_bbcode_bitfield'])) ? $row['user_sig_bbcode_bitfield'] : '',
1055 'viewonline' => $row['user_allow_viewonline'],
1056 'allow_pm' => $row['user_allow_pm'],
1058 'avatar' => ($user->optionget('viewavatars')) ? get_user_avatar($row['user_avatar'], $row['user_avatar_type'], $row['user_avatar_width'], $row['user_avatar_height']) : '',
1059 'age' => '',
1061 'rank_title' => '',
1062 'rank_image' => '',
1063 'rank_image_src' => '',
1065 'username' => $row['username'],
1066 'user_colour' => $row['user_colour'],
1068 'online' => false,
1069 'profile' => append_sid('memberlist', "mode=viewprofile&amp;u=$poster_id"),
1070 'www' => $row['user_website'],
1071 'aim' => ($row['user_aim'] && $auth->acl_get('u_sendim')) ? append_sid('memberlist', "mode=contact&amp;action=aim&amp;u=$poster_id") : '',
1072 'msn' => ($row['user_msnm'] && $auth->acl_get('u_sendim')) ? append_sid('memberlist', "mode=contact&amp;action=msnm&amp;u=$poster_id") : '',
1073 'yim' => ($row['user_yim']) ? 'http://edit.yahoo.com/config/send_webmesg?.target=' . urlencode($row['user_yim']) . '&amp;.src=pg' : '',
1074 'jabber' => ($row['user_jabber'] && $auth->acl_get('u_sendim')) ? append_sid('memberlist', "mode=contact&amp;action=jabber&amp;u=$poster_id") : '',
1075 'search' => ($auth->acl_get('u_search')) ? append_sid('search', 'search_author=' . urlencode($row['username']) .'&amp;sr=posts') : '',
1078 get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
1080 if (!empty($row['user_allow_viewemail']) || $auth->acl_get('a_email'))
1082 $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid('memberlist', "mode=email&amp;u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']);
1084 else
1086 $user_cache[$poster_id]['email'] = '';
1089 if (!empty($row['user_icq']))
1091 $user_cache[$poster_id]['icq'] = 'http://www.icq.com/people/webmsg.php?to=' . $row['user_icq'];
1092 $user_cache[$poster_id]['icq_status_img'] = '<img src="http://web.icq.com/whitepages/online?icq=' . $row['user_icq'] . '&amp;img=5" width="18" height="18" alt="" />';
1094 else
1096 $user_cache[$poster_id]['icq_status_img'] = '';
1097 $user_cache[$poster_id]['icq'] = '';
1100 if ($config['allow_birthdays'] && !empty($row['user_birthday']))
1102 list($bday_day, $bday_month, $bday_year) = array_map('intval', explode('-', $row['user_birthday']));
1104 if ($bday_year)
1106 $diff = $now['mon'] - $bday_month;
1107 if ($diff == 0)
1109 $diff = ($now['mday'] - $bday_day < 0) ? 1 : 0;
1111 else
1113 $diff = ($diff < 0) ? 1 : 0;
1116 $user_cache[$poster_id]['age'] = (int) ($now['year'] - $bday_year - $diff);
1122 $db->sql_freeresult($result);
1124 // Load custom profile fields
1125 if ($config['load_cpf_viewtopic'])
1127 include(PHPBB_ROOT_PATH . 'includes/functions_profile_fields.' . PHP_EXT);
1128 $cp = new custom_profile();
1130 // Grab all profile fields from users in id cache for later use - similar to the poster cache
1131 $profile_fields_cache = $cp->generate_profile_fields_template('grab', $id_cache);
1134 // Generate online information for user
1135 if ($config['load_onlinetrack'] && sizeof($id_cache))
1137 $sql = 'SELECT session_user_id, MAX(session_time) as online_time, MIN(session_viewonline) AS viewonline
1138 FROM ' . SESSIONS_TABLE . '
1139 WHERE ' . $db->sql_in_set('session_user_id', $id_cache) . '
1140 GROUP BY session_user_id';
1141 $result = $db->sql_query($sql);
1143 $update_time = $config['load_online_time'] * 60;
1144 while ($row = $db->sql_fetchrow($result))
1146 $user_cache[$row['session_user_id']]['online'] = (time() - $update_time < $row['online_time'] && (($row['viewonline']) || $auth->acl_get('u_viewonline'))) ? true : false;
1148 $db->sql_freeresult($result);
1150 unset($id_cache);
1152 // Pull attachment data
1153 if (sizeof($attach_list))
1155 if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id))
1157 $sql = 'SELECT *
1158 FROM ' . ATTACHMENTS_TABLE . '
1159 WHERE ' . $db->sql_in_set('post_msg_id', $attach_list) . '
1160 AND in_message = 0
1161 ORDER BY filetime DESC, post_msg_id ASC';
1162 $result = $db->sql_query($sql);
1164 while ($row = $db->sql_fetchrow($result))
1166 $attachments[$row['post_msg_id']][] = $row;
1168 $db->sql_freeresult($result);
1170 // No attachments exist, but post table thinks they do so go ahead and reset post_attach flags
1171 if (!sizeof($attachments))
1173 $sql = 'UPDATE ' . POSTS_TABLE . '
1174 SET post_attachment = 0
1175 WHERE ' . $db->sql_in_set('post_id', $attach_list);
1176 $db->sql_query($sql);
1178 // We need to update the topic indicator too if the complete topic is now without an attachment
1179 if (sizeof($rowset) != $total_posts)
1181 // Not all posts are displayed so we query the db to find if there's any attachment for this topic
1182 $sql = 'SELECT a.post_msg_id as post_id
1183 FROM ' . ATTACHMENTS_TABLE . ' a, ' . POSTS_TABLE . " p
1184 WHERE p.topic_id = $topic_id
1185 AND p.post_approved = 1
1186 AND p.topic_id = a.topic_id";
1187 $result = $db->sql_query_limit($sql, 1);
1188 $row = $db->sql_fetchrow($result);
1189 $db->sql_freeresult($result);
1191 if (!$row)
1193 $sql = 'UPDATE ' . TOPICS_TABLE . "
1194 SET topic_attachment = 0
1195 WHERE topic_id = $topic_id";
1196 $db->sql_query($sql);
1199 else
1201 $sql = 'UPDATE ' . TOPICS_TABLE . "
1202 SET topic_attachment = 0
1203 WHERE topic_id = $topic_id";
1204 $db->sql_query($sql);
1207 else if ($has_attachments && !$topic_data['topic_attachment'])
1209 // Topic has approved attachments but its flag is wrong
1210 $sql = 'UPDATE ' . TOPICS_TABLE . "
1211 SET topic_attachment = 1
1212 WHERE topic_id = $topic_id";
1213 $db->sql_query($sql);
1215 $topic_data['topic_attachment'] = 1;
1218 else
1220 $display_notice = true;
1224 // Instantiate BBCode if need be
1225 if ($bbcode_bitfield !== '')
1227 $bbcode = new bbcode(base64_encode($bbcode_bitfield));
1230 $i_total = sizeof($rowset) - 1;
1231 $prev_post_id = '';
1233 $template->assign_vars(array(
1234 'S_NUM_POSTS' => sizeof($post_list))
1237 // Output the posts
1238 $first_unread = $post_unread = false;
1239 for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
1241 // A non-existing rowset only happens if there was no user present for the entered poster_id
1242 // This could be a broken posts table.
1243 if (!isset($rowset[$post_list[$i]]))
1245 continue;
1248 $row =& $rowset[$post_list[$i]];
1249 $poster_id = $row['user_id'];
1251 // End signature parsing, only if needed
1252 if ($user_cache[$poster_id]['sig'] && $row['enable_sig'] && empty($user_cache[$poster_id]['sig_parsed']))
1254 $user_cache[$poster_id]['sig'] = censor_text($user_cache[$poster_id]['sig']);
1256 if ($user_cache[$poster_id]['sig_bbcode_bitfield'])
1258 $bbcode->bbcode_second_pass($user_cache[$poster_id]['sig'], $user_cache[$poster_id]['sig_bbcode_uid'], $user_cache[$poster_id]['sig_bbcode_bitfield']);
1261 $user_cache[$poster_id]['sig'] = bbcode_nl2br($user_cache[$poster_id]['sig']);
1262 $user_cache[$poster_id]['sig'] = smiley_text($user_cache[$poster_id]['sig']);
1263 $user_cache[$poster_id]['sig_parsed'] = true;
1266 // Parse the message and subject
1267 $message = censor_text($row['post_text']);
1269 // Second parse bbcode here
1270 if ($row['bbcode_bitfield'])
1272 $bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
1275 $message = bbcode_nl2br($message);
1276 $message = smiley_text($message);
1278 if (!empty($attachments[$row['post_id']]))
1280 parse_attachments($forum_id, $message, $attachments[$row['post_id']], $update_count);
1283 // Replace naughty words such as farty pants
1284 $row['post_subject'] = censor_text($row['post_subject']);
1286 // Highlight active words (primarily for search)
1287 if ($highlight_match)
1289 $message = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $message);
1290 $row['post_subject'] = preg_replace('#(?!<.*)(?<!\w)(' . $highlight_match . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#is', '<span class="posthilit">\1</span>', $row['post_subject']);
1293 // Editing information
1294 if (($row['post_edit_count'] && $config['display_last_edited']) || $row['post_edit_reason'])
1296 // Get usernames for all following posts if not already stored
1297 if (!sizeof($post_edit_list) && ($row['post_edit_reason'] || ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))))
1299 // Remove all post_ids already parsed (we do not have to check them)
1300 $post_storage_list = (!$store_reverse) ? array_slice($post_list, $i) : array_slice(array_reverse($post_list), $i);
1302 $sql = 'SELECT DISTINCT u.user_id, u.username, u.user_colour
1303 FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u
1304 WHERE ' . $db->sql_in_set('p.post_id', $post_storage_list) . '
1305 AND p.post_edit_count <> 0
1306 AND p.post_edit_user <> 0
1307 AND p.post_edit_user = u.user_id';
1308 $result2 = $db->sql_query($sql);
1309 while ($user_edit_row = $db->sql_fetchrow($result2))
1311 $post_edit_list[$user_edit_row['user_id']] = $user_edit_row;
1313 $db->sql_freeresult($result2);
1315 unset($post_storage_list);
1318 $l_edit_time_total = ($row['post_edit_count'] == 1) ? $user->lang['EDITED_TIME_TOTAL'] : $user->lang['EDITED_TIMES_TOTAL'];
1320 if ($row['post_edit_reason'])
1322 // User having edited the post also being the post author?
1323 if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
1325 $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
1327 else
1329 $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']);
1332 $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time']), $row['post_edit_count']);
1334 else
1336 if ($row['post_edit_user'] && !isset($user_cache[$row['post_edit_user']]))
1338 $user_cache[$row['post_edit_user']] = $post_edit_list[$row['post_edit_user']];
1341 // User having edited the post also being the post author?
1342 if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id)
1344 $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']);
1346 else
1348 $display_username = get_username_string('full', $row['post_edit_user'], $user_cache[$row['post_edit_user']]['username'], $user_cache[$row['post_edit_user']]['user_colour']);
1351 $l_edited_by = sprintf($l_edit_time_total, $display_username, $user->format_date($row['post_edit_time']), $row['post_edit_count']);
1354 else
1356 $l_edited_by = '';
1359 // Bump information
1360 if ($topic_data['topic_bumped'] && $row['post_id'] == $topic_data['topic_last_post_id'] && isset($user_cache[$topic_data['topic_bumper']]) )
1362 // It is safe to grab the username from the user cache array, we are at the last
1363 // post and only the topic poster and last poster are allowed to bump.
1364 // Admins and mods are bound to the above rules too...
1365 $l_bumped_by = '<br /><br />' . sprintf($user->lang['BUMPED_BY'], $user_cache[$topic_data['topic_bumper']]['username'], $user->format_date($topic_data['topic_last_post_time']));
1367 else
1369 $l_bumped_by = '';
1372 $cp_row = array();
1375 if ($config['load_cpf_viewtopic'])
1377 $cp_row = (isset($profile_fields_cache[$poster_id])) ? $cp->generate_profile_fields_template('show', false, $profile_fields_cache[$poster_id]) : array();
1380 $post_unread = (isset($topic_tracking_info[$topic_id]) && $row['post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
1382 $s_first_unread = false;
1383 if (!$first_unread && $post_unread)
1385 $s_first_unread = $first_unread = true;
1389 $postrow = array(
1390 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
1391 'POST_AUTHOR_COLOUR' => get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
1392 'POST_AUTHOR' => get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
1393 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
1395 'RANK_TITLE' => $user_cache[$poster_id]['rank_title'],
1396 'RANK_IMG' => $user_cache[$poster_id]['rank_image'],
1397 'RANK_IMG_SRC' => $user_cache[$poster_id]['rank_image_src'],
1398 'POSTER_JOINED' => $user_cache[$poster_id]['joined'],
1399 'POSTER_POSTS' => $user_cache[$poster_id]['posts'],
1400 'POSTER_FROM' => $user_cache[$poster_id]['from'],
1401 'POSTER_AVATAR' => $user_cache[$poster_id]['avatar'],
1402 'POSTER_WARNINGS' => $user_cache[$poster_id]['warnings'],
1403 'POSTER_AGE' => $user_cache[$poster_id]['age'],
1405 'POST_DATE' => $user->format_date($row['post_time']),
1406 'POST_SUBJECT' => $row['post_subject'],
1407 'MESSAGE' => $message,
1408 'SIGNATURE' => ($row['enable_sig']) ? $user_cache[$poster_id]['sig'] : '',
1409 'EDITED_MESSAGE' => $l_edited_by,
1410 'EDIT_REASON' => $row['post_edit_reason'],
1411 'BUMPED_MESSAGE' => $l_bumped_by,
1413 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'),
1414 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '',
1415 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '',
1416 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '',
1417 'ICQ_STATUS_IMG' => $user_cache[$poster_id]['icq_status_img'],
1418 'ONLINE_IMG' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? '' : (($user_cache[$poster_id]['online']) ? $user->img('icon_user_online', 'ONLINE') : $user->img('icon_user_offline', 'OFFLINE')),
1419 'S_ONLINE' => ($poster_id == ANONYMOUS || !$config['load_onlinetrack']) ? false : (($user_cache[$poster_id]['online']) ? true : false),
1421 'U_EDIT' => (!$user->data['is_registered']) ? '' : ((($user->data['user_id'] == $poster_id && $auth->acl_get('f_edit', $forum_id) && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_edit', $forum_id)) ? append_sid('posting', "mode=edit&amp;f=$forum_id&amp;p={$row['post_id']}") : ''),
1422 'U_QUOTE' => ($auth->acl_get('f_reply', $forum_id)) ? append_sid('posting', "mode=quote&amp;f=$forum_id&amp;p={$row['post_id']}") : '',
1423 'U_INFO' => ($auth->acl_get('m_info', $forum_id)) ? append_sid('mcp', "i=main&amp;mode=post_details&amp;f=$forum_id&amp;p=" . $row['post_id'], true, $user->session_id) : '',
1424 'U_DELETE' => (!$user->data['is_registered']) ? '' : ((($user->data['user_id'] == $poster_id && $auth->acl_get('f_delete', $forum_id) && $topic_data['topic_last_post_id'] == $row['post_id'] && ($row['post_time'] > time() - ($config['edit_time'] * 60) || !$config['edit_time'])) || $auth->acl_get('m_delete', $forum_id)) ? append_sid('posting', "mode=delete&amp;f=$forum_id&amp;p={$row['post_id']}") : ''),
1426 'U_PROFILE' => $user_cache[$poster_id]['profile'],
1427 'U_SEARCH' => $user_cache[$poster_id]['search'],
1428 'U_PM' => ($poster_id != ANONYMOUS && $config['allow_privmsg'] && $auth->acl_get('u_sendpm') && ($user_cache[$poster_id]['allow_pm'] || $auth->acl_gets('a_', 'm_') || $auth->acl_getf_global('m_'))) ? append_sid('ucp', 'i=pm&amp;mode=compose&amp;action=quotepost&amp;p=' . $row['post_id']) : '',
1429 'U_EMAIL' => $user_cache[$poster_id]['email'],
1430 'U_WWW' => $user_cache[$poster_id]['www'],
1431 'U_ICQ' => $user_cache[$poster_id]['icq'],
1432 'U_AIM' => $user_cache[$poster_id]['aim'],
1433 'U_MSN' => $user_cache[$poster_id]['msn'],
1434 'U_YIM' => $user_cache[$poster_id]['yim'],
1435 'U_JABBER' => $user_cache[$poster_id]['jabber'],
1437 'U_REPORT' => ($auth->acl_get('f_report', $forum_id)) ? append_sid('report', 'f=' . $forum_id . '&amp;p=' . $row['post_id']) : '',
1438 'U_MCP_REPORT' => ($auth->acl_get('m_report', $forum_id)) ? append_sid('mcp', 'i=reports&amp;mode=report_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
1439 'U_MCP_APPROVE' => ($auth->acl_get('m_approve', $forum_id)) ? append_sid('mcp', 'i=queue&amp;mode=approve_details&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
1440 'U_MINI_POST' => append_sid('viewtopic', 'p=' . $row['post_id']) . (($topic_data['topic_type'] == POST_GLOBAL) ? '&amp;f=' . $forum_id : '') . '#p' . $row['post_id'],
1441 'U_NEXT_POST_ID' => ($i < $i_total && isset($rowset[$post_list[$i + 1]])) ? $rowset[$post_list[$i + 1]]['post_id'] : '',
1442 'U_PREV_POST_ID' => $prev_post_id,
1443 'U_NOTES' => ($auth->acl_getf_global('m_')) ? append_sid('mcp', 'i=notes&amp;mode=user_notes&amp;u=' . $poster_id, true, $user->session_id) : '',
1444 'U_WARN' => ($auth->acl_get('m_warn') && $poster_id != $user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid('mcp', 'i=warn&amp;mode=warn_post&amp;f=' . $forum_id . '&amp;p=' . $row['post_id'], true, $user->session_id) : '',
1446 'POST_ID' => $row['post_id'],
1447 'POSTER_ID' => $poster_id,
1449 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
1450 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
1451 'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,
1452 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
1453 'S_FRIEND' => ($row['friend']) ? true : false,
1454 'S_UNREAD_POST' => $post_unread,
1455 'S_FIRST_UNREAD' => $s_first_unread,
1456 'S_CUSTOM_FIELDS' => (isset($cp_row['row']) && sizeof($cp_row['row'])) ? true : false,
1457 'S_TOPIC_POSTER' => ($topic_data['topic_poster'] == $poster_id) ? true : false,
1459 'S_IGNORE_POST' => ($row['hide_post']) ? true : false,
1460 'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',
1463 if (isset($cp_row['row']) && sizeof($cp_row['row']))
1465 $postrow = array_merge($postrow, $cp_row['row']);
1468 // Dump vars into template
1469 $template->assign_block_vars('postrow', $postrow);
1471 if (!empty($cp_row['blockrow']))
1473 foreach ($cp_row['blockrow'] as $field_data)
1475 $template->assign_block_vars('postrow.custom_fields', $field_data);
1479 // Display not already displayed Attachments for this post, we already parsed them. ;)
1480 if (!empty($attachments[$row['post_id']]))
1482 foreach ($attachments[$row['post_id']] as $attachment)
1484 $template->assign_block_vars('postrow.attachment', array(
1485 'DISPLAY_ATTACHMENT' => $attachment)
1490 $prev_post_id = $row['post_id'];
1492 unset($rowset[$post_list[$i]]);
1493 unset($attachments[$row['post_id']]);
1495 unset($rowset, $user_cache);
1497 // Update topic view and if necessary attachment view counters ... but only if this is the first 'page view'
1498 if (isset($user->data['session_page']) && strpos($user->data['session_page'], '&t=' . $topic_id) === false)
1500 $sql = 'UPDATE ' . TOPICS_TABLE . '
1501 SET topic_views = topic_views + 1, topic_last_view_time = ' . time() . "
1502 WHERE topic_id = $topic_id";
1503 $db->sql_query($sql);
1505 // Update the attachment download counts
1506 if (sizeof($update_count))
1508 $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
1509 SET download_count = download_count + 1
1510 WHERE ' . $db->sql_in_set('attach_id', array_unique($update_count));
1511 $db->sql_query($sql);
1515 // Only mark topic if it's currently unread. Also make sure we do not set topic tracking back if earlier pages are viewed.
1516 if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id] && $max_post_time > $topic_tracking_info[$topic_id])
1518 markread('topic', $forum_id, $topic_id, $max_post_time);
1520 // Update forum info
1521 $all_marked_read = update_forum_tracking_info($forum_id, $topic_data['forum_last_post_time'], (isset($topic_data['forum_mark_time'])) ? $topic_data['forum_mark_time'] : false, false);
1523 else
1525 $all_marked_read = true;
1528 // If there are absolutely no more unread posts in this forum and unread posts shown, we can savely show the #unread link
1529 if ($all_marked_read)
1531 if ($post_unread)
1533 $template->assign_vars(array(
1534 'U_VIEW_UNREAD_POST' => '#unread',
1537 else if (isset($topic_tracking_info[$topic_id]) && $topic_data['topic_last_post_time'] > $topic_tracking_info[$topic_id])
1539 $template->assign_vars(array(
1540 'U_VIEW_UNREAD_POST' => append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
1544 else if (!$all_marked_read)
1546 $last_page = ((floor($start / $config['posts_per_page']) + 1) == max(ceil($total_posts / $config['posts_per_page']), 1)) ? true : false;
1548 // What can happen is that we are at the last displayed page. If so, we also display the #unread link based in $post_unread
1549 if ($last_page && $post_unread)
1551 $template->assign_vars(array(
1552 'U_VIEW_UNREAD_POST' => '#unread',
1555 else if (!$last_page)
1557 $template->assign_vars(array(
1558 'U_VIEW_UNREAD_POST' => append_sid('viewtopic', "f=$forum_id&amp;t=$topic_id&amp;view=unread") . '#unread',
1563 // We overwrite $_REQUEST['f'] if there is no forum specified
1564 // to be able to display the correct online list.
1565 // One downside is that the user currently viewing this topic/post is not taken into account.
1566 if (empty($_REQUEST['f']))
1568 $_REQUEST['f'] = $forum_id;
1571 // Output the page
1572 page_header($user->lang['VIEW_TOPIC'] .' - ' . $topic_data['topic_title']);
1574 $template->set_filenames(array(
1575 'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
1577 make_jumpbox(append_sid('viewforum'), $forum_id);
1579 page_footer();