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