Oppaitime'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 9.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <?
  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 class="thin">
  41. <div class="header">
  42. <h2>Subscribed collections<?=($ShowAll ? '' : ' with new additions')?></h2>
  43. <div class="linkbox">
  44. <?
  45. if ($ShowAll) {
  46. ?>
  47. <br /><br />
  48. <a href="userhistory.php?action=subscribed_collages&amp;showall=0" class="brackets">Only display collections with new additions</a>&nbsp;&nbsp;&nbsp;
  49. <?
  50. } else {
  51. ?>
  52. <br /><br />
  53. <a href="userhistory.php?action=subscribed_collages&amp;showall=1" class="brackets">Show all subscribed collections</a>&nbsp;&nbsp;&nbsp;
  54. <?
  55. }
  56. ?>
  57. <a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;
  58. </div>
  59. </div>
  60. <?
  61. if (!$NumResults) {
  62. ?>
  63. <div class="center">
  64. No subscribed collections<?=($ShowAll ? '' : ' with new additions')?>
  65. </div>
  66. <?
  67. } else {
  68. $HideGroup = '';
  69. $ActionTitle = 'Hide';
  70. $ActionURL = 'hide';
  71. $ShowGroups = 0;
  72. foreach ($CollageSubs as $Collage) {
  73. $TorrentTable = '';
  74. list($CollageID, $CollageName, $CollageSize, $LastVisit) = $Collage;
  75. $RS = $DB->query("
  76. SELECT GroupID
  77. FROM collages_torrents
  78. WHERE CollageID = $CollageID
  79. AND AddedOn > '" . db_string($LastVisit) . "'
  80. ORDER BY AddedOn");
  81. $NewTorrentCount = $DB->record_count();
  82. $GroupIDs = $DB->collect('GroupID', false);
  83. if (count($GroupIDs) > 0) {
  84. $TorrentList = Torrents::get_groups($GroupIDs);
  85. } else {
  86. $TorrentList = [];
  87. }
  88. $Artists = Artists::get_artists($GroupIDs);
  89. $Number = 0;
  90. foreach ($GroupIDs as $GroupID) {
  91. if (!isset($TorrentList[$GroupID])) {
  92. continue;
  93. }
  94. $Group = $TorrentList[$GroupID];
  95. extract(Torrents::array_group($Group));
  96. $TorrentTags = new Tags($TagList);
  97. $DisplayName = '';
  98. if (isset($Artists)) {
  99. $DisplayName .= '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  100. }
  101. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  102. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  103. $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage).'" ';
  104. }
  105. $DisplayName .= "dir=\"ltr\">".($GroupName ? $GroupName : ($GroupNameRJ ? $GroupNameRJ : $GroupNameJP))."</a>";
  106. if ($GroupYear > 0) {
  107. $DisplayName = "$DisplayName [$GroupYear]";
  108. }
  109. $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
  110. // Start an output buffer, so we can store this output in $TorrentTable
  111. ob_start();
  112. if (count($Torrents) > 1 || $GroupCategoryID == 1) {
  113. ?>
  114. <tr class="group<?=$SnatchedGroupClass?>" id="group_<?=$CollageID?>_<?=$GroupID?>">
  115. <td class="center">
  116. <div id="showimg_<?=$CollageID?>_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  117. <a class="tooltip show_torrents_link" onclick="toggle_group('<?=$CollageID?>_<?=$GroupID?>', this, event);" title="Toggle this group (Hold &quot;Shift&quot; to toggle all groups)"></a>
  118. </div>
  119. </td>
  120. <td class="center cats_col">
  121. <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>">
  122. </div>
  123. </td>
  124. <td colspan="5" class="big_info">
  125. <div class="group_info clear">
  126. <strong><?=$DisplayName?></strong>
  127. <div class="tags"><?=$TorrentTags->format()?></tags>
  128. </div>
  129. </td>
  130. </tr>
  131. <?
  132. foreach ($Torrents as $TorrentID => $Torrent) {
  133. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  134. ?>
  135. <tr class="group_torrent groupid_<?=$CollageID?>_<?=$GroupID?> hidden<?=$SnatchedTorrentClass . $SnatchedGroupClass?>">
  136. <td colspan="3">
  137. <span>
  138. <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>
  139. </span>
  140. &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
  141. </td>
  142. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  143. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  144. <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Torrent['Seeders'])?></td>
  145. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  146. </tr>
  147. <?
  148. }
  149. } else {
  150. // Viewing a type that does not require grouping
  151. $TorrentID = key($Torrents);
  152. $Torrent = current($Torrents);
  153. $DisplayName = '';
  154. if (isset($Artists)) {
  155. $DisplayName .= '<div class="torrent_artists">'.Artists::display_artists($Artists).'</div> ';
  156. }
  157. $DisplayName .= "<a class=\"torrent_title\" href=\"torrents.php?id=$GroupID\" ";
  158. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  159. $DisplayName .= 'data-cover="'.ImageTools::process($WikiImage).'" ';
  160. }
  161. $DisplayName .= "dir=\"ltr\">".($GroupName ? $GroupName : ($GroupNameRJ ? $GroupNameRJ : $GroupNameJP))."</a>";
  162. if ($Torrent['IsSnatched']) {
  163. $DisplayName .= ' ' . Format::torrent_label('Snatched!');
  164. }
  165. if (!empty($Torrent['FreeTorrent'])) {
  166. $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
  167. }
  168. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  169. ?>
  170. <tr class="torrent<?=$SnatchedTorrentClass?>" id="group_<?=$CollageID?>_<?=$GroupID?>">
  171. <td></td>
  172. <td class="center">
  173. <div title="<?=Format::pretty_category($GroupCategoryID)?>" class="tooltip <?=Format::css_category($GroupCategoryID)?>">
  174. </div>
  175. </td>
  176. <td class="big_info">
  177. <div class="group_info clear">
  178. <span>
  179. [ <a href="torrents.php?action=download&amp;id=<?=$TorrentID?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>" class="tooltip" title="Download">DL</a>
  180. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  181. </span>
  182. <strong><?=$DisplayName?></strong>
  183. <div class="tags"><?=$TorrentTags->format()?></div>
  184. </div>
  185. </td>
  186. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  187. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  188. <td class="number_column<?=($Torrent['Seeders'] == 0) ? ' r00' : ''?>"><?=number_format($Torrent['Seeders'])?></td>
  189. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  190. </tr>
  191. <?
  192. }
  193. $TorrentTable .= ob_get_clean();
  194. } ?>
  195. <!-- I hate that proton is making me do it like this -->
  196. <!--<div class="head colhead_dark" style="margin-top: 8px;">-->
  197. <table style="margin-top: 8px;" class="subscribed_collages_table">
  198. <tr class="colhead_dark">
  199. <td>
  200. <span class="float_left">
  201. <strong><a href="collage.php?id=<?=$CollageID?>"><?=$CollageName?></a></strong> (<?=$NewTorrentCount?> new torrent<?=($NewTorrentCount == 1 ? '' : 's')?>)
  202. </span>&nbsp;
  203. <span class="float_right">
  204. <a data-toggle-target="#discog_table_<?=$CollageID?>" data-toggle-replace="<?=($ShowAll ? 'Hide' : 'Show')?>" class="brackets"><?=($ShowAll ? 'Show' : 'Hide')?></a>&nbsp;&nbsp;&nbsp;<a href="userhistory.php?action=catchup_collages&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;collageid=<?=$CollageID?>" class="brackets">Catch up</a>&nbsp;&nbsp;&nbsp;<a href="#" onclick="CollageSubscribe(<?=$CollageID?>); return false;" id="subscribelink<?=$CollageID?>" class="brackets">Unsubscribe</a>
  205. </span>
  206. </td>
  207. </tr>
  208. </table>
  209. <!--</div>-->
  210. <table class="torrent_table<?=$ShowAll ? ' hidden' : ''?>" id="discog_table_<?=$CollageID?>">
  211. <tr class="colhead">
  212. <td class="small"></td>
  213. <td class="small cats_col"></td>
  214. <td><strong>Torrents</strong></td>
  215. <td>Size</td>
  216. <td class="sign snatches">
  217. <a><svg width="15" height="15" fill="white" class="tooltip" alt="Snatches" title="Snatches" viewBox="3 0 88 98"><path d="M20 20 A43 43,0,1,0,77 23 L90 10 L55 10 L55 45 L68 32 A30.27 30.27,0,1,1,28 29"></path></svg></a>
  218. </td>
  219. <td class="sign seeders">
  220. <a><svg width="11" height="15" fill="white" class="tooltip" alt="Seeders" title="Seeders"><polygon points="0,7 5.5,0 11,7 8,7 8,15 3,15 3,7"></polygon></svg></a>
  221. </td>
  222. <td class="sign leechers">
  223. <a><svg width="11" height="15" fill="white" class="tooltip" alt="Leechers" title="Leechers"><polygon points="0,8 5.5,15 11,8 8,8 8,0 3,0 3,8"></polygon></svg></a>
  224. </td>
  225. </tr>
  226. <?=$TorrentTable?>
  227. </table>
  228. <?
  229. } // foreach ()
  230. } // else -- if (empty($NumResults))
  231. ?>
  232. </div>
  233. <?
  234. View::show_footer();
  235. ?>