Gazelle/sections/top10/torrents.php

583 lines
19 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2011-10-30 08:00:11 +00:00
$Where = array();
2012-12-01 08:00:18 +00:00
if (!empty($_GET['advanced']) && check_perms('site_advanced_top10')) {
2011-03-28 14:21:28 +00:00
$Details = 'all';
$Limit = 10;
2012-12-01 08:00:18 +00:00
if ($_GET['tags']) {
$TagWhere = array();
2011-03-28 14:21:28 +00:00
$Tags = explode(',', str_replace(".","_",trim($_GET['tags'])));
foreach ($Tags as $Tag) {
$Tag = preg_replace('/[^a-z0-9_]/', '', $Tag);
2012-12-01 08:00:18 +00:00
if ($Tag != '') {
$TagWhere[] = "g.TagList REGEXP '[[:<:]]".db_string($Tag)."[[:>:]]'";
}
}
if (!empty($TagWhere)) {
if ($_GET['anyall'] == 'any') {
$Where[] = '('.implode(' OR ', $TagWhere).')';
} else {
$Where[] = '('.implode(' AND ', $TagWhere).')';
2011-03-28 14:21:28 +00:00
}
}
}
2012-12-01 08:00:18 +00:00
if ($_GET['format']) {
if (in_array($_GET['format'], $Formats)) {
$Where[] = "t.Format='".db_string($_GET['format'])."'";
2011-03-28 14:21:28 +00:00
}
}
2012-12-01 08:00:18 +00:00
2011-03-28 14:21:28 +00:00
} else {
// error out on invalid requests (before caching)
2013-04-17 08:00:58 +00:00
if (isset($_GET['details'])) {
2013-05-31 08:00:59 +00:00
if (in_array($_GET['details'], array('day', 'week', 'overall', 'snatched', 'data', 'seeded', 'month', 'year'))) {
2011-03-28 14:21:28 +00:00
$Details = $_GET['details'];
} else {
error(404);
}
} else {
$Details = 'all';
}
2013-02-12 08:00:08 +00:00
2011-03-28 14:21:28 +00:00
// defaults to 10 (duh)
2013-05-31 08:00:59 +00:00
$Limit = (isset($_GET['limit']) ? intval($_GET['limit']) : 10);
$Limit = (in_array($Limit, array(10, 100, 250)) ? $Limit : 10);
2011-03-28 14:21:28 +00:00
}
2011-10-30 08:00:11 +00:00
$Filtered = !empty($Where);
2013-05-31 08:00:59 +00:00
View::show_header("Top $Limit Torrents");
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
<h2>Top <?=$Limit?> Torrents</h2>
2013-09-09 08:00:52 +00:00
<? Top10View::render_linkbox("torrents"); ?>
2011-03-28 14:21:28 +00:00
</div>
<?
2013-04-17 08:00:58 +00:00
if (check_perms('site_advanced_top10')) {
2011-03-28 14:21:28 +00:00
?>
2012-09-15 08:00:25 +00:00
<form class="search_form" name="torrents" action="" method="get">
<input type="hidden" name="advanced" value="1" />
<table cellpadding="6" cellspacing="1" border="0" class="layout border" width="100%">
2012-11-06 08:00:20 +00:00
<tr id="tagfilter">
2012-09-15 08:00:25 +00:00
<td class="label">Tags (comma-separated):</td>
2012-11-06 08:00:20 +00:00
<td class="ft_taglist">
2013-07-04 08:00:56 +00:00
<input type="text" name="tags" id="tags" size="75" value="<? if (!empty($_GET['tags'])) { echo display_str($_GET['tags']);} ?>"<? Users::has_autocomplete_enabled('other'); ?> />&nbsp;
2013-01-15 08:00:37 +00:00
<input type="radio" id="rdoAll" name="anyall" value="all"<?=($_GET['anyall']!='any'?' checked="checked"':'')?> /><label for="rdoAll"> All</label>&nbsp;&nbsp;
<input type="radio" id="rdoAny" name="anyall" value="any"<?=($_GET['anyall']=='any'?' checked="checked"':'')?> /><label for="rdoAny"> Any</label>
2012-10-27 08:00:09 +00:00
</td>
2012-10-28 08:00:19 +00:00
</tr>
2012-09-15 08:00:25 +00:00
<tr>
2012-11-06 08:00:20 +00:00
<td class="label">Format:</td>
2012-09-15 08:00:25 +00:00
<td>
2013-05-25 08:01:03 +00:00
<select name="format" style="width: auto;" class="ft_format">
2012-09-15 08:00:25 +00:00
<option value="">Any</option>
2011-03-28 14:21:28 +00:00
<? foreach ($Formats as $FormatName) { ?>
2013-04-17 08:00:58 +00:00
<option value="<?=display_str($FormatName)?>"<? if (isset($_GET['format']) && $FormatName==$_GET['format']) { ?> selected="selected"<? } ?>><?=display_str($FormatName)?></option>
2012-09-15 08:00:25 +00:00
<? } ?> </select>
</td>
</tr>
<tr>
<td colspan="2" class="center">
<input type="submit" value="Filter torrents" />
</td>
</tr>
2013-02-12 08:00:08 +00:00
</table>
2012-09-15 08:00:25 +00:00
</form>
2011-03-28 14:21:28 +00:00
<?
}
2011-10-30 08:00:11 +00:00
// default setting to have them shown
$DisableFreeTorrentTop10 = (isset($LoggedUser['DisableFreeTorrentTop10']) ? $LoggedUser['DisableFreeTorrentTop10'] : 0);
// did they just toggle it?
2013-04-17 08:00:58 +00:00
if (isset($_GET['freeleech'])) {
2011-10-30 08:00:11 +00:00
// what did they choose?
2013-05-30 08:00:30 +00:00
$NewPref = (($_GET['freeleech'] == 'hide') ? 1 : 0);
2011-10-30 08:00:11 +00:00
// Pref id different
if ($NewPref != $DisableFreeTorrentTop10) {
$DisableFreeTorrentTop10 = $NewPref;
2012-10-11 08:00:15 +00:00
Users::update_site_options($LoggedUser['ID'], array('DisableFreeTorrentTop10' => $DisableFreeTorrentTop10));
2011-10-30 08:00:11 +00:00
}
}
// Modify the Where query
if ($DisableFreeTorrentTop10) {
$Where[] = "t.FreeTorrent='0'";
}
// The link should say the opposite of the current setting
$FreeleechToggleName = ($DisableFreeTorrentTop10 ? 'show' : 'hide');
2013-05-30 08:00:30 +00:00
$FreeleechToggleQuery = Format::get_url(array('freeleech', 'groups'));
2011-10-30 08:00:11 +00:00
if (!empty($FreeleechToggleQuery))
$FreeleechToggleQuery .= '&amp;';
$FreeleechToggleQuery .= 'freeleech=' . $FreeleechToggleName;
2013-05-31 08:00:59 +00:00
$GroupByToggleName = ($_GET['groups'] == 'show' ? 'hide' : 'show');
2013-05-30 08:00:30 +00:00
$GroupByToggleQuery = Format::get_url(array('freeleech', 'groups'));
if (!empty($GroupByToggleQuery))
$GroupByToggleQuery .= '&amp;';
$GroupByToggleQuery .= 'groups=' . $GroupByToggleName;
$GroupBySum = '';
$GroupBy = '';
if ($_GET['groups'] == 'show') {
$GroupBy = ' GROUP BY g.ID ';
2013-05-28 08:01:02 +00:00
$GroupBySum = md5($GroupBy);
}
2011-10-30 08:00:11 +00:00
?>
2012-12-27 08:00:27 +00:00
<div style="text-align: right;" class="linkbox">
2013-03-09 08:00:18 +00:00
<a href="top10.php?<?=$FreeleechToggleQuery?>" class="brackets"><?=ucfirst($FreeleechToggleName)?> freeleech in Top 10</a>
2013-05-30 08:00:30 +00:00
<? if (check_perms('users_mod')) { ?>
<a href="top10.php?<?=$GroupByToggleQuery?>" class="brackets"><?=ucfirst($GroupByToggleName)?> top groups</a>
2013-05-28 08:01:02 +00:00
<? } ?>
2011-10-30 08:00:11 +00:00
</div>
<?
2012-12-01 08:00:18 +00:00
if (!empty($Where)) {
$Where = '('.implode(' AND ', $Where).')';
$WhereSum = md5($Where);
2012-10-27 08:00:09 +00:00
} else {
2012-12-01 08:00:18 +00:00
$WhereSum = '';
2012-10-27 08:00:09 +00:00
}
2013-05-30 08:00:30 +00:00
$BaseQuery = '
SELECT
t.ID,
g.ID,
g.Name,
g.CategoryID,
g.wikiImage,
g.TagList,
t.Format,
t.Encoding,
t.Media,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.RemasterYear,
g.Year,
t.RemasterTitle,
t.Snatched,
t.Seeders,
t.Leechers,
((t.Size * t.Snatched) + (t.Size * 0.5 * t.Leechers)) AS Data,
g.ReleaseType,
t.Size
2011-03-28 14:21:28 +00:00
FROM torrents AS t
2013-05-30 08:00:30 +00:00
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID';
2013-02-12 08:00:08 +00:00
2013-05-30 08:00:30 +00:00
if ($Details == 'all' || $Details == 'day') {
2013-05-28 08:01:02 +00:00
$TopTorrentsActiveLastDay = $Cache->get_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsActiveLastDay === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
$DayAgo = time_minus(86400);
$Query = $BaseQuery.' WHERE t.Seeders>0 AND ';
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= $Where.' AND ';
}
2012-10-09 08:00:17 +00:00
$Query .= "
t.Time>'$DayAgo'
2013-05-30 08:00:30 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY (t.Seeders + t.Leechers) DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsActiveLastDay = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_day_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastDay, 3600 * 2);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsActiveLastDay = false;
2012-10-09 08:00:17 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Most Active Torrents Uploaded in the Past Day', 'day', $TopTorrentsActiveLastDay, $Limit);
}
2013-05-30 08:00:30 +00:00
if ($Details == 'all' || $Details == 'week') {
2013-05-28 08:01:02 +00:00
$TopTorrentsActiveLastWeek = $Cache->get_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsActiveLastWeek === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
$WeekAgo = time_minus(604800);
$Query = $BaseQuery.' WHERE ';
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= $Where.' AND ';
}
2012-10-09 08:00:17 +00:00
$Query .= "
t.Time>'$WeekAgo'
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY (t.Seeders + t.Leechers) DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsActiveLastWeek = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_week_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastWeek, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsActiveLastWeek = false;
2012-10-09 08:00:17 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Most Active Torrents Uploaded in the Past Week', 'week', $TopTorrentsActiveLastWeek, $Limit);
}
2013-05-30 08:00:30 +00:00
if ($Details == 'all' || $Details == 'month') {
2013-05-28 08:01:02 +00:00
$TopTorrentsActiveLastMonth = $Cache->get_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsActiveLastMonth === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
$Query = $BaseQuery.' WHERE ';
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= $Where.' AND ';
}
2012-10-09 08:00:17 +00:00
$Query .= "
t.Time>'".sqltime()."' - INTERVAL 1 MONTH
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY (t.Seeders + t.Leechers) DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsActiveLastMonth = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_month_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastMonth, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsActiveLastMonth = false;
2012-10-09 08:00:17 +00:00
}
2012-03-16 08:00:25 +00:00
}
generate_torrent_table('Most Active Torrents Uploaded in the Past Month', 'month', $TopTorrentsActiveLastMonth, $Limit);
}
2013-05-30 08:00:30 +00:00
if ($Details == 'all' || $Details == 'year') {
2013-05-28 08:01:02 +00:00
$TopTorrentsActiveLastYear = $Cache->get_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsActiveLastYear === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
// IMPORTANT NOTE - we use WHERE t.Seeders>200 in order to speed up this query. You should remove it!
$Query = $BaseQuery.' WHERE ';
2013-05-30 08:00:30 +00:00
if ($Details == 'all' && !$Filtered) {
2012-10-09 08:00:17 +00:00
$Query .= 't.Seeders>=200 AND ';
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= $Where.' AND ';
}
} elseif (!empty($Where)) {
$Query .= $Where.' AND ';
2012-10-09 08:00:17 +00:00
}
$Query .= "
t.Time>'".sqltime()."' - INTERVAL 1 YEAR
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY (t.Seeders + t.Leechers) DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsActiveLastYear = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_year_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveLastYear, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsActiveLastYear = false;
2012-03-30 08:00:20 +00:00
}
2012-03-16 08:00:25 +00:00
}
generate_torrent_table('Most Active Torrents Uploaded in the Past Year', 'year', $TopTorrentsActiveLastYear, $Limit);
}
2013-05-30 08:00:30 +00:00
if ($Details == 'all' || $Details == 'overall') {
2013-05-28 08:01:02 +00:00
$TopTorrentsActiveAllTime = $Cache->get_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsActiveAllTime === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
// IMPORTANT NOTE - we use WHERE t.Seeders>500 in order to speed up this query. You should remove it!
$Query = $BaseQuery;
if ($Details=='all' && !$Filtered) {
$Query .= " WHERE t.Seeders>=500 ";
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= ' AND '.$Where;
}
} elseif (!empty($Where)) {
$Query .= ' WHERE '.$Where;
2012-10-09 08:00:17 +00:00
}
$Query .= "
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY (t.Seeders + t.Leechers) DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsActiveAllTime = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_overall_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsActiveAllTime, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsActiveAllTime = false;
2011-10-30 08:00:11 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Most Active Torrents of All Time', 'overall', $TopTorrentsActiveAllTime, $Limit);
}
2013-05-30 08:00:30 +00:00
if (($Details == 'all' || $Details == 'snatched') && !$Filtered) {
2013-05-28 08:01:02 +00:00
$TopTorrentsSnatched = $Cache->get_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsSnatched === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
$Query = $BaseQuery;
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= ' WHERE '.$Where;
}
2012-10-09 08:00:17 +00:00
$Query .= "
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY t.Snatched DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsSnatched = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_snatched_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSnatched, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsSnatched = false;
2012-10-09 08:00:17 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Most Snatched Torrents', 'snatched', $TopTorrentsSnatched, $Limit);
}
2013-05-30 08:00:30 +00:00
if (($Details == 'all' || $Details == 'data') && !$Filtered) {
2013-05-28 08:01:02 +00:00
$TopTorrentsTransferred = $Cache->get_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsTransferred === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
// IMPORTANT NOTE - we use WHERE t.Snatched>100 in order to speed up this query. You should remove it!
$Query = $BaseQuery;
if ($Details=='all') {
$Query .= " WHERE t.Snatched>=100 ";
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= ' AND '.$Where;
}
2012-10-09 08:00:17 +00:00
}
$Query .= "
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY Data DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsTransferred = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_data_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsTransferred, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsTransferred = false;
2011-10-30 08:00:11 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Most Data Transferred Torrents', 'data', $TopTorrentsTransferred, $Limit);
}
2013-05-30 08:00:30 +00:00
if (($Details == 'all' || $Details == 'seeded') && !$Filtered) {
2013-05-28 08:01:02 +00:00
$TopTorrentsSeeded = $Cache->get_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum);
2012-10-09 08:00:17 +00:00
if ($TopTorrentsSeeded === false) {
2012-10-11 08:00:15 +00:00
if ($Cache->get_query_lock('top10')) {
2012-10-09 08:00:17 +00:00
$Query = $BaseQuery;
2013-05-30 08:00:30 +00:00
if (!empty($Where)) {
$Query .= ' WHERE '.$Where;
}
2012-10-09 08:00:17 +00:00
$Query .= "
2013-05-28 08:01:02 +00:00
$GroupBy
2012-10-09 08:00:17 +00:00
ORDER BY t.Seeders DESC
LIMIT $Limit;";
$DB->query($Query);
$TopTorrentsSeeded = $DB->to_array(false, MYSQLI_NUM);
2013-05-30 08:00:30 +00:00
$Cache->cache_value('top10tor_seeded_'.$Limit.$WhereSum.$GroupBySum, $TopTorrentsSeeded, 3600 * 6);
2012-10-11 08:00:15 +00:00
$Cache->clear_query_lock('top10');
} else {
$TopTorrentsSeeded = false;
2012-10-09 08:00:17 +00:00
}
2011-03-28 14:21:28 +00:00
}
generate_torrent_table('Best Seeded Torrents', 'seeded', $TopTorrentsSeeded, $Limit);
}
?>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
// generate a table based on data from most recent query to $DB
function generate_torrent_table($Caption, $Tag, $Details, $Limit) {
2013-08-28 23:08:41 +00:00
global $LoggedUser, $Categories, $ReleaseTypes, $GroupBy;
2011-03-28 14:21:28 +00:00
?>
2013-08-28 23:08:41 +00:00
<h3>Top <?="$Limit $Caption"?>
2013-04-20 08:01:01 +00:00
<? if (empty($_GET['advanced'])) { ?>
2013-02-12 08:00:08 +00:00
<small class="top10_quantity_links">
<?
2013-04-20 08:01:01 +00:00
switch ($Limit) {
case 100: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <span class="brackets">Top 100</span>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? break;
case 250: ?>
- <a href="top10.php?details=<?=$Tag?>" class="brackets">Top 10</a>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <span class="brackets">Top 250</span>
<? break;
default: ?>
- <span class="brackets">Top 10</span>
- <a href="top10.php?type=torrents&amp;limit=100&amp;details=<?=$Tag?>" class="brackets">Top 100</a>
- <a href="top10.php?type=torrents&amp;limit=250&amp;details=<?=$Tag?>" class="brackets">Top 250</a>
<? } ?>
2011-03-28 14:21:28 +00:00
</small>
2013-02-12 08:00:08 +00:00
<? } ?>
2011-03-28 14:21:28 +00:00
</h3>
2012-09-01 08:00:24 +00:00
<table class="torrent_table cats numbering border">
2011-03-28 14:21:28 +00:00
<tr class="colhead">
2013-05-25 08:01:03 +00:00
<td class="center" style="width: 15px;"></td>
2012-10-04 08:00:22 +00:00
<td class="cats_col"></td>
2013-10-05 08:01:00 +00:00
<td>Name</td>
<td style="text-align: right;">Size</td>
<td style="text-align: right;">Data</td>
<td style="text-align: right;"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/snatched.png" alt="Snatches" title="Snatches" class="tooltip" /></td>
<td style="text-align: right;"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/seeders.png" alt="Seeders" title="Seeders" class="tooltip" /></td>
<td style="text-align: right;"><img src="static/styles/<?=$LoggedUser['StyleName']?>/images/leechers.png" alt="Leechers" title="Leechers" class="tooltip" /></td>
<td style="text-align: right;">Peers</td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2012-10-09 08:00:17 +00:00
// Server is already processing a top10 query. Starting another one will make things slow
if ($Details === false) {
?>
<tr class="rowb">
<td colspan="9" class="center">
2012-10-11 08:00:15 +00:00
Server is busy processing another top list request. Please try again in a minute.
2012-10-09 08:00:17 +00:00
</td>
</tr>
</table><br />
<?
return;
}
2011-03-28 14:21:28 +00:00
// in the unlikely event that query finds 0 rows...
2012-10-09 08:00:17 +00:00
if (empty($Details)) {
2011-03-28 14:21:28 +00:00
?>
<tr class="rowb">
<td colspan="9" class="center">
2013-04-20 08:01:01 +00:00
Found no torrents matching the criteria.
2011-03-28 14:21:28 +00:00
</td>
</tr>
</table><br />
<?
return;
}
$Rank = 0;
2011-10-30 08:00:11 +00:00
foreach ($Details as $Detail) {
$GroupIDs[] = $Detail[1];
}
2012-10-11 08:00:15 +00:00
$Artists = Artists::get_artists($GroupIDs);
2011-03-28 14:21:28 +00:00
2013-08-28 23:08:41 +00:00
foreach ($Details as $Detail) {
list($TorrentID, $GroupID, $GroupName, $GroupCategoryID, $WikiImage, $TagsList,
$Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
$RemasterTitle, $Snatched, $Seeders, $Leechers, $Data, $ReleaseType, $Size) = $Detail;
2011-03-28 14:21:28 +00:00
2013-03-29 08:00:08 +00:00
$IsBookmarked = Bookmarks::has_bookmarked('torrent', $GroupID);
2012-11-04 08:00:20 +00:00
$IsSnatched = Torrents::has_snatched($TorrentID);
2011-03-28 14:21:28 +00:00
// highlight every other row
$Rank++;
$Highlight = ($Rank % 2 ? 'a' : 'b');
// generate torrent's title
2013-04-17 08:00:58 +00:00
$DisplayName = '';
2013-02-12 08:00:08 +00:00
2013-04-17 08:00:58 +00:00
if (!empty($Artists[$GroupID])) {
2012-10-11 08:00:15 +00:00
$DisplayName = Artists::display_artists($Artists[$GroupID], true, true);
2011-03-28 14:21:28 +00:00
}
2013-02-12 08:00:08 +00:00
2013-08-28 23:08:41 +00:00
$DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" title=\"View Torrent\" dir=\"ltr\">$GroupName</a>";
2011-03-28 14:21:28 +00:00
2013-04-17 08:00:58 +00:00
if ($GroupCategoryID == 1 && $GroupYear > 0) {
2013-08-28 23:08:41 +00:00
$DisplayName .= " [$GroupYear]";
2011-03-28 14:21:28 +00:00
}
2013-04-17 08:00:58 +00:00
if ($GroupCategoryID == 1 && $ReleaseType > 0) {
2013-08-28 23:08:41 +00:00
$DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
2012-02-07 08:00:20 +00:00
}
2012-10-28 08:00:19 +00:00
2011-03-28 14:21:28 +00:00
// append extra info to torrent title
2013-04-19 08:00:55 +00:00
$ExtraInfo = '';
$AddExtra = '';
2013-05-30 08:00:30 +00:00
if (empty($GroupBy)) {
2013-05-28 08:01:02 +00:00
if ($Format) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $Format;
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
if ($Encoding) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.$Encoding;
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
// "FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.'Log ('.$LogScore.'%)';
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
if ($HasCue) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.'Cue';
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
if ($Media) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.$Media;
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
if ($Scene) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.'Scene';
2013-05-28 08:01:02 +00:00
$AddExtra = ' / ';
}
if ($Year > 0) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.$Year;
2013-05-28 08:01:02 +00:00
$AddExtra = ' ';
}
if ($RemasterTitle) {
2013-08-28 23:08:41 +00:00
$ExtraInfo .= $AddExtra.$RemasterTitle;
2013-05-28 08:01:02 +00:00
}
if ($IsSnatched) {
if ($GroupCategoryID == 1) {
$ExtraInfo .= ' / ';
}
2013-08-28 23:08:41 +00:00
$ExtraInfo .= Format::torrent_label('Snatched!');
2013-05-28 08:01:02 +00:00
}
if ($ExtraInfo != '') {
$ExtraInfo = "- [$ExtraInfo]";
2013-04-19 08:00:55 +00:00
}
2011-03-28 14:21:28 +00:00
}
2012-10-28 08:00:19 +00:00
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags($TagsList);
2013-04-19 08:00:55 +00:00
2013-04-17 08:00:58 +00:00
//Get report info, use the cache if available, if not, add to it.
$Reported = false;
2013-08-12 08:00:44 +00:00
$Reports = Torrents::get_reports($TorrentID);
2013-04-17 08:00:58 +00:00
if (count($Reports) > 0) {
$Reported = true;
}
2011-03-28 14:21:28 +00:00
// print row
?>
2012-11-04 08:00:20 +00:00
<tr class="torrent row<?=$Highlight . ($IsBookmarked ? ' bookmarked' : '') . ($IsSnatched ? ' snatched_torrent' : '')?>">
2013-04-19 08:00:55 +00:00
<td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
2013-02-25 21:16:55 +00:00
<td class="center cats_col"><div title="<?=$TorrentTags->title()?>" class="<?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>"></div></td>
<td class="big_info">
2013-08-28 23:08:41 +00:00
<? if ($LoggedUser['CoverArt']) { ?>
2013-02-25 21:16:55 +00:00
<div class="group_image float_left clear">
2013-04-30 18:18:07 +00:00
<? ImageTools::cover_thumb($WikiImage, $GroupCategoryID) ?>
2013-02-25 21:16:55 +00:00
</div>
2013-08-28 23:08:41 +00:00
<? } ?>
2013-02-25 21:16:55 +00:00
<div class="group_info clear">
2013-04-17 08:00:58 +00:00
<span><a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download" class="brackets">DL</a></span>
2013-02-25 21:16:55 +00:00
2013-08-28 23:08:41 +00:00
<strong><?=$DisplayName?></strong> <?=$ExtraInfo?><? if ($Reported) { ?> - <strong class="torrent_label tl_reported">Reported</strong><? } ?>
2013-04-17 08:00:58 +00:00
<span class="bookmark" style="float: right;">
2012-10-27 08:00:09 +00:00
<?
2013-04-17 08:00:58 +00:00
if ($IsBookmarked) {
2012-10-27 08:00:09 +00:00
?>
2013-08-28 23:08:41 +00:00
<a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
2013-04-17 08:00:58 +00:00
<? } else { ?>
2013-08-28 23:08:41 +00:00
<a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
2013-04-17 08:00:58 +00:00
<? } ?>
2013-02-25 21:16:55 +00:00
</span>
<div class="tags"><?=$TorrentTags->format()?></div>
</div>
2011-03-28 14:21:28 +00:00
</td>
2013-08-28 23:08:41 +00:00
<td class="number_column nobr"><?=Format::get_size($Size)?></td>
<td class="number_column nobr"><?=Format::get_size($Data)?></td>
<td class="number_column"><?=number_format((double)$Snatched)?></td>
<td class="number_column"><?=number_format((double)$Seeders)?></td>
<td class="number_column"><?=number_format((double)$Leechers)?></td>
<td class="number_column"><?=number_format($Seeders + $Leechers)?></td>
2011-03-28 14:21:28 +00:00
</tr>
<?
2013-08-28 23:08:41 +00:00
} //foreach ($Details as $Detail)
2011-03-28 14:21:28 +00:00
?>
</table><br />
<?
}
2012-10-27 08:00:09 +00:00
?>