'p.topic_id, p.posted', 'FROM' => 'posts AS p', 'WHERE' => 'p.id='.$pid ); ($hook = get_hook('vt_qr_get_post_info')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); if (!$forum_db->num_rows($result)) message($lang_common['Bad request']); list($id, $posted) = $forum_db->fetch_row($result); // Determine on what page the post is located (depending on $forum_user['disp_posts']) $query = array( 'SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id='.$id.' AND p.posted<'.$posted ); ($hook = get_hook('vt_qr_get_post_page')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $num_posts = $forum_db->result($result) + 1; $_GET['p'] = ceil($num_posts / $forum_user['disp_posts']); } // If action=new, we redirect to the first new post (if any) else if ($action == 'new') { if (!$forum_user['is_guest']) { // We need to check if this topic has been viewed recently by the user $tracked_topics = get_tracked_topics(); $last_viewed = isset($tracked_topics['topics'][$id]) ? $tracked_topics['topics'][$id] : $forum_user['last_visit']; ($hook = get_hook('vt_find_new_post')) ? eval($hook) : null; $query = array( 'SELECT' => 'MIN(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.topic_id='.$id.' AND p.posted>'.$last_viewed ); ($hook = get_hook('vt_qr_get_first_new_post')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $first_new_post_id = $forum_db->result($result); if ($first_new_post_id) { header('Location: '.str_replace('&', '&', forum_link($forum_url['post'], $first_new_post_id))); exit; } } header('Location: '.str_replace('&', '&', forum_link($forum_url['topic_last_post'], $id))); exit; } // If action=last, we redirect to the last post else if ($action == 'last') { $query = array( 'SELECT' => 't.last_post_id', 'FROM' => 'topics AS t', 'WHERE' => 't.id='.$id ); ($hook = get_hook('vt_qr_get_last_post')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $last_post_id = $forum_db->result($result); if ($last_post_id) { header('Location: '.str_replace('&', '&', forum_link($forum_url['post'], $last_post_id))); exit; } } // Fetch some info about the topic $query = array( 'SELECT' => 't.subject, t.posted, t.poster, t.first_post_id, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies', 'FROM' => 'topics AS t', 'JOINS' => array( array( 'INNER JOIN' => 'forums AS f', 'ON' => 'f.id=t.forum_id' ), array( 'LEFT JOIN' => 'forum_perms AS fp', 'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')' ) ), 'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL' ); if (!$forum_user['is_guest']) { $query['SELECT'] .= ', s.user_id AS is_subscribed'; $query['JOINS'][] = array( 'LEFT JOIN' => 'subscriptions AS s', 'ON' => '(t.id=s.topic_id AND s.user_id='.$forum_user['id'].')' ); } ($hook = get_hook('vt_qr_get_topic_info')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); if (!$forum_db->num_rows($result)) message($lang_common['Bad request']); $cur_topic = $forum_db->fetch_assoc($result); ($hook = get_hook('vt_modify_topic_info')) ? eval($hook) : null; // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_topic['moderators'] != '') ? unserialize($cur_topic['moderators']) : array(); $forum_page['is_admmod'] = ($forum_user['g_id'] == FORUM_ADMIN || ($forum_user['g_moderator'] == '1' && array_key_exists($forum_user['username'], $mods_array))) ? true : false; // Can we or can we not post replies? if ($cur_topic['closed'] == '0' || $forum_page['is_admmod']) $forum_user['may_post'] = (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1' || $forum_page['is_admmod']) ? true : false; else $forum_user['may_post'] = false; // Add/update this topic in our list of tracked topics if (!$forum_user['is_guest']) { $tracked_topics = get_tracked_topics(); $tracked_topics['topics'][$id] = time(); set_tracked_topics($tracked_topics); } // Determine the post offset (based on $_GET['p']) $forum_page['num_pages'] = ceil(($cur_topic['num_replies'] + 1) / $forum_user['disp_posts']); $forum_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $forum_page['num_pages']) ? 1 : $_GET['p']; $forum_page['start_from'] = $forum_user['disp_posts'] * ($forum_page['page'] - 1); $forum_page['finish_at'] = min(($forum_page['start_from'] + $forum_user['disp_posts']), ($cur_topic['num_replies'] + 1)); $forum_page['items_info'] = generate_items_info($lang_topic['Posts'], ($forum_page['start_from'] + 1), ($cur_topic['num_replies'] + 1)); ($hook = get_hook('vt_modify_page_details')) ? eval($hook) : null; // Navigation links for header and page numbering for title/meta description if ($forum_page['page'] < $forum_page['num_pages']) { $forum_page['nav']['last'] = ''; $forum_page['nav']['next'] = ''; } if ($forum_page['page'] > 1) { $forum_page['nav']['prev'] = ''; $forum_page['nav']['first'] = ''; } if ($forum_config['o_censoring'] == '1') $cur_topic['subject'] = censor_words($cur_topic['subject']); // Generate paging and posting links $forum_page['page_post']['paging'] = '

