Ejemplo n.º 1
0
if (isset($_GET['year'])) {
    if (is_number($_GET['year']) || $_GET['year'] === '0') {
        $SphQL->where('year', $_GET['year']);
    } else {
        error(404);
    }
}
if (!empty($_GET['page']) && is_number($_GET['page']) && $_GET['page'] > 0) {
    $Page = $_GET['page'];
    $Offset = ($Page - 1) * REQUESTS_PER_PAGE;
    $SphQL->limit($Offset, REQUESTS_PER_PAGE, $Offset + REQUESTS_PER_PAGE);
} else {
    $Page = 1;
    $SphQL->limit(0, REQUESTS_PER_PAGE, REQUESTS_PER_PAGE);
}
$SphQLResult = $SphQL->query();
$NumResults = (int) $SphQLResult->get_meta('total_found');
if ($NumResults > 0) {
    $SphRequests = $SphQLResult->to_array('id');
    if ($OrderBy === 'random') {
        $NumResults = count($SphRequests);
    }
    if ($NumResults > REQUESTS_PER_PAGE) {
        if (($Page - 1) * REQUESTS_PER_PAGE > $NumResults) {
            $Page = 0;
        }
        $PageLinks = Format::get_pages($Page, $NumResults, REQUESTS_PER_PAGE);
    }
}
$CurrentURL = Format::get_url(array('order', 'sort', 'page'));
View::show_header($Title, 'requests');
Ejemplo n.º 2
0
    $NumResults = SPHINX_MAX_MATCHES;
}
if ($NumResults) {
    $Groups = Torrents::get_groups($GroupIDs);
    if (!empty($Groups) && $GroupResults) {
        $TorrentIDs = array();
        foreach ($Groups as $Group) {
            if (!empty($Group['Torrents'])) {
                $TorrentIDs = array_merge($TorrentIDs, array_keys($Group['Torrents']));
            }
        }
        $TorrentCount = count($TorrentIDs);
        if ($TorrentCount > 0) {
            // Get a list of all torrent ids that match the search query
            $SphQLTor->where('id', $TorrentIDs)->limit(0, $TorrentCount, $TorrentCount);
            $SphQLResultTor = $SphQLTor->query();
            $TorrentIDs = $SphQLResultTor->to_pair('id', 'id');
            // Because isset() is faster than in_array()
        }
    }
}
/** End run search query and collect results **/
if ($NumResults == 0) {
    $DB->query("\n\tSELECT\n\t\ttags.Name,\n\t\t((COUNT(tags.Name) - 2) * (SUM(tt.PositiveVotes) - SUM(tt.NegativeVotes))) / (tags.Uses * 0.8) AS Score\n\tFROM xbt_snatched AS s\n\t\tINNER JOIN torrents AS t ON t.ID = s.fid\n\t\tINNER JOIN torrents_group AS g ON t.GroupID = g.ID\n\t\tINNER JOIN torrents_tags AS tt ON tt.GroupID = g.ID\n\t\tINNER JOIN tags ON tags.ID = tt.TagID\n\tWHERE s.uid = '{$LoggedUser['ID']}'\n\t\tAND tt.TagID != '13679'\n\t\tAND tt.TagID != '4820'\n\t\tAND tt.TagID != '2838'\n\t\tAND g.CategoryID = '1'\n\t\tAND tags.Uses > '10'\n\tGROUP BY tt.TagID\n\tORDER BY Score DESC\n\tLIMIT 8");
    $JsonYouMightLike = array();
    while (list($Tag) = $DB->next_record()) {
        $JsonYouMightLike[] = $Tag;
    }
    json_die("success", array('results' => array(), 'youMightLike' => $JsonYouMightLike));
}
$Bookmarks = Bookmarks::all_bookmarks('torrent');