BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

history.php 5.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. if (!check_perms('users_mod')) {
  3. error(404);
  4. }
  5. // if (!check_perms('site_top10_history')) {
  6. // error(403);
  7. // }
  8. View::show_header('Top 10 Torrents history!');
  9. ?>
  10. <div>
  11. <div class="header">
  12. <h2>Top 10 Torrents</h2>
  13. <?php Top10View::render_linkbox(); ?>
  14. </div>
  15. <div class="pad box">
  16. <form class="search_form" name="top10" method="get" action="">
  17. <input type="hidden" name="type" value="history" />
  18. <h3>Search for a date! (After 2010-09-05)</h3>
  19. <table class="layout">
  20. <tr>
  21. <td class="label">Date</td>
  22. <td><input type="text" id="date" name="date"
  23. value="<?=!empty($_GET['date']) ? display_str($_GET['date']) : 'YYYY-MM-DD'?>"
  24. onfocus="if ($('#date').raw().value == 'YYYY-MM-DD') { $('#date').raw().value = ''; }" /></td>
  25. </tr>
  26. <tr>
  27. <td class="label">Type</td>
  28. <td>
  29. <input type="radio" name="datetype" value="day" checked="checked"> Day
  30. <input type="radio" name="datetype" value="week"> Week
  31. </td>
  32. </tr>
  33. <tr>
  34. <td colspan="2">
  35. <input type="submit" value="Submit" />
  36. </td>
  37. </tr>
  38. </table>
  39. </form>
  40. </div>
  41. <?php
  42. if (!empty($_GET['date'])) {
  43. $Date = $_GET['date'];
  44. $SQLTime = $Date.' 00:00:00';
  45. if (!validDate($SQLTime)) {
  46. error('Something is wrong with the date you provided');
  47. }
  48. if (empty($_GET['datetype']) || $_GET['datetype'] == 'day') {
  49. $Type = 'day';
  50. $Where = "
  51. WHERE th.Date BETWEEN '$SQLTime' AND '$SQLTime' + INTERVAL 24 HOUR
  52. AND Type = 'Daily'";
  53. } else {
  54. $Type = 'week';
  55. $Where = "
  56. WHERE th.Date BETWEEN '$SQLTime' - AND '$SQLTime' + INTERVAL 7 DAY
  57. AND Type = 'Weekly'";
  58. }
  59. $Details = $Cache->get_value("top10_history_$SQLTime");
  60. if ($Details === false) {
  61. $DB->query("
  62. SELECT
  63. tht.`Rank`,
  64. tht.`TitleString`,
  65. tht.`TagString`,
  66. tht.`TorrentID`,
  67. g.`ID`,
  68. g.`Name`,
  69. g.`CategoryID`,
  70. g.`TagList`,
  71. t.`Format`,
  72. t.`Encoding`,
  73. t.`Media`,
  74. t.`Scene`,
  75. t.`HasLog`,
  76. t.`HasCue`,
  77. t.`LogScore`,
  78. t.`RemasterYear`,
  79. g.`Year`,
  80. t.`RemasterTitle`
  81. FROM
  82. `top10_history` AS th
  83. LEFT JOIN `top10_history_torrents` AS tht
  84. ON
  85. tht.`HistoryID` = th.`ID`
  86. LEFT JOIN `torrents` AS t
  87. ON
  88. t.`ID` = tht.`TorrentID`
  89. LEFT JOIN `torrents_group` AS g
  90. ON
  91. g.`ID` = t.`GroupID`
  92. $Where
  93. ORDER BY
  94. tht.`Rank` ASC
  95. ");
  96. $Details = $DB->to_array();
  97. $Cache->cache_value("top10_history_$SQLTime", $Details, 3600 * 24);
  98. } ?>
  99. <br />
  100. <div class="pad box">
  101. <h3>Top 10 for <?=($Type == 'day' ? $Date : "the first week after $Date")?>
  102. </h3>
  103. <table class="torrent_table cats numbering border">
  104. <tr class="colhead">
  105. <td class="center" style="width: 15px;"></td>
  106. <td class="center"></td>
  107. <td><strong>Name</strong></td>
  108. </tr>
  109. <?php
  110. foreach ($Details as $Detail) {
  111. list($Rank, $TitleString, $TagString, $TorrentID, $GroupID, $GroupName, $GroupCategoryID, $TorrentTags,
  112. $Format, $Encoding, $Media, $Scene, $HasLog, $HasCue, $LogScore, $Year, $GroupYear,
  113. $RemasterTitle, $Snatched, $Seeders, $Leechers, $Data) = $Detail;
  114. if ($GroupID) {
  115. // Group still exists
  116. $DisplayName = '';
  117. $Artists = Artists::get_artist($GroupID);
  118. if (!empty($Artists)) {
  119. $DisplayName = Artists::display_artists($Artists, true, true);
  120. }
  121. $DisplayName .= "<a href=\"torrents.php?id=$GroupID&amp;torrentid=$TorrentID\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">$GroupName</a>";
  122. if ($GroupCategoryID === 1 && $GroupYear > 0) {
  123. $DisplayName .= " [$GroupYear]";
  124. }
  125. // Append extra info to torrent title
  126. $ExtraInfo = '';
  127. $AddExtra = '&thinsp;|&thinsp;'; # breaking
  128. if ($Format) {
  129. $ExtraInfo .= $Format;
  130. }
  131. if ($Encoding) {
  132. $ExtraInfo .= $AddExtra.$Encoding;
  133. }
  134. if ($HasLog) {
  135. $ExtraInfo .= "$AddExtra Log ($LogScore%)";
  136. }
  137. if ($HasCue) {
  138. $ExtraInfo .= "{$AddExtra}Cue";
  139. }
  140. if ($Media) {
  141. $ExtraInfo .= $AddExtra.$Media;
  142. }
  143. if ($Scene) {
  144. $ExtraInfo .= "{$AddExtra}Scene";
  145. }
  146. if ($Year > 0) {
  147. $ExtraInfo .= $AddExtra.$Year;
  148. }
  149. if ($RemasterTitle) {
  150. $ExtraInfo .= $AddExtra.$RemasterTitle;
  151. }
  152. if ($ExtraInfo !== '') {
  153. $ExtraInfo = "- [$ExtraInfo]";
  154. }
  155. $DisplayName .= $ExtraInfo;
  156. $TorrentTags = new Tags($TorrentTags);
  157. } else {
  158. $DisplayName = "$TitleString (Deleted)";
  159. $TorrentTags = new Tags($TagString);
  160. } // if ($GroupID)
  161. ?>
  162. <tr class="group_torrent row">
  163. <td style="padding: 8px; text-align: center;"><strong><?=$Rank?></strong></td>
  164. <td class="center cats_col">
  165. <div title="<?=$TorrentTags->title()?>"
  166. class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
  167. </div>
  168. </td>
  169. <td>
  170. <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 tooltip">DL</a>' : '(Deleted)')?></span>
  171. <?=$DisplayName?>
  172. <div class="tags"><?=$TorrentTags->format()?>
  173. </div>
  174. </td>
  175. </tr>
  176. <?php
  177. } // foreach ($Details as $Detail)
  178. ?>
  179. </table><br />
  180. </div>
  181. </div>
  182. <?php
  183. }
  184. View::show_footer();