Example #1
0
$topic_id = $t_data['topic_id'];
$forum_id = $t_data['forum_id'];
if ($t_data['allow_porno_topic'] && bf($userdata['user_opt'], 'user_opt', 'user_porn_forums')) {
    bb_die($lang['ERROR_PORNO_FORUM']);
}
if ($userdata['session_admin'] && !empty($_REQUEST['mod'])) {
    if (IS_ADMIN) {
        $datastore->enqueue(array('viewtopic_forum_select'));
    }
}
if ($t_data['topic_attachment']) {
    $datastore->enqueue(array('attach_extensions'));
}
// Find newest post
if (($next_topic_id || @$_GET['view'] === 'newest') && !IS_GUEST && $topic_id) {
    $post_time = 'post_time >= ' . get_last_read($topic_id, $forum_id);
    $post_id_altern = $next_topic_id ? '' : ' OR post_id = ' . $t_data['topic_last_post_id'];
    $sql = "SELECT post_id, post_time\n\t\tFROM " . BB_POSTS . "\n\t\tWHERE topic_id = {$topic_id}\n\t\t\tAND ({$post_time} {$post_id_altern})\n\t\tORDER BY post_time ASC\n\t\tLIMIT 1";
    if ($row = DB()->fetch_row($sql)) {
        $post_id = $newest = $row['post_id'];
        $t_data['post_time'] = $row['post_time'];
    }
}
if ($post_id && !empty($t_data['post_time']) && $t_data['topic_replies'] + 1 > $posts_per_page) {
    $sql = "SELECT COUNT(post_id) AS prev_posts\n\t\tFROM " . BB_POSTS . "\n\t\tWHERE topic_id = {$topic_id}\n\t\t\tAND post_time <= {$t_data['post_time']}";
    if ($row = DB()->fetch_row($sql)) {
        $t_data['prev_posts'] = $row['prev_posts'];
    }
}
// Auth check
$is_auth = auth(AUTH_ALL, $forum_id, $userdata, $t_data);
Example #2
0
function is_unread($ref, $topic_id = 0, $forum_id = 0)
{
    return !IS_GUEST && $ref > get_last_read($topic_id, $forum_id);
}