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.

torrents.php 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. <?php
  2. ini_set('max_execution_time', 600);
  3. set_time_limit(0);
  4. //~~~~~~~~~~~ Main bookmarks page ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
  5. function compare($X, $Y) {
  6. return($Y['count'] - $X['count']);
  7. }
  8. if (!empty($_GET['userid'])) {
  9. if (!check_perms('users_override_paranoia')) {
  10. error(403);
  11. }
  12. $UserID = $_GET['userid'];
  13. if (!is_number($UserID)) {
  14. error(404);
  15. }
  16. $DB->query("
  17. SELECT Username
  18. FROM users_main
  19. WHERE ID = '$UserID'");
  20. list($Username) = $DB->next_record();
  21. } else {
  22. $UserID = $LoggedUser['ID'];
  23. }
  24. $Sneaky = $UserID !== $LoggedUser['ID'];
  25. $Title = $Sneaky ? "$Username's bookmarked torrent groups" : 'Your bookmarked torrent groups';
  26. // Loop through the result set, building up $Collage and $TorrentTable
  27. // Then we print them.
  28. $Collage = [];
  29. $TorrentTable = '';
  30. $NumGroups = 0;
  31. $ArtistCount = [];
  32. list($GroupIDs, $CollageDataList, $TorrentList) = Users::get_bookmarks($UserID);
  33. foreach ($GroupIDs as $GroupID) {
  34. if (!isset($TorrentList[$GroupID])) {
  35. continue;
  36. }
  37. $Group = $TorrentList[$GroupID];
  38. extract(Torrents::array_group($Group));
  39. list(, $Sort, $AddedTime) = array_values($CollageDataList[$GroupID]);
  40. // Handle stats and stuff
  41. $NumGroups++;
  42. if ($Artists) {
  43. foreach ($Artists as $Artist) {
  44. if (!isset($ArtistCount[$Artist['id']])) {
  45. $ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1);
  46. } else {
  47. $ArtistCount[$Artist['id']]['count']++;
  48. }
  49. }
  50. }
  51. $TorrentTags = new Tags($TagList);
  52. /*if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) {
  53. unset($ExtendedArtists[2]);
  54. unset($ExtendedArtists[3]);
  55. $DisplayName = Artists::display_artists($ExtendedArtists);
  56. } elseif (count($Artists) > 0) {
  57. $DisplayName = Artists::display_artists(array('1' => $Artists));
  58. } else {
  59. $DisplayName = '';
  60. }*/
  61. $DisplayName = Artists::display_artists($Artists);
  62. $GroupName = empty($GroupName) ? (empty($GroupNameRJ) ? $GroupNameJP : $GroupNameRJ) : $GroupName;
  63. $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
  64. if ($GroupYear > 0) {
  65. $DisplayName = "$DisplayName [$GroupYear]";
  66. }
  67. /*
  68. if ($GroupVanityHouse) {
  69. $DisplayName .= ' [<abbr class="tooltip" title="This is a Vanity House release">VH</abbr>]';
  70. }
  71. */
  72. $SnatchedGroupClass = $GroupFlags['IsSnatched'] ? ' snatched_group' : '';
  73. // Start an output buffer, so we can store this output in $TorrentTable
  74. ob_start();
  75. if (count($Torrents) > 1) {
  76. // Grouped torrents
  77. $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1);
  78. ?>
  79. <tr class="group discog<?=$SnatchedGroupClass?>" id="group_<?=$GroupID?>">
  80. <td class="center">
  81. <div id="showimg_<?=$GroupID?>" class="<?=($ShowGroups ? 'hide' : 'show')?>_torrents">
  82. <a href="#" class="tooltip show_torrents_link" onclick="toggle_group(<?=$GroupID?>, this, event);" title="Collapse this group. Hold &quot;Ctrl&quot; while clicking to collape all groups on this page."></a>
  83. </div>
  84. </td>
  85. <td class="center">
  86. <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>"></div>
  87. </td>
  88. <td colspan="5">
  89. <strong><?=$DisplayName?></strong>
  90. <span style="text-align: right;" class="float_right">
  91. <?=time_diff($AddedTime);?>
  92. <? if (!$Sneaky) { ?>
  93. <br />
  94. <a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a>
  95. <? } ?>
  96. </span>
  97. <div class="tags"><?=$TorrentTags->format()?></div>
  98. </td>
  99. </tr>
  100. <?
  101. $LastRemasterYear = '-';
  102. $LastRemasterTitle = '';
  103. $LastRemasterRecordLabel = '';
  104. $LastRemasterCatalogueNumber = '';
  105. $LastMedia = '';
  106. $EditionID = 0;
  107. unset($FirstUnknown);
  108. foreach ($Torrents as $TorrentID => $Torrent) {
  109. /*
  110. if ($Torrent['Remastered'] && !$Torrent['RemasterYear']) {
  111. $FirstUnknown = !isset($FirstUnknown);
  112. }
  113. */
  114. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  115. /*
  116. if (
  117. $Torrent['RemasterTitle'] != $LastRemasterTitle
  118. || $Torrent['RemasterYear'] != $LastRemasterYear
  119. || $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel
  120. || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber
  121. || $FirstUnknown
  122. || $Torrent['Media'] != $LastMedia
  123. ) {
  124. $EditionID++;
  125. ?>
  126. <tr class="group_torrent groupid_<?=$GroupID?> edition<?=$SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
  127. <td colspan="7" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?=$GroupID?>, <?=$EditionID?>, this, event)" class="tooltip" title="Collapse this edition. Hold &quot;Ctrl&quot; while clicking to collapse all editions in this torrent group.">&minus;</a> <?=Torrents::edition_string($Torrent, $Group)?></strong></td>
  128. </tr>
  129. <?
  130. }
  131. $LastRemasterTitle = $Torrent['RemasterTitle'];
  132. $LastRemasterYear = $Torrent['RemasterYear'];
  133. $LastRemasterRecordLabel = $Torrent['RemasterRecordLabel'];
  134. $LastRemasterCatalogueNumber = $Torrent['RemasterCatalogueNumber'];
  135. $LastMedia = $Torrent['Media'];
  136. */
  137. ?>
  138. <tr class="group_torrent torrent_row groupid_<?=$GroupID?> edition_<?=$EditionID?><?=$SnatchedTorrentClass . $SnatchedGroupClass . (!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1 ? ' hidden' : '')?>">
  139. <td colspan="3">
  140. <span>[ <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>
  141. <? if (Torrents::can_use_token($Torrent)) { ?>
  142. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  143. <? } ?>
  144. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  145. </span>
  146. &nbsp;&nbsp;&raquo;&nbsp; <a href="torrents.php?id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>"><?=Torrents::torrent_info($Torrent)?></a>
  147. </td>
  148. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  149. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  150. <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
  151. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  152. </tr>
  153. <?
  154. }
  155. } else {
  156. // Viewing a type that does not require grouping
  157. $TorrentID = key($Torrents);
  158. $Torrent = current($Torrents);
  159. $DisplayName = Artists::display_artists(Artists::get_artist($GroupID));
  160. $DisplayName .= '<a href="torrents.php?id='.$GroupID.'" class="tooltip" title="View torrent group" dir="ltr">'.$GroupName.'</a>';
  161. if ($Torrent['IsSnatched']) {
  162. $DisplayName .= ' ' . Format::torrent_label('Snatched!');
  163. }
  164. if ($Torrent['FreeTorrent'] === '1') {
  165. $DisplayName .= ' ' . Format::torrent_label('Freeleech!');
  166. } elseif ($Torrent['FreeTorrent'] === '2') {
  167. $DisplayName .= ' ' . Format::torrent_label('Neutral leech!');
  168. } elseif ($Torrent['PersonalFL']) {
  169. $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!');
  170. }
  171. $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : '';
  172. ?>
  173. <tr class="torrent torrent_row<?=$SnatchedTorrentClass . $SnatchedGroupClass?>" id="group_<?=$GroupID?>">
  174. <td></td>
  175. <td class="center">
  176. <div title="<?=$TorrentTags->title()?>" class="tooltip <?=Format::css_category($GroupCategoryID)?> <?=$TorrentTags->css_name()?>">
  177. </div>
  178. </td>
  179. <td>
  180. <span>
  181. [ <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>
  182. <? if (Torrents::can_use_token($Torrent)) { ?>
  183. | <a href="torrents.php?action=download&amp;id=<?=$TorrentID ?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;torrent_pass=<?=$LoggedUser['torrent_pass']?>&amp;usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a>
  184. <? } ?>
  185. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a> ]
  186. </span>
  187. <span class="float_right float_clear"><?=time_diff($AddedTime);?></span>
  188. <? if (!$Sneaky) { ?>
  189. <span class="float_right float_clear"><a href="#group_<?=$GroupID?>" class="brackets remove_bookmark" onclick="Unbookmark('torrent', <?=$GroupID?>, ''); return false;">Remove bookmark</a></span>
  190. <? } ?>
  191. <strong><?=$DisplayName?></strong>
  192. <div class="tags"><?=$TorrentTags->format()?></div>
  193. </td>
  194. <td class="number_column nobr"><?=Format::get_size($Torrent['Size'])?></td>
  195. <td class="number_column"><?=number_format($Torrent['Snatched'])?></td>
  196. <td class="number_column<?=(($Torrent['Seeders'] == 0) ? ' r00' : '')?>"><?=number_format($Torrent['Seeders'])?></td>
  197. <td class="number_column"><?=number_format($Torrent['Leechers'])?></td>
  198. </tr>
  199. <?
  200. }
  201. $TorrentTable .= ob_get_clean();
  202. // Album art
  203. ob_start();
  204. $DisplayName = '';
  205. /*if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5])|| !empty($ExtendedArtists[6])) {
  206. unset($ExtendedArtists[2]);
  207. unset($ExtendedArtists[3]);
  208. $DisplayName .= Artists::display_artists($ExtendedArtists, false);
  209. } elseif (count($Artists) > 0) {
  210. $DisplayName .= Artists::display_artists(array('1' => $Artists), false);
  211. }*/
  212. $DisplayName .= Artists::display_artists($Artists, false);
  213. $DisplayName .= $GroupName;
  214. if ($GroupYear > 0) {
  215. $DisplayName = "$DisplayName [$GroupYear]";
  216. }
  217. $Tags = display_str($TorrentTags->format());
  218. $PlainTags = implode(', ', $TorrentTags->get_tags());
  219. ?>
  220. <? /* ?>
  221. <li class="image_group_<?=$GroupID?>">
  222. <a href="torrents.php?id=<?=$GroupID?>" class="bookmark_<?=$GroupID?>">
  223. <? if ($WikiImage) { ?>
  224. <img class="tooltip_interactive" src="<?=ImageTools::process($WikiImage, 'thumb')?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?> <br /> <?=$Tags?>" data-title-plain="<?="$DisplayName ($PlainTags)"?>" width="118" />
  225. <? } else { ?>
  226. <div style="width: 107px; padding: 5px;"><?=$DisplayName?></div>
  227. <? } ?>
  228. </a>
  229. </li>
  230. <? */ ?>
  231. <div class='collage_image image_group_<?=$GroupID?>'>
  232. <a href="torrents.php?id=<?=$GroupID?>" class="bookmark_<?=$GroupID?>">
  233. <? if (!$WikiImage) {
  234. $WikiImage = STATIC_SERVER.'common/noartwork/nocover.png';
  235. } ?>
  236. <img class="tooltip_interactive" src="<?=ImageTools::process($WikiImage, 'thumb')?>" alt="<?=$DisplayName?>" title="<?=$DisplayName?> <br /> <?=$Tags?>" data-title-plain="<?="$DisplayName ($PlainTags)"?>" width="100%" />
  237. </a>
  238. </div>
  239. <?
  240. $Collage[] = ob_get_clean();
  241. }
  242. $CollageCovers = isset($LoggedUser['CollageCovers']) ? (int)$LoggedUser['CollageCovers'] : 10;
  243. $CollagePages = [];
  244. for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) {
  245. $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers);
  246. $CollagePage = '';
  247. foreach ($Groups as $Group) {
  248. $CollagePage .= $Group;
  249. }
  250. $CollagePages[] = $CollagePage;
  251. }
  252. View::show_header($Title, 'browse,collage,wall');
  253. ?>
  254. <div class="thin">
  255. <div class="header">
  256. <h2><? if (!$Sneaky) { ?><a href="feeds.php?feed=torrents_bookmarks_t_<?=$LoggedUser['torrent_pass']?>&amp;user=<?=$LoggedUser['ID']?>&amp;auth=<?=$LoggedUser['RSS_Auth']?>&amp;passkey=<?=$LoggedUser['torrent_pass']?>&amp;authkey=<?=$LoggedUser['AuthKey']?>&amp;name=<?=urlencode(SITE_NAME.': Bookmarked Torrents')?>"><img src="<?=STATIC_SERVER?>/common/symbols/rss.png" alt="RSS feed" /></a>&nbsp;<? } ?><?=$Title?></h2>
  257. <div class="linkbox">
  258. <a href="bookmarks.php?type=torrents" class="brackets">Torrents</a>
  259. <a href="bookmarks.php?type=artists" class="brackets">Artists</a>
  260. <a href="bookmarks.php?type=collages" class="brackets">Collections</a>
  261. <a href="bookmarks.php?type=requests" class="brackets">Requests</a>
  262. <? if (count($TorrentList) > 0) { ?>
  263. <br /><br />
  264. <a href="bookmarks.php?action=remove_snatched&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets" onclick="return confirm('Are you sure you want to remove the bookmarks for all items you\'ve snatched?');">Remove snatched</a>
  265. <a href="bookmarks.php?action=edit&amp;type=torrents" class="brackets">Manage torrents</a>
  266. <? } ?>
  267. </div>
  268. </div>
  269. <? if (count($TorrentList) === 0) { ?>
  270. <div class="box pad" align="center">
  271. <h2>You have not bookmarked any torrents.</h2>
  272. </div>
  273. </div><!--content-->
  274. <?
  275. View::show_footer();
  276. die();
  277. } ?>
  278. <div class="sidebar">
  279. <div class="box box_info box_statistics_bookmarked_torrents">
  280. <div class="head"><strong>Stats</strong></div>
  281. <ul class="stats nobullet">
  282. <li>Torrent groups: <?=$NumGroups?></li>
  283. <li>Artists: <?=count($ArtistCount)?></li>
  284. </ul>
  285. </div>
  286. <div class="box box_tags">
  287. <div class="head"><strong>Top Tags</strong></div>
  288. <div class="pad">
  289. <ol style="padding-left: 5px;">
  290. <? Tags::format_top(5) ?>
  291. </ol>
  292. </div>
  293. </div>
  294. <div class="box box_artists">
  295. <div class="head"><strong>Top Artists</strong></div>
  296. <div class="pad">
  297. <?
  298. $Indent = "\t\t\t\t";
  299. if (count($ArtistCount) > 0) {
  300. echo "$Indent<ol style=\"padding-left: 5px;\">\n";
  301. uasort($ArtistCount, 'compare');
  302. $i = 0;
  303. foreach ($ArtistCount as $ID => $Artist) {
  304. $i++;
  305. if ($i > 10) {
  306. break;
  307. }
  308. ?>
  309. <li><a href="artist.php?id=<?=$ID?>"><?=display_str($Artist['name'])?></a> (<?=$Artist['count']?>)</li>
  310. <?
  311. }
  312. echo "$Indent</ol>\n";
  313. } else {
  314. echo "$Indent<ul class=\"nobullet\" style=\"padding-left: 5px;\">\n";
  315. echo "$Indent\t<li>There are no artists to display.</li>\n";
  316. echo "$Indent</ul>\n";
  317. }
  318. ?>
  319. </div>
  320. </div>
  321. </div>
  322. <div class="main_column">
  323. <?
  324. if ($CollageCovers !== 0) { ?>
  325. <div id="coverart" class="box">
  326. <div class="head" id="coverhead"><strong>Cover art</strong></div>
  327. <div class="collage_images" id="collage_page0">
  328. <?
  329. $Page1 = array_slice($Collage, 0, $CollageCovers);
  330. foreach ($Page1 as $Group) {
  331. echo $Group;
  332. }
  333. ?>
  334. </div>
  335. <script>
  336. $('.collage_image img').on('load', function() {
  337. var test = true
  338. $('.collage_image img').toArray().forEach(function(el) {
  339. if (!el.complete) test = false
  340. })
  341. if (test) wall('.collage_images', '.collage_image', 4)
  342. })
  343. wall('.collage_images', '.collage_image', 4)
  344. </script>
  345. </div>
  346. <? if ($NumGroups > $CollageCovers) { ?>
  347. <div class="linkbox pager" style="clear: left;" id="pageslinksdiv">
  348. <span id="firstpage" class="invisible"><a href="#" class="pageslink" onclick="collageShow.page(0, this); return false;">&lt;&lt; First</a> | </span>
  349. <span id="prevpage" class="invisible"><a href="#" id="prevpage" class="pageslink" onclick="collageShow.prevPage(); return false;">&lt; Prev</a> | </span>
  350. <? for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { ?>
  351. <span id="pagelink<?=$i?>" class="<?=(($i > 4) ? 'hidden' : '')?><?=(($i === 0) ? ' selected' : '')?>"><a href="#" class="pageslink" onclick="collageShow.page(<?=$i?>, this); wall('.collage_images', '.collage_image', 4); return false;"><?=($CollageCovers * $i + 1)?>-<?=min($NumGroups, $CollageCovers * ($i + 1))?></a><?=(($i !== ceil($NumGroups / $CollageCovers) - 1) ? ' | ' : '')?></span>
  352. <? } ?>
  353. <span id="nextbar" class="<?=(($NumGroups / $CollageCovers > 5) ? 'hidden' : '')?>"> | </span>
  354. <span id="nextpage"><a href="#" class="pageslink" onclick="collageShow.nextPage(); wall('.collage_images', '.collage_image', 4); return false;">Next &gt;</a></span>
  355. <span id="lastpage" class="<?=(ceil($NumGroups / $CollageCovers) === 2 ? 'invisible' : '')?>"> | <a href="#" id="lastpage" class="pageslink" onclick="collageShow.page(<?=(ceil($NumGroups / $CollageCovers) - 1)?>, this); return false;">Last &gt;&gt;</a></span>
  356. </div>
  357. <script type="text/javascript">
  358. collageShow.init(<?=json_encode($CollagePages)?>);
  359. </script>
  360. <?
  361. }
  362. }
  363. ?>
  364. <table class="torrent_table grouping cats" id="torrent_table">
  365. <tr class="colhead_dark">
  366. <td><!-- expand/collapse --></td>
  367. <td><!-- Category --></td>
  368. <td width="70%"><strong>Torrents</strong></td>
  369. <td>Size</td>
  370. <td class="sign snatches">
  371. <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>
  372. </td>
  373. <td class="sign seeders">
  374. <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>
  375. </td>
  376. <td class="sign leechers">
  377. <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>
  378. </td>
  379. </tr>
  380. <?=$TorrentTable?>
  381. </table>
  382. </div>
  383. </div>
  384. <?
  385. View::show_footer();