2001-02-17 08:37:32 +00:00
|
|
|
<?php
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* -------------------
|
|
|
|
* begin : Saturday, Feb 13, 2001
|
|
|
|
* copyright : (C) 2001 The phpBB Group
|
|
|
|
* email : support@phpbb.com
|
|
|
|
*
|
2001-02-24 14:05:52 +00:00
|
|
|
* $Id$ *
|
2001-02-17 08:37:32 +00:00
|
|
|
*
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
***************************************************************************/
|
2001-02-23 20:34:43 +00:00
|
|
|
include('extension.inc');
|
2001-02-24 00:31:58 +00:00
|
|
|
include('common.'.$phpEx);
|
2001-02-17 08:37:32 +00:00
|
|
|
|
2001-03-09 23:33:06 +00:00
|
|
|
$pagetype = "viewforum";
|
|
|
|
$page_title = "View Forum - $forum_name";
|
|
|
|
|
2001-02-23 23:39:42 +00:00
|
|
|
// Check if the user has acutally sent a forum ID with his/her request
|
|
|
|
// If not give them a nice error page.
|
2001-02-23 20:34:43 +00:00
|
|
|
if(isset($forum_id))
|
|
|
|
{
|
2001-03-05 01:40:39 +00:00
|
|
|
$sql = "SELECT f.forum_type, f.forum_name, f.forum_topics, u.username, u.user_id
|
2001-03-02 06:32:50 +00:00
|
|
|
FROM ".FORUMS_TABLE." f, ".FORUM_MODS_TABLE." fm, ".USERS_TABLE." u
|
2001-03-02 18:19:18 +00:00
|
|
|
WHERE f.forum_id = '$forum_id'
|
|
|
|
AND fm.forum_id = '$forum_id'
|
|
|
|
AND u.user_id = fm.user_id";
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-23 23:39:42 +00:00
|
|
|
error_die($db, "", "You have reached this page in error, please go back and try again");
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die($db, QUERY_ERROR);
|
|
|
|
}
|
2001-02-23 23:39:42 +00:00
|
|
|
|
2001-03-02 18:19:18 +00:00
|
|
|
//
|
|
|
|
// Add checking for private forums here!!
|
|
|
|
//
|
|
|
|
|
|
|
|
|
2001-02-23 23:39:42 +00:00
|
|
|
// If the query dosan't return any rows this isn't a valid forum. Inform the user.
|
|
|
|
if(!$total_rows = $db->sql_numrows($result))
|
|
|
|
{
|
|
|
|
error_die($db, "", "The forum you selected does not exist. Please go back and try again.");
|
|
|
|
}
|
|
|
|
|
2001-02-23 20:34:43 +00:00
|
|
|
$forum_row = $db->sql_fetchrowset($result);
|
|
|
|
if(!$forum_row)
|
|
|
|
{
|
|
|
|
error_die($db, QUERY_ERROR);
|
|
|
|
}
|
2001-02-23 23:39:42 +00:00
|
|
|
|
2001-02-23 20:34:43 +00:00
|
|
|
$forum_name = stripslashes($forum_row[0]["forum_name"]);
|
2001-03-05 01:40:39 +00:00
|
|
|
$topics_count = $forum_row[0]["forum_topics"];
|
2001-03-02 06:32:50 +00:00
|
|
|
for($x = 0; $x < $db->sql_numrows($result); $x++)
|
|
|
|
{
|
|
|
|
if($x > 0)
|
|
|
|
$forum_moderators .= ", ";
|
|
|
|
$forum_moderators .= "<a href=\"profile.$phpEx?mode=viewprofile&user_id=".$forum_row[$x]["user_id"]."\">".$forum_row[$x]["username"]."</a>";
|
|
|
|
}
|
2001-03-09 23:33:06 +00:00
|
|
|
|
|
|
|
include('includes/page_header.'.$phpEx);
|
2001-02-24 14:05:52 +00:00
|
|
|
|
2001-02-23 20:34:43 +00:00
|
|
|
|
|
|
|
if(!isset($start))
|
|
|
|
{
|
|
|
|
$start = 0;
|
|
|
|
}
|
|
|
|
|
2001-03-11 02:31:05 +00:00
|
|
|
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time
|
2001-03-02 18:19:18 +00:00
|
|
|
FROM " . TOPICS_TABLE ." t
|
|
|
|
LEFT JOIN ". USERS_TABLE. " u ON t.topic_poster = u.user_id
|
|
|
|
LEFT JOIN ".POSTS_TABLE." p ON p.post_id = t.topic_last_post_id
|
2001-03-11 02:31:05 +00:00
|
|
|
LEFT JOIN " . USERS_TABLE . " u2 ON p.poster_id = u2.user_id
|
2001-03-02 18:19:18 +00:00
|
|
|
WHERE t.forum_id = '$forum_id'
|
|
|
|
ORDER BY topic_time DESC
|
|
|
|
LIMIT $start, $topics_per_page";
|
2001-02-23 20:34:43 +00:00
|
|
|
if(!$t_result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die($db, QUERY_ERROR);
|
|
|
|
}
|
|
|
|
$total_topics = $db->sql_numrows();
|
|
|
|
|
|
|
|
if($total_topics)
|
|
|
|
{
|
2001-03-05 01:40:39 +00:00
|
|
|
$topic_rowset = $db->sql_fetchrowset($t_result);
|
|
|
|
for($x = 0; $x < $total_topics; $x++)
|
|
|
|
{
|
|
|
|
$topic_title = stripslashes($topic_rowset[$x]["topic_title"]);
|
|
|
|
$topic_id = $topic_rowset[$x]["topic_id"];
|
|
|
|
$replies = $topic_rowset[$x]["topic_replies"];
|
2001-03-12 19:24:23 +00:00
|
|
|
if($replies > $posts_per_page)
|
|
|
|
{
|
|
|
|
$goto_page = " (<img src=\"images/posticon.gif\">$l_gotopage: ";
|
|
|
|
$times = 1;
|
|
|
|
for($i = 0; $i < ($replies + 1); $i += $posts_per_page)
|
|
|
|
{
|
|
|
|
if($times > 4)
|
|
|
|
{
|
|
|
|
if(($i + $posts_per_page) >= ($replies + 1))
|
|
|
|
{
|
|
|
|
$goto_page.=" ... <a href=\"viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i\">$times</a>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($times != 1)
|
|
|
|
{
|
|
|
|
$goto_page.= ", ";
|
|
|
|
}
|
|
|
|
$goto_page.= "<a href=\"viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i\">$times</a>";
|
|
|
|
}
|
|
|
|
$times++;
|
|
|
|
}
|
|
|
|
$goto_page.= ")";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$goto_page = "";
|
|
|
|
}
|
2001-03-11 02:31:05 +00:00
|
|
|
$topic_poster = stripslashes($topic_rowset[$x]["username"]);
|
2001-03-05 01:40:39 +00:00
|
|
|
$views = $topic_rowset[$x]["topic_views"];
|
|
|
|
$last_post_time = date($date_format, $topic_rowset[$x]["post_time"]);
|
2001-03-11 02:31:05 +00:00
|
|
|
$last_post_user = $topic_rowset[$x]["user2"];
|
2001-03-05 01:40:39 +00:00
|
|
|
$folder_img = "<img src=\"images/folder.gif\">";
|
2001-03-17 00:46:26 +00:00
|
|
|
$template->assign_block_vars("topicrow", array("FORUM_ID" => $forum_id,
|
2001-03-12 19:24:23 +00:00
|
|
|
"POST_TOPIC_URL" => POST_TOPIC_URL,
|
2001-03-05 01:40:39 +00:00
|
|
|
"TOPIC_ID" => $topic_id,
|
|
|
|
"FOLDER" => $folder_img,
|
2001-03-11 02:31:05 +00:00
|
|
|
"TOPIC_POSTER" => "<a href=\"profile.$phpEx?mode=viewprofile?user_id=".$topic_rowset[$x]["user_id"]."\">".$topic_poster."</a>",
|
2001-03-12 19:24:23 +00:00
|
|
|
"GOTO_PAGE" => $goto_page,
|
2001-03-05 01:40:39 +00:00
|
|
|
"REPLIES" => $replies,
|
|
|
|
"TOPIC_TITLE" => $topic_title,
|
|
|
|
"VIEWS" => $views,
|
2001-03-11 02:31:05 +00:00
|
|
|
"LAST_POST" => $last_post_time . "<br><a href=\"profile.$phpEx?mode=viewprofile?user_id=".$topic_rowset[$x]["id2"]."\">" . $last_post_user ."</a>"));
|
2001-03-05 01:40:39 +00:00
|
|
|
}
|
2001-03-17 00:46:26 +00:00
|
|
|
|
2001-03-05 01:40:39 +00:00
|
|
|
$count = 1;
|
|
|
|
$next = $start + $topics_per_page;
|
|
|
|
if($topics_count > $topics_per_page)
|
|
|
|
{
|
|
|
|
if($next < $topics_count)
|
|
|
|
{
|
|
|
|
$pagination = "<a href=\"viewforum.$phpEx?forum_id=$forum_id&start=$next\">$l_nextpage</a> | ";
|
|
|
|
}
|
|
|
|
for($x = 0; $x < $topics_count; $x++)
|
|
|
|
{
|
|
|
|
if(!($x % $topics_per_page))
|
|
|
|
{
|
|
|
|
if($x == $start)
|
|
|
|
{
|
|
|
|
$pagination .= "$count";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$pagination .= " <a href=\"viewforum.$phpEx?forum_id=$forum_id&start=$x\">$count</a> ";
|
|
|
|
}
|
|
|
|
$count++;
|
|
|
|
if(!($count % 20))
|
|
|
|
{
|
|
|
|
$pagination .= "<br>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-03-17 00:46:26 +00:00
|
|
|
$template->assign_vars(array("PAGINATION" => $pagination));
|
|
|
|
$template->pparse("body");
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-02-24 14:05:52 +00:00
|
|
|
error_die($db, NO_POSTS);
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 23:33:06 +00:00
|
|
|
include('includes/page_tail.'.$phpEx);
|
2001-02-17 08:37:32 +00:00
|
|
|
|
|
|
|
?>
|