phpBB
Statistics
| Revision:

root / tags / release_2_0_2 / phpBB / viewforum.php

History | View | Annotate | Download (22.6 kB)

1 2 thefinn
<?php
2 437 thefinn
/***************************************************************************
3 932 psotfx
 *                               viewforum.php
4 437 thefinn
 *                            -------------------
5 437 thefinn
 *   begin                : Saturday, Feb 13, 2001
6 437 thefinn
 *   copyright            : (C) 2001 The phpBB Group
7 437 thefinn
 *   email                : support@phpbb.com
8 437 thefinn
 *
9 265 psotfx
 *   $Id$
10 437 thefinn
 *
11 437 thefinn
 *
12 437 thefinn
 ***************************************************************************/
13 2 thefinn
14 943 thefinn
/***************************************************************************
15 943 thefinn
 *
16 943 thefinn
 *   This program is free software; you can redistribute it and/or modify
17 943 thefinn
 *   it under the terms of the GNU General Public License as published by
18 943 thefinn
 *   the Free Software Foundation; either version 2 of the License, or
19 943 thefinn
 *   (at your option) any later version.
20 943 thefinn
 *
21 943 thefinn
 ***************************************************************************/
22 943 thefinn
23 2305 psotfx
define('IN_PHPBB', true);
24 2384 psotfx
$phpbb_root_path = './';
25 646 psotfx
include($phpbb_root_path . 'extension.inc');
26 646 psotfx
include($phpbb_root_path . 'common.'.$phpEx);
27 2 thefinn
28 143 psotfx
//
29 616 psotfx
// Start initial var setup
30 143 psotfx
//
31 2384 psotfx
if ( isset($HTTP_GET_VARS[POST_FORUM_URL]) || isset($HTTP_POST_VARS[POST_FORUM_URL]) )
32 143 psotfx
{
33 1312 psotfx
        $forum_id = ( isset($HTTP_GET_VARS[POST_FORUM_URL]) ) ? intval($HTTP_GET_VARS[POST_FORUM_URL]) : intval($HTTP_POST_VARS[POST_FORUM_URL]);
34 143 psotfx
}
35 2384 psotfx
else if ( isset($HTTP_GET_VARS['forum']))
36 1778 bartvb
{
37 2503 psotfx
        $forum_id = intval($HTTP_GET_VARS['forum']);
38 1778 bartvb
}
39 143 psotfx
else
40 143 psotfx
{
41 2384 psotfx
        $forum_id = '';
42 143 psotfx
}
43 143 psotfx
44 1312 psotfx
$start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
45 822 psotfx
46 2384 psotfx
if ( isset($HTTP_GET_VARS['mark']) || isset($HTTP_POST_VARS['mark']) )
47 822 psotfx
{
48 822 psotfx
        $mark_read = (isset($HTTP_POST_VARS['mark'])) ? $HTTP_POST_VARS['mark'] : $HTTP_GET_VARS['mark'];
49 822 psotfx
}
50 822 psotfx
else
51 822 psotfx
{
52 2384 psotfx
        $mark_read = '';
53 822 psotfx
}
54 616 psotfx
//
55 616 psotfx
// End initial var setup
56 616 psotfx
//
57 329 psotfx
58 143 psotfx
//
59 237 psotfx
// Check if the user has actually sent a forum ID with his/her request
60 237 psotfx
// If not give them a nice error page.
61 143 psotfx
//
62 2384 psotfx
if ( !empty($forum_id) )
63 34 thefinn
{
64 1093 psotfx
        $sql = "SELECT *
65 877 thefinn
                FROM " . FORUMS_TABLE . "
66 525 psotfx
                WHERE forum_id = $forum_id";
67 2384 psotfx
        if ( !($result = $db->sql_query($sql)) )
68 568 psotfx
        {
69 2384 psotfx
                message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
70 568 psotfx
        }
71 34 thefinn
}
72 437 thefinn
else
73 34 thefinn
{
74 1746 psotfx
        message_die(GENERAL_MESSAGE, 'Forum_not_exist');
75 34 thefinn
}
76 525 psotfx
77 525 psotfx
//
78 616 psotfx
// If the query doesn't return any rows this isn't a valid forum. Inform
79 616 psotfx
// the user.
80 525 psotfx
//
81 2384 psotfx
if ( !($forum_row = $db->sql_fetchrow($result)) )
82 237 psotfx
{
83 1746 psotfx
        message_die(GENERAL_MESSAGE, 'Forum_not_exist');
84 237 psotfx
}
85 281 psotfx
86 76 psotfx
//
87 1746 psotfx
// Start session management
88 1746 psotfx
//
89 1997 psotfx
$userdata = session_pagestart($user_ip, $forum_id);
90 1746 psotfx
init_userprefs($userdata);
91 1746 psotfx
//
92 1746 psotfx
// End session management
93 1746 psotfx
//
94 1746 psotfx
95 1746 psotfx
//
96 305 psotfx
// Start auth check
97 281 psotfx
//
98 1147 psotfx
$is_auth = array();
99 525 psotfx
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
100 329 psotfx
101 2384 psotfx
if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
102 377 psotfx
{
103 2079 psotfx
        if ( !$userdata['session_logged_in'] )
104 2079 psotfx
        {
105 2579 psotfx
                $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
106 2444 the_systech
                $header_location = ( @preg_match("/Microsoft|WebSTAR|Xitami/", getenv("SERVER_SOFTWARE")) ) ? "Refresh: 0; URL=" : "Location: ";
107 2410 psotfx
                header($header_location . append_sid("login.$phpEx?redirect=viewforum.$phpEx&$redirect", true));
108 2575 psotfx
                exit;
109 2079 psotfx
        }
110 377 psotfx
        //
111 559 uid42062
        // The user is not authed to read this forum ...
112 377 psotfx
        //
113 2079 psotfx
        $message = ( !$is_auth['auth_view'] ) ? $lang['Forum_not_exist'] : sprintf($lang['Sorry_auth_read'], $is_auth['auth_read_type']);
114 377 psotfx
115 1435 psotfx
        message_die(GENERAL_MESSAGE, $message);
116 377 psotfx
}
117 281 psotfx
//
118 305 psotfx
// End of auth check
119 281 psotfx
//
120 281 psotfx
121 516 the_systech
//
122 1093 psotfx
// Handle marking posts
123 1093 psotfx
//
124 2384 psotfx
if ( $mark_read == 'topics' )
125 1093 psotfx
{
126 2384 psotfx
        if ( $userdata['session_logged_in'] )
127 1093 psotfx
        {
128 1566 psotfx
                $sql = "SELECT MAX(post_time) AS last_post
129 1566 psotfx
                        FROM " . POSTS_TABLE . "
130 1566 psotfx
                        WHERE forum_id = $forum_id";
131 2384 psotfx
                if ( !($result = $db->sql_query($sql)) )
132 1566 psotfx
                {
133 2384 psotfx
                        message_die(GENERAL_ERROR, 'Could not obtain forums information', '', __LINE__, __FILE__, $sql);
134 1566 psotfx
                }
135 1093 psotfx
136 2384 psotfx
                if ( $row = $db->sql_fetchrow($result) )
137 1566 psotfx
                {
138 2384 psotfx
                        $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();
139 2384 psotfx
                        $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
140 1511 psotfx
141 2384 psotfx
                        if ( ( count($tracking_forums) + count($tracking_topics) ) >= 150 && empty($tracking_forums[$forum_id]) )
142 1851 psotfx
                        {
143 1851 psotfx
                                asort($tracking_forums);
144 1851 psotfx
                                unset($tracking_forums[key($tracking_forums)]);
145 1851 psotfx
                        }
146 1851 psotfx
147 2384 psotfx
                        if ( $row['last_post'] > $userdata['user_lastvisit'] )
148 1566 psotfx
                        {
149 2384 psotfx
                                $tracking_forums[$forum_id] = time();
150 1851 psotfx
151 2384 psotfx
                                setcookie($board_config['cookie_name'] . '_f', serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
152 1566 psotfx
                        }
153 1093 psotfx
                }
154 1566 psotfx
155 1566 psotfx
                $template->assign_vars(array(
156 2384 psotfx
                        'META' => '<meta http-equiv="refresh" content="3;url=' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">')
157 1566 psotfx
                );
158 1511 psotfx
        }
159 1093 psotfx
160 2384 psotfx
        $message = $lang['Topics_marked_read'] . '<br /><br />' . sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ');
161 1511 psotfx
        message_die(GENERAL_MESSAGE, $message);
162 1093 psotfx
}
163 1093 psotfx
//
164 1093 psotfx
// End handle marking posts
165 1093 psotfx
//
166 1093 psotfx
167 2384 psotfx
$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : '';
168 2384 psotfx
$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : '';
169 1851 psotfx
170 1093 psotfx
//
171 516 the_systech
// Do the forum Prune
172 516 the_systech
//
173 2384 psotfx
if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
174 516 the_systech
{
175 2384 psotfx
        if ( $forum_row['prune_next'] < time() && $forum_row['prune_enable'] )
176 516 the_systech
        {
177 1966 psotfx
                include($phpbb_root_path . 'includes/prune.'.$phpEx);
178 2464 psotfx
                require($phpbb_root_path . 'includes/functions_admin.'.$phpEx);
179 516 the_systech
                auto_prune($forum_id);
180 516 the_systech
        }
181 516 the_systech
}
182 516 the_systech
//
183 516 the_systech
// End of forum prune
184 516 the_systech
//
185 516 the_systech
186 525 psotfx
//
187 1962 psotfx
// Obtain list of moderators of each forum
188 1962 psotfx
// First users, then groups ... broken into two queries
189 525 psotfx
//
190 1962 psotfx
$sql = "SELECT u.user_id, u.username
191 1962 psotfx
        FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u
192 1962 psotfx
        WHERE aa.forum_id = $forum_id
193 1962 psotfx
                AND aa.auth_mod = " . TRUE . "
194 1962 psotfx
                AND g.group_single_user = 1
195 1962 psotfx
                AND ug.group_id = aa.group_id
196 1962 psotfx
                AND g.group_id = aa.group_id
197 1962 psotfx
                AND u.user_id = ug.user_id
198 1962 psotfx
        GROUP BY u.user_id, u.username
199 1962 psotfx
        ORDER BY u.user_id";
200 2384 psotfx
if ( !($result = $db->sql_query($sql)) )
201 74 thefinn
{
202 2384 psotfx
        message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
203 525 psotfx
}
204 616 psotfx
205 1962 psotfx
$moderators = array();
206 1962 psotfx
while( $row = $db->sql_fetchrow($result) )
207 525 psotfx
{
208 1962 psotfx
        $moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
209 1962 psotfx
}
210 437 thefinn
211 1962 psotfx
$sql = "SELECT g.group_id, g.group_name
212 1962 psotfx
        FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
213 1962 psotfx
        WHERE aa.forum_id = $forum_id
214 1962 psotfx
                AND aa.auth_mod = " . TRUE . "
215 1962 psotfx
                AND g.group_single_user = 0
216 2156 bartvb
                AND g.group_type <> ". GROUP_HIDDEN ."
217 1962 psotfx
                AND ug.group_id = aa.group_id
218 1962 psotfx
                AND g.group_id = aa.group_id
219 1962 psotfx
        GROUP BY g.group_id, g.group_name
220 1962 psotfx
        ORDER BY g.group_id";
221 2384 psotfx
if ( !($result = $db->sql_query($sql)) )
222 1962 psotfx
{
223 2384 psotfx
        message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
224 74 thefinn
}
225 1962 psotfx
226 1962 psotfx
while( $row = $db->sql_fetchrow($result) )
227 525 psotfx
{
228 1962 psotfx
        $moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
229 525 psotfx
}
230 1962 psotfx
231 1997 psotfx
$l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
232 2384 psotfx
$forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
233 1962 psotfx
unset($moderators);
234 44 psotfx
235 281 psotfx
//
236 770 psotfx
// Generate a 'Show topics in previous x days' select box. If the topicsdays var is sent
237 559 uid42062
// then get it's value, find the number of topics with dates newer than it (to properly
238 559 uid42062
// handle pagination) and alter the main query
239 305 psotfx
//
240 478 psotfx
$previous_days = array(0, 1, 7, 14, 30, 90, 180, 364);
241 1355 psotfx
$previous_days_text = array($lang['All_Topics'], $lang['1_Day'], $lang['7_Days'], $lang['2_Weeks'], $lang['1_Month'], $lang['3_Months'], $lang['6_Months'], $lang['1_Year']);
242 305 psotfx
243 2384 psotfx
if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
244 305 psotfx
{
245 1312 psotfx
        $topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? $HTTP_POST_VARS['topicdays'] : $HTTP_GET_VARS['topicdays'];
246 770 psotfx
        $min_topic_time = time() - ($topic_days * 86400);
247 305 psotfx
248 1511 psotfx
        $sql = "SELECT COUNT(t.topic_id) AS forum_topics
249 1511 psotfx
                FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
250 1511 psotfx
                WHERE t.forum_id = $forum_id
251 877 thefinn
                        AND p.post_id = t.topic_last_post_id
252 1511 psotfx
                        AND p.post_time >= $min_topic_time";
253 305 psotfx
254 2384 psotfx
        if ( !($result = $db->sql_query($sql)) )
255 305 psotfx
        {
256 2384 psotfx
                message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
257 305 psotfx
        }
258 987 psotfx
        $row = $db->sql_fetchrow($result);
259 681 psotfx
260 2587 psotfx
        $topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
261 987 psotfx
        $limit_topics_time = "AND p.post_time >= $min_topic_time";
262 330 psotfx
263 2384 psotfx
        if ( !empty($HTTP_POST_VARS['topicdays']) )
264 330 psotfx
        {
265 330 psotfx
                $start = 0;
266 330 psotfx
        }
267 305 psotfx
}
268 305 psotfx
else
269 305 psotfx
{
270 2462 psotfx
        $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
271 616 psotfx
272 2384 psotfx
        $limit_topics_time = '';
273 770 psotfx
        $topic_days = 0;
274 305 psotfx
}
275 305 psotfx
276 2384 psotfx
$select_topic_days = '<select name="topicdays">';
277 305 psotfx
for($i = 0; $i < count($previous_days); $i++)
278 305 psotfx
{
279 2384 psotfx
        $selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
280 2384 psotfx
        $select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
281 305 psotfx
}
282 2384 psotfx
$select_topic_days .= '</select>';
283 305 psotfx
284 2036 psotfx
285 305 psotfx
//
286 2036 psotfx
// All announcement data, this keeps announcements
287 2036 psotfx
// on each viewforum page ...
288 281 psotfx
//
289 463 thefinn
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_time, p.post_username
290 503 psotfx
        FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . USERS_TABLE . " u2
291 2477 psotfx
        WHERE t.forum_id = $forum_id
292 437 thefinn
                AND t.topic_poster = u.user_id
293 437 thefinn
                AND p.post_id = t.topic_last_post_id
294 437 thefinn
                AND p.poster_id = u2.user_id
295 2036 psotfx
                AND t.topic_type = " . POST_ANNOUNCE . "
296 2036 psotfx
        ORDER BY t.topic_last_post_id DESC ";
297 2384 psotfx
if ( !($result = $db->sql_query($sql)) )
298 34 thefinn
{
299 2384 psotfx
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
300 34 thefinn
}
301 34 thefinn
302 2036 psotfx
$topic_rowset = array();
303 2036 psotfx
$total_announcements = 0;
304 2036 psotfx
while( $row = $db->sql_fetchrow($result) )
305 2036 psotfx
{
306 2036 psotfx
        $topic_rowset[] = $row;
307 2036 psotfx
        $total_announcements++;
308 2036 psotfx
}
309 2036 psotfx
310 2036 psotfx
$db->sql_freeresult($result);
311 2036 psotfx
312 237 psotfx
//
313 2036 psotfx
// Grab all the basic data (all topics except announcements)
314 2036 psotfx
// for this forum
315 822 psotfx
//
316 2036 psotfx
$sql = "SELECT t.*, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time
317 2036 psotfx
        FROM " . TOPICS_TABLE . " t, " . USERS_TABLE . " u, " . POSTS_TABLE . " p, " . POSTS_TABLE . " p2, " . USERS_TABLE . " u2
318 2036 psotfx
        WHERE t.forum_id = $forum_id
319 822 psotfx
                AND t.topic_poster = u.user_id
320 2036 psotfx
                AND p.post_id = t.topic_first_post_id
321 2036 psotfx
                AND p2.post_id = t.topic_last_post_id
322 2036 psotfx
                AND u2.user_id = p2.poster_id
323 2036 psotfx
                AND t.topic_type <> " . POST_ANNOUNCE . "
324 2036 psotfx
                $limit_topics_time
325 2036 psotfx
        ORDER BY t.topic_type DESC, t.topic_last_post_id DESC
326 2036 psotfx
        LIMIT $start, ".$board_config['topics_per_page'];
327 2384 psotfx
if ( !($result = $db->sql_query($sql)) )
328 822 psotfx
{
329 2384 psotfx
   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
330 822 psotfx
}
331 822 psotfx
332 2036 psotfx
$total_topics = 0;
333 2036 psotfx
while( $row = $db->sql_fetchrow($result) )
334 2036 psotfx
{
335 2036 psotfx
        $topic_rowset[] = $row;
336 2036 psotfx
        $total_topics++;
337 2036 psotfx
}
338 2036 psotfx
339 2036 psotfx
$db->sql_freeresult($result);
340 2036 psotfx
341 822 psotfx
//
342 916 psotfx
// Total topics ...
343 916 psotfx
//
344 916 psotfx
$total_topics += $total_announcements;
345 916 psotfx
346 916 psotfx
//
347 887 psotfx
// Define censored word matches
348 887 psotfx
//
349 987 psotfx
$orig_word = array();
350 987 psotfx
$replacement_word = array();
351 987 psotfx
obtain_word_list($orig_word, $replacement_word);
352 887 psotfx
353 887 psotfx
//
354 616 psotfx
// Post URL generation for templating vars
355 237 psotfx
//
356 237 psotfx
$template->assign_vars(array(
357 2384 psotfx
        'L_DISPLAY_TOPICS' => $lang['Display_topics'],
358 672 psotfx
359 2384 psotfx
        'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&amp;" . POST_FORUM_URL . "=$forum_id"),
360 672 psotfx
361 2384 psotfx
        'S_SELECT_TOPIC_DAYS' => $select_topic_days,
362 2384 psotfx
        'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&amp;start=$start"))
363 568 psotfx
);
364 237 psotfx
365 237 psotfx
//
366 666 psotfx
// User authorisation levels output
367 666 psotfx
//
368 2384 psotfx
$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
369 2384 psotfx
$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
370 2384 psotfx
$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
371 2384 psotfx
$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
372 2384 psotfx
$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . '<br />';
373 666 psotfx
374 2384 psotfx
if ( $is_auth['auth_mod'] )
375 666 psotfx
{
376 2384 psotfx
        $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="' . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>');
377 666 psotfx
}
378 666 psotfx
379 2036 psotfx
//
380 2036 psotfx
// Mozilla navigation bar
381 2036 psotfx
//
382 2036 psotfx
$nav_links['up'] = array(
383 2410 psotfx
        'url' => append_sid('index.'.$phpEx),
384 2036 psotfx
        'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
385 2036 psotfx
);
386 2036 psotfx
387 2036 psotfx
//
388 2036 psotfx
// Dump out the page header and load viewforum template
389 2036 psotfx
//
390 2384 psotfx
$page_title = $lang['View_forum'] . ' - ' . $forum_row['forum_name'];
391 2036 psotfx
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
392 2036 psotfx
393 311 psotfx
$template->set_filenames(array(
394 2448 psotfx
        'body' => 'viewforum_body.tpl')
395 311 psotfx
);
396 2448 psotfx
make_jumpbox('viewforum.'.$phpEx);
397 568 psotfx
398 311 psotfx
$template->assign_vars(array(
399 2384 psotfx
        'FORUM_ID' => $forum_id,
400 2384 psotfx
        'FORUM_NAME' => $forum_row['forum_name'],
401 2384 psotfx
        'MODERATORS' => $forum_moderators,
402 2448 psotfx
        'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],
403 666 psotfx
404 2384 psotfx
        'FOLDER_IMG' => $images['folder'],
405 2384 psotfx
        'FOLDER_NEW_IMG' => $images['folder_new'],
406 2384 psotfx
        'FOLDER_HOT_IMG' => $images['folder_hot'],
407 2384 psotfx
        'FOLDER_HOT_NEW_IMG' => $images['folder_hot_new'],
408 2384 psotfx
        'FOLDER_LOCKED_IMG' => $images['folder_locked'],
409 2384 psotfx
        'FOLDER_LOCKED_NEW_IMG' => $images['folder_locked_new'],
410 2384 psotfx
        'FOLDER_STICKY_IMG' => $images['folder_sticky'],
411 2384 psotfx
        'FOLDER_STICKY_NEW_IMG' => $images['folder_sticky_new'],
412 2384 psotfx
        'FOLDER_ANNOUNCE_IMG' => $images['folder_announce'],
413 2384 psotfx
        'FOLDER_ANNOUNCE_NEW_IMG' => $images['folder_announce_new'],
414 1566 psotfx
415 2448 psotfx
        'L_TOPICS' => $lang['Topics'],
416 2448 psotfx
        'L_REPLIES' => $lang['Replies'],
417 2448 psotfx
        'L_VIEWS' => $lang['Views'],
418 2448 psotfx
        'L_POSTS' => $lang['Posts'],
419 2448 psotfx
        'L_LASTPOST' => $lang['Last_Post'],
420 2384 psotfx
        'L_MODERATOR' => $l_moderators,
421 2384 psotfx
        'L_MARK_TOPICS_READ' => $lang['Mark_all_topics'],
422 2384 psotfx
        'L_POST_NEW_TOPIC' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic'],
423 2448 psotfx
        'L_NO_NEW_POSTS' => $lang['No_new_posts'],
424 2448 psotfx
        'L_NEW_POSTS' => $lang['New_posts'],
425 2448 psotfx
        'L_NO_NEW_POSTS_LOCKED' => $lang['No_new_posts_locked'],
426 2448 psotfx
        'L_NEW_POSTS_LOCKED' => $lang['New_posts_locked'],
427 2448 psotfx
        'L_NO_NEW_POSTS_HOT' => $lang['No_new_posts_hot'],
428 2448 psotfx
        'L_NEW_POSTS_HOT' => $lang['New_posts_hot'],
429 2448 psotfx
        'L_ANNOUNCEMENT' => $lang['Post_Announcement'],
430 2448 psotfx
        'L_STICKY' => $lang['Post_Sticky'],
431 2448 psotfx
        'L_POSTED' => $lang['Posted'],
432 2448 psotfx
        'L_JOINED' => $lang['Joined'],
433 2448 psotfx
        'L_AUTHOR' => $lang['Author'],
434 822 psotfx
435 2384 psotfx
        'S_AUTH_LIST' => $s_auth_can,
436 2036 psotfx
437 2384 psotfx
        'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),
438 2161 the_systech
439 2384 psotfx
        'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;mark=topics"))
440 311 psotfx
);
441 237 psotfx
//
442 311 psotfx
// End header
443 311 psotfx
//
444 311 psotfx
445 311 psotfx
//
446 237 psotfx
// Okay, lets dump out the page ...
447 237 psotfx
//
448 1312 psotfx
if( $total_topics )
449 34 thefinn
{
450 616 psotfx
        for($i = 0; $i < $total_topics; $i++)
451 237 psotfx
        {
452 2198 psotfx
                $topic_id = $topic_rowset[$i]['topic_id'];
453 2198 psotfx
454 2036 psotfx
                $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
455 437 thefinn
456 2198 psotfx
                $replies = $topic_rowset[$i]['topic_replies'];
457 2198 psotfx
458 616 psotfx
                $topic_type = $topic_rowset[$i]['topic_type'];
459 437 thefinn
460 1312 psotfx
                if( $topic_type == POST_ANNOUNCE )
461 437 thefinn
                {
462 2384 psotfx
                        $topic_type = $lang['Topic_Announcement'] . ' ';
463 437 thefinn
                }
464 1312 psotfx
                else if( $topic_type == POST_STICKY )
465 437 thefinn
                {
466 2384 psotfx
                        $topic_type = $lang['Topic_Sticky'] . ' ';
467 437 thefinn
                }
468 437 thefinn
                else
469 437 thefinn
                {
470 2384 psotfx
                        $topic_type = '';
471 1259 thefinn
                }
472 437 thefinn
473 1043 psotfx
                if( $topic_rowset[$i]['topic_vote'] )
474 1043 psotfx
                {
475 2384 psotfx
                        $topic_type .= $lang['Topic_Poll'] . ' ';
476 1043 psotfx
                }
477 1215 dougk_ff7
478 1274 psotfx
                if( $topic_rowset[$i]['topic_status'] == TOPIC_MOVED )
479 877 thefinn
                {
480 2384 psotfx
                        $topic_type = $lang['Topic_Moved'] . ' ';
481 877 thefinn
                        $topic_id = $topic_rowset[$i]['topic_moved_id'];
482 1147 psotfx
483 2448 psotfx
                        $folder_image =  $images['folder'];
484 2563 thefinn
                        $folder_alt = $lang['Topics_Moved'];
485 2036 psotfx
                        $newest_post_img = '';
486 877 thefinn
                }
487 616 psotfx
                else
488 616 psotfx
                {
489 1565 bartvb
                        if( $topic_rowset[$i]['topic_type'] == POST_ANNOUNCE )
490 672 psotfx
                        {
491 672 psotfx
                                $folder = $images['folder_announce'];
492 672 psotfx
                                $folder_new = $images['folder_announce_new'];
493 672 psotfx
                        }
494 1247 psotfx
                        else if( $topic_rowset[$i]['topic_type'] == POST_STICKY )
495 672 psotfx
                        {
496 672 psotfx
                                $folder = $images['folder_sticky'];
497 672 psotfx
                                $folder_new = $images['folder_sticky_new'];
498 672 psotfx
                        }
499 1565 bartvb
                        else if( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED )
500 1565 bartvb
                        {
501 1565 bartvb
                                $folder = $images['folder_locked'];
502 1565 bartvb
                                $folder_new = $images['folder_locked_new'];
503 1565 bartvb
                        }
504 672 psotfx
                        else
505 672 psotfx
                        {
506 897 psotfx
                                if($replies >= $board_config['hot_threshold'])
507 897 psotfx
                                {
508 897 psotfx
                                        $folder = $images['folder_hot'];
509 1274 psotfx
                                        $folder_new = $images['folder_hot_new'];
510 897 psotfx
                                }
511 897 psotfx
                                else
512 897 psotfx
                                {
513 897 psotfx
                                        $folder = $images['folder'];
514 897 psotfx
                                        $folder_new = $images['folder_new'];
515 897 psotfx
                                }
516 672 psotfx
                        }
517 672 psotfx
518 2384 psotfx
                        $newest_post_img = '';
519 1566 psotfx
                        if( $userdata['session_logged_in'] )
520 616 psotfx
                        {
521 1606 psotfx
                                if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] )
522 1566 psotfx
                                {
523 2384 psotfx
                                        if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
524 1606 psotfx
                                        {
525 1606 psotfx
                                                $unread_topics = true;
526 1511 psotfx
527 2384 psotfx
                                                if( !empty($tracking_topics[$topic_id]) )
528 1566 psotfx
                                                {
529 2384 psotfx
                                                        if( $tracking_topics[$topic_id] >= $topic_rowset[$i]['post_time'] )
530 1606 psotfx
                                                        {
531 1606 psotfx
                                                                $unread_topics = false;
532 1606 psotfx
                                                        }
533 1566 psotfx
                                                }
534 1111 psotfx
535 2384 psotfx
                                                if( !empty($tracking_forums[$forum_id]) )
536 1566 psotfx
                                                {
537 2384 psotfx
                                                        if( $tracking_forums[$forum_id] >= $topic_rowset[$i]['post_time'] )
538 1606 psotfx
                                                        {
539 1606 psotfx
                                                                $unread_topics = false;
540 1606 psotfx
                                                        }
541 1566 psotfx
                                                }
542 1511 psotfx
543 2384 psotfx
                                                if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all']) )
544 1566 psotfx
                                                {
545 2384 psotfx
                                                        if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f_all'] >= $topic_rowset[$i]['post_time'] )
546 1606 psotfx
                                                        {
547 1606 psotfx
                                                                $unread_topics = false;
548 1606 psotfx
                                                        }
549 1566 psotfx
                                                }
550 1566 psotfx
551 1606 psotfx
                                                if( $unread_topics )
552 1606 psotfx
                                                {
553 2448 psotfx
                                                        $folder_image = $folder_new;
554 2448 psotfx
                                                        $folder_alt = $lang['New_posts'];
555 1566 psotfx
556 2036 psotfx
                                                        $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
557 1606 psotfx
                                                }
558 1606 psotfx
                                                else
559 1606 psotfx
                                                {
560 2448 psotfx
                                                        $folder_image = $folder;
561 1606 psotfx
                                                        $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
562 1606 psotfx
563 2036 psotfx
                                                        $newest_post_img = '';
564 1606 psotfx
                                                }
565 1566 psotfx
                                        }
566 1566 psotfx
                                        else
567 1566 psotfx
                                        {
568 2448 psotfx
                                                $folder_image = $folder_new;
569 2648 dougk_ff7
                                                $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
570 1566 psotfx
571 2036 psotfx
                                                $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=newest") . '"><img src="' . $images['icon_newest_reply'] . '" alt="' . $lang['View_newest_post'] . '" title="' . $lang['View_newest_post'] . '" border="0" /></a> ';
572 1566 psotfx
                                        }
573 744 psotfx
                                }
574 1566 psotfx
                                else
575 744 psotfx
                                {
576 2448 psotfx
                                        $folder_image = $folder;
577 1274 psotfx
                                        $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
578 2448 psotfx
579 2036 psotfx
                                        $newest_post_img = '';
580 744 psotfx
                                }
581 431 psotfx
                        }
582 1566 psotfx
                        else
583 1511 psotfx
                        {
584 2448 psotfx
                                $folder_image = $folder;
585 1511 psotfx
                                $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts'];
586 2448 psotfx
587 2036 psotfx
                                $newest_post_img = '';
588 1511 psotfx
                        }
589 616 psotfx
                }
590 2198 psotfx
591 2198 psotfx
                if( ( $replies + 1 ) > $board_config['posts_per_page'] )
592 2198 psotfx
                {
593 2384 psotfx
                        $total_pages = ceil( ( $replies + 1 ) / $board_config['posts_per_page'] );
594 2198 psotfx
                        $goto_page = ' [ <img src="' . $images['icon_gotopost'] . '" alt="' . $lang['Goto_page'] . '" title="' . $lang['Goto_page'] . '" />' . $lang['Goto_page'] . ': ';
595 2198 psotfx
596 2198 psotfx
                        $times = 1;
597 2198 psotfx
                        for($j = 0; $j < $replies + 1; $j += $board_config['posts_per_page'])
598 2198 psotfx
                        {
599 2198 psotfx
                                $goto_page .= '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&amp;start=$j") . '">' . $times . '</a>';
600 2198 psotfx
                                if( $times == 1 && $total_pages > 4 )
601 2198 psotfx
                                {
602 2198 psotfx
                                        $goto_page .= ' ... ';
603 2198 psotfx
                                        $times = $total_pages - 3;
604 2198 psotfx
                                        $j += ( $total_pages - 4 ) * $board_config['posts_per_page'];
605 2198 psotfx
                                }
606 2198 psotfx
                                else if ( $times < $total_pages )
607 2198 psotfx
                                {
608 2198 psotfx
                                        $goto_page .= ', ';
609 2198 psotfx
                                }
610 2198 psotfx
                                $times++;
611 2198 psotfx
                        }
612 2198 psotfx
                        $goto_page .= ' ] ';
613 2198 psotfx
                }
614 2198 psotfx
                else
615 2198 psotfx
                {
616 2198 psotfx
                        $goto_page = '';
617 2198 psotfx
                }
618 1222 dougk_ff7
619 1222 dougk_ff7
                $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
620 877 thefinn
621 2448 psotfx
                $topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '=' . $topic_rowset[$i]['user_id']) . '">' : '';
622 2448 psotfx
                $topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? $topic_rowset[$i]['username'] : ( ( $topic_rowset[$i]['post_username'] != '' ) ? $topic_rowset[$i]['post_username'] : $lang['Guest'] );
623 237 psotfx
624 2448 psotfx
                $topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
625 2448 psotfx
626 2448 psotfx
                $first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);
627 2448 psotfx
628 1093 psotfx
                $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
629 1093 psotfx
630 2448 psotfx
                $last_post_author = ( $topic_rowset[$i]['id2'] == ANONYMOUS ) ? ( ($topic_rowset[$i]['post_username2'] != '' ) ? $topic_rowset[$i]['post_username2'] . ' ' : $lang['Guest'] . ' ' ) : '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&amp;" . POST_USERS_URL . '='  . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
631 237 psotfx
632 2448 psotfx
                $last_post_url = '<a href="' . append_sid("viewtopic.$phpEx?"  . POST_POST_URL . '=' . $topic_rowset[$i]['topic_last_post_id']) . '#' . $topic_rowset[$i]['topic_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" border="0" /></a>';
633 2448 psotfx
634 616 psotfx
                $views = $topic_rowset[$i]['topic_views'];
635 1425 thefinn
636 1511 psotfx
                $row_color = ( !($i % 2) ) ? $theme['td_color1'] : $theme['td_color2'];
637 1511 psotfx
                $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
638 237 psotfx
639 2448 psotfx
                $template->assign_block_vars('topicrow', array(
640 2448 psotfx
                        'ROW_COLOR' => $row_color,
641 2448 psotfx
                        'ROW_CLASS' => $row_class,
642 2384 psotfx
                        'FORUM_ID' => $forum_id,
643 2384 psotfx
                        'TOPIC_ID' => $topic_id,
644 2448 psotfx
                        'TOPIC_FOLDER_IMG' => $folder_image,
645 2448 psotfx
                        'TOPIC_AUTHOR' => $topic_author,
646 2384 psotfx
                        'GOTO_PAGE' => $goto_page,
647 2384 psotfx
                        'REPLIES' => $replies,
648 2384 psotfx
                        'NEWEST_POST_IMG' => $newest_post_img,
649 2384 psotfx
                        'TOPIC_TITLE' => $topic_title,
650 2384 psotfx
                        'TOPIC_TYPE' => $topic_type,
651 2384 psotfx
                        'VIEWS' => $views,
652 2448 psotfx
                        'FIRST_POST_TIME' => $first_post_time,
653 2448 psotfx
                        'LAST_POST_TIME' => $last_post_time,
654 2448 psotfx
                        'LAST_POST_AUTHOR' => $last_post_author,
655 2448 psotfx
                        'LAST_POST_IMG' => $last_post_url,
656 237 psotfx
657 2448 psotfx
                        'L_TOPIC_FOLDER_ALT' => $folder_alt,
658 2448 psotfx
659 2384 psotfx
                        'U_VIEW_TOPIC' => $view_topic_url)
660 265 psotfx
                );
661 237 psotfx
        }
662 265 psotfx
663 237 psotfx
        $template->assign_vars(array(
664 2384 psotfx
                'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&amp;topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
665 2384 psotfx
                'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
666 388 psotfx
667 2384 psotfx
                'L_GOTO_PAGE' => $lang['Goto_page'])
668 265 psotfx
        );
669 34 thefinn
}
670 34 thefinn
else
671 34 thefinn
{
672 666 psotfx
        //
673 666 psotfx
        // No topics
674 666 psotfx
        //
675 2384 psotfx
        $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
676 877 thefinn
        $template->assign_vars(array(
677 2384 psotfx
                'L_NO_TOPICS' => $no_topics_msg)
678 616 psotfx
        );
679 666 psotfx
680 2448 psotfx
        $template->assign_block_vars('switch_no_topics', array() );
681 720 psotfx
682 34 thefinn
}
683 437 thefinn
684 666 psotfx
//
685 666 psotfx
// Parse the page and print
686 666 psotfx
//
687 2384 psotfx
$template->pparse('body');
688 666 psotfx
689 666 psotfx
//
690 666 psotfx
// Page footer
691 666 psotfx
//
692 646 psotfx
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
693 34 thefinn
694 2444 the_systech
?>