'.$lang_common['Pages'].' '.paginate($forum_page['num_pages'], $forum_page['page'], $forum_url['topic'], $lang_common['Paging separator'], array($id, sef_friendly($cur_topic['subject']))).'

'; if ($forum_user['may_post']) $forum_page['page_post']['posting'] = '

'.$lang_topic['Post reply'].'

'; else if (!$forum_user['may_post'] && !$forum_user['is_guest'] && $cur_topic['closed'] != '1') $forum_page['page_post']['posting'] = '

'.$lang_topic['No permission'].'

'; if (!$forum_user['may_post'] && $forum_user['is_guest']) $forum_page['page_post']['posting'] = '

'.sprintf($lang_topic['Login to post'], ''.$lang_common['login'].'', ''.$lang_common['register'].'').'

'; // Setup main options $forum_page['main_title'] = $lang_topic['Topic options']; $forum_page['main_head_options'] = array( 'rss' => ''.$lang_topic['RSS topic feed'].'' ); if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1') { if ($cur_topic['is_subscribed']) $forum_page['main_head_options']['unsubscribe'] = ''.$lang_topic['Unsubscribe'].''; else $forum_page['main_head_options']['subscribe'] = ''.$lang_topic['Subscribe'].''; } if ($forum_page['is_admmod']) { $forum_page['main_foot_options'] = array( 'move' => ''.$lang_topic['Move'].'', 'delete' => ''.$lang_topic['Delete topic'].'', 'close' => (($cur_topic['closed'] == '1') ? ''.$lang_topic['Open'].'' : ''.$lang_topic['Close'].''), 'sticky' => (($cur_topic['sticky'] == '1') ? ''.$lang_topic['Unstick'].'' : ''.$lang_topic['Stick'].'') ); if ($cur_topic['num_replies'] != 0) $forum_page['main_foot_options']['moderate_topic'] = ''.$lang_topic['Moderate topic'].''; } // Setup breadcrumbs $forum_page['crumbs'] = array( array($forum_config['o_board_title'], forum_link($forum_url['index'])), array($cur_topic['forum_name'], forum_link($forum_url['forum'], array($cur_topic['forum_id'], sef_friendly($cur_topic['forum_name'])))), array($cur_topic['subject'], forum_link($forum_url['topic'], array($id, sef_friendly($cur_topic['subject'])))) ); // Setup main heading $forum_page['main_title'] = (($cur_topic['closed'] == '1') ? $lang_topic['Topic closed'].' ' : '').''; if ($forum_page['num_pages'] > 1) $forum_page['main_head_pages'] = sprintf($lang_common['Page info'], $forum_page['page'], $forum_page['num_pages']); ($hook = get_hook('vt_pre_header_load')) ? eval($hook) : null; // Allow indexing if this is a permalink if (!$pid) define('FORUM_ALLOW_INDEX', 1); define('FORUM_PAGE', 'viewtopic'); require FORUM_ROOT.'header.php'; // START SUBST - ob_start(); ($hook = get_hook('vt_main_output_start')) ? eval($hook) : null; ?>
'.implode(' ', $forum_page['main_head_options']).'

'; ?>

