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

