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 6.0KB

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