Esempio n. 1
0
    if (!($result = DB()->sql_query($sql))) {
        bb_die('Could not delete topic watch information #1');
    }
}
$template->assign_vars(array('PAGE_TITLE' => $lang['WATCHED_TOPICS'], 'S_FORM_ACTION' => BB_ROOT . 'profile.php?mode=watch'));
$sql = "SELECT COUNT(topic_id) as watch_count FROM " . BB_TOPICS_WATCH . " WHERE user_id = {$user_id}";
if (!($result = DB()->sql_query($sql))) {
    bb_die('Could not obtain watch topic information #2');
}
$row = DB()->sql_fetchrow($result);
$watch_count = $row['watch_count'] ? $row['watch_count'] : 0;
DB()->sql_freeresult($result);
if ($watch_count > 0) {
    $sql = "SELECT w.*, t.*, f.*, u.*, u2.username as last_username, u2.user_id as last_user_id,\n\t\tu2.user_level as last_user_level, u2.user_rank as last_user_rank\n\tFROM " . BB_TOPICS_WATCH . " w, " . BB_TOPICS . " t, " . BB_USERS . " u, " . BB_FORUMS . " f, " . BB_POSTS . " p, " . BB_USERS . " u2\n\tWHERE w.topic_id = t.topic_id\n\t\tAND t.forum_id = f.forum_id\n\t\tAND p.post_id = t.topic_last_post_id\n\t\tAND p.poster_id = u2.user_id\n\t\tAND t.topic_poster = u.user_id\n\t\tAND w.user_id = {$user_id}\n\tGROUP BY t.topic_last_post_time DESC\n\tLIMIT {$start}, {$per_page}";
    if (!($result = DB()->sql_query($sql))) {
        bb_die('Could not obtain watch topic information #3');
    }
    $watch = DB()->sql_fetchrowset($result);
    if ($watch) {
        for ($i = 0; $i < count($watch); $i++) {
            $is_unread = is_unread($watch[$i]['topic_last_post_time'], $watch[$i]['topic_id'], $watch[$i]['forum_id']);
            $template->assign_block_vars('watch', array('ROW_CLASS' => !($i % 2) ? 'row1' : 'row2', 'POST_ID' => $watch[$i]['topic_first_post_id'], 'TOPIC_ID' => $watch[$i]['topic_id'], 'TOPIC_TITLE' => wbr(str_short($watch[$i]['topic_title'], 70)), 'FULL_TOPIC_TITLE' => wbr($watch[$i]['topic_title']), 'U_TOPIC' => TOPIC_URL . $watch[$i]['topic_id'], 'FORUM_TITLE' => wbr($watch[$i]['forum_name']), 'U_FORUM' => FORUM_URL . $watch[$i]['forum_id'], 'REPLIES' => $watch[$i]['topic_replies'], 'AUTHOR' => profile_url($watch[$i]), 'LAST_POST' => bb_date($watch[$i]['topic_last_post_time']) . '<br />' . profile_url(array('user_id' => $watch[$i]['last_user_id'], 'username' => $watch[$i]['last_username'], 'user_rank' => $watch[$i]['last_user_rank'])), 'LAST_POST_ID' => $watch[$i]['topic_last_post_id'], 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($watch[$i], $is_unread), 'PAGINATION' => $watch[$i]['topic_status'] == TOPIC_MOVED ? '' : build_topic_pagination(TOPIC_URL . $watch[$i]['topic_id'], $watch[$i]['topic_replies'], $bb_cfg['posts_per_page'])));
        }
        $template->assign_vars(array('MATCHES' => count($watch) == 1 ? sprintf($lang['FOUND_SEARCH_MATCH'], count($watch)) : sprintf($lang['FOUND_SEARCH_MATCHES'], count($watch)), 'PAGINATION' => generate_pagination(BB_ROOT . 'profile.php?mode=watch', $watch_count, $per_page, $start), 'PAGE_NUMBER' => sprintf($lang['PAGE_OF'], floor($start / $per_page) + 1, ceil($watch_count / $per_page)), 'U_PER_PAGE' => BB_ROOT . 'profile.php?mode=watch', 'PER_PAGE' => $per_page));
    }
    DB()->sql_freeresult($result);
} else {
    meta_refresh('index.php', 3);
    bb_die($lang['NO_WATCHED_TOPICS']);
}
print_page('usercp_topic_watch.tpl');
Esempio n. 2
0
    $t_type = $topic['topic_type'];
    $separator = '';
    $is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id);
    if ($t_type == POST_ANNOUNCE && !defined('ANNOUNCE_SEP')) {
        define('ANNOUNCE_SEP', true);
        $separator = $lang['TOPICS_ANNOUNCEMENT'];
    } elseif ($t_type == POST_STICKY && !defined('STICKY_SEP')) {
        define('STICKY_SEP', true);
        $separator = $lang['TOPICS_STICKY'];
    } elseif ($t_type == POST_NORMAL && !defined('NORMAL_SEP')) {
        if (defined('ANNOUNCE_SEP') || defined('STICKY_SEP')) {
            define('NORMAL_SEP', true);
            $separator = $lang['TOPICS_NORMAL'];
        }
    }
    $template->assign_block_vars('t', array('FORUM_ID' => $forum_id, 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'], 'TOPIC_TITLE' => wbr($topic['topic_title']), 'TOPICS_SEPARATOR' => $separator, 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $replies, $bb_cfg['posts_per_page']), 'REPLIES' => $replies, 'VIEWS' => $topic['topic_views'], 'TOR_STALED' => $forum_data['allow_reg_tracker'] && !($t_type == POST_ANNOUNCE || $t_type == POST_STICKY || $topic['tor_size']), 'TOR_FROZEN' => isset($topic['tor_status']) ? !IS_AM ? isset($bb_cfg['tor_frozen'][$topic['tor_status']]) : '' : '', 'TOR_TYPE' => isset($topic['tor_type']) ? is_gold($topic['tor_type']) : '', 'TOR_STATUS_ICON' => isset($topic['tor_status']) ? $bb_cfg['tor_icons'][$topic['tor_status']] : '', 'TOR_STATUS_TEXT' => isset($topic['tor_status']) ? $lang['TOR_STATUS_NAME'][$topic['tor_status']] : '', 'ATTACH' => $topic['topic_attachment'], 'STATUS' => $topic['topic_status'], 'TYPE' => $topic['topic_type'], 'DL' => $topic['topic_dl_type'] == TOPIC_DL_TYPE_DL && !$forum_data['allow_reg_tracker'], 'POLL' => $topic['topic_vote'], 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'TOPIC_AUTHOR' => profile_url(array('username' => str_short($topic['first_username'], 15), 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank'])), 'LAST_POSTER' => profile_url(array('username' => str_short($topic['last_username'], 15), 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank'])), 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), 'LAST_POST_ID' => $topic['topic_last_post_id']));
    if (isset($topic['tor_size'])) {
        $tor_magnet = create_magnet($topic['info_hash'], $topic['auth_key'], $userdata['session_logged_in']);
        $template->assign_block_vars('t.tor', array('SEEDERS' => (int) $topic['seeders'], 'LEECHERS' => (int) $topic['leechers'], 'TOR_SIZE' => humn_size($topic['tor_size']), 'COMPL_CNT' => (int) $topic['complete_count'], 'ATTACH_ID' => $topic['attach_id'], 'MAGNET' => $tor_magnet));
    }
    $found_topics++;
}
unset($topic_rowset);
$pg_url = FORUM_URL . $forum_id;
$pg_url .= $sort_value ? "&sort={$sort_value}" : '';
$pg_url .= $order_value ? "&order={$order_value}" : '';
$template->assign_var('MOD_URL', $pg_url);
$pg_url = FORUM_URL . $forum_id;
$pg_url .= $topic_days ? "&amp;topicdays={$topic_days}" : '';
$pg_url .= $sort_value ? "&amp;sort={$sort_value}" : '';
$pg_url .= $order_value ? "&amp;order={$order_value}" : '';
Esempio n. 3
0
    }
    if (!$topic_rows) {
        bb_die($lang['NO_SEARCH_MATCH']);
    }
    // Output page
    foreach ($items_display as $row_num => $item_id) {
        if (empty($topic_rows[$item_id])) {
            continue;
            // if topic was deleted but still remain in search results
        }
        $topic = $topic_rows[$item_id];
        $topic_id = $topic['topic_id'];
        $forum_id = $topic['forum_id'];
        $is_unread = is_unread($topic['topic_last_post_time'], $topic_id, $forum_id);
        $moved = $topic['topic_status'] == TOPIC_MOVED;
        $template->assign_block_vars('t', array('ROW_NUM' => $row_num, 'FORUM_ID' => $forum_id, 'FORUM_NAME' => $forum_name_html[$forum_id], 'TOPIC_ID' => $topic_id, 'HREF_TOPIC_ID' => $moved ? $topic['topic_moved_id'] : $topic['topic_id'], 'TOPIC_TITLE' => wbr($topic['topic_title']), 'IS_UNREAD' => $is_unread, 'TOPIC_ICON' => get_topic_icon($topic, $is_unread), 'PAGINATION' => $moved ? '' : build_topic_pagination(TOPIC_URL . $topic_id, $topic['topic_replies'], $bb_cfg['posts_per_page']), 'REPLIES' => $topic['topic_replies'], 'ATTACH' => $topic['topic_attachment'], 'STATUS' => $topic['topic_status'], 'TYPE' => $topic['topic_type'], 'DL' => $topic['topic_dl_type'] == TOPIC_DL_TYPE_DL, 'POLL' => $topic['topic_vote'], 'DL_CLASS' => isset($topic['dl_status']) ? $dl_link_css[$topic['dl_status']] : '', 'TOPIC_AUTHOR' => profile_url(array('username' => $topic['first_username'], 'user_id' => $topic['first_user_id'], 'user_rank' => $topic['first_user_rank'])), 'LAST_POSTER' => profile_url(array('username' => $topic['last_username'], 'user_id' => $topic['last_user_id'], 'user_rank' => $topic['last_user_rank'])), 'LAST_POST_TIME' => bb_date($topic['topic_last_post_time']), 'LAST_POST_ID' => $topic['topic_last_post_id']));
    }
}
if ($items_display) {
    $items_count = count($items_found);
    $pages = !$items_count ? 1 : ceil($items_count / $per_page);
    $url = $search_id ? url_arg($url, 'id', $search_id) : $url;
    generate_pagination($url, $items_count, $per_page, $start);
    $template->assign_vars(array('PAGE_TITLE' => $lang['SEARCH'], 'SEARCH_MATCHES' => $items_count ? sprintf($lang['FOUND_SEARCH_MATCHES'], $items_count) : '', 'DISPLAY_AS_POSTS' => $post_mode, 'DL_CONTROLS' => $dl_search && $dl_user_id_val == $user_id, 'DL_ACTION' => 'dl_list.php', 'MY_POSTS' => !$post_mode && $my_posts && $user->id == $poster_id_val));
    print_page('search_results.tpl');
}
redirect(basename(__FILE__));
// ----------------------------------------------------------- //
// Functions
//
function fetch_search_ids($sql, $search_type = SEARCH_TYPE_POST)