123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?php
-
- if (!check_perms('users_mod')) {
- error(404);
- }
-
- // if (!check_perms('site_top10_history')) {
- // error(403);
- // }
-
- View::show_header('Top 10 Torrents history!');
- ?>
-
- <div>
- <div class="header">
- <h2>Top 10 Torrents</h2>
- <?php Top10View::render_linkbox(); ?>
- </div>
- <div class="pad box">
- <form class="search_form" name="top10" method="get" action="">
- <input type="hidden" name="type" value="history" />
- <h3>Search for a date! (After 2010-09-05)</h3>
- <table class="layout">
- <tr>
- <td class="label">Date</td>
- <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>
- </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>
-
- <?php
- if (!empty($_GET['date'])) {
- $Date = $_GET['date'];
- $SQLTime = $Date.' 00:00:00';
- if (!validDate($SQLTime)) {
- error('Something is wrong with the date you provided');
- }
-
- if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
- $Type = 'day';
- $Where = "
- WHERE th.Date BETWEEN '$SQLTime' AND '$SQLTime' + INTERVAL 24 HOUR
- AND Type = 'Daily'";
- } else {
- $Type = 'week';
- $Where = "
- WHERE th.Date BETWEEN '$SQLTime' - AND '$SQLTime' + INTERVAL 7 DAY
- AND Type = 'Weekly'";
- }
-
- $Details = $Cache->get_value("top10_history_$SQLTime");
- if ($Details === false) {
- $DB->query("
- SELECT
- 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`
- $Where
- ORDER BY
- tht.`Rank` ASC
- ");
-
- $Details = $DB->to_array();
-
- $Cache->cache_value("top10_history_$SQLTime", $Details, 3600 * 24);
- } ?>
-
- <br />
- <div class="pad box">
- <h3>Top 10 for <?=($Type == 'day' ? $Date : "the first week after $Date")?>
- </h3>
- <table class="torrent_table cats numbering border">
- <tr class="colhead">
- <td class="center" style="width: 15px;"></td>
- <td class="center"></td>
- <td><strong>Name</strong></td>
- </tr>
-
- <?php
- foreach ($Details as $Detail) {
- list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
- $Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
- $RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
-
- if ($GroupID) {
- // Group still exists
- $DisplayName = '';
-
- $Artists = Artists::get_artist($GroupID);
-
- if (!empty($Artists)) {
- $DisplayName = Artists::display_artists($Artists, true, true);
- }
-
- $DisplayName .= "<a href=\"torrents.php?id=$GroupID&torrentid=$TorrentID\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">$GroupName</a>";
-
- if ($GroupCategoryID === 1 && $GroupYear > 0) {
- $DisplayName .= " [$GroupYear]";
- }
-
- // Append extra info to torrent title
- $ExtraInfo = '';
- $AddExtra = ' | '; # breaking
-
- if ($Format) {
- $ExtraInfo .= $Format;
- }
-
- if ($Encoding) {
- $ExtraInfo .= $AddExtra.$Encoding;
- }
-
- if ($HasLog) {
- $ExtraInfo .= "$AddExtra Log ($LogScore%)";
- }
-
- if ($HasCue) {
- $ExtraInfo .= "{$AddExtra}Cue";
- }
-
- if ($Media) {
- $ExtraInfo .= $AddExtra.$Media;
- }
-
- if ($Scene) {
- $ExtraInfo .= "{$AddExtra}Scene";
- }
-
- if ($Year > 0) {
- $ExtraInfo .= $AddExtra.$Year;
- }
-
- if ($RemasterTitle) {
- $ExtraInfo .= $AddExtra.$RemasterTitle;
- }
-
- if ($ExtraInfo !== '') {
- $ExtraInfo = "- [$ExtraInfo]";
- }
-
- $DisplayName .= $ExtraInfo;
- $TorrentTags = new Tags($TorrentTags);
- } else {
- $DisplayName = "$TitleString (Deleted)";
- $TorrentTags = new Tags($TagString);
- } // if ($GroupID)
-
- ?>
- <tr class="group_torrent row">
- <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
- <td class="center cats_col">
- <div title="<?=$TorrentTags->title()?>"
- class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
- </div>
- </td>
- <td>
- <span><?=($GroupID ? '<a href="torrents.php?action=download&id='.$TorrentID.'&authkey='.$LoggedUser['AuthKey'].'&torrent_pass='.$LoggedUser['torrent_pass'].' title="Download" class="brackets tooltip">DL</a>' : '(Deleted)')?></span>
- <?=$DisplayName?>
- <div class="tags"><?=$TorrentTags->format()?>
- </div>
- </td>
- </tr>
- <?php
- } // foreach ($Details as $Detail)
- ?>
- </table><br />
- </div>
- </div>
- <?php
- }
- View::show_footer();
|