PageRenderTime 65ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/doweneed/forums/viewforum.php

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