// We need these to do our rankification
include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
$UserVotes = Votes::get_user_votes($LoggedUser['ID']);
if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
$Details = 'all';
$Limit = 25;
if ($_GET['tags']) {
$Tags = explode(',', str_replace(".","_",trim($_GET['tags'])));
foreach ($Tags as $Tag) {
$Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
if ($Tag != '') {
$Where[]="g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
}
}
}
$Year1 = (int)$_GET['year1'];
$Year2 = (int)$_GET['year2'];
if ($Year1 > 0 && $Year2 <= 0) {
$Where[] = "g.Year = $Year1";
} elseif ($Year1 > 0 && $Year2 > 0) {
$Where[] = "g.Year BETWEEN $Year1 AND $Year2";
} elseif ($Year2 > 0 && $Year1 <= 0) {
$Where[] = "g.Year <= $Year2";
}
} else {
$Details = 'all';
// defaults to 10 (duh)
$Limit = isset($_GET['limit']) ? intval($_GET['limit']) : 25;
$Limit = in_array($Limit, array(25, 100, 250)) ? $Limit : 25;
}
$Filtered = !empty($Where);
if ($_GET['anyall'] == 'any' && !empty($Where)) {
$Where = '('.implode(' OR ', $Where).')';
} else {
$Where = implode(' AND ', $Where);
}
$WhereSum = (empty($Where)) ? '' : md5($Where);
// Unlike the other top 10s, this query just gets some raw stats
// We'll need to do some fancy-pants stuff to translate it into
// BPCI scores before getting the torrent data
$Query = 'SELECT v.GroupID, v.Ups, v.Total, v.Score
FROM torrents_votes AS v';
if (!empty($Where)) {
$Query .= " JOIN torrents_group AS g ON g.ID = v.GroupID
WHERE $Where AND ";
} else {
$Query .= ' WHERE ';
}
$Query .= "Score > 0 ORDER BY Score DESC LIMIT $Limit";
$TopVotes = $Cache->get_value('top10votes_'.$Limit.$WhereSum);
if ($TopVotes === false) {
if ($Cache->get_query_lock('top10votes')) {
$DB->query($Query);
$Results = $DB->collect('GroupID');
$Data = $DB->to_array('GroupID');
$Groups = Torrents::get_groups($Results);
$TopVotes = array();
foreach ($Results as $GroupID) {
$TopVotes[$GroupID] = $Groups['matches'][$GroupID];
$TopVotes[$GroupID]['Ups'] = $Data[$GroupID]['Ups'];
$TopVotes[$GroupID]['Total'] = $Data[$GroupID]['Total'];
$TopVotes[$GroupID]['Score'] = $Data[$GroupID]['Score'];
}
$Cache->cache_value('top10votes_'.$Limit.$WhereSum,$TopVotes,60*30);
$Cache->clear_query_lock('top10votes');
} else {
$TopVotes = false;
}
}
View::show_header('Top '.$Limit.' Voted Groups','browse,voting');
?>
if (check_perms('site_advanced_top10')) { ?>
}
$Bookmarks = Bookmarks::all_bookmarks('torrent');
?>
Top =$Limit.' '.$Caption?>
if (empty($_GET['advanced'])) { ?>
switch($Limit) {
case 100: ?>
- Top 25
- Top 100
- Top 250
break;
case 250: ?>
- Top 25
- Top 100
- Top 250
break;
default: ?>
- Top 25
- Top 100
- Top 250
} ?>
} ?>
// This code was copy-pasted from collages and should die in a fire
$Number = 0;
$NumGroups = 0;
foreach ($TopVotes as $GroupID => $Group) {
extract(Torrents::array_group($Group));
$Ups = $Group['Ups'];
$Total = $Group['Total'];
$Score = $Group['Score'];
$IsBookmarked = in_array($GroupID, $Bookmarks);
// Handle stats and stuff
$Number++;
$NumGroups++;
$TorrentTags = new Tags($TagList);
$DisplayName = $Number.' - ';
if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5])|| !empty($ExtendedArtists[6])) {
unset($ExtendedArtists[2]);
unset($ExtendedArtists[3]);
$DisplayName .= Artists::display_artists($ExtendedArtists);
} elseif (count($GroupArtists) > 0) {
$DisplayName .= Artists::display_artists(array('1'=>$GroupArtists));
}
$DisplayName .= '
'.$GroupName.'';
if ($GroupYear > 0) {
$DisplayName = $DisplayName. " [$GroupYear]";
}
if ($GroupVanityHouse) {
$DisplayName .= ' [
VH]';
}
// Start an output buffer, so we can store this output in $TorrentTable
ob_start();
if (count($Torrents) > 1 || $GroupCategoryID == 1) :
// Grouped torrents
$GroupSnatched = false;
foreach ($Torrents as &$Torrent) {
if (($Torrent['IsSnatched'] = Torrents::has_snatched($Torrent['ID'])) && !$GroupSnatched) {
$GroupSnatched = true;
}
}
unset($Torrent);
$SnatchedGroupClass = $GroupSnatched ? ' snatched_group' : '';
?>
|
|
if ($LoggedUser['CoverArt']) : ?>
ImageTools::cover_thumb($WikiImage, $GroupCategoryID - 1) ?>
endif; ?>
=$DisplayName?>
if ($IsBookmarked) { ?>
Unbookmark
} else { ?>
Bookmark
} ?>
=$TorrentTags->format()?>
|
=number_format($Ups)?> upvotes out of =number_format($Total)?> total (Score: =number_format($Score * 100)?>). |
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
unset($FirstUnknown);
foreach ($Torrents as $TorrentID => $Torrent) :
//Get report info, use the cache if available, if not, add to it.
$Reported = false;
$Reports = get_reports($TorrentID);
if (count($Reports) > 0) {
$Reported = true;
}
if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
$FirstUnknown = !isset($FirstUnknown);
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear ||
$Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) {
$EditionID++;
?>
− =Torrents::edition_string($Torrent, $Group)?> |
}
$LastRemasterTitle = $Torrent['RemasterTitle'];
$LastRemasterYear = $Torrent['RemasterYear'];
$LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
$LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
$LastMedia = $Torrent['Media'];
?>
[ DL
if (Torrents::can_use_token($Torrent)) { ?>
| FL
} ?>
| RP ]
» =Torrents::torrent_info($Torrent)?> if ($Reported) { ?> / Reported } ?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
>=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
endforeach;
else:
// Viewing a type that does not require grouping
list($TorrentID, $Torrent) = each($Torrents);
$Torrent['IsSnatched'] = Torrents::has_snatched($TorrentID);
$DisplayName = $Number .' -
'.$GroupName.'';
if ($Torrent['IsSnatched']) {
$DisplayName .= ' ' . Format::torrent_label('Snatched!');
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= ' ' . Format::torrent_label('Freeleech!');
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
} elseif (Torrents::has_token($TorrentID)) {
$DisplayName .= ' ' . Format::torrent_label('Personal freeleech!');
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
|
|
if ($LoggedUser['CoverArt']) : ?>
ImageTools::cover_thumb($WikiImage, $GroupCategoryID - 1) ?>
endif; ?>
[ DL
if (Torrents::can_use_token($Torrent)) { ?>
| FL
} ?>
| RP
if ($IsBookmarked) { ?>
| Unbookmark
} else { ?>
| Bookmark
} ?>
]
=$DisplayName?>
=$TorrentTags->format()?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
>=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
endif;
$TorrentTable.=ob_get_clean();
}
?>
|
|
Torrents |
Size |
|
|
|
if ($TorrentList === false) { ?>
Server is busy processing another top list request. Please try again in a minute. |
} elseif (count($TopVotes) == 0) { ?>
No torrents were found that meet your criteria. |
} else {
echo $TorrentTable;
}
?>
View::show_footer();
?>