+ | + | + | + + |
---|---|---|---|
+ | + | + | + + |
+ | + | + | + |
+ +
+
+ +
diff -r 5e1f1e916419 -r 98bbc533541c punbb/viewforum.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/punbb/viewforum.php Sun Apr 06 00:28:50 2008 -0400 @@ -0,0 +1,344 @@ + $_ ) +{ + $$key =& $GLOBALS[$key]; +} + +($hook = get_hook('vf_start')) ? eval($hook) : null; + +if ($pun_user['g_read_board'] == '0') + message($lang_common['No view']); + +// Load the viewforum.php language file +require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php'; + + +$id = isset($_GET['id']) ? intval($_GET['id']) : 0; +if ($id < 1) + message($lang_common['Bad request']); + + +// Fetch some info about the forum +$query = array( + 'SELECT' => '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='.$pun_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 = $pun_db->query_build($query) or error(__FILE__, __LINE__); +if (!$pun_db->num_rows($result)) + message($lang_common['Bad request']); + +$cur_forum = $pun_db->fetch_assoc($result); + +// 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 = array(); +if ($cur_forum['moderators'] != '') + $mods_array = unserialize($cur_forum['moderators']); + +$pun_user['is_admmod'] = ($session->user_level >= USER_LEVEL_ADMIN || ($pun_user['g_moderator'] == '1' && array_key_exists($pun_user['username'], $mods_array))) ? true : false; + +// Sort out whether or not this user can post +$pun_user['may_post'] = (($cur_forum['post_topics'] == '' && $pun_user['g_post_topics'] == '1') || $cur_forum['post_topics'] == '1' || $pun_user['is_admmod']) ? true : false; + +// Get topic/forum tracking data +if (!$pun_user['is_guest']) + $tracked_topics = get_tracked_topics(); + +// Determine the topic offset (based on $_GET['p']) +$pun_page['num_pages'] = ceil($cur_forum['num_topics'] / $pun_user['disp_topics']); +$pun_page['page'] = (!isset($_GET['p']) || $_GET['p'] <= 1 || $_GET['p'] > $pun_page['num_pages']) ? 1 : $_GET['p']; +$pun_page['start_from'] = $pun_user['disp_topics'] * ($pun_page['page'] - 1); +$pun_page['finish_at'] = min(($pun_page['start_from'] + $pun_user['disp_topics']), ($cur_forum['num_topics'])); + +// Navigation links for header and page numbering for title/meta description +if ($pun_page['page'] < $pun_page['num_pages']) +{ + $pun_page['nav'][] = ''; + $pun_page['nav'][] = ''; +} +if ($pun_page['page'] > 1) +{ + $pun_page['nav'][] = ''; + $pun_page['nav'][] = ''; +} + + +// 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' => 'sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC', + 'LIMIT' => $pun_page['start_from'].', '.$pun_user['disp_topics'] +); + +// With "has posted" indication +if (!$pun_user['is_guest'] && $pun_config['o_show_dot'] == '1') +{ + $query['SELECT'] .= ', p.poster_id AS has_posted'; + $query['JOINS'][] = array( + 'LEFT JOIN' => 'posts AS p', + 'ON' => 't.id=p.topic_id AND p.poster_id='.$pun_user['id'] + ); + + if ($db_type == 'sqlite') + { + $query['WHERE'] = 't.id IN(SELECT id FROM '.$pun_db->prefix.'topics WHERE forum_id='.$id.' ORDER BY sticky DESC, '.(($cur_forum['sort_by'] == '1') ? 'posted' : 'last_post').' DESC LIMIT '.$pun_page['start_from'].', '.$pun_user['disp_topics'].')'; + $query['ORDER BY'] = 't.sticky DESC, t.last_post DESC'; + } + + $query['GROUP BY'] = ($db_type != 'pgsql') ? 't.id' : 't.id, t.subject, t.poster, 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, p.poster_id'; +} + +($hook = get_hook('vf_qr_get_topics')) ? eval($hook) : null; +$result = $pun_db->query_build($query) or error(__FILE__, __LINE__); + +// Generate page information +if ($pun_page['num_pages'] > 1) + $pun_page['main_info'] = ''.sprintf($lang_common['Page number'], $pun_page['page'], $pun_page['num_pages']).' '.sprintf($lang_common['Paged info'], $lang_common['Topics'], $pun_page['start_from'] + 1, $pun_page['finish_at'], $cur_forum['num_topics']); +else + $pun_page['main_info'] = (($pun_db->num_rows($result)) ? sprintf($lang_common['Page info'], $lang_common['Topics'], $cur_forum['num_topics']) : $lang_forum['No topics']); + +// Generate paging/posting links +$pun_page['page_post'][] = '
'.$lang_common['Pages'].' '.pun_paginate($pun_page['num_pages'], $pun_page['page'], $pun_url['forum'], array($id, sef_friendly($cur_forum['forum_name']))).'
'; + +if ($pun_user['may_post']) + $pun_page['page_post'][] = ''; + +// Setup main head/foot options +$pun_page['main_head_options'] = array( + ''.$lang_common['ATOM Feed'].'', + ''.$lang_common['RSS Feed'].'' +); + +$pun_page['main_foot_options'] = array(); +if ($pun_user['is_guest'] && !$pun_user['may_post']) + $pun_page['main_foot_options'][] = sprintf($lang_forum['Forum login nag'], ''.strtolower($lang_common['Login']).'', ''.strtolower($lang_common['Register']).''); + +if (!$pun_user['is_guest'] && $pun_db->num_rows($result)) +{ + $pun_page['main_foot_options'][] = ''.$lang_forum['Mark forum read'].''; + + if ($pun_user['is_admmod']) + $pun_page['main_foot_options'][] = ''.$lang_forum['Moderate forum'].''; +} + +// Setup breadcrumbs +$pun_page['crumbs'] = array( + array($pun_config['o_board_title'], pun_link($pun_url['index'])), + array($cur_forum['forum_name'], pun_link($pun_url['forum'], array($id, sef_friendly($cur_forum['forum_name'])))) +); + +($hook = get_hook('vf_pre_header_load')) ? eval($hook) : null; + +define('PUN_ALLOW_INDEX', 1); +define('PUN_PAGE', 'viewforum'); +require PUN_ROOT.'header.php'; + +?> ++ | + | + | + + |
---|---|---|---|
+ | + | + | + + |
+ | + | + | + |
+ +