'f.forum_name, f.redirect_url, f.moderators, f.num_topics, f.sort_by, fp.post_topics', 'FROM' => 'forums AS f', 'JOINS' => array( 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 f.id='.$id ); ($hook = get_hook('vf_qr_get_forum_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_forum = $forum_db->fetch_assoc($result); ($hook = get_hook('vf_modify_forum_info')) ? eval($hook) : null; // Is this a redirect forum? In that case, redirect! if ($cur_forum['redirect_url'] != '') { ($hook = get_hook('vf_redirect_forum_pre_redirect')) ? eval($hook) : null; header('Location: '.$cur_forum['redirect_url']); exit; } // Sort out who the moderators are and if we are currently a moderator (or an admin) $mods_array = ($cur_forum['moderators'] != '') ? unserialize($cur_forum['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; // Sort out whether or not this user can post $forum_user['may_post'] = (($cur_forum['post_topics'] == '' && $forum_user['g_post_topics'] == '1') || $cur_forum['post_topics'] == '1' || $forum_page['is_admmod']) ? true : false; // Get topic/forum tracking data if (!$forum_user['is_guest']) $tracked_topics = get_tracked_topics(); // Determine the topic offset (based on $_GET['p']) $forum_page['num_pages'] = ceil($cur_forum['num_topics'] / $forum_user['disp_topics']); $forum_page['page'] = (!isset($_GET['p']) || !is_numeric($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $forum_page['num_pages']) ? 1 : $_GET['p']; $forum_page['start_from'] = $forum_user['disp_topics'] * ($forum_page['page'] - 1); $forum_page['finish_at'] = min(($forum_page['start_from'] + $forum_user['disp_topics']), ($cur_forum['num_topics'])); $forum_page['items_info'] = generate_items_info($lang_forum['Topics'], ($forum_page['start_from'] + 1), $cur_forum['num_topics']); ($hook = get_hook('vf_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'] = ''; } // Fetch list of topics $query = array( 'SELECT' => 't.id, t.poster, t.subject, t.posted, t.first_post_id, t.last_post, t.last_post_id, t.last_poster, t.num_views, t.num_replies, t.closed, t.sticky, t.moved_to', 'FROM' => 'topics AS t', 'WHERE' => 't.forum_id='.$id, 'ORDER BY' => 't.sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 't.posted' : 't.last_post').' DESC', 'LIMIT' => $forum_page['start_from'].', '.$forum_user['disp_topics'] ); // With "has posted" indication if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1') { $subquery = array( 'SELECT' => 'COUNT(p.id)', 'FROM' => 'posts AS p', 'WHERE' => 'p.poster_id='.$forum_user['id'].' AND p.topic_id=t.id' ); ($hook = get_hook('vf_qr_get_has_posted')) ? eval($hook) : null; $query['SELECT'] .= ', ('.$forum_db->query_build($subquery, true).') AS has_posted'; } ($hook = get_hook('vf_qr_get_topics')) ? eval($hook) : null; $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); // Generate paging/posting links $forum_page['page_post']['paging'] = '

'.$lang_common['Pages'].' '.paginate($forum_page['num_pages'], $forum_page['page'], $forum_url['forum'], $lang_common['Paging separator'], array($id, sef_friendly($cur_forum['forum_name']))).'

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

'.$lang_forum['Post topic'].'

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

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

'; else $forum_page['page_post']['posting'] = '

'.$lang_forum['No permission'].'

'; // Setup main options $forum_page['main_head_options'] = array( 'feed' => ''.$lang_forum['RSS forum feed'].'' ); $forum_page['main_foot_options'] = array(); if (!$forum_user['is_guest'] && $forum_db->num_rows($result)) { $forum_page['main_foot_options']['mark_read'] = ''.$lang_forum['Mark forum read'].''; if ($forum_page['is_admmod']) $forum_page['main_foot_options']['moderate'] = ''.$lang_forum['Moderate forum'].''; } // Setup breadcrumbs $forum_page['crumbs'] = array( array($forum_config['o_board_title'], forum_link($forum_url['index'])), array($cur_forum['forum_name'], forum_link($forum_url['forum'], array($id, sef_friendly($cur_forum['forum_name'])))) ); // Setup main header $forum_page['main_title'] = ''; 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('vf_pre_header_load')) ? eval($hook) : null; define('FORUM_ALLOW_INDEX', 1); define('FORUM_PAGE', 'viewforum'); require FORUM_ROOT.'header.php'; // START SUBST - ob_start(); $forum_page['item_header'] = array(); $forum_page['item_header']['subject']['title'] = ''.$lang_forum['Topics'].''; $forum_page['item_header']['info']['replies'] = ''.$lang_forum['replies'].''; if ($forum_config['o_topic_views'] == '1') $forum_page['item_header']['info']['views'] = ''.$lang_forum['views'].''; $forum_page['item_header']['info']['lastpost'] = ''.$lang_forum['last post'].''; ($hook = get_hook('vf_main_output_start')) ? eval($hook) : null; // If there are topics in this forum if ($forum_db->num_rows($result)) { ?>
'.implode(' ', $forum_page['main_head_options']).'

'; ?>

fetch_assoc($result)) { ($hook = get_hook('vf_topic_loop_start')) ? eval($hook) : null; ++$forum_page['item_count']; // Start from scratch $forum_page['item_subject'] = $forum_page['item_body'] = $forum_page['item_status'] = $forum_page['item_nav'] = $forum_page['item_title'] = $forum_page['item_title_status'] = array(); if ($forum_config['o_censoring'] == '1') $cur_topic['subject'] = censor_words($cur_topic['subject']); $forum_page['item_subject']['starter'] = ''.sprintf($lang_forum['Topic starter'], forum_htmlencode($cur_topic['poster'])).''; if ($cur_topic['moved_to'] != null) { $forum_page['item_status']['moved'] = 'moved'; $forum_page['item_title']['link'] = ''.sprintf($lang_forum['Item status'], $lang_forum['Moved']).' '.forum_htmlencode($cur_topic['subject']).''; // Combine everything to produce the Topic heading $forum_page['item_body']['subject']['title'] = '

'.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).''.$forum_page['item_title']['link'].'

'; ($hook = get_hook('vf_topic_loop_moved_topic_pre_item_subject_merge')) ? eval($hook) : null; $forum_page['item_body']['info']['replies'] = '
  • '.$lang_forum['No replies info'].'
  • '; if ($forum_config['o_topic_views'] == '1') $forum_page['item_body']['info']['views'] = '
  • '.$lang_forum['No views info'].'
  • '; $forum_page['item_body']['info']['lastpost'] = '
  • '.$lang_forum['No lastpost info'].'
  • '; } else { // Assemble the Topic heading // Should we display the dot or not? :) if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_topic['has_posted'] > 0) { $forum_page['item_title']['posted'] = ''.$lang_forum['You posted indicator'].''; $forum_page['item_status']['posted'] = 'posted'; } if ($cur_topic['sticky'] == '1') { $forum_page['item_title_status']['sticky'] = ''.$lang_forum['Sticky'].''; $forum_page['item_status']['sticky'] = 'sticky'; } if ($cur_topic['closed'] == '1') { $forum_page['item_title_status']['closed'] = ''.$lang_forum['Closed'].''; $forum_page['item_status']['closed'] = 'closed'; } ($hook = get_hook('vf_topic_loop_normal_topic_pre_item_title_status_merge')) ? eval($hook) : null; if (!empty($forum_page['item_title_status'])) $forum_page['item_title']['status'] = ''.sprintf($lang_forum['Item status'], implode(', ', $forum_page['item_title_status'])).''; $forum_page['item_title']['link'] = ''.forum_htmlencode($cur_topic['subject']).''; ($hook = get_hook('vf_topic_loop_normal_topic_pre_item_title_merge')) ? eval($hook) : null; $forum_page['item_body']['subject']['title'] = '

    '.forum_number_format($forum_page['start_from'] + $forum_page['item_count']).' '.implode(' ', $forum_page['item_title']).'

    '; if (empty($forum_page['item_status'])) $forum_page['item_status']['normal'] = 'normal'; $forum_page['item_pages'] = ceil(($cur_topic['num_replies'] + 1) / $forum_user['disp_posts']); if ($forum_page['item_pages'] > 1) $forum_page['item_nav']['pages'] = ''.$lang_forum['Pages'].' '.paginate($forum_page['item_pages'], -1, $forum_url['topic'], $lang_common['Page separator'], array($cur_topic['id'], sef_friendly($cur_topic['subject']))); // Does this topic contain posts we haven't read? If so, tag it accordingly. if (!$forum_user['is_guest'] && $cur_topic['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post']) && (!isset($tracked_topics['forums'][$id]) || $tracked_topics['forums'][$id] < $cur_topic['last_post'])) { $forum_page['item_nav']['new'] = ''.$lang_forum['New posts'].''; $forum_page['item_status']['new'] = 'new'; } ($hook = get_hook('vf_topic_loop_normal_topic_pre_item_nav_merge')) ? eval($hook) : null; if (!empty($forum_page['item_nav'])) $forum_page['item_subject']['nav'] = ''.sprintf($lang_forum['Topic navigation'], implode('  ', $forum_page['item_nav'])).''; // Assemble the Topic subject $forum_page['item_body']['info']['replies'] = '
  • '.forum_number_format($cur_topic['num_replies']).' '.(($cur_topic['num_replies'] == 1) ? $lang_forum['reply'] : $lang_forum['replies']).'
  • '; if ($forum_config['o_topic_views'] == '1') $forum_page['item_body']['info']['views'] = '
  • '.forum_number_format($cur_topic['num_views']).' '.(($cur_topic['num_views'] == 1) ? $lang_forum['view'] : $lang_forum['views']).'
  • '; $forum_page['item_body']['info']['lastpost'] = '
  • '.$lang_forum['Last post'].' '.format_time($cur_topic['last_post']).' '.sprintf($lang_forum['by poster'], forum_htmlencode($cur_topic['last_poster'])).'
  • '; } ($hook = get_hook('vf_row_pre_item_subject_merge')) ? eval($hook) : null; $forum_page['item_body']['subject']['desc'] = '

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

    '; ($hook = get_hook('vf_row_pre_item_status_merge')) ? eval($hook) : null; $forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? ' odd' : ' even').(($forum_page['item_count'] == 1) ? ' main-first-item' : '').((!empty($forum_page['item_status'])) ? ' '.implode(' ', $forum_page['item_status']) : ''); ($hook = get_hook('vf_row_pre_display')) ? eval($hook) : null; ?>
    '.implode(' ', $forum_page['main_foot_options']).'

    '; ?>

    '.$lang_forum['No topics'].''; $forum_page['item_body']['subject']['desc'] = '

    '.$lang_forum['First topic nag'].'

    '; ($hook = get_hook('vf_no_results_row_pre_display')) ? eval($hook) : null; ?>

    ', $tpl_temp, $tpl_main); ob_end_clean(); // END SUBST - $forum_id = $id; require FORUM_ROOT.'footer.php';