123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354 |
- <?
- // 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 (!empty($_GET['tags'])) {
- $TagsAny = isset($_GET['anyall']) && $_GET['anyall'] === 'any';
- $Tags = explode(',', str_replace('.', '_', trim($_GET['tags'])));
- foreach ($Tags as $Tag) {
- $Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
- if ($Tag != '') {
- $TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
- }
- }
- $Operator = $TagsAny ? ' OR ' : ' AND ';
- $Where[] = '('.implode($Operator, $TagWhere).')';
- }
- $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 (!empty($Where)) {
- $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->to_array('GroupID', MYSQLI_ASSOC, false);
- $Ranks = Votes::calc_ranks($DB->to_pair('GroupID', 'Score', false));
-
- $Groups = Torrents::get_groups(array_keys($Results));
-
- $TopVotes = array();
- foreach ($Results as $GroupID => $Votes) {
- $TopVotes[$GroupID] = $Groups[$GroupID];
- $TopVotes[$GroupID]['Ups'] = $Votes['Ups'];
- $TopVotes[$GroupID]['Total'] = $Votes['Total'];
- $TopVotes[$GroupID]['Score'] = $Votes['Score'];
- $TopVotes[$GroupID]['Rank'] = $Ranks[$GroupID];
- }
-
- $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');
- ?>
- <div class="thin">
- <div class="header">
- <h2>Top <?=$Limit?> Voted Groups</h2>
- <? Top10View::render_linkbox("votes"); ?>
- </div>
- <?
-
- if (check_perms('site_advanced_top10')) { ?>
- <form class="search_form" name="votes" action="" method="get">
- <input type="hidden" name="advanced" value="1" />
- <input type="hidden" name="type" value="votes" />
- <table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
- <tr id="tagfilter">
- <td class="label">Tags (comma-separated):</td>
- <td class="ft_taglist">
- <input type="text" name="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>" />
- <input type="radio" id="rdoAll" name="anyall" value="all"<?=(!isset($TagsAny) ? ' checked="checked"' : '')?> /><label for="rdoAll"> All</label>
- <input type="radio" id="rdoAny" name="anyall" value="any"<?=(isset($TagsAny) ? ' checked="checked"' : '')?> /><label for="rdoAny"> Any</label>
- </td>
- </tr>
- <tr id="yearfilter">
- <td class="label">Year:</td>
- <td class="ft_year">
- <input type="text" name="year1" size="4" value="<? if (!empty($_GET['year1'])) { echo display_str($_GET['year1']);} ?>" />
- to
- <input type="text" name="year2" size="4" value="<? if (!empty($_GET['year2'])) { echo display_str($_GET['year2']);} ?>" />
- </td>
- </tr>
- <tr>
- <td colspan="2" class="center">
- <input type="submit" value="Filter torrents" />
- </td>
- </tr>
- </table>
- </form>
- <?
- }
-
- $Bookmarks = Bookmarks::all_bookmarks('torrent');
- ?>
- <h3>Top <?=$Limit?>
- <?
- if (empty($_GET['advanced'])) { ?>
- <small class="top10_quantity_links">
- <?
- switch ($Limit) {
- case 100: ?>
- - <a href="top10.php?type=votes" class="brackets">Top 25</a>
- - <span class="brackets">Top 100</span>
- - <a href="top10.php?type=votes&limit=250" class="brackets">Top 250</a>
- <? break;
- case 250: ?>
- - <a href="top10.php?type=votes" class="brackets">Top 25</a>
- - <a href="top10.php?type=votes&limit=100" class="brackets">Top 100</a>
- - <span class="brackets">Top 250</span>
- <? break;
- default: ?>
- - <span class="brackets">Top 25</span>
- - <a href="top10.php?type=votes&limit=100" class="brackets">Top 100</a>
- - <a href="top10.php?type=votes&limit=250" class="brackets">Top 250</a>
- <? } ?>
- </small>
- <?
- } ?>
- </h3>
- <?
-
- $TorrentTable = '';
- foreach ($TopVotes as $GroupID => $Group) {
- extract(Torrents::array_group($Group));
- $UpVotes = $Group['Ups'];
- $TotalVotes = $Group['Total'];
- $Score = $Group['Score'];
- $DownVotes = $TotalVotes - $UpVotes;
-
- $IsBookmarked = in_array($GroupID, $Bookmarks);
- $UserVote = isset($UserVotes[$GroupID]) ? $UserVotes[$GroupID]['Type'] : '';
-
- $TorrentTags = new Tags($TagList);
- $DisplayName = "$Group[Rank] - ";
-
- $DisplayName .= Artists::display_artists($Artists);
-
- $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" dir="ltr"';
- if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
- $DisplayName .= ' onmouseover="getCover(event)" data-cover="'.ImageTools::process($WikiImage, true).'" onmouseleave="ungetCover(event)"';
- }
- $DisplayName .= '>'.$GroupName.'</a>';
- if ($GroupYear > 0) {
- $DisplayName = $DisplayName. " [$GroupYear]";
- }
- // 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' : '';
- ?>
- <tr class="group<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
- <td class="center">
- <div id="showimg_<?=$GroupID?>" class="show_torrents">
- <a class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Toggle this group (Hold "Shift" to toggle all groups)"></a>
- </div>
- </td>
- <td class="center cats_col">
- <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>"></div>
- </td>
- <td class="big_info">
- <div class="group_info clear">
-
- <strong><?=$DisplayName?></strong> <!--<?Votes::vote_link($GroupID, $UserVote);?>-->
- <? if ($IsBookmarked) { ?>
- <span class="remove_bookmark float_right">
- <a href="#" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
- </span>
- <? } else { ?>
- <span class="add_bookmark float_right">
- <a href="#" class="bookmarklink_torrent_<?=$GroupID?> brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
- </span>
- <? } ?>
- <div class="tags"><?=$TorrentTags->format()?></div>
-
- </div>
- </td>
- <td colspan="4" class="votes_info_td">
- <span style="white-space: nowrap;">
- <span class="favoritecount_small tooltip" title="<?=$UpVotes . ($UpVotes == 1 ? ' upvote' : ' upvotes')?>"><span id="upvotes"><?=number_format($UpVotes)?></span> <span class="vote_album_up">∧</span></span>
-
- <span class="favoritecount_small tooltip" title="<?=$DownVotes . ($DownVotes == 1 ? ' downvote' : ' downvotes')?>"><span id="downvotes"><?=number_format($DownVotes)?></span> <span class="vote_album_down">∨</span></span>
-
- <span style="float: right;"><span class="favoritecount_small" id="totalvotes"><?=number_format($TotalVotes)?></span> Total</span>
- </span>
- <br />
- <span style="white-space: nowrap;">
- <span class="tooltip_interactive" title="<span style="font-weight: bold;">Score: <?=number_format($Score * 100, 4)?></span><br /><br />This is the lower bound of the binomial confidence interval <a href="wiki.php?action=article&id=1037">described here</a>, multiplied by 100." data-title-plain="Score: <?=number_format($Score * 100, 4)?>. This is the lower bound of the binomial confidence interval described in the Favorite Album Votes wiki article, multiplied by 100.">Score: <span class="favoritecount_small"><?=number_format($Score * 100, 1)?></span></span>
- |
- <span class="favoritecount_small"><?=number_format($UpVotes / $TotalVotes * 100, 1)?>%</span> positive
- </span>
- </td>
- </tr>
- <?
- foreach ($Torrents as $TorrentID => $Torrent) {
- //Get report info, use the cache if available, if not, add to it.
- $Reported = false;
- $Reports = Torrents::get_reports($TorrentID);
- if (count($Reports) > 0) {
- $Reported = true;
- }
- $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
- ?>
- <tr class="group_torrent torrent_row groupid_<?=$GroupID?> <?=$SnatchedTorrentClass . $SnatchedGroupClass?> hidden">
- <td colspan="3">
- <span>
- [ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
- <? if (Torrents::can_use_token($Torrent)) { ?>
- | <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
- <? } ?>
- | <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
- </span>
- » <a href="torrents.php?id=<?=$GroupID?>&torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?><? if ($Reported) { ?> / <strong class="torrent_label tl_reported">Reported</strong><? } ?></a>
- </td>
- <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
- <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
- <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : '' ?>"><?=number_format($Torrent['Seeders'])?></td>
- <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
- </tr>
- <?
- }
- } else { //if (count($Torrents) > 1 || $GroupCategoryID == 1)
- // Viewing a type that does not require grouping
-
- list($TorrentID, $Torrent) = each($Torrents);
- $Torrent['IsSnatched'] = Torrents::has_snatched($TorrentID);
-
- $DisplayName = $Group['Rank'] .' - <a href="torrents.php?id='.$GroupID.'" dir="ltr"';
- if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
- $DisplayName .= ' onmouseover="getCover(event)" data-cover="'.ImageTools::process($WikiImage, true).'" onmouseleave="ungetCover(event)"';
- }
- $DisplayName .= '>'.$GroupName.'</a>';
- 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' : '';
- ?>
- <tr class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>" id="group_<?=$GroupID?>">
- <td></td>
- <td class="center cats_col">
- <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>">
- </div>
- </td>
- <td class="big_info">
- <div class="group_info clear">
- <span>
- [ <a href="torrents.php?action=download&id=<?=$TorrentID?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
- <? if (Torrents::can_use_token($Torrent)) { ?>
- | <a href="torrents.php?action=download&id=<?=$TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>&usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
- <? } ?>
- | <a href="reportsv2.php?action=report&id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
- <? if ($IsBookmarked) { ?>
- | <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
- <? } else { ?>
- | <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
- <? } ?>
- ]
- </span>
- <strong><?=$DisplayName?></strong> <!--<?Votes::vote_link($GroupID, $UserVote);?>-->
- <div class="tags"><?=$TorrentTags->format()?></div>
- </div>
- </td>
- <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
- <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
- <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : '' ?>"><?=number_format($Torrent['Seeders'])?></td>
- <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
- </tr>
- <?
- } //if (count($Torrents) > 1 || $GroupCategoryID == 1)
- $TorrentTable .= ob_get_clean();
- }
- ?>
- <table class="torrent_table grouping cats box" id="discog_table">
- <tr class="colhead_dark">
- <td><!-- expand/collapse --></td>
- <td class="cats_col"><!-- category --></td>
- <td width="70%">Torrents</td>
- <td>Size</td>
- <td class="sign snatches"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" class="tooltip" /></td>
- <td class="sign seeders"><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></td>
- <td class="sign leechers"><svg width="11" height="15" fill="white" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></td>
- </tr>
- <?
- if ($TopVotes === false) { ?>
- <tr>
- <td colspan="7" class="center">Server is busy processing another top list request. Please try again in a minute.</td>
- </tr>
- <?
- } elseif (count($TopVotes) === 0) { ?>
- <tr>
- <td colspan="7" class="center">No torrents were found that meet your criteria.</td>
- </tr>
- <?
- } else {
- echo $TorrentTable;
- }
- ?>
- </table>
- </div>
- <?
- View::show_footer();
- ?>
|