Gazelle/sections/top10/history.php

194 lines
5.1 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-04-17 08:00:58 +00:00
if (!check_perms('users_mod')) {
error(404);
}
// if (!check_perms('site_top10_history')) {
// error(403);
// }
2012-10-11 08:00:15 +00:00
View::show_header('Top 10 Torrents history!');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
2012-08-19 08:00:19 +00:00
<div class="header">
<h2>Top 10 Torrents</h2>
2013-09-09 08:00:52 +00:00
<? Top10View::render_linkbox(); ?>
2011-03-28 14:21:28 +00:00
</div>
<div class="pad box">
2012-09-15 08:00:25 +00:00
<form class="search_form" name="top10" method="get" action="">
2011-03-28 14:21:28 +00:00
<input type="hidden" name="type" value="history" />
<h3>Search for a date! (After 2010-09-05)</h3>
2012-09-01 08:00:24 +00:00
<table class="layout">
2011-03-28 14:21:28 +00:00
<tr>
<td class="label">Date:</td>
2013-04-17 08:00:58 +00:00
<td><input type="text" id="date" name="date" value="<?=!empty($_GET['date']) ? display_str($_GET['date']) : 'YYYY-MM-DD'?>" onfocus="if ($('#date').raw().value == 'YYYY-MM-DD') $('#date').raw().value = ''" /></td>
2011-03-28 14:21:28 +00:00
</tr>
<tr>
<td class="label">Type:</td>
<td>
<input type="radio" name="datetype" value="day" checked="checked"> Day
<input type="radio" name="datetype" value="week"> Week
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="Submit" />
</td>
</tr>
</table>
</form>
</div>
<?
2013-04-17 08:00:58 +00:00
if (!empty($_GET['date'])) {
2011-03-28 14:21:28 +00:00
$Date = $_GET['date'];
2013-04-17 08:00:58 +00:00
$SQLTime = $Date.' 00:00:00';
if (!validDate($SQLTime)) {
2011-03-28 14:21:28 +00:00
error('Something is wrong with the date you provided');
}
2013-04-17 08:00:58 +00:00
if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
2011-03-28 14:21:28 +00:00
$Type = 'day';
2013-07-04 08:00:56 +00:00
$Where = "
WHERE th.Date BETWEEN '$SQLTime' AND '$SQLTime' + INTERVAL 24 HOUR
AND Type = 'Daily'";
2011-03-28 14:21:28 +00:00
} else {
$Type = 'week';
2013-07-04 08:00:56 +00:00
$Where = "
WHERE th.Date BETWEEN '$SQLTime' - AND '$SQLTime' + INTERVAL 7 DAY
AND Type = 'Weekly'";
2011-03-28 14:21:28 +00:00
}
2013-07-04 08:00:56 +00:00
$Details = $Cache->get_value("top10_history_$SQLTime");
2013-04-17 08:00:58 +00:00
if ($Details === false) {
2013-07-04 08:00:56 +00:00
$DB->query("
SELECT
2011-03-28 14:21:28 +00:00
tht.Rank,
tht.TitleString,
tht.TagString,
tht.TorrentID,
g.ID,
g.Name,
g.CategoryID,
g.TagList,
t.Format,
t.Encoding,
t.Media,
t.Scene,
t.HasLog,
t.HasCue,
t.LogScore,
t.RemasterYear,
g.Year,
t.RemasterTitle
FROM top10_history AS th
LEFT JOIN top10_history_torrents AS tht ON tht.HistoryID = th.ID
LEFT JOIN torrents AS t ON t.ID = tht.TorrentID
LEFT JOIN torrents_group AS g ON g.ID = t.GroupID
2013-07-04 08:00:56 +00:00
$Where
2011-03-28 14:21:28 +00:00
ORDER BY tht.Rank ASC");
2013-02-15 08:00:35 +00:00
2011-03-28 14:21:28 +00:00
$Details = $DB->to_array();
2013-07-04 08:00:56 +00:00
$Cache->cache_value("top10_history_$SQLTime", $Details, 3600 * 24);
2011-03-28 14:21:28 +00:00
}
?>
<br />
<div class="pad box">
2013-08-28 23:08:41 +00:00
<h3>Top 10 for <?=($Type == 'day' ? $Date : "the first week after $Date")?></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-04-17 08:00:58 +00:00
<td class="center" style="width: 15px;"></td>
2011-03-28 14:21:28 +00:00
<td class="center"></td>
<td><strong>Name</strong></td>
</tr>
<?
2013-08-28 23:08:41 +00:00
foreach ($Details as $Detail) {
2013-07-04 08:00:56 +00:00
list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
$Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
$RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
2011-03-28 14:21:28 +00:00
// highlight every other row
$Highlight = ($Rank % 2 ? 'a' : 'b');
2013-08-28 23:08:41 +00:00
if ($GroupID) {
2013-07-04 08:00:56 +00:00
// Group still exists
$DisplayName = '';
2013-02-15 08:00:35 +00:00
2012-10-11 08:00:15 +00:00
$Artists = Artists::get_artist($GroupID);
2013-02-15 08:00:35 +00:00
2013-04-17 08:00:58 +00:00
if (!empty($Artists)) {
2012-10-11 08:00:15 +00:00
$DisplayName = Artists::display_artists($Artists, true, true);
2011-03-28 14:21:28 +00:00
}
2013-02-15 08:00:35 +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-07-04 08:00:56 +00:00
$DisplayName .= " [$GroupYear]";
2011-03-28 14:21:28 +00:00
}
// append extra info to torrent title
2013-04-17 08:00:58 +00:00
$ExtraInfo = '';
$AddExtra = '';
if ($Format) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= $Format;
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
if ($Encoding) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= $AddExtra.$Encoding;
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
//"FLAC / Lossless / Log (100%) / Cue / CD";
if ($HasLog) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= "$AddExtra Log ($LogScore%)";
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
if ($HasCue) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= "{$AddExtra}Cue";
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
if ($Media) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= $AddExtra.$Media;
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
if ($Scene) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= "{$AddExtra}Scene";
2013-04-17 08:00:58 +00:00
$AddExtra = ' / ';
}
if ($Year > 0) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= $AddExtra.$Year;
2013-04-17 08:00:58 +00:00
$AddExtra = ' ';
}
if ($RemasterTitle) {
2013-07-04 08:00:56 +00:00
$ExtraInfo .= $AddExtra.$RemasterTitle;
2013-04-17 08:00:58 +00:00
}
if ($ExtraInfo != '') {
2011-03-28 14:21:28 +00:00
$ExtraInfo = "- [$ExtraInfo]";
}
$DisplayName .= $ExtraInfo;
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags($TorrentTags);
2013-08-28 23:08:41 +00:00
} else {
2013-07-04 08:00:56 +00:00
$DisplayName = "$TitleString (Deleted)";
2013-02-25 21:16:55 +00:00
$TorrentTags = new Tags($TagString);
2013-08-28 23:08:41 +00:00
} // if ($GroupID)
2013-02-15 08:00:35 +00:00
2011-03-28 14:21:28 +00:00
?>
<tr class="group_torrent row<?=$Highlight?>">
2013-04-17 08:00:58 +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>
2011-03-28 14:21:28 +00:00
<td>
2013-02-15 08:00:35 +00:00
<span><?=($GroupID ? '<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>' : '(Deleted)')?></span>
2011-03-28 14:21:28 +00:00
<?=$DisplayName?>
2013-02-25 21:16:55 +00:00
<div class="tags"><?=$TorrentTags->format()?></div>
2011-03-28 14:21:28 +00:00
</td>
</tr>
<?
2013-08-28 23:08:41 +00:00
} //foreach ($Details as $Detail)
2011-03-28 14:21:28 +00:00
?>
</table><br />
</div>
</div>
<?
}
2012-10-11 08:00:15 +00:00
View::show_footer();
2011-03-28 14:21:28 +00:00
?>