Thanks, but now i'm getting this error in easymod
Code: Select all
Critical Error
FIND FAILED: In file [viewtopic.php] could not find:
if (!$topic_id && !$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));
}
MOD script line #1022
Heres the relevant section in the mod installation file:
Code: Select all
#
#-----[ OPEN ]------------------------------------------------
#
viewtopic.php
#
#-----[ FIND ]------------------------------------------------
#
if (!$topic_id && !$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));
}
And the relevant section of my viewtopic.php:
Code: Select all
if (!$topic_id && !$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
AND p.post_draft = 0
ORDER BY p.post_time ASC
LIMIT 1";
// start mod save posts as drafts (and end mod too): added an AND constraint in the foregoing sql definition that post_draft be zero (i.e. that the post not just be a draft)
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));
}
Again, the query above has a reference to the drafts:
Code: Select all
$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
AND p.post_draft = 0
ORDER BY p.post_time ASC