// We need these to do our rankification
include(SERVER_ROOT.'/sections/torrents/ranking_funcs.php');
include(SERVER_ROOT.'/sections/bookmarks/functions.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);
if (count($Results) > 0) {
$DB->query('SELECT ID, CategoryID FROM torrents_group
WHERE ID IN ('.implode(',', $Results).')');
$Cats = $DB->to_array('ID');
}
// Make sure it's still in order.
$TopVotes = array();
foreach ($Results as $GroupID) {
$TopVotes[$GroupID] = $Groups['matches'][$GroupID];
$TopVotes[$GroupID]['CategoryID'] = $Cats[$GroupID]['CategoryID'];
$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 = 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) {
list($GroupID, $GroupName, $GroupYear, $GroupRecordLabel,
$GroupCatalogueNumber, $TagList, $ReleaseType, $GroupVanityHouse,
$Torrents, $GroupArtists, $ExtendedArtists, $GroupFlags, $GroupCategoryID,$Ups,$Total,$Score) = array_values($Group);
$IsBookmarked = in_array($GroupID, $Bookmarks);
// Handle stats and stuff
$Number++;
$NumGroups++;
$TagList = explode(' ',str_replace('_','.',$TagList));
$TorrentTags = array();
foreach($TagList as $Tag) {
$TorrentTags[]='
'.$Tag.'';
}
$PrimaryTag = $TagList[0];
$TorrentTags = implode(', ', $TorrentTags);
$TorrentTags='
'.$TorrentTags.'
';
$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;
}
}
$SnatchedGroupClass = $GroupSnatched ? ' snatched_group' : '';
?>
|
|
=$DisplayName?>
if($IsBookmarked) { ?>
[ Unbookmark ]
} else { ?>
[ Bookmark ]
} ?>
=$TorrentTags?>
|
=$Ups?> upvotes out of =$Total?> total (Score: =round($Score*100)?>). |
$LastRemasterYear = '-';
$LastRemasterTitle = '';
$LastRemasterRecordLabel = '';
$LastRemasterCatalogueNumber = '';
$LastMedia = '';
$EditionID = 0;
unset($FirstUnknown);
foreach ($Torrents as $TorrentID => $Torrent) {
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++;
if($Torrent['Remastered'] && $Torrent['RemasterYear'] != 0) {
$RemasterName = $Torrent['RemasterYear'];
$AddExtra = " - ";
if($Torrent['RemasterRecordLabel']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterRecordLabel']); $AddExtra=' / '; }
if($Torrent['RemasterCatalogueNumber']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterCatalogueNumber']); $AddExtra=' / '; }
if($Torrent['RemasterTitle']) { $RemasterName .= $AddExtra.display_str($Torrent['RemasterTitle']); $AddExtra=' / '; }
$RemasterName .= $AddExtra.display_str($Torrent['Media']);
?>
− =$RemasterName?> |
} else {
$AddExtra = " / ";
if (!$Torrent['Remastered']) {
$MasterName = "Original Release";
if($GroupRecordLabel) { $MasterName .= $AddExtra.$GroupRecordLabel; $AddExtra=' / '; }
if($GroupCatalogueNumber) { $MasterName .= $AddExtra.$GroupCatalogueNumber; $AddExtra=' / '; }
} else {
$MasterName = "Unknown Release(s)";
}
$MasterName .= $AddExtra.display_str($Torrent['Media']);
?>
− =$MasterName?> |
}
}
$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)?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
>=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
}
} 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 .= '
Snatched!';
}
if ($Torrent['FreeTorrent'] == '1') {
$DisplayName .= '
Freeleech!';
} elseif ($Torrent['FreeTorrent'] == '2') {
$DisplayName .= '
Neutral Leech!';
} elseif (Torrents::has_token($TorrentID)) {
$DisplayName .= '
Personal Freeleech!';
}
$SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
?>
|
|
[ DL
if (Torrents::can_use_token($Torrent)) { ?>
| FL
} ?>
| RP
if($IsBookmarked) { ?>
| Unbookmark
} else { ?>
| Bookmark
} ?>
]
=$DisplayName?>
=$TorrentTags?>
|
=Format::get_size($Torrent['Size'])?> |
=number_format($Torrent['Snatched'])?> |
>=number_format($Torrent['Seeders'])?> |
=number_format($Torrent['Leechers'])?> |
}
$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();
?>