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

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