"; exit(); } /* sanitize variable */ $_GET['id'] = stripslashes(strip_tags($_GET['id'])); $_GET['sort'] = stripslashes(strip_tags($_GET['sort'])); if (!array_key_exists('start', $_GET) || $_GET['start'] < 0) { $_GET['start'] = 0; } $forum = getForum($_GET['id']); $category = getCategory($forum->category); if ($category->is_helpdesk) { doHeader('Help Desk'); $sort_style = 'help-activity-most'; } else { doHeader('Forum'); ($_GET['sort'] != NULL) ? $sort_style = $_GET['sort'] : $sort_style = 'modified-new'; } echo "
"; // Only show the sort combo box for normal forums, never for the help desk. if (!$category->is_helpdesk) { echo ""; } echo "\n
"; show_forum_title($forum, NULL, $category->is_helpdesk); echo "

\n"; if ($category->is_helpdesk) { echo "Post a New Question"; } else { echo "Post a New Thread / Question"; } echo "\n

\n
"; show_combo_from_array("sort", $forum_sort_styles, $sort_style); echo "\n
\n
"; // If there are more than the threshold number of threads on the page, only show the // first $n and display links to the rest show_page_nav($forum); if ($category->is_helpdesk) { start_forum_table(array("Question", "Answers"), array(NULL, 50)); } else { start_forum_table(array("Titles", "Replies", "Author", "Views", "Last Post"), array(NULL, 50, 150, 50, 170)); } $threads = getThreads($forum->id, $_GET['start'], $n, $sort_style); while($thread = mysql_fetch_object($threads)) { $user = lookup_user_id($thread->owner); $first_post = getFirstPost($thread->id); $excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true); echo " id, "\">", stripslashes($thread->title), "
"; if ($category->is_helpdesk) { echo "", stripslashes($excerpt), ""; } echo ""; if ($category->is_helpdesk) { echo "", $thread->replies, ""; } else { echo " ", $thread->replies, " owner, "\">", $user->name, " ", $thread->views, " ", pretty_time_str($thread->timestamp), " "; } echo ""; } end_forum_table(); if ($forum->threads > $n) { echo $gotoStr; } doFooter(); function show_page_nav($forum) { global $n; if ($forum->threads > $n) { $totalPages = floor($forum->threads / $n); $curPage = floor($_GET['start'] / $n); $pages = array(0, 1, 2); for ($i = -1 ; $i <= 1 ; $i++) if ($curPage + $i > 0 && $curPage + $i < $totalPages - 1) array_push($pages, $curPage + $i); for ($i = -3 ; $i <= -1 ; $i++) if ($totalPages + $i > 0) array_push($pages, $totalPages + $i); $pages = array_unique($pages); natsort($pages); $pages = array_values($pages); $gotoStr = '

Goto page '; if ($curPage == 0) $gotoStr .= '1'; else $gotoStr .= 'Previous 1'; for ($i = 1 ; $i < count($pages)-1 ; $i++) { if ($curPage == $pages[$i]) { $gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... '; $gotoStr .= ''.($pages[$i]+1).''; } else { $gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... '; $gotoStr .= ''.($pages[$i]+1).''; } } if ($curPage == $totalPages-1) $gotoStr .= ', '.$totalPages.''; else $gotoStr .= ', '.$totalPages.' Next'; $gotoStr .= '

'; echo $gotoStr; } } ?>