diff options
-rw-r--r-- | phpBB/index.php | 23 | ||||
-rw-r--r-- | phpBB/posting.php | 80 | ||||
-rw-r--r-- | phpBB/search.php | 170 | ||||
-rw-r--r-- | phpBB/viewforum.php | 31 | ||||
-rw-r--r-- | phpBB/viewtopic.php | 196 |
5 files changed, 302 insertions, 198 deletions
diff --git a/phpBB/index.php b/phpBB/index.php index 6854545463..995cef6838 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -27,7 +27,7 @@ include($phpbb_root_path . 'common.'.$phpEx); // // Start session management // -$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); +$userdata = session_pagestart($user_ip, PAGE_INDEX, $board_config['session_length']); init_userprefs($userdata); // // End session management @@ -84,6 +84,11 @@ if( $mark_read == "forums" ) // End handle marking posts // + +$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : ""; +$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : ""; + + // // If you don't use these stats on your index // you may want to consider removing them since @@ -226,9 +231,9 @@ if($total_categories = $db->sql_numrows($q_categories)) $sql = "SELECT aa.forum_id, g.group_name, g.group_id, g.group_single_user, u.user_id, u.username FROM " . AUTH_ACCESS_TABLE . " aa, " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g, " . USERS_TABLE . " u WHERE aa.auth_mod = " . TRUE . " - AND ug.group_id = aa.group_id - AND g.group_id = aa.group_id - AND u.user_id = ug.user_id + AND ug.group_id = aa.group_id + AND g.group_id = aa.group_id + AND u.user_id = ug.user_id ORDER BY aa.forum_id, g.group_id, u.user_id"; if(!$q_forum_mods = $db->sql_query($sql)) { @@ -322,7 +327,7 @@ if($total_categories = $db->sql_numrows($q_categories)) while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) ) { - if( !isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$check_topic_id"]) ) + if( empty($tracking_topics['' . $check_topic_id . '']) ) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); @@ -330,7 +335,7 @@ if($total_categories = $db->sql_numrows($q_categories)) } else { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$check_topic_id"] < $check_post_time ) + if( $tracking_topics['' . $check_topic_id . ''] < $check_post_time ) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); @@ -338,9 +343,9 @@ if($total_categories = $db->sql_numrows($q_categories)) } } - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ) + if( !empty($tracking_forums['' . $forum_id . '']) ) { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $forum_last_post_time ) + if( $tracking_forums['' . $forum_id . ''] > $forum_last_post_time ) { $unread_topics = false; } @@ -473,4 +478,4 @@ $template->pparse("body"); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -?> +?>
\ No newline at end of file diff --git a/phpBB/posting.php b/phpBB/posting.php index 11f4075520..2de9922fbe 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -34,7 +34,7 @@ include($phpbb_root_path . 'includes/search.'.$phpEx); function topic_review($topic_id, $is_inline_review) { global $db, $board_config, $template, $lang, $images, $theme, $phpEx; - global $userdata, $session_length, $user_ip; + global $userdata, $user_ip; global $orig_word, $replacement_word; global $starttime; @@ -68,7 +68,7 @@ function topic_review($topic_id, $is_inline_review) // // Start session management // - $userdata = session_pagestart($user_ip, $forum_id, $session_length); + $userdata = session_pagestart($user_ip, $forum_id, $board_config['session_length']); init_userprefs($userdata); // // End session management @@ -216,11 +216,14 @@ function topic_review($topic_id, $is_inline_review) include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } } - // // End page specific functions // --------------------------- + + + + // ------------------------------------------- // Do some initial checks, set basic variables, // etc. @@ -313,14 +316,9 @@ if( $cancel ) // Continue var definitions // -// -// Start session management -// -$userdata = session_pagestart($user_ip, PAGE_POSTING, $session_length); -init_userprefs($userdata); -// -// End session management -// + + + // // If the mode is set to topic review then output @@ -337,6 +335,20 @@ else if( $mode == "smilies" ) exit; } + + + +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_POSTING, $board_config['session_length']); +init_userprefs($userdata); +// +// End session management +// + + + // // Set toggles for various options // @@ -369,6 +381,13 @@ else $attach_sig = ( $submit || $refresh ) ? ( ( !empty($HTTP_POST_VARS['attach_sig']) ) ? TRUE : 0 ) : ( ( $userdata['user_id'] == ANONYMOUS ) ? 0 : $userdata['user_attachsig'] ); + + + + + + + // // Here we do various lookups to find topic_id, forum_id, post_id etc. // Doing it here prevents spoofing (eg. faking forum_id, topic_id or post_id @@ -828,6 +847,7 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) // Flood control // $where_sql = ( $userdata['user_id'] == ANONYMOUS ) ? "poster_ip = '$user_ip'" : "poster_id = " . $userdata['user_id']; + $sql = "SELECT MAX(post_time) AS last_post_time FROM " . POSTS_TABLE . " WHERE $where_sql"; @@ -835,11 +855,12 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) { $db_row = $db->sql_fetchrow($result); - $last_post_time = $db_row['last_post_time']; - - if( ($current_time - $last_post_time) < $board_config['flood_interval'] ) + if( $last_post_time = $db_row['last_post_time'] ) { - message_die(GENERAL_MESSAGE, $lang['Flood_Error']); + if( ($current_time - $last_post_time) < $board_config['flood_interval'] ) + { + message_die(GENERAL_MESSAGE, $lang['Flood_Error']); + } } } // @@ -850,16 +871,14 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) { $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('" . str_replace("\'", "''", $post_subject) . "', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)"; - - if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) ) - { - $new_topic_id = $db->sql_nextid(); - } - else + $result = $db->sql_query($sql, BEGIN_TRANSACTION); + if( !$result ) { message_die(GENERAL_ERROR, "Error inserting data into topics table", "", __LINE__, __FILE__, $sql); } + $new_topic_id = $db->sql_nextid(); + // // Handle poll ... // @@ -951,7 +970,7 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) if( $db->sql_query($sql, END_TRANSACTION)) { - add_search_words($new_post_id, stripslashes($post_message)); + add_search_words($new_post_id, stripslashes($post_message), stripslashes($post_subject)); // // Email users who are watching this topic @@ -1088,6 +1107,18 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) } } + $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array(); + + if( count($tracking_topics) == 150 && empty($tracking_topics['' . $new_topic_id . '']) ) + { + asort($tracking_topics); + unset($tracking_topics[key($tracking_topics)]); + } + + $tracking_topics['' . $new_topic_id . ''] = time(); + + setcookie($board_config['cookie_name'] . "_t", serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + // // If we get here the post has been inserted successfully. // @@ -1556,7 +1587,7 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) { if( $db->sql_query($sql) ) { - add_search_words($post_id, stripslashes($post_message)); + add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject)); remove_unmatched_words(); // @@ -1680,7 +1711,7 @@ if( ( $submit || $confirm || $mode == "delete" ) && !$error ) } else { - add_search_words($post_id, stripslashes($post_message)); + add_search_words($post_id, stripslashes($post_message), stripslashes($post_subject)); remove_unmatched_words(); if( $db->sql_query($sql, END_TRANSACTION) ) @@ -2140,6 +2171,7 @@ $template->assign_var_from_handle("JUMPBOX", "jumpbox"); $template->assign_vars(array( "FORUM_NAME" => $forum_name, "L_POST_A" => $page_title, + "L_POST_SUBJECT" => $lang['Post_subject'], "U_VIEW_FORUM" => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")) ); diff --git a/phpBB/search.php b/phpBB/search.php index ba03b967df..4e88347bc6 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -29,7 +29,7 @@ include($phpbb_root_path . 'includes/search.'.$phpEx); // // Start session management // -$userdata = session_pagestart($user_ip, PAGE_SEARCH, $session_length); +$userdata = session_pagestart($user_ip, PAGE_SEARCH, $board_config['session_length']); init_userprefs($userdata); // // End session management @@ -80,6 +80,19 @@ else $search_all_terms = 0; } +if( isset($HTTP_POST_VARS['searchfields']) ) +{ + $search_msg_title = ( $HTTP_POST_VARS['searchfields'] == "all" ) ? 1 : 0; +} +else if( isset($HTTP_GET_VARS['searchfields']) ) +{ + $search_msg_title = ( $HTTP_GET_VARS['searchfields'] == "all" ) ? 1 : 0; +} +else +{ + $search_msg_title = 0; +} + if( isset($HTTP_POST_VARS['charsreqd']) || isset($HTTP_GET_VARS['charsreqd']) ) { $return_chars = ( isset($HTTP_POST_VARS['charsreqd']) ) ? intval($HTTP_POST_VARS['charsreqd']) : intval($HTTP_GET_VARS['charsreqd']); @@ -218,7 +231,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $query_author = str_replace("*", "%", trim($query_author)); $sql = "SELECT user_id - FROM ".USERS_TABLE." + FROM " . USERS_TABLE . " WHERE username LIKE '" . str_replace("\'", "''", $query_author) . "'"; $result = $db->sql_query($sql); if( !$result ) @@ -336,6 +349,8 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $split_search = array(); $split_search = split_words($cleaned_search); + $search_msg_only = ( !$search_msg_title ) ? "AND m.title_match = 0" : ""; + $word_count = 0; $word_match = array(); $result_list = array(); @@ -367,7 +382,9 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $sql = "SELECT m.post_id FROM " . SEARCH_WORD_TABLE . " w, " . SEARCH_MATCH_TABLE . " m WHERE w.word_text LIKE '$match_word' - AND m.word_id = w.word_id"; + AND m.word_id = w.word_id + AND w.word_common <> 1 + $search_msg_only"; $result = $db->sql_query($sql); if( !$result ) { @@ -586,6 +603,11 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $sql .= " ORDER BY " . $sortby_sql[$sortby] . " $sortby_dir"; + // + // Throw in a limit of 1500 posts/topics ... + // + $sql .= " LIMIT 1500"; + if( !$result = $db->sql_query($sql) ) { message_die(GENERAL_ERROR, "Couldn't obtain search results", "", __LINE__, __FILE__, $sql); @@ -821,6 +843,9 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $highlight_active = urlencode(trim($highlight_active)); + $tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array(); + $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array(); + for($i = 0; $i < min($per_page, count($searchset)); $i++) { $forum_url = append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=" . $searchset[$i]['forum_id']); @@ -833,6 +858,9 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $message = $searchset[$i]['post_text']; $topic_title = $searchset[$i]['topic_title']; + $forum_id = $searchset[$i]['forum_id']; + $topic_id = $searchset[$i]['topic_id']; + if( $showresults == "posts" ) { if( isset($return_chars) ) @@ -920,6 +948,31 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) } + if( $userdata['session_logged_in'] && $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) + { + if( !empty($tracking_topics['' . $topic_id . '']) && !empty($tracking_forums['' . $forum_id . '']) ) + { + $topic_last_read = ( $tracking_topics['' . $topic_id . ''] > $tracking_forums['' . $forum_id . ''] ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . '']; + } + else if( !empty($tracking_topics['' . $topic_id . '']) || !empty($tracking_forums['' . $forum_id . '']) ) + { + $topic_last_read = ( !empty($tracking_topics['' . $topic_id . '']) ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . '']; + } + + if( $searchset[$i]['post_time'] > $topic_last_read ) + { + $mini_post_img = '<img src="' . $images['icon_minipost_new'] . '" alt="' . $lang['New_post'] . '" title="' . $lang['New_post'] . '" border="0" />'; + } + else + { + $mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" title="' . $lang['Post'] . '" border="0" />'; + } + } + else + { + $mini_post_img = '<img src="' . $images['icon_minipost'] . '" alt="' . $lang['Post'] . '" title="' . $lang['Post'] . '" border="0" />'; + } + $template->assign_block_vars("searchresults", array( "TOPIC_TITLE" => $topic_title, "FORUM_NAME" => $searchset[$i]['forum_name'], @@ -930,6 +983,8 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) "TOPIC_VIEWS" => $searchset[$i]['topic_views'], "MESSAGE" => $message, + "MINI_POST_IMG" => $mini_post_img, + "U_POST" => $post_url, "U_TOPIC" => $topic_url, "U_FORUM" => $forum_url, @@ -965,9 +1020,7 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $topic_type .= $lang['Topic_Poll'] . " "; } - $forum_id = $searchset[$i]['forum_id']; - $topic_id = $searchset[$i]['topic_id']; - + $views = $searchset[$i]['topic_views']; $replies = $searchset[$i]['topic_replies']; if( $replies > $board_config['topics_per_page'] ) @@ -1044,61 +1097,77 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) } } - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) || - isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) || - isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) + if( $userdata['session_logged_in'] ) { - - $unread_topics = true; - - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ) + if( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $topic_rowset[$i]['post_time'] ) + if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) { - $unread_topics = false; - } - } - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ) - { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $topic_rowset[$i]['post_time'] ) - { - $unread_topics = false; + $unread_topics = true; + + if( !empty($tracking_topics['' . $topic_id . '']) ) + { + if( $tracking_topics['' . $topic_id . ''] > $searchset[$i]['post_time'] ) + { + $unread_topics = false; + } + } + + if( !empty($tracking_forums['' . $forum_id . '']) ) + { + if( $tracking_forums['' . $forum_id . ''] > $searchset[$i]['post_time'] ) + { + $unread_topics = false; + } + } + + if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) + { + if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $searchset[$i]['post_time'] ) + { + $unread_topics = false; + } + } + + if( $unread_topics ) + { + $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />"; + + $newest_post_img = "<a href=\"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> "; + } + else + { + $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; + + $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />"; + $newest_post_img = ""; + } + } - } + else if( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) + { + $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />"; - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) - { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"] > $topic_rowset[$i]['post_time'] ) + $newest_post_img = "<a href=\"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> "; + } + else { - $unread_topics = false; + $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; + $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />"; + $newest_post_img = ""; } } - - if( $unread_topics ) - { - $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />"; - - $newest_post_img = "<a href=\"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> "; - } else { - $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; - + $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />"; $newest_post_img = ""; } - } - else if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] ) - { - $folder_image = "<img src=\"$folder_new\" alt=\"" . $lang['New_posts'] . "\" title=\"" . $lang['New_posts'] . "\" />"; - - $newest_post_img = "<a href=\"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> "; - } - else + else { - $folder_alt = ( $topic_rowset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; + $folder_alt = ( $searchset[$i]['topic_status'] == TOPIC_LOCKED ) ? $lang['Topic_locked'] : $lang['No_new_posts']; $folder_image = "<img src=\"$folder\" alt=\"$folder_alt\" title=\"$folder_alt\" border=\"0\" />"; $newest_post_img = ""; } @@ -1108,21 +1177,12 @@ else if( $query_keywords != "" || $query_author != "" || $search_id ) $last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']); - if( $searchset[$i]['id2'] == ANONYMOUS && $searchset[$i]['post_username'] != '' ) - { - $last_post_user = $searchset[$i]['post_username']; - } - else - { - $last_post_user = $searchset[$i]['user2']; - } + $last_post_user = ( $searchset[$i]['id2'] == ANONYMOUS && $searchset[$i]['post_username'] != '' ) ? $searchset[$i]['post_username'] : $searchset[$i]['user2']; $last_post = $last_post_time . "<br />" . $lang['by'] . " "; $last_post .= "<a href=\"" . append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $searchset[$i]['id2']) . "\">" . $last_post_user . "</a> "; $last_post .= "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=" . $searchset[$i]['topic_last_post_id']) . "#" . $searchset[$i]['topic_last_post_id'] . "\"><img src=\"" . $images['icon_latest_reply'] . "\" border=\"0\" alt=\"" . $lang['View_latest_post'] . "\" /></a>"; - $views = $searchset[$i]['topic_views']; - $template->assign_block_vars("searchresults", array( "FORUM_NAME" => $searchset[$i]['forum_name'], "FORUM_ID" => $forum_id, diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 0dac3cad4d..ec28e2463e 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -86,7 +86,7 @@ $forum_row = $db->sql_fetchrow($result); // // Start session management // -$userdata = session_pagestart($user_ip, $forum_id, $session_length); +$userdata = session_pagestart($user_ip, $forum_id, $board_config['session_length']); init_userprefs($userdata); // // End session management @@ -130,9 +130,19 @@ if( $mark_read == "topics" ) { $row = $db->sql_fetchrow($result); + $tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array(); + + if( count($tracking_forums) == 150 && empty($tracking_forums['' . $forum_id . '']) ) + { + asort($tracking_forums); + unset($tracking_forums[key($tracking_forums)]); + } + if( $row['last_post'] > $userdata['user_lastvisit'] ) { - setcookie($board_config['cookie_name'] . "_f_$forum_id", time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + $tracking_forums['' . $forum_id . ''] = time(); + + setcookie($board_config['cookie_name'] . "_f", serialize($tracking_forums), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); } } @@ -148,6 +158,11 @@ if( $mark_read == "topics" ) // End handle marking posts // + +$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : ""; +$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : ""; + + // // Do the forum Prune // @@ -522,24 +537,22 @@ if( $total_topics ) { if( $topic_rowset[$i]['post_time'] > $userdata['user_lastvisit'] ) { - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) || - isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) || - isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) + if( !empty($tracking_topics) || !empty($tracking_forums) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_all"]) ) { $unread_topics = true; - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ) + if( !empty($tracking_topics['' . $topic_id . '']) ) { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $topic_rowset[$i]['post_time'] ) + if( $tracking_topics['' . $topic_id . ''] > $topic_rowset[$i]['post_time'] ) { $unread_topics = false; } } - if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ) + if( !empty($tracking_forums['' . $forum_id . '']) ) { - if( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] > $topic_rowset[$i]['post_time'] ) + if( $tracking_forums['' . $forum_id . ''] > $topic_rowset[$i]['post_time'] ) { $unread_topics = false; } diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 07a9b02bd7..301f50816d 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -176,7 +176,7 @@ $forum_id = $forum_row['forum_id']; // // Start session management // -$userdata = session_pagestart($user_ip, $forum_id, $session_length); +$userdata = session_pagestart($user_ip, $forum_id, $board_config['session_length']); init_userprefs($userdata); // // End session management @@ -362,7 +362,7 @@ else $select_post_days = "<select name=\"postdays\">"; for($i = 0; $i < count($previous_days); $i++) { - $selected = ($post_days == $previous_days[$i]) ? " selected=\"selected\"" : ""; + $selected = ($post_days == $previous_days[$i]) ? ' selected="selected"' : ''; $select_post_days .= "<option value=\"" . $previous_days[$i] . "\"$selected>" . $previous_days_text[$i] . "</option>"; } $select_post_days .= "</select>"; @@ -397,9 +397,9 @@ $select_post_order .= "</select>"; $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id - AND p.poster_id = u.user_id - AND p.post_id = pt.post_id $limit_posts_time + AND pt.post_id = p.post_id + AND u.user_id = p.poster_id ORDER BY p.post_time $post_time_order LIMIT $start, ".$board_config['posts_per_page']; if(!$result = $db->sql_query($sql)) @@ -503,26 +503,37 @@ $post_img = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $images['post_locke $post_alt = ( $forum_row['forum_status'] == FORUM_LOCKED ) ? $lang['Forum_locked'] : $lang['Post_new_topic']; // -// Dump out the page header and load viewtopic body template +// Set a cookie for this topic // -if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) && isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ) +$tracking_topics = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t"]) : array(); +$tracking_forums = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f"]) : array(); + +if( !empty($tracking_topics['' . $topic_id . '']) && !empty($tracking_forums['' . $forum_id . '']) ) { - $topic_last_read = ( $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] > $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"] ) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] : $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]; + $topic_last_read = ( $tracking_topics['' . $topic_id . ''] > $tracking_forums['' . $forum_id . ''] ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . '']; } -else if( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]) ) +else if( !empty($tracking_topics['' . $topic_id . '']) || !empty($tracking_forums['' . $forum_id . '']) ) { - $topic_last_read = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"]) ) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_t_$topic_id"] : $HTTP_COOKIE_VARS[$board_config['cookie_name'] . "_f_$forum_id"]; + $topic_last_read = ( !empty($tracking_topics['' . $topic_id . '']) ) ? $tracking_topics['' . $topic_id . ''] : $tracking_forums['' . $forum_id . '']; } else { $topic_last_read = $userdata['session_last_visit']; } +if( count($tracking_topics) == 150 && empty($tracking_topics['' . $topic_id . '']) ) +{ + asort($tracking_topics); + unset($tracking_topics[key($tracking_topics)]); +} + +$tracking_topics['' . $topic_id . ''] = time(); + +setcookie($board_config['cookie_name'] . "_t", serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); + // -// Set a cookie for this topic +// Dump out the page header and load viewtopic body template // -setcookie($board_config['cookie_name'] . "_t_$topic_id", time(), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']); - // // Load templates // @@ -542,11 +553,72 @@ $template->assign_vars(array( ); $template->assign_var_from_handle("JUMPBOX", "jumpbox"); +// +// Output page header +// +$page_title = $lang['View_topic'] ." - $topic_title"; +include($phpbb_root_path . 'includes/page_header.'.$phpEx); +// +// End header +// + +// +// User authorisation levels output +// +$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . "<br />"; +$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . "<br />"; +$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . "<br />"; +$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . "<br />"; +$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . "<br />"; + +if( $is_auth['auth_mod'] ) +{ + $s_auth_can .= sprintf($lang['Rules_moderate'], '<a href="' . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a>'); + + $topic_mod = '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete") . '"><img src="' . $images['topic_mod_delete'] . '" alt="' . $lang['Delete_topic'] . '" title="' . $lang['Delete_topic'] . '" border="0" /></a> '; + + $topic_mod .= '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move"). '"><img src="' . $images['topic_mod_move'] . '" alt="' . $lang['Move_topic'] . '" title="' . $lang['Move_topic'] . '" border="0" /></a> '; + + $topic_mod .= ( $forum_row['topic_status'] == TOPIC_UNLOCKED ) ? '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock") . '"><img src="' . $images['topic_mod_lock'] . '" alt="' . $lang['Lock_topic'] . '" title="' . $lang['Lock_topic'] . '" border="0" /></a> ' : '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=unlock") . '"><img src="' . $images['topic_mod_unlock'] . '" alt="' . $lang['Unlock_topic'] . '" title="' . $lang['Unlock_topic'] . '" border="0" /></a> '; + + $topic_mod .= '<a href="' . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=split") . '"><img src="' . $images['topic_mod_split'] . '" alt="' . $lang['Split_topic'] . '" title="' . $lang['Split_topic'] . '" border="0" /></a> '; +} + +// +// Topic watch information +// +$s_watching_topic = ""; + +if( $can_watch_topic ) +{ + if( $is_watching_topic ) + { + $s_watching_topic = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start") . '">' . $lang['Stop_watching_topic'] . '</a>'; + $s_watching_topic_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start") . '"><img src="' . $images['Topic_un_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Stop_watching_topic'] . '" border="0"></a>'; + } + else + { + $s_watching_topic = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start") . '">' . $lang['Start_watching_topic'] . '</a>'; + $s_watching_topic_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start") . '"><img src="' . $images['Topic_watch'] . '" alt="' . $lang['Stop_watching_topic'] . '" title="' . $lang['Start_watching_topic'] . '" border="0"></a>'; + } +} + +// +// If we've got a hightlight set pass it on to pagination, +// I get annoyed when I lose my highlight after the first page. +// +$pagination = ( $highlight_active ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start); + +// +// Send vars to template +// $template->assign_vars(array( "FORUM_ID" => $forum_id, "FORUM_NAME" => $forum_name, "TOPIC_ID" => $topic_id, "TOPIC_TITLE" => $topic_title, + "PAGINATION" => $pagination, + "PAGE_NUMBER" => sprintf($lang['Page_of'], ( floor( $start / $board_config['posts_per_page'] ) + 1 ), ceil( $total_replies / $board_config['posts_per_page'] )), "IMG_POST" => $post_img, "IMG_REPLY" => $reply_img, @@ -559,11 +631,20 @@ $template->assign_vars(array( "L_POST_REPLY_TOPIC" => $reply_alt, "L_BACK_TO_TOP" => $lang['Back_to_top'], "L_DISPLAY_POSTS" => $lang['Display_posts'], + "L_LOCK_TOPIC" => $lang['Lock_topic'], + "L_UNLOCK_TOPIC" => $lang['Unlock_topic'], + "L_MOVE_TOPIC" => $lang['Move_topic'], + "L_SPLIT_TOPIC" => $lang['Split_topic'], + "L_DELETE_TOPIC" => $lang['Delete_topic'], + "L_GOTO_PAGE" => $lang['Goto_page'], "S_TOPIC_LINK" => POST_TOPIC_URL, "S_SELECT_POST_DAYS" => $select_post_days, "S_SELECT_POST_ORDER" => $select_post_order, "S_POST_DAYS_ACTION" => append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=" . $topic_id . "&start=$start"), + "S_AUTH_LIST" => $s_auth_can, + "S_TOPIC_ADMIN" => $topic_mod, + "S_WATCH_TOPIC" => $s_watching_topic, "U_VIEW_FORUM" => $view_forum_url, "U_VIEW_OLDER_TOPIC" => $view_prev_topic_url, @@ -573,16 +654,7 @@ $template->assign_vars(array( ); // -// Output page header -// -$page_title = $lang['View_topic'] ." - $topic_title"; -include($phpbb_root_path . 'includes/page_header.'.$phpEx); -// -// End header -// - -// -// Does this topic contain a voting element? +// Does this topic contain a poll? // if( !empty($forum_row['topic_vote']) ) { @@ -1076,86 +1148,8 @@ for($i = 0; $i < $total_posts; $i++) ); } -// -// User authorisation levels output -// -$s_auth_can = ( ( $is_auth['auth_post'] ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . "<br />"; -$s_auth_can .= ( ( $is_auth['auth_reply'] ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . "<br />"; -$s_auth_can .= ( ( $is_auth['auth_edit'] ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . "<br />"; -$s_auth_can .= ( ( $is_auth['auth_delete'] ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . "<br />"; -$s_auth_can .= ( ( $is_auth['auth_vote'] ) ? $lang['Rules_vote_can'] : $lang['Rules_vote_cannot'] ) . "<br />"; - -if( $is_auth['auth_mod'] ) -{ - $s_auth_can .= sprintf($lang['Rules_moderate'], "<a href=\"" . append_sid("modcp.$phpEx?" . POST_FORUM_URL . "=$forum_id") . "\">", "</a>"); - - $topic_mod = "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=delete") . "\"><img src=\"" . $images['topic_mod_delete'] . "\" alt=\"" . $lang['Delete_topic'] . "\" title=\"" . $lang['Delete_topic'] . "\" border=\"0\" /></a> "; - - $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=move"). "\"><img src=\"" . $images['topic_mod_move'] . "\" alt=\"" . $lang['Move_topic'] . "\" title=\"" . $lang['Move_topic'] . "\" border=\"0\" /></a> "; - - if($forum_row['topic_status'] == TOPIC_UNLOCKED) - { - $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=lock") . "\"><img src=\"" . $images['topic_mod_lock'] . "\" alt=\"" . $lang['Lock_topic'] . "\" title=\"" . $lang['Lock_topic'] . "\" border=\"0\" /></a> "; - } - else - { - $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=unlock") . "\"><img src=\"" . $images['topic_mod_unlock'] . "\" alt=\"" . $lang['Unlock_topic'] . "\" title=\"" . $lang['Unlock_topic'] . "\" border=\"0\" /></a> "; - } - $topic_mod .= "<a href=\"" . append_sid("modcp.$phpEx?" . POST_TOPIC_URL . "=$topic_id&mode=split") . "\"><img src=\"" . $images['topic_mod_split'] . "\" alt=\"" . $lang['Split_topic'] . "\" title=\"" . $lang['Split_topic'] . "\" border=\"0\" /></a> "; -} - -// -// Topic watch information -// -if( $can_watch_topic ) -{ - if( $is_watching_topic ) - { - $s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start") . "\">" . $lang['Stop_watching_topic'] . "</a>"; - $s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&unwatch=topic&start=$start") . "\"><img src=\"" . $images['Topic_un_watch'] . "\" alt=\"" . $lang['Stop_watching_topic'] . "\" title=\"" . $lang['Stop_watching_topic'] . "\" border=\"0\"></a>"; - } - else - { - $s_watching_topic = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start") . "\">" . $lang['Start_watching_topic'] . "</a>"; - $s_watching_topic_img = "<a href=\"" . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&watch=topic&start=$start") . "\"><img src=\"" . $images['Topic_watch'] . "\" alt=\"" . $lang['Start_watching_topic'] . "\" title=\"" . $lang['Start_watching_topic'] . "\" border=\"0\"></a>"; - } -} -else -{ - $s_watching_topic = ""; -} - -// -// If we've got a hightlight set pass it on to pagination, I get annoyed when I lose my highlight after the first page. -// -if(isset($HTTP_GET_VARS['highlight'])) -{ - $pagination = generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order&highlight=" . $HTTP_GET_VARS['highlight'], $total_replies, $board_config['posts_per_page'], $start); -} -else -{ - $pagination = generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&postdays=$post_days&postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start); -} - -$template->assign_vars(array( - "PAGINATION" => $pagination, - "PAGE_NUMBER" => sprintf($lang['Page_of'], ( floor( $start / $board_config['posts_per_page'] ) + 1 ), ceil( $total_replies / $board_config['posts_per_page'] )), - - "L_LOCK_TOPIC" => $lang['Lock_topic'], - "L_UNLOCK_TOPIC" => $lang['Unlock_topic'], - "L_MOVE_TOPIC" => $lang['Move_topic'], - "L_SPLIT_TOPIC" => $lang['Split_topic'], - "L_DELETE_TOPIC" => $lang['Delete_topic'], - - "S_AUTH_LIST" => $s_auth_can, - "S_TOPIC_ADMIN" => $topic_mod, - "S_WATCH_TOPIC" => $s_watching_topic, - - "L_GOTO_PAGE" => $lang['Goto_page']) -); - $template->pparse("body"); include($phpbb_root_path . 'includes/page_tail.'.$phpEx); -?> +?>
\ No newline at end of file |