'u.email, u.title, u.url, u.location, u.signature, u.email_setting, u.num_posts, u.registered, u.admin_note, p.id, p.poster AS username, p.poster_id, p.poster_ip, p.poster_email, p.message, p.hide_smilies, p.posted, p.edited, p.edited_by, g.g_id, g.g_user_title, o.user_id AS is_online', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'INNER JOIN' => 'users AS u', 'ON' => 'u.id=p.poster_id' ), array( 'INNER JOIN' => 'groups AS g', 'ON' => 'g.g_id=u.group_id' ), array( 'LEFT JOIN' => 'online AS o', 'ON' => '(o.user_id=u.id AND o.user_id!=1 AND o.idle=0)' ), ), 'WHERE' => 'p.topic_id='.$id, 'ORDER BY' => 'p.id', 'LIMIT' => $forum_page['start_from'].','.$forum_user['disp_posts'] ); ($hook = get_hook('vt_qr_get_posts')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $user_data_cache = array(); while ($cur_post = $forum_db->fetch_assoc($result)) { ($hook = get_hook('vt_post_loop_start')) ? eval($hook) : null; ++$forum_page['item_count']; $forum_page['post_ident'] = array(); $forum_page['author_ident'] = array(); $forum_page['author_info'] = array(); $forum_page['post_options'] = array(); $forum_page['post_contacts'] = array(); $forum_page['post_actions'] = array(); $forum_page['message'] = array(); // Generate the post heading $forum_page['post_ident']['num'] = ''.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; if ($cur_post['poster_id'] > 1) $forum_page['post_ident']['byline'] = ''.sprintf((($cur_post['id'] == $cur_topic['first_post_id']) ? $lang_topic['Topic byline'] : $lang_topic['Reply byline']), (($forum_user['g_view_users'] == '1') ? ''.forum_htmlencode($cur_post['username']).'' : ''.forum_htmlencode($cur_post['username']).'')).''; else $forum_page['post_ident']['byline'] = ''.sprintf((($cur_post['id'] == $cur_topic['first_post_id']) ? $lang_topic['Topic byline'] : $lang_topic['Reply byline']), ''.forum_htmlencode($cur_post['username']).'').''; $forum_page['post_ident']['link'] = ''; ($hook = get_hook('vt_row_pre_post_ident_merge')) ? eval($hook) : null; if (isset($user_data_cache[$cur_post['poster_id']]['author_ident'])) $forum_page['author_ident'] = $user_data_cache[$cur_post['poster_id']]['author_ident']; else { // Generate author identification if ($cur_post['poster_id'] > 1) { if ($forum_config['o_avatars'] == '1' && $forum_user['show_avatars'] != '0') $forum_page['avatar_markup'] = generate_avatar_markup($cur_post['poster_id']); if (!empty($forum_page['avatar_markup'])) $forum_page['author_ident']['avatar'] = '
  • '.$forum_page['avatar_markup'].'
  • '; $forum_page['author_ident']['username'] = '
  • '.(($forum_user['g_view_users'] == '1') ? ''.forum_htmlencode($cur_post['username']).'' : ''.forum_htmlencode($cur_post['username']).'').'
  • '; $forum_page['author_ident']['usertitle'] = '
  • '.get_title($cur_post).'
  • '; if ($cur_post['is_online'] == $cur_post['poster_id']) $forum_page['author_ident']['status'] = '
  • '.$lang_topic['Online'].'
  • '; else $forum_page['author_ident']['status'] = '
  • '.$lang_topic['Offline'].'
  • '; } else { $forum_page['author_ident']['username'] = '
  • '.forum_htmlencode($cur_post['username']).'
  • '; $forum_page['author_ident']['usertitle'] = '
  • '.get_title($cur_post).'
  • '; } } if (isset($user_data_cache[$cur_post['poster_id']]['author_info'])) $forum_page['author_info'] = $user_data_cache[$cur_post['poster_id']]['author_info']; else { // Generate author information if ($cur_post['poster_id'] > 1) { if ($forum_config['o_show_user_info'] == '1') { if ($cur_post['location'] != '') { if ($forum_config['o_censoring'] == '1') $cur_post['location'] = censor_words($cur_post['location']); $forum_page['author_info']['from'] = '
  • '.$lang_topic['From'].' '.forum_htmlencode($cur_post['location']).'
  • '; } $forum_page['author_info']['registered'] = '
  • '.$lang_topic['Registered'].' '.format_time($cur_post['registered'], 1).'
  • '; if ($forum_config['o_show_post_count'] == '1' || $forum_user['is_admmod']) $forum_page['author_info']['posts'] = '
  • '.$lang_topic['Posts info'].' '.forum_number_format($cur_post['num_posts']).'
  • '; } if ($forum_user['is_admmod']) { if ($cur_post['admin_note'] != '') $forum_page['author_info']['note'] = '
  • '.$lang_topic['Note'].' '.forum_htmlencode($cur_post['admin_note']).'
  • '; } } } // Generate IP information for moderators/administrators if ($forum_user['is_admmod']) $forum_page['author_info']['ip'] = '
  • '.$lang_topic['IP'].' '.$cur_post['poster_ip'].'
  • '; // Generate author contact details if ($forum_config['o_show_user_info'] == '1') { if (isset($user_data_cache[$cur_post['poster_id']]['post_contacts'])) $forum_page['post_contacts'] = $user_data_cache[$cur_post['poster_id']]['post_contacts']; else { if ($cur_post['poster_id'] > 1) { if ($cur_post['url'] != '') $forum_page['post_contacts']['url'] = ''.sprintf($lang_topic['Visit website'], ''.sprintf($lang_topic['User possessive'], forum_htmlencode($cur_post['username'])).'').''; if ((($cur_post['email_setting'] == '0' && !$forum_user['is_guest']) || $forum_user['is_admmod']) && $forum_user['g_send_email'] == '1') $forum_page['post_contacts']['email'] = ''.$lang_topic['E-mail'].' '.forum_htmlencode($cur_post['username']).''; else if ($cur_post['email_setting'] == '1' && !$forum_user['is_guest'] && $forum_user['g_send_email'] == '1') $forum_page['post_contacts']['email'] = ''.$lang_topic['E-mail'].' '.forum_htmlencode($cur_post['username']).''; } else { if ($cur_post['poster_email'] != '' && !$forum_user['is_guest'] && $forum_user['g_send_email'] == '1') $forum_page['post_contacts']['email'] = ''.$lang_topic['E-mail'].' '.forum_htmlencode($cur_post['username']).''; } } ($hook = get_hook('vt_row_pre_post_contacts_merge')) ? eval($hook) : null; if (!empty($forum_page['post_contacts'])) $forum_page['post_options']['contacts'] = '

    '.implode(' ', $forum_page['post_contacts']).'

    '; } // Generate the post options links if (!$forum_user['is_guest']) { $forum_page['post_actions']['report'] = ''.$lang_topic['Report'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; if (!$forum_page['is_admmod']) { if ($cur_topic['closed'] == '0') { if ($cur_post['poster_id'] == $forum_user['id']) { if (($forum_page['start_from'] + $forum_page['item_count']) == 1 && $forum_user['g_delete_topics'] == '1') $forum_page['post_actions']['delete'] = ''.$lang_topic['Delete topic'].''; if (($forum_page['start_from'] + $forum_page['item_count']) > 1 && $forum_user['g_delete_posts'] == '1') $forum_page['post_actions']['delete'] = ''.$lang_topic['Delete'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; if ($forum_user['g_edit_posts'] == '1') $forum_page['post_actions']['edit'] = ''.$lang_topic['Edit'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; } if (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1') $forum_page['post_actions']['quote'] = ''.$lang_topic['Quote'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; } } else { if (($forum_page['start_from'] + $forum_page['item_count']) == 1) $forum_page['post_actions']['delete'] = ''.$lang_topic['Delete topic'].''; else $forum_page['post_actions']['delete'] = ''.$lang_topic['Delete'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; $forum_page['post_actions']['edit'] = ''.$lang_topic['Edit'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; $forum_page['post_actions']['quote'] = ''.$lang_topic['Quote'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; } } else { if ($cur_topic['closed'] == '0') { if (($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1') || $cur_topic['post_replies'] == '1') $forum_page['post_actions']['quote'] = ''.$lang_topic['Quote'].' '.$lang_topic['Post'].' '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''; } } ($hook = get_hook('vt_row_pre_post_actions_merge')) ? eval($hook) : null; if (!empty($forum_page['post_actions'])) $forum_page['post_options']['actions'] = '

    '.implode(' ', $forum_page['post_actions']).'

    '; // Give the post some class $forum_page['item_status'] = array( 'post', ($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even' ); if ($forum_page['item_count'] == 1) $forum_page['item_status']['firstpost'] = 'firstpost'; if (($forum_page['start_from'] + $forum_page['item_count']) == $forum_page['finish_at']) $forum_page['item_status']['lastpost'] = 'lastpost'; if ($cur_post['id'] == $cur_topic['first_post_id']) $forum_page['item_status']['topicpost'] = 'topicpost'; else $forum_page['item_status']['replypost'] = 'replypost'; // Generate the post title if ($cur_post['id'] == $cur_topic['first_post_id']) $forum_page['item_subject'] = sprintf($lang_topic['Topic title'], $cur_topic['subject']); else $forum_page['item_subject'] = sprintf($lang_topic['Reply title'], $cur_topic['subject']); $forum_page['item_subject'] = forum_htmlencode($forum_page['item_subject']); // Perform the main parsing of the message (BBCode, smilies, censor words etc) $forum_page['message']['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']); if ($cur_post['edited'] != '') $forum_page['message']['edited'] = '

    '.sprintf($lang_topic['Last edited'], forum_htmlencode($cur_post['edited_by']), format_time($cur_post['edited'])).'

    '; // Do signature parsing/caching if ($cur_post['signature'] != '' && $forum_user['show_sig'] != '0' && $forum_config['o_signatures'] == '1') { if (!isset($signature_cache[$cur_post['poster_id']])) $signature_cache[$cur_post['poster_id']] = parse_signature($cur_post['signature']); $forum_page['message']['signature'] = '
    '.$signature_cache[$cur_post['poster_id']].'
    '; } ($hook = get_hook('vt_row_pre_display')) ? eval($hook) : null; // Do user data caching for the post if ($cur_post['poster_id'] > 1 && !isset($user_data_cache[$cur_post['poster_id']])) { $user_data_cache[$cur_post['poster_id']] = array( 'author_ident' => $forum_page['author_ident'], 'author_info' => $forum_page['author_info'], 'post_contacts' => $forum_page['post_contacts'] ); ($hook = get_hook('vt_row_add_user_data_cache')) ? eval($hook) : null; } ?>

    '.implode(' ', $forum_page['main_foot_options']).'

    '; ?>

    ', $tpl_temp, $tpl_main); ob_end_clean(); // END SUBST - // Display quick post if enabled if ($forum_config['o_quickpost'] == '1' && !$forum_user['is_guest'] && ($cur_topic['post_replies'] == '1' || ($cur_topic['post_replies'] == '' && $forum_user['g_post_replies'] == '1')) && ($cur_topic['closed'] == '0' || $forum_page['is_admmod'])) { // START SUBST - ob_start(); ($hook = get_hook('vt_qpost_output_start')) ? eval($hook) : null; // Setup form $forum_page['form_action'] = forum_link($forum_url['new_reply'], $id); $forum_page['form_attributes'] = array(); $forum_page['hidden_fields'] = array( 'form_sent' => '', 'form_user' => '', 'csrf_token' => '' ); if (!$forum_user['is_guest'] && $forum_config['o_subscriptions'] == '1' && ($forum_user['auto_notify'] == '1' || $cur_topic['is_subscribed'])) $forum_page['hidden_fields']['subscribe'] = ''; // Setup help $forum_page['main_head_options'] = array(); if ($forum_config['p_message_bbcode'] == '1') $forum_page['text_options']['bbcode'] = ''.$lang_common['BBCode'].''; if ($forum_config['p_message_img_tag'] == '1') $forum_page['text_options']['img'] = ''.$lang_common['Images'].''; if ($forum_config['o_smilies'] == '1') $forum_page['text_options']['smilies'] = ''.$lang_common['Smilies'].''; ($hook = get_hook('vt_quickpost_pre_display')) ? eval($hook) : null; ?>

    '.sprintf($lang_common['You may use'], implode(' ', $forum_page['text_options'])).'

    '."\n" ?>

    >
    ', $tpl_temp, $tpl_main); ob_end_clean(); // END SUBST - } // Increment "num_views" for topic if ($forum_config['o_topic_views'] == '1') { $query = array( 'UPDATE' => 'topics', 'SET' => 'num_views=num_views+1', 'WHERE' => 'id='.$id, ); ($hook = get_hook('vt_qr_increment_num_views')) ? eval($hook) : null; $forum_db->query_build($query) or error(__FILE__, __LINE__); } $forum_id = $cur_topic['forum_id']; require FORUM_ROOT.'footer.php';