2003-07-18 21:38:51 +00:00
|
|
|
<?php
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once('../inc/forum.inc');
|
|
|
|
require_once('../inc/util.inc');
|
|
|
|
require_once('../inc/time.inc');
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-07-30 00:50:54 +00:00
|
|
|
// Number of forum topics per page.
|
2003-08-14 00:56:20 +00:00
|
|
|
// TODO: Make this a constant.
|
2003-07-18 21:38:51 +00:00
|
|
|
$n = 50;
|
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
if (empty($_GET['id'])) {
|
2003-11-30 21:05:57 +00:00
|
|
|
// TODO: Standard error page
|
|
|
|
echo "Invalid forum ID.<br>";
|
|
|
|
exit();
|
2003-08-14 00:56:20 +00:00
|
|
|
}
|
|
|
|
|
2003-07-18 21:38:51 +00:00
|
|
|
$_GET['id'] = stripslashes(strip_tags($_GET['id']));
|
2003-07-30 00:50:54 +00:00
|
|
|
$_GET['sort'] = stripslashes(strip_tags($_GET['sort']));
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
if (!array_key_exists('start', $_GET) || $_GET['start'] < 0) {
|
2003-11-30 21:05:57 +00:00
|
|
|
$_GET['start'] = 0;
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-01 20:30:25 +00:00
|
|
|
$forum = getForum($_GET['id']);
|
2003-08-13 22:08:12 +00:00
|
|
|
$category = getCategory($forum->category);
|
2003-08-01 20:30:25 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
if ($category->is_helpdesk) {
|
2003-12-08 01:19:49 +00:00
|
|
|
$sort_style = $_GET['sort'];
|
2004-01-19 01:12:53 +00:00
|
|
|
if (!$sort_style) {
|
|
|
|
$sort_style = $_COOKIE['hd_sort_style'];
|
|
|
|
} else {
|
|
|
|
setcookie('hd_sort_style', $sort_style, time()+3600*24*365);
|
|
|
|
}
|
2003-12-21 05:55:48 +00:00
|
|
|
if (!$sort_style) $sort_style = 'activity';
|
2004-01-19 01:12:53 +00:00
|
|
|
page_head('Help Desk');
|
2003-08-01 20:30:25 +00:00
|
|
|
} else {
|
2003-12-08 01:19:49 +00:00
|
|
|
$sort_style = $_GET['sort'];
|
2004-01-19 01:12:53 +00:00
|
|
|
if (!$sort_style) {
|
|
|
|
$sort_style = $_COOKIE['forum_sort_style'];
|
|
|
|
} else {
|
|
|
|
setcookie('forum_sort_style', $sort_style, time()+3600*24*365);
|
|
|
|
}
|
2003-12-08 07:36:43 +00:00
|
|
|
if (!$sort_style) $sort_style = 'modified-new';
|
2004-01-19 01:12:53 +00:00
|
|
|
page_head('Message boards : '.$forum->title);
|
2003-07-30 00:50:54 +00:00
|
|
|
}
|
2003-08-13 22:08:12 +00:00
|
|
|
|
|
|
|
echo "
|
2003-11-30 21:05:57 +00:00
|
|
|
<form action=\"forum.php\" method=\"get\">
|
|
|
|
<input type=\"hidden\" name=\"id\" value=", $forum->id, ">
|
|
|
|
<table width=100% cellspacing=0 cellpadding=0>
|
|
|
|
<tr valign=\"bottom\">
|
|
|
|
<td align=\"left\" style=\"border:0px\">
|
2003-08-13 22:08:12 +00:00
|
|
|
";
|
|
|
|
|
|
|
|
show_forum_title($forum, NULL, $category->is_helpdesk);
|
|
|
|
|
|
|
|
echo "<p>\n<a href=\"post.php?id=", $_GET['id'], "\">";
|
|
|
|
|
|
|
|
if ($category->is_helpdesk) {
|
2003-12-09 06:46:50 +00:00
|
|
|
echo "Submit a question or problem";
|
2003-08-13 22:08:12 +00:00
|
|
|
} else {
|
2003-11-30 21:05:57 +00:00
|
|
|
echo "Create a new thread";
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "</a>\n</p>\n</td>";
|
|
|
|
|
2003-12-08 01:19:49 +00:00
|
|
|
echo "<td align=right>";
|
|
|
|
if ($category->is_helpdesk) {
|
|
|
|
show_select_from_array("sort", $faq_sort_styles, $sort_style);
|
|
|
|
} else {
|
|
|
|
show_select_from_array("sort", $forum_sort_styles, $sort_style);
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
2003-12-08 01:19:49 +00:00
|
|
|
echo "<input type=submit value=OK></td>\n";
|
2003-08-13 22:08:12 +00:00
|
|
|
|
|
|
|
echo "</tr>\n</table>\n</form>";
|
|
|
|
|
2003-11-30 21:05:57 +00:00
|
|
|
// If there are more than the threshold number of threads on the page,
|
|
|
|
// show only the first $n and display links to the rest
|
|
|
|
//
|
2003-08-13 22:08:12 +00:00
|
|
|
show_page_nav($forum);
|
|
|
|
|
|
|
|
if ($category->is_helpdesk) {
|
2003-11-30 21:05:57 +00:00
|
|
|
start_forum_table(array("Question", "Answers"));
|
2003-08-13 22:08:12 +00:00
|
|
|
} else {
|
2003-11-30 21:05:57 +00:00
|
|
|
start_forum_table(array("Threads", "Posts", "Author", "Views", "Last post"));
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
|
|
|
|
2003-08-22 19:07:43 +00:00
|
|
|
// TODO: Move this into its own function?
|
|
|
|
|
2003-08-14 00:56:20 +00:00
|
|
|
$threads = getThreads($forum->id, $_GET['start'], $n, $sort_style);
|
2003-08-22 19:07:43 +00:00
|
|
|
$n = 0;
|
2003-08-13 22:08:12 +00:00
|
|
|
|
2004-04-18 02:10:55 +00:00
|
|
|
while ($thread = mysql_fetch_object($threads)) {
|
2003-11-30 21:05:57 +00:00
|
|
|
$user = lookup_user_id($thread->owner);
|
|
|
|
$first_post = getFirstPost($thread->id);
|
|
|
|
$excerpt = sub_sentence($first_post->content, ' ', EXCERPT_LENGTH, true);
|
|
|
|
echo "
|
2003-12-21 05:55:48 +00:00
|
|
|
<tr class=row$n style=\"font-size:8pt; text-align:center\">
|
2004-04-18 02:10:55 +00:00
|
|
|
<td style=\"font-size:10pt; text-align:left\"><a href=\"thread.php?id=", $thread->id, "\"><b>", strip_tags(stripslashes($thread->title)), "</b></a><br>
|
2003-11-30 21:05:57 +00:00
|
|
|
";
|
|
|
|
$n = ($n+1)%2;
|
|
|
|
|
|
|
|
if ($category->is_helpdesk) {
|
2004-04-18 02:10:55 +00:00
|
|
|
echo strip_tags(stripslashes($excerpt));
|
2003-12-04 22:42:51 +00:00
|
|
|
$na = $thread->sufferers + 1;
|
2003-12-08 01:19:49 +00:00
|
|
|
$x = time_diff_str($first_post->timestamp, time());
|
|
|
|
echo "<br><font size=-2>Asked $x; asked $na times";
|
2003-11-30 21:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo "</td>";
|
2003-12-04 22:42:51 +00:00
|
|
|
$x = time_diff_str($thread->timestamp, time());
|
2003-11-30 21:05:57 +00:00
|
|
|
if ($category->is_helpdesk) {
|
2003-12-08 01:19:49 +00:00
|
|
|
if ($thread->replies == 0) $x = "---";
|
2003-12-03 23:29:22 +00:00
|
|
|
echo "<td align=left>
|
|
|
|
Total: $thread->replies
|
|
|
|
<br>Last: $x
|
|
|
|
</td>
|
|
|
|
";
|
2003-11-30 21:05:57 +00:00
|
|
|
} else {
|
|
|
|
echo "
|
2003-12-18 00:22:25 +00:00
|
|
|
<td>", $thread->replies+1, "</td>
|
|
|
|
<td align=left>", user_links($user, "../"), "</td>
|
2003-11-30 21:05:57 +00:00
|
|
|
<td>", $thread->views, "</td>
|
2003-12-04 22:42:51 +00:00
|
|
|
<td style=\"text-align:right\">", $x, "</td>
|
2003-11-30 21:05:57 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "</tr>";
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
end_forum_table();
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-13 22:08:12 +00:00
|
|
|
if ($forum->threads > $n) {
|
2003-11-30 21:05:57 +00:00
|
|
|
echo $gotoStr;
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
2003-07-18 21:38:51 +00:00
|
|
|
|
2003-08-15 01:01:00 +00:00
|
|
|
page_tail();
|
2003-08-13 22:08:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
function show_page_nav($forum) {
|
2003-11-30 21:05:57 +00:00
|
|
|
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 = '<p style="text-align:right">Go to page ';
|
|
|
|
|
|
|
|
if ($curPage == 0) {
|
|
|
|
$gotoStr .= '<span style="font-size:larger; font-weight:bold">1</span>';
|
|
|
|
} else {
|
|
|
|
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
|
|
|
|
$gotoStr .= '&start='.(($curPage-1)*$n);
|
|
|
|
$gotoStr .= '&sort='.$_GET["sort"];
|
|
|
|
$gotoStr .= '">Previous</a> <a href="forum.php?id='.$_GET['id'].'&start=0">1</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
for ($i = 1 ; $i < count($pages)-1 ; $i++) {
|
|
|
|
if ($curPage == $pages[$i]) {
|
|
|
|
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
|
|
|
|
$gotoStr .= '<span style="font-size:larger; font-weight:bold">'.($pages[$i]+1).'</span>';
|
|
|
|
} else {
|
|
|
|
$gotoStr .= ($i > 0 && $pages[$i-1] == $pages[$i] - 1)?', ':' ... ';
|
|
|
|
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
|
|
|
|
$gotoStr .= '&start='.($pages[$i]*$n);
|
|
|
|
$gotoStr .= '&sort='.$_GET["sort"];
|
|
|
|
$gotoStr .= '">'.($pages[$i]+1).'</a>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($curPage == $totalPages-1) {
|
|
|
|
$gotoStr .= ', <span style="font-size:larger; font-weight:bold">'.$totalPages.'</span>';
|
|
|
|
} else {
|
|
|
|
$gotoStr .= ', <a href="forum.php?id='.$_GET['id'];
|
|
|
|
$gotoStr .= '&start='.(($totalPages-1)*$n);
|
|
|
|
$gotoStr .= '&sort='.$_GET["sort"];
|
|
|
|
$gotoStr .= '">'.$totalPages.'</a> ';
|
|
|
|
$gotoStr .= '<a href="forum.php?id='.$_GET['id'];
|
|
|
|
$gotoStr .= '&start='.(($curPage+1)*$n);
|
|
|
|
$gotoStr .= '&sort='.$_GET["sort"];
|
|
|
|
$gotoStr .= '">Next</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$gotoStr .= '</p>';
|
|
|
|
|
|
|
|
echo $gotoStr;
|
|
|
|
}
|
2003-08-13 22:08:12 +00:00
|
|
|
}
|
2003-11-30 21:05:57 +00:00
|
|
|
?>
|