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-05-07 23:04:16 +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-05-03 22:10:23 +00:00
|
|
|
$pagetype = "viewforum";
|
|
|
|
$page_title = "View Forum - $forum_name";
|
|
|
|
|
2001-04-15 14:14:56 +00:00
|
|
|
//
|
|
|
|
// Obtain which forum id is required
|
|
|
|
//
|
|
|
|
if(!isset($HTTP_GET_VARS['forum']) && !isset($HTTP_POST_VARS['forum'])) // For backward compatibility
|
|
|
|
{
|
|
|
|
$forum_id = ($HTTP_GET_VARS[POST_FORUM_URL]) ? $HTTP_GET_VARS[POST_FORUM_URL] : $HTTP_POST_VARS[POST_FORUM_URL];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$forum_id = ($HTTP_GET_VARS['forum']) ? $HTTP_GET_VARS['forum'] : $HTTP_POST_VARS['forum'];
|
|
|
|
}
|
|
|
|
|
2001-05-16 20:07:23 +00:00
|
|
|
//
|
|
|
|
// Start session management
|
|
|
|
//
|
|
|
|
$userdata = session_pagestart($user_ip, $forum_id, $session_length);
|
|
|
|
init_userprefs($userdata);
|
|
|
|
//
|
|
|
|
// End session management
|
|
|
|
//
|
|
|
|
|
2001-04-15 14:14:56 +00:00
|
|
|
//
|
2001-05-03 22:10:23 +00:00
|
|
|
// Check if the user has actually sent a forum ID with his/her request
|
2001-02-23 23:39:42 +00:00
|
|
|
// If not give them a nice error page.
|
2001-05-03 22:10:23 +00:00
|
|
|
//
|
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-05-16 20:07:23 +00:00
|
|
|
WHERE f.forum_id = $forum_id
|
2001-05-13 16:02:30 +00:00
|
|
|
AND fm.forum_id = $forum_id
|
2001-03-02 18:19:18 +00:00
|
|
|
AND u.user_id = fm.user_id";
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(GENERAL_ERROR, "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))
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't obtain forums information.", __LINE__, __FILE__);
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
2001-05-03 22:10:23 +00:00
|
|
|
// If the query doesn't return any rows this
|
|
|
|
// isn't a valid forum. Inform the user.
|
|
|
|
if(!$total_rows = $db->sql_numrows($result))
|
|
|
|
{
|
|
|
|
error_die(GENERAL_ERROR, "The forum you selected does not exist. Please go back and try again.");
|
|
|
|
}
|
2001-02-23 23:39:42 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
|
|
|
|
//
|
2001-05-16 20:07:23 +00:00
|
|
|
// Start auth check
|
2001-05-13 16:02:30 +00:00
|
|
|
//
|
|
|
|
//
|
2001-05-16 20:07:23 +00:00
|
|
|
// End of auth check
|
2001-03-02 18:19:18 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
|
2001-02-23 20:34:43 +00:00
|
|
|
$forum_row = $db->sql_fetchrowset($result);
|
|
|
|
if(!$forum_row)
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't obtain rowset.", __LINE__, __FILE__);
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
2001-02-23 23:39:42 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$forum_name = stripslashes($forum_row[0]['forum_name']);
|
2001-05-16 20:07:23 +00:00
|
|
|
if(empty($HTTP_POST_VARS['postdays']))
|
|
|
|
{
|
|
|
|
$topics_count = $forum_row[0]['forum_topics'];
|
|
|
|
}
|
2001-05-07 23:04:16 +00:00
|
|
|
|
2001-03-02 06:32:50 +00:00
|
|
|
for($x = 0; $x < $db->sql_numrows($result); $x++)
|
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
if($x > 0)
|
|
|
|
$forum_moderators .= ", ";
|
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$forum_moderators .= "<a href=\"".append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$forum_row[$x]['user_id'])."\">".$forum_row[$x]['username']."</a>";
|
2001-03-02 06:32:50 +00:00
|
|
|
}
|
2001-03-09 23:33:06 +00:00
|
|
|
|
2001-05-16 20:07:23 +00:00
|
|
|
//
|
|
|
|
// Check for start
|
|
|
|
//
|
|
|
|
if(!isset($HTTP_GET_VARS['start']))
|
|
|
|
{
|
|
|
|
$start = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$start = $HTTP_GET_VARS['start'];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Generate a 'Show posts in previous x days'
|
|
|
|
// select box. If the postdays var is POSTed
|
|
|
|
// then get it's value, find the number of topics
|
|
|
|
// with dates newer than it (to properly handle
|
|
|
|
// pagination) and alter the main query
|
|
|
|
//
|
|
|
|
$previous_days = array(0, 1, 7, 14, 20, 30, 60, 90, 120);
|
|
|
|
|
|
|
|
if(!empty($HTTP_POST_VARS['postdays']))
|
2001-02-23 20:34:43 +00:00
|
|
|
{
|
2001-05-16 20:07:23 +00:00
|
|
|
|
|
|
|
$min_post_time = time() - ($HTTP_POST_VARS['postdays'] * 86400);
|
|
|
|
|
|
|
|
$sql = "SELECT COUNT(*) AS forum_topics
|
|
|
|
FROM ".TOPICS_TABLE."
|
|
|
|
WHERE forum_id = $forum_id
|
|
|
|
AND topic_time > $min_post_time";
|
|
|
|
|
|
|
|
if(!$result = $db->sql_query($sql))
|
|
|
|
{
|
|
|
|
error_die(SQL_QUERY, "Couldn't obtain limited topics count information.", __LINE__, __FILE__);
|
|
|
|
}
|
|
|
|
$topics_count = $db->sql_numrows($result);
|
|
|
|
|
|
|
|
$limit_posts_time = "AND t.topic_time > $min_post_time ";
|
2001-05-03 22:10:23 +00:00
|
|
|
$start = 0;
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
2001-05-16 20:07:23 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
$limit_posts_time = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$select_post_days .= "<select name=\"postdays\">";
|
|
|
|
for($i = 0; $i < count($previous_days); $i++)
|
|
|
|
{
|
|
|
|
if(isset($HTTP_POST_VARS['postdays']))
|
|
|
|
{
|
|
|
|
$selected = ($HTTP_POST_VARS['postdays'] == $previous_days[$i]) ? " selected" : "";
|
|
|
|
}
|
|
|
|
$select_post_days .= ($previous_days[$i] == 0) ? "<option value=\"0\"$selected>$l_All_posts</option>" : "<option value=\"".$previous_days[$i]."\"$selected>".$previous_days[$i]." $l_Days</option>";
|
|
|
|
}
|
|
|
|
$select_post_days .= "</select>";
|
2001-02-23 20:34:43 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
//
|
|
|
|
// Grab all the basic data for
|
|
|
|
// this forum
|
|
|
|
//
|
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-05-13 16:02:30 +00:00
|
|
|
FROM ".TOPICS_TABLE." t, ".USERS_TABLE." u, ".POSTS_TABLE." p, ".USERS_TABLE." u2
|
|
|
|
WHERE t.forum_id = $forum_id
|
|
|
|
AND t.topic_poster = u.user_id
|
|
|
|
AND p.post_id = t.topic_last_post_id
|
|
|
|
AND p.poster_id = u2.user_id
|
2001-05-16 20:07:23 +00:00
|
|
|
$limit_posts_time
|
2001-03-02 18:19:18 +00:00
|
|
|
ORDER BY topic_time DESC
|
2001-05-03 22:10:23 +00:00
|
|
|
LIMIT $start, ".$board_config['topics_per_page'];
|
2001-02-23 20:34:43 +00:00
|
|
|
if(!$t_result = $db->sql_query($sql))
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(SQL_QUERY, "Couldn't obtain topic information.", __LINE__, __FILE__);
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
2001-05-03 22:10:23 +00:00
|
|
|
$total_topics = $db->sql_numrows($t_result);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Post URL generation for
|
|
|
|
// templating vars
|
|
|
|
//
|
2001-05-06 16:16:22 +00:00
|
|
|
$post_new_topic_url = append_sid("posting.".$phpEx."?mode=newtopic&".POST_FORUM_URL."=$forum_id");
|
2001-05-03 22:10:23 +00:00
|
|
|
$template->assign_vars(array(
|
2001-05-16 20:07:23 +00:00
|
|
|
"U_POST_NEW_TOPIC" => $post_new_topic_url,
|
|
|
|
"S_SELECT_POST_DAYS" => $select_post_days,
|
|
|
|
"S_POST_DAYS_ACTION" => append_sid("viewforum.$phpEx?".POST_FORUM_URL."=".$forum_id."&start=$start")));
|
2001-02-23 20:34:43 +00:00
|
|
|
|
2001-05-03 22:10:23 +00:00
|
|
|
//
|
|
|
|
// Dump out the page header
|
|
|
|
//
|
|
|
|
include('includes/page_header.'.$phpEx);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Okay, lets dump out the page ...
|
|
|
|
//
|
2001-02-23 20:34:43 +00:00
|
|
|
if($total_topics)
|
|
|
|
{
|
2001-05-03 22:10:23 +00:00
|
|
|
$topic_rowset = $db->sql_fetchrowset($t_result);
|
|
|
|
for($x = 0; $x < $total_topics; $x++)
|
|
|
|
{
|
2001-05-13 16:02:30 +00:00
|
|
|
$topic_title = stripslashes($topic_rowset[$x]['topic_title']);
|
|
|
|
$topic_id = $topic_rowset[$x]['topic_id'];
|
|
|
|
$replies = $topic_rowset[$x]['topic_replies'];
|
2001-05-03 22:10:23 +00:00
|
|
|
if($replies > $board_config['posts_per_page'])
|
|
|
|
{
|
|
|
|
$goto_page = " (<img src=\"".$images['posticon']."\">$l_gotopage: ";
|
|
|
|
$times = 1;
|
|
|
|
for($i = 0; $i < ($replies + 1); $i += $board_config['posts_per_page'])
|
|
|
|
{
|
|
|
|
if($times > 4)
|
|
|
|
{
|
|
|
|
if(($i + $board_config['posts_per_page']) >= ($replies + 1))
|
|
|
|
{
|
2001-05-06 16:16:22 +00:00
|
|
|
$goto_page.=" ... <a href=\"".append_sid("viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i")."\">$times</a>";
|
2001-05-03 22:10:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if($times != 1)
|
|
|
|
{
|
|
|
|
$goto_page.= ", ";
|
|
|
|
}
|
2001-05-06 16:16:22 +00:00
|
|
|
$goto_page.= "<a href=\"".append_sid("viewtopic.$phpEx?".POST_TOPIC_URL."=".$topic_id."&start=$i")."\">$times</a>";
|
2001-05-03 22:10:23 +00:00
|
|
|
}
|
|
|
|
$times++;
|
|
|
|
}
|
|
|
|
$goto_page.= ")";
|
|
|
|
}
|
2001-03-12 19:24:23 +00:00
|
|
|
else
|
2001-05-03 22:10:23 +00:00
|
|
|
{
|
|
|
|
$goto_page = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$folder_img = "<img src=\"".$images['folder']."\">";
|
|
|
|
|
2001-05-06 16:16:22 +00:00
|
|
|
$view_topic_url = append_sid("viewtopic.".$phpEx."?".POST_TOPIC_URL."=".$topic_id."&".$replies);
|
2001-05-03 22:10:23 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$topic_poster = stripslashes($topic_rowset[$x]['username']);
|
|
|
|
$topic_poster_profile_url = append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]['user_id']);
|
2001-05-03 22:10:23 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$x]['post_time'], $board_config['default_timezone']);
|
|
|
|
$last_post_user = $topic_rowset[$x]['user2'];
|
|
|
|
$last_post_profile_url = append_sid("profile.$phpEx?mode=viewprofile&".POST_USERS_URL."=".$topic_rowset[$x]['id2']);
|
2001-05-03 22:10:23 +00:00
|
|
|
|
2001-05-13 16:02:30 +00:00
|
|
|
$views = $topic_rowset[$x]['topic_views'];
|
2001-05-03 22:10:23 +00:00
|
|
|
|
|
|
|
$template->assign_block_vars("topicrow", array(
|
|
|
|
"FORUM_ID" => $forum_id,
|
|
|
|
"TOPIC_ID" => $topic_id,
|
|
|
|
"FOLDER" => $folder_img,
|
|
|
|
"TOPIC_POSTER" => $topic_poster,
|
|
|
|
"U_TOPIC_POSTER_PROFILE" => $topic_poster_profile_url,
|
|
|
|
"GOTO_PAGE" => $goto_page,
|
|
|
|
"REPLIES" => $replies,
|
|
|
|
"TOPIC_TITLE" => $topic_title,
|
|
|
|
"VIEWS" => $views,
|
|
|
|
"LAST_POST_TIME" => $last_post_time,
|
|
|
|
"LAST_POST_USER" => $last_post_user,
|
|
|
|
|
|
|
|
"U_VIEW_TOPIC" => $view_topic_url,
|
2001-05-07 23:04:16 +00:00
|
|
|
"U_LAST_POST_USER_PROFILE" => $last_post_profile_url)
|
|
|
|
);
|
2001-05-03 22:10:23 +00:00
|
|
|
}
|
2001-05-07 23:04:16 +00:00
|
|
|
|
2001-05-03 22:10:23 +00:00
|
|
|
$template->assign_vars(array(
|
2001-05-07 23:04:16 +00:00
|
|
|
"PAGINATION" => generate_pagination("viewforum.$phpEx?".POST_FORUM_URL."=$forum_id", $topics_count, $board_config['topics_per_page'], $start))
|
|
|
|
);
|
2001-05-03 22:10:23 +00:00
|
|
|
$template->pparse("body");
|
2001-02-23 20:34:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-15 17:32:12 +00:00
|
|
|
error_die(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
|
|
|
|
2001-04-15 17:32:12 +00:00
|
|
|
?>
|