Пример #1
0
        $where_tor_sql = "AND tor.tor_status = {$tor_status}";
    }
    $select_tor_sql = ',
		bt.auth_key, tor.info_hash, tor.size AS tor_size, tor.reg_time, tor.complete_count, tor.seeder_last_seen, tor.attach_id, tor.tor_status, tor.tor_type,
		sn.seeders, sn.leechers
	';
    $select_tor_sql .= $join_dl ? ', dl.user_status AS dl_status' : '';
    $join_tor_sql = "\n\t\tLEFT JOIN " . BB_BT_TORRENTS . " tor ON(t.topic_id = tor.topic_id)\n\t\tLEFT JOIN " . BB_BT_USERS . " bt  ON(bt.user_id = {$userdata['user_id']})\n\t\tLEFT JOIN " . BB_BT_TRACKER_SNAP . " sn  ON(tor.topic_id = sn.topic_id)\n\t";
    $join_tor_sql .= $join_dl ? " LEFT JOIN " . BB_BT_DLSTATUS . " dl ON(dl.user_id = {$userdata['user_id']} AND dl.topic_id = t.topic_id)" : '';
}
// Title match
$title_match_sql = '';
if ($title_match =& $_REQUEST[$title_match_key]) {
    if ($tmp = mb_substr(trim($title_match), 0, $title_match_max_len)) {
        $title_match_val = clean_text_match($tmp, true, false, false);
        $title_match_topics = get_title_match_topics($title_match_val, array(0 => $forum_id));
        if ($search_match_topics_csv = join(',', $title_match_topics)) {
            $title_match_sql = "AND t.topic_id IN({$search_match_topics_csv})";
        }
    }
}
// Get topics
$topic_ids = $topic_rowset = array();
// IDs
$sql = "\n\tSELECT t.topic_id\n\tFROM " . BB_TOPICS . " t\n\tWHERE t.forum_id = {$forum_id}\n\t\t{$only_new_sql}\n\t\t{$title_match_sql}\n\t\t{$limit_topics_time_sql}\n\t{$order_sql}\n\tLIMIT {$start}, {$topics_per_page}\n";
foreach (DB()->fetch_rowset($sql) as $row) {
    $topic_ids[] = $row['topic_id'];
}
// Titles, posters etc.
if ($topics_csv = join(',', $topic_ids)) {
    $topic_rowset = DB()->fetch_rowset("\n\t\tSELECT\n\t\t\tt.*, t.topic_poster AS first_user_id, u1.user_rank as first_user_rank,\n\t\t\tIF(t.topic_poster = {$anon}, p1.post_username, u1.username) AS first_username,\n\t\t\tp2.poster_id AS last_user_id, u2.user_rank as last_user_rank,\n\t\t\tIF(p2.poster_id = {$anon}, p2.post_username, u2.username) AS last_username\n\t\t\t\t{$select_tor_sql}\n\t\tFROM      " . BB_TOPICS . " t\n\t\tLEFT JOIN " . BB_POSTS . " p1 ON(t.topic_first_post_id = p1.post_id)\n\t\tLEFT JOIN " . BB_USERS . " u1 ON(t.topic_poster = u1.user_id)\n\t\tLEFT JOIN " . BB_POSTS . " p2 ON(t.topic_last_post_id = p2.post_id)\n\t\tLEFT JOIN " . BB_USERS . " u2 ON(p2.poster_id = u2.user_id)\n\t\t\t{$join_tor_sql}\n\t\tWHERE t.topic_id IN({$topics_csv})\n\t\t    {$where_tor_sql}\n\t\tGROUP BY t.topic_id\n\t\t{$order_sql}\n\t");
Пример #2
0
}
if ($dl_search) {
    $my_val = 0;
}
if ($allowed_forums) {
    // Save current search settings
    $save_in_db = array('all_words', 'active', 'dl_cancel', 'dl_compl', 'dl_down', 'dl_will', 'forum', 'my', 'new', 'order', 'poster_id', 'poster_name', 's_not_seen', 's_rg', 'seed_exist', 'show_author', 'show_cat', 'show_forum', 'show_speed', 'sort', 'time');
    $curr_set = array();
    foreach ($save_in_db as $name) {
        $curr_set[${"{$name}_key"}] = ${"{$name}_val"};
    }
    $curr_set_sql = DB()->escape(serialize($curr_set));
    // Text search
    $search_match_topics_csv = '';
    if ($title_match) {
        $title_match_topics = get_title_match_topics($title_match_sql, $search_in_forums_ary);
        if (!($search_match_topics_csv = join(',', $title_match_topics))) {
            $tr_error = true;
        }
    } else {
        $title_match_val = '';
    }
    // Get torrents list
    if (!$tr_error && !$tor_list_sql) {
        $reg_time = $time_opt[$time_val]['sql'];
        $poster_id_sql = (int) $poster_id_val;
        $rg_id_sql = (int) $s_rg_val;
        $s_seen_time = $s_not_seen_opt[$s_not_seen_val]['sql'];
        $s_seen_sign = $s_not_seen_val == $never ? '=' : '<';
        $s_seen_exclude = $s_not_seen_val == $never ? '' : "AND tor.seeder_last_seen != 0";
        $order_by_peers = $order_val == $ord_seeders || $order_val == $ord_leechers;
Пример #3
0
            if ($userdata['user_posts']) {
                $template->assign_var('BB_DIE_APPEND_MSG', '
					<form id="mod-action" method="POST" action="search.php">
						<input type="submit" name="add_my_post" value="' . $lang['RESTORE_ALL_POSTS'] . '" class="bold" onclick="if (!window.confirm( this.value +\'?\' )){ return false };" />
					</form>
					<br /><br />
					<a href="index.php">' . $lang['INDEX_RETURN'] . '</a>
				');
            }
        }
        if ($my_topics) {
            $SQL['WHERE'][] = "t.topic_poster = {$poster_id_val}";
        }
        if ($text_match_sql) {
            $search_match_topics_csv = '';
            $title_match_topics = get_title_match_topics($text_match_sql, $forum_selected);
            if (!($search_match_topics_csv = join(',', $title_match_topics))) {
                bb_die($lang['NO_SEARCH_MATCH']);
            }
            $where_id = $title_match ? 't.topic_id' : 'p.post_id';
            $SQL['WHERE'][] = "{$where_id} IN({$search_match_topics_csv})";
            prevent_huge_searches($SQL);
        }
        if ($join_dl) {
            $SQL['FROM'][] = $dl_stat_tbl;
        }
        if ($join_dl) {
            $SQL['WHERE'][] = "dl.topic_id = t.topic_id AND dl.user_id = {$dl_user_id_val} AND dl.user_status IN({$dl_status_csv})";
        }
        if (!$SQL['WHERE']) {
            redirect(basename(__FILE__));