1 rizwank 1.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.9 2002/12/19 17:17:40 psotfx Exp $
10 *
11 *
12 ***************************************************************************/
13
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 ***************************************************************************/
22 rizwank 1.1
23 define('IN_PHPBB', true);
24 $phpbb_root_path = './';
25 include($phpbb_root_path . 'extension.inc');
26 include($phpbb_root_path . 'common.'.$phpEx);
27
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 }
43 rizwank 1.1
44 $start = ( isset($HTTP_GET_VARS['start']) ) ? intval($HTTP_GET_VARS['start']) : 0;
45
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 //
57
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 rizwank 1.1 $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 }
76
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 }
85 rizwank 1.1
86 //
87 // Start session management
88 //
89 $userdata = session_pagestart($user_ip, $forum_id);
90 init_userprefs($userdata);
91 //
92 // End session management
93 //
94
95 //
96 // Start auth check
97 //
98 $is_auth = array();
99 $is_auth = auth(AUTH_ALL, $forum_id, $userdata, $forum_row);
100
101 if ( !$is_auth['auth_read'] || !$is_auth['auth_view'] )
102 {
103 if ( !$userdata['session_logged_in'] )
104 {
105 $redirect = POST_FORUM_URL . "=$forum_id" . ( ( isset($start) ) ? "&start=$start" : '' );
106 rizwank 1.1 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']);
112
113 message_die(GENERAL_MESSAGE, $message);
114 }
115 //
116 // End of auth check
117 //
118
119 //
120 // Handle marking posts
121 //
122 if ( $mark_read == 'topics' )
123 {
124 if ( $userdata['session_logged_in'] )
125 {
126 $sql = "SELECT MAX(post_time) AS last_post
127 rizwank 1.1 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 }
133
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();
138
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 }
144
145 if ( $row['last_post'] > $userdata['user_lastvisit'] )
146 {
147 $tracking_forums[$forum_id] = time();
148 rizwank 1.1
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 }
152
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 }
157
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);
160 }
161 //
162 // End handle marking posts
163 //
164
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']) : '';
167
168 //
169 rizwank 1.1 // Do the forum Prune
170 //
171 if ( $is_auth['auth_mod'] && $board_config['prune_enable'] )
172 {
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 }
179 }
180 //
181 // End of forum prune
182 //
183
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 rizwank 1.1 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)) )
199 {
200 message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
201 }
202
203 $moderators = array();
204 while( $row = $db->sql_fetchrow($result) )
205 {
206 $moderators[] = '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $row['user_id']) . '">' . $row['username'] . '</a>';
207 }
208
209 $sql = "SELECT g.group_id, g.group_name
210 FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
211 rizwank 1.1 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)) )
220 {
221 message_die(GENERAL_ERROR, 'Could not query forum moderator information', '', __LINE__, __FILE__, $sql);
222 }
223
224 while( $row = $db->sql_fetchrow($result) )
225 {
226 $moderators[] = '<a href="' . append_sid("groupcp.$phpEx?" . POST_GROUPS_URL . "=" . $row['group_id']) . '">' . $row['group_name'] . '</a>';
227 }
228
229 $l_moderators = ( count($moderators) == 1 ) ? $lang['Moderator'] : $lang['Moderators'];
230 $forum_moderators = ( count($moderators) ) ? implode(', ', $moderators) : $lang['None'];
231 unset($moderators);
232 rizwank 1.1
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']);
240
241 if ( !empty($HTTP_POST_VARS['topicdays']) || !empty($HTTP_GET_VARS['topicdays']) )
242 {
243 $topic_days = ( !empty($HTTP_POST_VARS['topicdays']) ) ? $HTTP_POST_VARS['topicdays'] : $HTTP_GET_VARS['topicdays'];
244 $min_topic_time = time() - ($topic_days * 86400);
245
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";
251
252 if ( !($result = $db->sql_query($sql)) )
253 rizwank 1.1 {
254 message_die(GENERAL_ERROR, 'Could not obtain limited topics count information', '', __LINE__, __FILE__, $sql);
255 }
256 $row = $db->sql_fetchrow($result);
257
258 $topics_count = ( $row['forum_topics'] ) ? $row['forum_topics'] : 1;
259 $limit_topics_time = "AND p.post_time >= $min_topic_time";
260
261 if ( !empty($HTTP_POST_VARS['topicdays']) )
262 {
263 $start = 0;
264 }
265 }
266 else
267 {
268 $topics_count = ( $forum_row['forum_topics'] ) ? $forum_row['forum_topics'] : 1;
269
270 $limit_topics_time = '';
271 $topic_days = 0;
272 }
273
274 rizwank 1.1 $select_topic_days = '<select name="topicdays">';
275 for($i = 0; $i < count($previous_days); $i++)
276 {
277 $selected = ($topic_days == $previous_days[$i]) ? ' selected="selected"' : '';
278 $select_topic_days .= '<option value="' . $previous_days[$i] . '"' . $selected . '>' . $previous_days_text[$i] . '</option>';
279 }
280 $select_topic_days .= '</select>';
281
282
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 rizwank 1.1 if ( !($result = $db->sql_query($sql)) )
296 {
297 message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
298 }
299
300 $topic_rowset = array();
301 $total_announcements = 0;
302 while( $row = $db->sql_fetchrow($result) )
303 {
304 $topic_rowset[] = $row;
305 $total_announcements++;
306 }
307
308 $db->sql_freeresult($result);
309
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 rizwank 1.1 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)) )
326 {
327 message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
328 }
329
330 $total_topics = 0;
331 while( $row = $db->sql_fetchrow($result) )
332 {
333 $topic_rowset[] = $row;
334 $total_topics++;
335 }
336
337 rizwank 1.1 $db->sql_freeresult($result);
338
339 //
340 // Total topics ...
341 //
342 $total_topics += $total_announcements;
343
344 //
345 // Define censored word matches
346 //
347 $orig_word = array();
348 $replacement_word = array();
349 obtain_word_list($orig_word, $replacement_word);
350
351 //
352 // Post URL generation for templating vars
353 //
354 $template->assign_vars(array(
355 'L_DISPLAY_TOPICS' => $lang['Display_topics'],
356
357 'U_POST_NEW_TOPIC' => append_sid("posting.$phpEx?mode=newtopic&" . POST_FORUM_URL . "=$forum_id"),
358 rizwank 1.1
359 'S_SELECT_TOPIC_DAYS' => $select_topic_days,
360 'S_POST_DAYS_ACTION' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $forum_id . "&start=$start"))
361 );
362
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 />';
371
372 if ( $is_auth['auth_mod'] )
373 {
374 $s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id&sid=" . $userdata['session_id'] . '">', '</a>');
375 }
376
377 //
378 // Mozilla navigation bar
379 rizwank 1.1 //
380 $nav_links['up'] = array(
381 'url' => append_sid('index.'.$phpEx),
382 'title' => sprintf($lang['Forum_Index'], $board_config['sitename'])
383 );
384
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);
391
392 $template->set_filenames(array(
393 'body' => 'viewforum_body.tpl')
394 );
395 make_jumpbox('viewforum.'.$phpEx);
396
397 $template->assign_vars(array(
398 'FORUM_ID' => $forum_id,
399 'FORUM_NAME' => $forum_row['forum_name'],
400 rizwank 1.1 'MODERATORS' => $forum_moderators,
401 'POST_IMG' => ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locked'] : $images['post_new'],
402
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'],
413
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 rizwank 1.1 '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'],
433
434 'S_AUTH_LIST' => $s_auth_can,
435
436 'U_VIEW_FORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL ."=$forum_id"),
437
438 'U_MARK_READ' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&mark=topics"))
439 );
440 //
441 // End header
442 rizwank 1.1 //
443
444 //
445 // Okay, lets dump out the page ...
446 //
447 if( $total_topics )
448 {
449 for($i = 0; $i < $total_topics; $i++)
450 {
451 $topic_id = $topic_rowset[$i]['topic_id'];
452
453 $topic_title = ( count($orig_word) ) ? preg_replace($orig_word, $replacement_word, $topic_rowset[$i]['topic_title']) : $topic_rowset[$i]['topic_title'];
454
455 $replies = $topic_rowset[$i]['topic_replies'];
456
457 $topic_type = $topic_rowset[$i]['topic_type'];
458
459 if( $topic_type == POST_ANNOUNCE )
460 {
461 $topic_type = $lang['Topic_Announcement'] . ' ';
462 }
463 rizwank 1.1 else if( $topic_type == POST_STICKY )
464 {
465 $topic_type = $lang['Topic_Sticky'] . ' ';
466 }
467 else
468 {
469 $topic_type = '';
470 }
471
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'];
481
482 $folder_image = $images['folder'];
483 $folder_alt = $lang['Topics_Moved'];
484 rizwank 1.1 $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 rizwank 1.1 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 }
516
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;
525
526 rizwank 1.1 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 }
533
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 }
541
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 rizwank 1.1 }
548 }
549
550 if( $unread_topics )
551 {
552 $folder_image = $folder_new;
553 $folder_alt = $lang['New_posts'];
554
555 $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&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'];
561
562 $newest_post_img = '';
563 }
564 }
565 else
566 {
567 $folder_image = $folder_new;
568 rizwank 1.1 $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['New_posts'];
569
570 $newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&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'];
577
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'];
585
586 $newest_post_img = '';
587 }
588 }
589 rizwank 1.1
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'] . ': ';
594
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 . "&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 rizwank 1.1 }
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");
619
620 $topic_author = ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '<a href="' . append_sid("profile.$phpEx?mode=viewprofile&" . 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'] );
622
623 $topic_author .= ( $topic_rowset[$i]['user_id'] != ANONYMOUS ) ? '</a>' : '';
624
625 $first_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['topic_time'], $board_config['board_timezone']);
626
627 $last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
628
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&" . POST_USERS_URL . '=' . $topic_rowset[$i]['id2']) . '">' . $topic_rowset[$i]['user2'] . '</a>';
630
631 rizwank 1.1 $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>';
632
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'];
637
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 rizwank 1.1 'LAST_POST_TIME' => $last_post_time,
653 'LAST_POST_AUTHOR' => $last_post_author,
654 'LAST_POST_IMG' => $last_post_url,
655
656 'L_TOPIC_FOLDER_ALT' => $folder_alt,
657
658 'U_VIEW_TOPIC' => $view_topic_url)
659 );
660 }
661
662 $template->assign_vars(array(
663 'PAGINATION' => generate_pagination("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id&topicdays=$topic_days", $topics_count, $board_config['topics_per_page'], $start),
664 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / $board_config['topics_per_page'] ) + 1 ), ceil( $topics_count / $board_config['topics_per_page'] )),
665
666 'L_GOTO_PAGE' => $lang['Goto_page'])
667 );
668 }
669 else
670 {
671 //
672 // No topics
673 rizwank 1.1 //
674 $no_topics_msg = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['No_topics_post_one'];
675 $template->assign_vars(array(
676 'L_NO_TOPICS' => $no_topics_msg)
677 );
678
679 $template->assign_block_vars('switch_no_topics', array() );
680
681 }
682
683 //
684 // Parse the page and print
685 //
686 $template->pparse('body');
687
688 //
689 // Page footer
690 //
691 include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
692
693 ?>
|