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.

subscribed_collages.php 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <?php
  2. #declare(strict_types=1);
  3. /*
  4. User collage subscription page
  5. */
  6. if (!check_perms('site_collages_subscribe')) {
  7. error(403);
  8. }
  9. View::show_header('Subscribed collections', 'browse,collage');
  10. $ShowAll = !empty($_GET['showall']);
  11. if (!$ShowAll) {
  12. $sql = "
  13. SELECT
  14. c.ID,
  15. c.Name,
  16. c.NumTorrents,
  17. s.LastVisit
  18. FROM collages AS c
  19. JOIN users_collage_subs AS s ON s.CollageID = c.ID
  20. JOIN collages_torrents AS ct ON ct.CollageID = c.ID
  21. WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
  22. AND ct.AddedOn > s.LastVisit
  23. GROUP BY c.ID";
  24. } else {
  25. $sql = "
  26. SELECT
  27. c.ID,
  28. c.Name,
  29. c.NumTorrents,
  30. s.LastVisit
  31. FROM collages AS c
  32. JOIN users_collage_subs AS s ON s.CollageID = c.ID
  33. LEFT JOIN collages_torrents AS ct ON ct.CollageID = c.ID
  34. WHERE s.UserID = $LoggedUser[ID] AND c.Deleted = '0'
  35. GROUP BY c.ID";
  36. }
  37. $DB->prepared_query($sql);
  38. $NumResults = $DB->record_count();
  39. $CollageSubs = $DB->to_array();
  40. ?>
  41. <div>
  42. <div class="header">
  43. <h2>Subscribed collections<?=($ShowAll ? '' : ' with new additions')?>
  44. </h2>
  45. <div class="linkbox">
  46. <?php
  47. if ($ShowAll) {
  48. ?>
  49. <br /><br />
  50. <a href="userhistory.php?action=subscribed_collages&amp;showall=0" class="brackets">Only display collections with
  51. new additions</a>&nbsp;&nbsp;&nbsp;
  52. <?php
  53. } else {
  54. ?>
  55. <br /><br />
  56. <a href="userhistory.php?action=subscribed_collages&amp;showall=1" class="brackets">Show all subscribed
  57. collections</a>&nbsp;&nbsp;&nbsp;
  58. <?php
  59. }
  60. ?>
  61. <a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>"
  62. class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
  63. </div>
  64. </div>
  65. <?php
  66. if (!$NumResults) {
  67. ?>
  68. <div class="center">
  69. No subscribed collections<?=($ShowAll ? '' : ' with new additions')?>
  70. </div>
  71. <?php
  72. } else {
  73. $HideGroup = '';
  74. $ActionTitle = 'Hide';
  75. $ActionURL = 'hide';
  76. $ShowGroups = 0;
  77. foreach ($CollageSubs as $Collage) {
  78. $TorrentTable = '';
  79. list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
  80. $RS = $DB->prepared_query("
  81. SELECT GroupID
  82. FROM collages_torrents
  83. WHERE CollageID = $CollageID
  84. AND AddedOn > '" . db_string($LastVisit) . "'
  85. ORDER BY AddedOn");
  86. $NewTorrentCount = $DB->record_count();
  87. $GroupIDs = $DB->collect('GroupID', false);
  88. if (count($GroupIDs) > 0) {
  89. $TorrentList = Torrents::get_groups($GroupIDs);
  90. } else {
  91. $TorrentList = [];
  92. }
  93. $Artists = Artists::get_artists($GroupIDs);
  94. $Number = 0;
  95. foreach ($GroupIDs as $GroupID) {
  96. if (!isset($TorrentList[$GroupID])) {
  97. continue;
  98. }
  99. $Group = $TorrentList[$GroupID];
  100. extract(Torrents::array_group($Group));
  101. $TorrentTags = new Tags($TagList);
  102. $DisplayName = '';
  103. if (isset($Artists)) {
  104. $DisplayName .= '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  105. }
  106. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  107. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  108. $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage).'" ';
  109. }
  110. $DisplayName .= "dir=\"ltr\">".($GroupName ? $GroupName : ($GroupTitle2 ? $GroupTitle2 : $GroupNameJP))."</a>";
  111. if ($GroupYear > 0) {
  112. $DisplayName = "$DisplayName [$GroupYear]";
  113. }
  114. $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
  115. // Start an output buffer, so we can store this output in $TorrentTable
  116. ob_start();
  117. if (count($Torrents) > 1 || $GroupCategoryID == 1) {
  118. ?>
  119. <tr class="group<?=$SnatchedGroupClass?>"
  120. id="group_<?=$CollageID?>_<?=$GroupID?>">
  121. <td class="center">
  122. <div
  123. id="showimg_<?=$CollageID?>_<?=$GroupID?>"
  124. class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  125. <a class="tooltip show_torrents_link"
  126. onclick="toggle_group('<?=$CollageID?>_<?=$GroupID?>', this, event);"
  127. title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
  128. </div>
  129. </td>
  130. <td class="center cats_col">
  131. <div title="<?=Format::pretty_category($GroupCategoryID)?>"
  132. class="tooltip <?=Format::css_category($GroupCategoryID)?>">
  133. </div>
  134. </td>
  135. <td colspan="5" class="big_info">
  136. <div class="group_info clear">
  137. <strong><?=$DisplayName?></strong>
  138. <div class="tags"><?=$TorrentTags->format()?>
  139. </tags>
  140. </div>
  141. </td>
  142. </tr>
  143. <?php
  144. foreach ($Torrents as $TorrentID => $Torrent) {
  145. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>
  146. <tr
  147. class="group_torrent groupid_<?=$CollageID?>_<?=$GroupID?> hidden<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  148. <td colspan="3">
  149. <span>
  150. <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
  151. title="Download" class="brackets tooltip">DL</a>
  152. </span>
  153. &nbsp;&nbsp;&raquo;&nbsp;<a
  154. href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
  155. </td>
  156. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
  157. </td>
  158. <td class="number_column"><?=number_format($Torrent['Snatched'])?>
  159. </td>
  160. <td
  161. class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>">
  162. <?=number_format($Torrent['Seeders'])?>
  163. </td>
  164. <td class="number_column"><?=number_format($Torrent['Leechers'])?>
  165. </td>
  166. </tr>
  167. <?php
  168. }
  169. } else {
  170. // Viewing a type that does not require grouping
  171. $TorrentID = key($Torrents);
  172. $Torrent = current($Torrents);
  173. $DisplayName = '';
  174. if (isset($Artists)) {
  175. $DisplayName .= '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  176. }
  177. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  178. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  179. $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage).'" ';
  180. }
  181. $DisplayName .= "dir=\"ltr\">".($GroupName ? $GroupName : ($GroupTitle2 ? $GroupTitle2 : $GroupNameJP))."</a>";
  182. if ($Torrent['IsSnatched']) {
  183. $DisplayName .= ' ' . Format::torrent_label('Snatched', 'bold');
  184. }
  185. if (!empty($Torrent['FreeTorrent'])) {
  186. $DisplayName .= ' ' . Format::torrent_label('Freeleech', 'important_text_alt');
  187. }
  188. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; ?>
  189. <tr class="torrent<?=$SnatchedTorrentClass?>"
  190. id="group_<?=$CollageID?>_<?=$GroupID?>">
  191. <td></td>
  192. <td class="center">
  193. <div title="<?=Format::pretty_category($GroupCategoryID)?>"
  194. class="tooltip <?=Format::css_category($GroupCategoryID)?>">
  195. </div>
  196. </td>
  197. <td class="big_info">
  198. <div class="group_info clear">
  199. <span>
  200. [ <a
  201. href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>"
  202. class="tooltip" title="Download">DL</a>
  203. | <a
  204. href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>"
  205. class="tooltip" title="Report">RP</a> ]
  206. </span>
  207. <strong><?=$DisplayName?></strong>
  208. <div class="tags"><?=$TorrentTags->format()?>
  209. </div>
  210. </div>
  211. </td>
  212. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?>
  213. </td>
  214. <td class="number_column"><?=number_format($Torrent['Snatched'])?>
  215. </td>
  216. <td
  217. class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>">
  218. <?=number_format($Torrent['Seeders'])?>
  219. </td>
  220. <td class="number_column"><?=number_format($Torrent['Leechers'])?>
  221. </td>
  222. </tr>
  223. <?php
  224. }
  225. $TorrentTable .= ob_get_clean();
  226. } ?>
  227. <!-- I hate that proton is making me do it like this -->
  228. <!--<div class="head colhead_dark" style="margin-top: 8px;">-->
  229. <table style="margin-top: 8px;" class="subscribed_collages_table">
  230. <tr class="colhead_dark">
  231. <td>
  232. <span class="float_left">
  233. <strong><a href="collage.php?id=<?=$CollageID?>"><?=$CollageName?></a></strong> (<?=$NewTorrentCount?> new torrent<?=($NewTorrentCount == 1 ? '' : 's')?>)
  234. </span>&nbsp;
  235. <span class="float_right">
  236. <a data-toggle-target="#discog_table_<?=$CollageID?>"
  237. data-toggle-replace="<?=($ShowAll ? 'Hide' : 'Show')?>"
  238. class="brackets"><?=($ShowAll ? 'Show' : 'Hide')?></a>&nbsp;&nbsp;&nbsp;<a
  239. href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;collageid=<?=$CollageID?>"
  240. class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;<a href="#"
  241. onclick="CollageSubscribe(<?=$CollageID?>); return false;"
  242. id="subscribelink<?=$CollageID?>"
  243. class="brackets">Unsubscribe</a>
  244. </span>
  245. </td>
  246. </tr>
  247. </table>
  248. <!--</div>-->
  249. <table
  250. class="torrent_table<?=$ShowAll ? ' hidden' : ''?>"
  251. id="discog_table_<?=$CollageID?>">
  252. <tr class="colhead">
  253. <td class="small"></td>
  254. <td class="small cats_col"></td>
  255. <td><strong>Torrents</strong></td>
  256. <td>Size</td>
  257. <td class="sign snatches">
  258. </td>
  259. <td class="sign seeders">
  260. &uarr;
  261. </td>
  262. <td class="sign leechers">
  263. &darr;
  264. </td>
  265. </tr>
  266. <?=$TorrentTable?>
  267. </table>
  268. <?php
  269. } // foreach ()
  270. } // else -- if (empty($NumResults))
  271. ?>
  272. </div>
  273. <?php
  274. View::show_footer();