Ну у меня же стоит keep unread flag 2, так вот он поменял кое чего, а как это прикрутить я не в курсе. Вот чего он натворил во viewtopic.php
Код: Выделить всё
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
if ( !isset($topic_id) && !isset($post_id) )
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
//
// Find topic id if user requested a newer
// or older topic
//
if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{
if ( $HTTP_GET_VARS['view'] == 'newest' )
{
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
{
$session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];
if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
{
$session_id = '';
}
if ( $session_id )
{
$sql = "SELECT p.post_id
FROM " . POSTS_TABLE . " p, " . SESSIONS_TABLE . " s, " . USERS_TABLE . " u
WHERE s.session_id = '$session_id'
AND u.user_id = s.session_user_id
AND p.topic_id = $topic_id
AND p.post_time >= u.user_lastvisit
ORDER BY p.post_time ASC
LIMIT 1";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
}
$post_id = $row['post_id'];
if (isset($HTTP_GET_VARS['sid']))
{
redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
}
else
{
redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
}
}
}
redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
//START MOD Keep_unread_2
$mode = ( isset($HTTP_GET_VARS['mode']) ) ? htmlspecialchars( $HTTP_GET_VARS['mode'] ) : '';
if ( !empty($post_id) )
{ //added topic_last_post_id, p.post_time to sql
$sql = "SELECT t.forum_id, t.topic_id, t.topic_last_post_id, p.post_time
FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p
WHERE t.topic_id = p.topic_id
AND t.topic_moved_id = 0
AND p.post_id = $post_id";
}
else if ( !empty($topic_id) )
{
$sql = "SELECT t.forum_id, t.topic_id, t.topic_last_post_id
FROM " . TOPICS_TABLE . " t
WHERE t.topic_moved_id = 0
AND t.topic_id = $topic_id";
}
else
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
}
if ( !$row = $db->sql_fetchrow($result) )
{
message_die(GENERAL_MESSAGE, 'Topic_post_not_exist');
}
$forum_id = $row['forum_id'];
$topic_id = $row['topic_id'];
$post_time = $row['post_time'];
$topic_last_post_id = $row['topic_last_post_id'];
//END MOD Keep_unread_2
//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
//
// End session management
//
//START MOD Keep_unread_2 * Keep topic unread from given post onwards
if ($mode == 'unread')
{
$board_config['tracking_unreads'][$topic_id] = $post_time-1; //testing for ">" only later on
write_cookies($userdata);
$message = $lang['keep_unread_done'] . '<br /><br />' .
sprintf($lang['Click_return_forum'], '<a href="' . append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id") . '">', '</a> ') . '<br /><br />' .
sprintf($lang['Click_return_index'], '<a href="' . append_sid("index.$phpEx") . '">', '</a> ');
message_die(GENERAL_MESSAGE, $message);
}
$topic_last_read = topic_last_read($forum_id, $topic_id);
//END MOD Keep_unread_2
//
// Find topic id if user requested a newer
// or older topic
//
if ( isset($HTTP_GET_VARS['view']) && empty($HTTP_GET_VARS[POST_POST_URL]) )
{
if ( $HTTP_GET_VARS['view'] == 'newest' )
{ // read the first unread post in this topic
$sql = "SELECT p.post_id, t.topic_last_post_id
FROM (" . TOPICS_TABLE . " t
LEFT JOIN " . POSTS_TABLE . " p ON p.topic_id = t.topic_id AND p.post_time > $topic_last_read)
WHERE t.topic_id = $topic_id
AND t.topic_moved_id = 0
ORDER BY p.post_time";
if ( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, 'Could not obtain newer/older topic information', '', __LINE__, __FILE__, $sql);
}
if ( !($row = $db->sql_fetchrow($result)) )
{
message_die(GENERAL_MESSAGE, 'No_new_posts_last_visit');
}
$post_id = empty($row['post_id']) ? $row['topic_last_post_id'] : $row['post_id'];
redirect(append_sid("./viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id", true));
}
#
#-----[ FIND ]------------------------------------------------
#
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$topic_id = intval($row['topic_id']);
}
#
#-----[ REPLACE WITH ]----------------------------------------
#
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain newer/older topic information", '', __LINE__, __FILE__, $sql);
}
if ( $row = $db->sql_fetchrow($result) )
{
$topic_id = intval($row['topic_id']);
//MOD Keep_unread_2
redirect(append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id", true));
}
#
#-----[ FIND ]------------------------------------------------
#
$forum_id = intval($forum_topic_data['forum_id']);
//
// Start session management
//
$userdata = session_pagestart($user_ip, $forum_id);
init_userprefs($userdata);
//
// End session management
//
#
#-----[ REPLACE WITH ]----------------------------------------
#
$forum_id = intval($forum_topic_data['forum_id']);
//MOD Keep_unread_2: session management already done above
#
#-----[ FIND ]------------------------------------------------
#
//
// Set a cookie for this topic
//
if ( $userdata['session_logged_in'] )
{
$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 = ( $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];
}
else
{
$topic_last_read = $userdata['user_lastvisit'];
}
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']);
}
#
#-----[ REPLACE WITH ]----------------------------------------
#
//
// Set a cookie for this topic
//
//START MOD Keep_unread_2 * $topic_last_read is known
//Reached the last post in a topic with unread posts
if ($topic_last_post_id == $postrow[($total_posts-1)]['post_id'])
{
//Read up to time of retrieval of this topic
$board_config['tracking_unreads'][$topic_id] = time();
}
//Reading a page, but not the last one, in a topic with new posts
elseif (isset($board_config['tracking_unreads'][$topic_id]))
{
//Set the highest of current topic_last_read and time of last post on page
$board_config['tracking_unreads'][$topic_id] = max($topic_last_read, $postrow[($total_posts-1)]['post_time']);
}
write_cookies($userdata); //Save
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
//
// Define the little post icon
//
if ( $userdata['session_logged_in'] && $postrow[$i]['post_time'] > $userdata['user_lastvisit'] && $postrow[$i]['post_time'] > $topic_last_read )
{
$mini_post_img = $images['icon_minipost_new'];
$mini_post_alt = $lang['New_post'];
}
else
{
$mini_post_img = $images['icon_minipost'];
$mini_post_alt = $lang['Post'];
}
#
#-----[ REPLACE WITH ]------------------------------------------------
#
//
//START MOD Keep_Unread_2 * Define the little post icon
//
if ( $postrow[$i]['post_time'] > $topic_last_read )
{
$mini_post_img = $images['icon_minipost_new'];
$mini_post_alt = $lang['New_post'];
}
else
{
$mini_post_img = $images['icon_minipost'];
$mini_post_alt = $lang['Post'];
}
//END MOD Keep_unread_2
#
#-----[ FIND ]------------------------------------------------
#
$search = '<a href="' . $temp_url . '">' . $lang['Search_user_posts'] . '</a>';
#
#-----[ AFTER, ADD ]------------------------------------------
#
//START MOD Keep_Unread_2
$temp_url = append_sid("viewtopic.$phpEx?mode=unread&" . POST_POST_URL . '=' . $postrow[$i]['post_id']);
//$keep_unread_img_ms = '<a class="postmenu" onclick="this.blur();" href="' . $temp_url . '" title = "' . $lang['keep_post_unread_explain'] . '">' . $lang['keep_post_unread'] . '</a>';
$keep_unread_img = '<a href="' . $temp_url . '"><img src="' . $images['icon_keep_unread'] . '" title = "' . $lang['keep_post_unread_explain'] . '" border="0" /></a>';
#
#-----[ FIND ]------------------------------------------------
#
'L_MINI_POST_ALT' => $mini_post_alt,
#
#-----[ AFTER, ADD ]------------------------------------------
#
//MOD Keep_Unread_2
'KEEP_UNREAD_IMG' => $keep_unread_img,
//'KEEP_UNREAD_IMG_MS' => $keep_unread_img_ms,
#