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.

details.php 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <?php
  2. function compare($X, $Y) {
  3. return($Y['score'] - $X['score']);
  4. }
  5. header('Access-Control-Allow-Origin: *');
  6. define('MAX_PERS_COLLAGES', 3); // How many personal collages should be shown by default
  7. define('MAX_COLLAGES', 5); // How many normal collages should be shown by default
  8. $GroupID = ceil($_GET['id']);
  9. if (!empty($_GET['revisionid']) && is_number($_GET['revisionid'])) {
  10. $RevisionID = $_GET['revisionid'];
  11. } else {
  12. $RevisionID = 0;
  13. }
  14. include(SERVER_ROOT.'/sections/torrents/functions.php');
  15. include(SERVER_ROOT.'/classes/mediainfo.class.php');
  16. $TorrentCache = get_group_info($GroupID, true, $RevisionID);
  17. $TorrentDetails = $TorrentCache[0];
  18. $TorrentList = $TorrentCache[1];
  19. // Group details
  20. list($WikiBody, $WikiImage, $GroupID, $GroupName, $GroupNameJP, $GroupYear,
  21. $GroupStudio, $GroupSeries, $GroupCatalogueNumber, $GroupPages, $GroupCategoryID,
  22. $GroupDLsiteID, $GroupTime, $TorrentTags, $TorrentTagIDs, $TorrentTagUserIDs,
  23. $TagPositiveVotes, $TagNegativeVotes, $Screenshots, $GroupFlags) = array_values($TorrentDetails);
  24. $DisplayName = "<span dir=\"ltr\">$GroupName</span><br />";
  25. $AltName = $GroupName; // Goes in the alt text of the image
  26. $Title = $GroupName; // goes in <title>
  27. $WikiBody = Text::full_format($WikiBody);
  28. $Artists = Artists::get_artist($GroupID);
  29. if ($GroupNameJP && $GroupNameJP != $GroupName) {
  30. $DisplayName .= "<span dir=\"ltr\">$GroupNameJP</span><br />";
  31. }
  32. if ($Artists) {
  33. $DisplayName = Artists::display_artists($Artists, true) . "$DisplayName";
  34. $AltName = display_str(Artists::display_artists($Artists, false)) . $AltName;
  35. $Title = $AltName;
  36. }
  37. if ($GroupCategoryID) {
  38. $DisplayName = '<div class="'.Format::css_category($GroupCategoryID).' group_cat"></div>' . "$DisplayName";
  39. }
  40. if ($GroupYear > 0) {
  41. $DisplayName .= " [$GroupYear]";
  42. $AltName .= " [$GroupYear]";
  43. $Title .= " [$GroupYear]";
  44. }
  45. if ($GroupStudio) {
  46. $DisplayName .= " [$GroupStudio]";
  47. }
  48. if ($GroupCatalogueNumber) {
  49. $DisplayName .= " [$GroupCatalogueNumber]";
  50. }
  51. if ($GroupPages) {
  52. $DisplayName .= " [{$GroupPages}p]";
  53. }
  54. if ($GroupDLsiteID) {
  55. $DisplayName .= " [$GroupDLsiteID]";
  56. }
  57. /*
  58. if ($GroupVanityHouse) {
  59. $DisplayName .= ' [Vanity House]';
  60. $AltName .= ' [Vanity House]';
  61. }
  62. */
  63. /*if ($GroupCategoryID == 1) {
  64. $DisplayName .= ' ['.$ReleaseTypes[$ReleaseType].']';
  65. $AltName .= ' ['.$ReleaseTypes[$ReleaseType].']';
  66. }*/
  67. $Tags = array();
  68. if ($TorrentTags != '') {
  69. $TorrentTags = explode('|', $TorrentTags);
  70. $TorrentTagIDs = explode('|', $TorrentTagIDs);
  71. $TorrentTagUserIDs = explode('|', $TorrentTagUserIDs);
  72. $TagPositiveVotes = explode('|', $TagPositiveVotes);
  73. $TagNegativeVotes = explode('|', $TagNegativeVotes);
  74. foreach ($TorrentTags as $TagKey => $TagName) {
  75. $Tags[$TagKey]['name'] = $TagName;
  76. $Tags[$TagKey]['score'] = ($TagPositiveVotes[$TagKey] - $TagNegativeVotes[$TagKey]);
  77. $Tags[$TagKey]['id'] = $TorrentTagIDs[$TagKey];
  78. $Tags[$TagKey]['userid'] = $TorrentTagUserIDs[$TagKey];
  79. $Split = Tags::get_name_and_class($TagName);
  80. $Tags[$TagKey]['display'] = $Split['name'];
  81. $Tags[$TagKey]['class'] = $Split['class'];
  82. }
  83. uasort($Tags, 'compare');
  84. }
  85. /*if (check_perms('site_debug')) {
  86. print_r($TorrentTags);
  87. print_r($Tags);
  88. print_r($TorrentTagUserIDs);
  89. die();
  90. }*/
  91. $CoverArt = $Cache->get_value("torrents_cover_art_$GroupID");
  92. if (!$CoverArt) {
  93. $DB->query("
  94. SELECT ID, Image, Summary, UserID, Time
  95. FROM cover_art
  96. WHERE GroupID = '$GroupID'
  97. ORDER BY Time ASC");
  98. $CoverArt = array();
  99. $CoverArt = $DB->to_array();
  100. if ($DB->has_results()) {
  101. $Cache->cache_value("torrents_cover_art_$GroupID", $CoverArt, 0);
  102. }
  103. }
  104. // Comments (must be loaded before View::show_header so that subscriptions and quote notifications are handled properly)
  105. list($NumComments, $Page, $Thread, $LastRead) = Comments::load('torrents', $GroupID);
  106. // Start output
  107. View::show_header($Title, 'browse,comments,torrent,bbcode,recommend,cover_art,subscriptions');
  108. ?>
  109. <div class="thin">
  110. <div class="header">
  111. <h2><?=$DisplayName?></h2>
  112. <div class="linkbox">
  113. <? if (check_perms('site_edit_wiki')) { ?>
  114. <a href="torrents.php?action=editgroup&amp;groupid=<?=$GroupID?>" class="brackets">Edit description</a>
  115. <? } ?>
  116. <a href="torrents.php?action=history&amp;groupid=<?=$GroupID?>" class="brackets">View history</a>
  117. <? if ($RevisionID && check_perms('site_edit_wiki')) { ?>
  118. <a href="torrents.php?action=revert&amp;groupid=<?=$GroupID ?>&amp;revisionid=<?=$RevisionID ?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Revert to this revision</a>
  119. <?
  120. }
  121. if (Bookmarks::has_bookmarked('torrent', $GroupID)) {
  122. ?>
  123. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="remove_bookmark brackets" onclick="Unbookmark('torrent', <?=$GroupID?>, 'Bookmark'); return false;">Remove bookmark</a>
  124. <? } else { ?>
  125. <a href="#" id="bookmarklink_torrent_<?=$GroupID?>" class="add_bookmark brackets" onclick="Bookmark('torrent', <?=$GroupID?>, 'Remove bookmark'); return false;">Bookmark</a>
  126. <? } ?>
  127. <a href="#" id="subscribelink_torrents<?=$GroupID?>" class="brackets" onclick="SubscribeComments('torrents', <?=$GroupID?>); return false;"><?=Subscriptions::has_subscribed_comments('torrents', $GroupID) !== false ? 'Unsubscribe' : 'Subscribe'?></a>
  128. <!-- <a href="#" id="recommend" class="brackets">Recommend</a> -->
  129. <?
  130. if ($Categories[$GroupCategoryID-1] == 'Movies' || $Categories[$GroupCategoryID-1] == 'Anime' || $Categories[$GroupCategoryID-1] == 'Manga' || $Categories[$GroupCategoryID-1] == 'Games') { ?>
  131. <a href="upload.php?groupid=<?=$GroupID?>" class="brackets">Add format</a>
  132. <?
  133. }
  134. if (check_perms('site_submit_requests')) { ?>
  135. <a href="requests.php?action=new&amp;groupid=<?=$GroupID?>" class="brackets">Request format</a>
  136. <? } ?>
  137. <a href="torrents.php?action=grouplog&amp;groupid=<?=$GroupID?>" class="brackets">View log</a>
  138. </div>
  139. </div>
  140. <? /* Misc::display_recommend($GroupID, "torrent"); */ ?>
  141. <div class="sidebar">
  142. <div class="box box_image box_image_albumart box_albumart"><!-- .box_albumart deprecated -->
  143. <div class="head">
  144. <strong><?=(count($CoverArt) > 0 ? 'Covers (' . (count($CoverArt) + 1) . ')' : 'Cover')?></strong>
  145. <?
  146. if (count($CoverArt) > 0) {
  147. if (empty($LoggedUser['ShowExtraCovers'])) {
  148. for ($Index = 0; $Index <= count($CoverArt); $Index++) { ?>
  149. <span id="cover_controls_<?=($Index)?>"<?=($Index > 0 ? ' style="display: none;"' : '')?>>
  150. <? if ($Index == count($CoverArt)) { ?>
  151. <a class="brackets prev_cover" data-gazelle-prev-cover="<?=($Index - 1)?>" href="#">Prev</a>
  152. <a class="brackets show_all_covers" href="#">Show all</a>
  153. <span class="brackets next_cover">Next</span>
  154. <? } elseif ($Index > 0) { ?>
  155. <a class="brackets prev_cover" data-gazelle-prev-cover="<?=($Index - 1)?>" href="#">Prev</a>
  156. <a class="brackets show_all_covers" href="#">Show all</a>
  157. <a class="brackets next_cover" data-gazelle-next-cover="<?=($Index + 1)?>" href="#">Next</a>
  158. <? } elseif ($Index == 0 && count($CoverArt) > 0) { ?>
  159. <span class="brackets prev_cover">Prev</span>
  160. <a class="brackets show_all_covers" href="#">Show all</a>
  161. <a class="brackets next_cover" data-gazelle-next-cover="<?=($Index + 1)?>" href="#">Next</a>
  162. <? } ?>
  163. </span>
  164. <?
  165. }
  166. } else { ?>
  167. <span>
  168. <a class="brackets show_all_covers" href="#">Hide</a>
  169. </span>
  170. <?
  171. }
  172. } ?>
  173. </div>
  174. <? $Index = 0; ?>
  175. <div id="covers">
  176. <div id="cover_div_<?=$Index?>">
  177. <? if ($WikiImage != '') { ?>
  178. <div><img width="100%" class="lightbox-init" src="<?=ImageTools::process($WikiImage, true)?>" alt="<?=$AltName?>" /></div>
  179. <? } else { ?>
  180. <div><img width="100%" src="<?=STATIC_SERVER?>common/noartwork/nocover.png" alt="<?=$Categories[$GroupCategoryID - 1]?>" class="brackets tooltip" title="<?=$Categories[$GroupCategoryID - 1]?>" /></div>
  181. <?
  182. }
  183. $Index++;
  184. ?>
  185. </div>
  186. <? foreach ($CoverArt as $Cover) {
  187. list($ImageID, $Image, $Summary, $AddedBy) = $Cover;
  188. ?>
  189. <div id="cover_div_<?=$Index?>"<?=(empty($LoggedUser['ShowExtraCovers']) ? ' style="display: none;"' : '')?>>
  190. <div>
  191. <?
  192. if (empty($LoggedUser['ShowExtraCovers'])) {
  193. $Src = 'src="" data-gazelle-temp-src="' . ImageTools::process($Image, true) . '"';
  194. } else {
  195. $Src = 'src="' . ImageTools::process($Image, true) . '"';
  196. }
  197. ?>
  198. <img id="cover_<?=$Index?>" class="lightbox-init" lightbox-img="<?=ImageTools::process($Image)?>" width="100%" <?=$Src?> alt="<?=$Summary?>" />
  199. </div>
  200. <ul class="stats nobullet">
  201. <li>
  202. <?=$Summary?>
  203. <?=(check_perms('users_mod') ? ' added by ' . Users::format_username($AddedBy, false, false, false, false, false) : '')?>
  204. <span class="remove remove_cover_art"><a href="#" onclick="if (confirm('Do not delete valid alternative cover art. Are you sure you want to delete this cover art?') == true) { ajax.get('torrents.php?action=remove_cover_art&amp;auth=<?=$LoggedUser['AuthKey']?>&amp;id=<?=$ImageID?>&amp;groupid=<?=$GroupID?>'); this.parentNode.parentNode.parentNode.style.display = 'none'; this.parentNode.parentNode.parentNode.previousElementSibling.style.display = 'none'; } else { return false; }" class="brackets tooltip" title="Remove image">X</a></span>
  205. </li>
  206. </ul>
  207. </div>
  208. <?
  209. $Index++;
  210. } ?>
  211. </div>
  212. <?
  213. if (check_perms('site_edit_wiki') && $WikiImage != '') { ?>
  214. <div id="add_cover_div">
  215. <div style="padding: 10px;">
  216. <span style="float: right;" class="additional_add_artists">
  217. <a onclick="addCoverField(); return false;" href="#" class="brackets">Add alternate cover</a>
  218. </span>
  219. </div>
  220. <div class="body">
  221. <form class="add_form" name="covers" id="add_covers_form" action="torrents.php" method="post">
  222. <div id="add_cover">
  223. <input type="hidden" name="action" value="add_cover_art" />
  224. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  225. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  226. </div>
  227. </form>
  228. </div>
  229. </div>
  230. <? } ?>
  231. </div>
  232. <?
  233. if ($Categories[$GroupCategoryID - 1] != 'Other') {
  234. $ShownWith = false;
  235. ?>
  236. <div class="box box_artists">
  237. <div class="head"><strong>Artists</strong>
  238. <?=check_perms('torrents_edit') ? '<span style="float: right;" class="edit_artists"><a onclick="ArtistManager(); return false;" href="#" class="brackets">Edit</a></span>' : ''?>
  239. </div>
  240. <ul class="stats nobullet" id="artist_list">
  241. <? foreach ($Artists as $Num => $Artist) { ?>
  242. <li class="artist"><?=Artists::display_artist($Artist)?>
  243. <? if (check_perms('torrents_edit')) { ?>
  244. <span class="remove remove_artist"><a href="javascript:void(0);" onclick="ajax.get('torrents.php?action=delete_alias&amp;auth=' + authkey + '&amp;groupid=<?=$GroupID?>&amp;artistid=<?=$Artist['id']?>&amp;importance=4'); this.parentNode.parentNode.style.display = 'none';" class="brackets tooltip" title="Remove artist">X</a></span>
  245. <? } ?>
  246. </li>
  247. <? } ?>
  248. </ul>
  249. </div>
  250. <? if (check_perms('torrents_add_artist')) { ?>
  251. <div class="box box_addartists">
  252. <div class="head"><strong>Add artist</strong></div>
  253. <div class="body">
  254. <form class="add_form" name="artists" action="torrents.php" method="post">
  255. <input type="hidden" name="action" value="add_alias" />
  256. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  257. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  258. <input type="text" id="artist" name="artistname[]" size="27"<? Users::has_autocomplete_enabled('other'); ?> />
  259. <input type="submit" value="Add" />
  260. </form>
  261. </div>
  262. </div>
  263. <?
  264. }
  265. }
  266. include(SERVER_ROOT.'/sections/torrents/vote_ranks.php');
  267. include(SERVER_ROOT.'/sections/torrents/vote.php');
  268. ?>
  269. <div class="box box_tags">
  270. <div class="head">
  271. <strong>Tags</strong>
  272. <?
  273. $DeletedTag = $Cache->get_value("deleted_tags_$GroupID".'_'.$LoggedUser['ID']);
  274. if (!empty($DeletedTag)) { ?>
  275. <form style="display: none;" id="undo_tag_delete_form" name="tags" action="torrents.php" method="post">
  276. <input type="hidden" name="action" value="add_tag" />
  277. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  278. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  279. <input type="hidden" name="tagname" value="<?=$DeletedTag?>" />
  280. <input type="hidden" name="undo" value="true" />
  281. </form>
  282. <a class="brackets" href="#" onclick="$('#undo_tag_delete_form').raw().submit(); return false;">Undo delete</a>
  283. <? } ?>
  284. </div>
  285. <?
  286. if (count($Tags) > 0) {
  287. ?>
  288. <ul class="stats nobullet">
  289. <?
  290. foreach ($Tags as $TagKey=>$Tag) {
  291. ?>
  292. <li>
  293. <a href="torrents.php?taglist=<?=$Tag['name']?>" style="float: left; display: block;" class="<?=display_str($Tag['class'])?>" ><?=display_str($Tag['display'])?></a>
  294. <div style="float: right; display: block; letter-spacing: -1px;" class="edit_tags_votes">
  295. <a href="torrents.php?action=vote_tag&amp;way=up&amp;groupid=<?=$GroupID?>&amp;tagid=<?=$Tag['id']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" title="Vote this tag up" class="brackets tooltip vote_tag_up">&and;</a>
  296. <?=$Tag['score']?>
  297. <a href="torrents.php?action=vote_tag&amp;way=down&amp;groupid=<?=$GroupID?>&amp;tagid=<?=$Tag['id']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" title="Vote this tag down" class="brackets tooltip vote_tag_down">&or;</a>
  298. <? if (check_perms('users_warn')) { ?>
  299. <a href="user.php?id=<?=$Tag['userid']?>" title="View the profile of the user that added this tag" class="brackets tooltip view_tag_user">U</a>
  300. <? } ?>
  301. <? if (empty($LoggedUser['DisableTagging']) && check_perms('site_delete_tag')) { ?>
  302. <span class="remove remove_tag"><a href="torrents.php?action=delete_tag&amp;groupid=<?=$GroupID?>&amp;tagid=<?=$Tag['id']?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets tooltip" title="Remove tag">X</a></span>
  303. <? } ?>
  304. </div>
  305. <br style="clear: both;" />
  306. </li>
  307. <?
  308. }
  309. ?>
  310. </ul>
  311. <?
  312. } else { // The "no tags to display" message was wrapped in <ul> tags to pad the text.
  313. ?>
  314. <ul><li>There are no tags to display.</li></ul>
  315. <?
  316. }
  317. ?>
  318. </div>
  319. <?
  320. if (empty($LoggedUser['DisableTagging'])) {
  321. ?>
  322. <div class="box box_addtag">
  323. <div class="head"><strong>Add tag</strong></div>
  324. <div class="body">
  325. <form class="add_form" name="tags" action="torrents.php" method="post">
  326. <input type="hidden" name="action" value="add_tag" />
  327. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  328. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  329. <input type="text" name="tagname" id="tagname" size="20"<? Users::has_autocomplete_enabled('other'); ?> />
  330. <input type="submit" value="Add" />
  331. </form>
  332. <br />
  333. <strong><a href="rules.php?p=tag" class="brackets">View tagging rules</a></strong>
  334. </div>
  335. </div>
  336. <?
  337. }
  338. ?>
  339. </div>
  340. <div class="main_column">
  341. <div class="box">
  342. <table class="torrent_table details<?=$GroupFlags['IsSnatched'] ? ' snatched' : ''?>" id="torrent_details">
  343. <tr class="colhead_dark">
  344. <td width="80%"><strong>Torrents</strong></td>
  345. <td><strong>Size</strong></td>
  346. <td class="sign snatches"><img src="static/styles/<?=$LoggedUser['StyleName'] ?>/images/snatched.png" class="tooltip" alt="Snatches" title="Snatches" /></td>
  347. <td class="sign seeders">
  348. <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>
  349. </td>
  350. <td class="sign leechers">
  351. <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>
  352. </td>
  353. </tr>
  354. <?
  355. function filelist($Str) {
  356. return "</td><td>".Format::get_size($Str[1])."</td></tr>";
  357. }
  358. foreach ($TorrentList as $Torrent) {
  359. list($TorrentID, $Media, $Container, $Codec, $Resolution, $AudioFormat, $Subbing,
  360. $Subber, $Language, $Censored, $Archive, $FileCount, $Size, $Seeders, $Leechers,
  361. $Snatched, $FreeTorrent, $FreeLeechType, $TorrentTime, $Description, $MediaInfo, $FileList,
  362. $FilePath, $UserID, $LastActive, $InfoHash, $BadTags, $BadFolders, $BadFiles,
  363. $LastReseedRequest, $LogInDB, $HasFile, $PersonalFL, $IsSnatched, $IsSeeding, $IsLeeching
  364. ) = array_values($Torrent);
  365. $Reported = false;
  366. $Reports = Torrents::get_reports($TorrentID);
  367. $NumReports = count($Reports);
  368. if ($NumReports > 0) {
  369. $Reported = true;
  370. include(SERVER_ROOT.'/sections/reportsv2/array.php');
  371. $ReportInfo = '
  372. <table class="reportinfo_table">
  373. <tr class="colhead_dark" style="font-weight: bold;">
  374. <td>This torrent has '.$NumReports.' active '.($NumReports === 1 ? 'report' : 'reports').":</td>
  375. </tr>";
  376. foreach ($Reports as $Report) {
  377. if (check_perms('admin_reports')) {
  378. $ReporterID = $Report['ReporterID'];
  379. $Reporter = Users::user_info($ReporterID);
  380. $ReporterName = $Reporter['Username'];
  381. $ReportLinks = "<a href=\"user.php?id=$ReporterID\">$ReporterName</a> <a href=\"reportsv2.php?view=report&amp;id=$Report[ID]\">reported it</a>";
  382. } else {
  383. $ReportLinks = 'Someone reported it';
  384. }
  385. if (isset($Types[$GroupCategoryID][$Report['Type']])) {
  386. $ReportType = $Types[$GroupCategoryID][$Report['Type']];
  387. } elseif (isset($Types['master'][$Report['Type']])) {
  388. $ReportType = $Types['master'][$Report['Type']];
  389. } else {
  390. //There was a type but it wasn't an option!
  391. $ReportType = $Types['master']['other'];
  392. }
  393. $ReportInfo .= "
  394. <tr>
  395. <td>$ReportLinks ".time_diff($Report['ReportedTime'], 2, true, true).' for the reason "'.$ReportType['title'].'":
  396. <blockquote>'.Text::full_format($Report['UserComment']).'</blockquote>
  397. </td>
  398. </tr>';
  399. }
  400. $ReportInfo .= "\n\t\t</table>";
  401. }
  402. $CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear)));
  403. $RegenLink = check_perms('users_mod') ? ' <a href="torrents.php?action=regen_filelist&amp;torrentid='.$TorrentID.'" class="brackets">Regenerate</a>' : '';
  404. $FileTable = '
  405. <table class="filelist_table">
  406. <tr class="colhead_dark">
  407. <td>
  408. <div class="filelist_title" style="float: left;">File Names' . $RegenLink . '</div>
  409. <div class="filelist_path" style="float: right;">' . ($FilePath ? "/$FilePath/" : '') . '</div>
  410. </td>
  411. <td class="nobr">
  412. <strong>Size</strong>
  413. </td>
  414. </tr>';
  415. if (substr($FileList, -3) == '}}}') { // Old style
  416. $FileListSplit = explode('|||', $FileList);
  417. foreach ($FileListSplit as $File) {
  418. $NameEnd = strrpos($File, '{{{');
  419. $Name = substr($File, 0, $NameEnd);
  420. if ($Spaces = strspn($Name, ' ')) {
  421. $Name = str_replace(' ', '&nbsp;', substr($Name, 0, $Spaces)) . substr($Name, $Spaces);
  422. }
  423. $FileSize = substr($File, $NameEnd + 3, -3);
  424. $FileTable .= sprintf("\n<tr class=\"row\"><td>%s</td><td class=\"number_column nobr\">%s</td></tr>", $Name, Format::get_size($FileSize));
  425. }
  426. } else {
  427. $FileListSplit = explode("\n", $FileList);
  428. foreach ($FileListSplit as $File) {
  429. $FileInfo = Torrents::filelist_get_file($File);
  430. $FileTable .= sprintf("\n<tr class=\"row\"><td>%s</td><td class=\"number_column nobr\">%s</td></tr>", $FileInfo['name'], Format::get_size($FileInfo['size']));
  431. }
  432. }
  433. $FileTable .= '
  434. </table>';
  435. $ExtraInfo = ''; // String that contains information on the torrent (e.g. format and encoding)
  436. $AddExtra = ''; // Separator between torrent properties
  437. // similar to Torrents::torrent_info()
  438. if ($Media && $GroupCategoryID != 5) { $ExtraInfo.=display_str($Media); $AddExtra=" / "; }
  439. if ($Container) { $ExtraInfo.=$AddExtra.display_str($Container); $AddExtra=' / '; }
  440. if ($Codec) { $ExtraInfo.=$AddExtra.display_str($Codec); $AddExtra=' / '; }
  441. if ($Resolution) { $ExtraInfo.=$AddExtra.display_str($Resolution); $AddExtra=' / '; }
  442. if ($AudioFormat) { $ExtraInfo.=$AddExtra.display_str($AudioFormat); $AddExtra=' / '; }
  443. if ($Language) {
  444. if ($Subber && ($GroupCategoryID == 3 || $GroupCategoryID == 4)) {
  445. $ExtraInfo.=$AddExtra.display_str($Language.' ('.$Subber.')'); $AddExtra=' / ';
  446. } else {
  447. $ExtraInfo.=$AddExtra.display_str($Language); $AddExtra=' / ';
  448. }
  449. }
  450. if ($Subbing) {
  451. if ($Subber) {
  452. if (($GroupCategoryID == 2 || $GroupCategoryID == 1) && $Subbing != "RAW") {
  453. $ExtraInfo.=$AddExtra.display_str($Subbing)." (".display_str($Subber).")"; $AddExtra=' / ';
  454. }
  455. } else {
  456. $ExtraInfo.=$AddExtra.display_str($Subbing); $AddExtra=' / ';
  457. }
  458. }
  459. if ($Archive) {
  460. $ExtraInfo .= $AddExtra.display_str('Archived ('.$Archive.')'); $AddExtra=' / ';
  461. }
  462. if (!$ExtraInfo) {
  463. $ExtraInfo = $GroupName ; $AddExtra=' / ';
  464. }
  465. if ($IsLeeching) { $ExtraInfo.=$AddExtra. Format::torrent_label('Leeching'); $AddExtra=' / '; }
  466. else if ($IsSeeding) { $ExtraInfo.=$AddExtra . Format::torrent_label('Seeding'); $AddExtra=' / '; }
  467. else if ($IsSnatched) { $ExtraInfo.=$AddExtra. Format::torrent_label('Snatched!'); $AddExtra=' / '; }
  468. if ($FreeTorrent == '1') { $ExtraInfo.=$AddExtra. Format::torrent_label('Freeleech!'); $AddExtra=' / '; }
  469. if ($FreeTorrent == '2') { $ExtraInfo.=$AddExtra. Format::torrent_label('Neutral Leech!'); $AddExtra=' / '; }
  470. // Freleechizer
  471. if ($FreeLeechType == '3') {
  472. $DB->query("
  473. SELECT GREATEST(NOW(), ExpiryTime)
  474. FROM shop_freeleeches
  475. WHERE TorrentID = $TorrentID");
  476. if ($DB->has_results()) {
  477. $ExpiryTime = $DB->next_record(MYSQLI_NUM, false)[0];
  478. $ExtraInfo .= " <strong>(" . str_replace(['week','day','hour','min','Just now','s',' '],['w','d','h','m','0m'],time_diff($ExpiryTime, 1, false)) . ")</strong>";
  479. }
  480. }
  481. if ($PersonalFL) { $ExtraInfo.=$AddExtra. Format::torrent_label('Personal Freeleech!'); $AddExtra=' / '; }
  482. if ($Reported) { $ExtraInfo.=$AddExtra. Format::torrent_label('Reported'); $AddExtra=' / '; }
  483. if (!$Censored) { $ExtraInfo .= $AddExtra.Format::torrent_label('Uncensored'); $AddExtra=' / '; }
  484. if (!empty($BadTags)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Tags'); $AddExtra=' / '; }
  485. if (!empty($BadFolders)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad Folders'); $AddExtra=' / '; }
  486. if (!empty($BadFiles)) { $ExtraInfo.=$AddExtra. Format::torrent_label('Bad File Names'); $AddExtra=' / '; }
  487. $TorrentDL = "torrents.php?action=download&amp;id=".$TorrentID."&amp;authkey=".$LoggedUser['AuthKey']."&amp;torrent_pass=".$LoggedUser['torrent_pass'];
  488. if (!($TorrentFileName = $Cache->get_value('torrent_file_name_'.$TorrentID))) {
  489. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  490. $Tor = new BencodeTorrent($TorrentFile);
  491. $TorrentFileName = $Tor->Dec['info']['name'];
  492. $Cache->cache_value('torrent_file_name_'.$TorrentID, $TorrentFileName);
  493. }
  494. $TorrentMG = "magnet:?dn=".rawurlencode($TorrentFileName)."&xt=urn:btih:".$InfoHash."&as=https://".SITE_DOMAIN."/".str_replace('&amp;','%26',$TorrentDL)."&tr=".implode("/".$LoggedUser['torrent_pass']."/announce&tr=",ANNOUNCE_URLS[0])."/".$LoggedUser['torrent_pass']."/announce&xl=".$Size;
  495. ?>
  496. <tr class="torrent_row groupid_<?=$GroupID?> group_torrent<?=($IsSnatched ? ' snatched_torrent' : '')?>" style="font-weight: normal;" id="torrent<?=$TorrentID?>">
  497. <td>
  498. <span>[ <a href="<?=$TorrentDL?>" class="tooltip" title="Download"><?=($HasFile ? 'DL' : 'Missing')?></a>
  499. | <a href="<?=$TorrentMG?>" class="tooltip" title="Magnet Link">MG</a>
  500. <? if (Torrents::can_use_token($Torrent)) { ?>
  501. | <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>
  502. <? } ?>
  503. | <a href="reportsv2.php?action=report&amp;id=<?=$TorrentID?>" class="tooltip" title="Report">RP</a>
  504. <? if ($CanEdit) { ?>
  505. | <a href="torrents.php?action=edit&amp;id=<?=$TorrentID ?>" class="tooltip" title="Edit">ED</a>
  506. <? }
  507. if (check_perms('torrents_delete') || $UserID == $LoggedUser['ID']) { ?>
  508. | <a href="torrents.php?action=delete&amp;torrentid=<?=$TorrentID ?>" class="tooltip" title="Remove">RM</a>
  509. <? }?>
  510. | <a href="torrents.php?torrentid=<?=$TorrentID ?>" class="tooltip" title="Permalink">PL</a>
  511. ]</span>
  512. &raquo; <a toggle-target="#torrent_<?=$TorrentID?>"><?=$ExtraInfo; ?></a>
  513. </td>
  514. <td class="number_column nobr"><?=Format::get_size($Size)?></td>
  515. <td class="number_column"><?=number_format($Snatched)?></td>
  516. <td class="number_column"><?=number_format($Seeders)?></td>
  517. <td class="number_column"><?=number_format($Leechers)?></td>
  518. </tr>
  519. <tr class=" groupid_<?=$GroupID?> torrentdetails pad <? if (!isset($_GET['torrentid']) || $_GET['torrentid'] != $TorrentID) { ?>hidden<? } ?>" id="torrent_<?=$TorrentID; ?>">
  520. <td colspan="5">
  521. <div id="release_<?=$TorrentID?>" class="no_overflow">
  522. <blockquote>
  523. Uploaded by <?=Users::format_username($UserID, false, false, false)?> <?=time_diff($TorrentTime);?>
  524. <? if ($Seeders == 0) {
  525. if ($LastActive != '0000-00-00 00:00:00' && time() - strtotime($LastActive) >= 1209600) { ?>
  526. <br /><strong>Last active: <?=time_diff($LastActive); ?></strong>
  527. <? } else { ?>
  528. <br />Last active: <?=time_diff($LastActive); ?>
  529. <? }
  530. }
  531. if (($Seeders == 0 && $LastActive != '0000-00-00 00:00:00' && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) || check_perms('users_mod')) { ?>
  532. <br /><a href="torrents.php?action=reseed&amp;torrentid=<?=$TorrentID?>&amp;groupid=<?=$GroupID?>" class="brackets">Request re-seed</a>
  533. <? }
  534. ?>
  535. </blockquote>
  536. </div>
  537. <? if (check_perms('site_moderate_requests')) { ?>
  538. <div class="linkbox">
  539. <a href="torrents.php?action=masspm&amp;id=<?=$GroupID?>&amp;torrentid=<?=$TorrentID?>" class="brackets">Mass PM snatchers</a>
  540. </div>
  541. <? } ?>
  542. <div class="linkbox">
  543. <a href="#" class="brackets" onclick="show_peers('<?=$TorrentID?>', 0); return false;">View peer list</a>
  544. <? if (check_perms('site_view_torrent_snatchlist')) { ?>
  545. <a href="#" class="brackets tooltip" onclick="show_downloads('<?=$TorrentID?>', 0); return false;" title="View the list of users that have clicked the &quot;DL&quot; button.">View download list</a>
  546. <a href="#" class="brackets tooltip" onclick="show_snatches('<?=$TorrentID?>', 0); return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a>
  547. <? } ?>
  548. <a href="#" class="brackets" onclick="show_files('<?=$TorrentID?>'); return false;">View file list</a>
  549. <? if ($Reported) { ?>
  550. <a href="#" class="brackets" onclick="show_reported('<?=$TorrentID?>'); return false;">View report information</a>
  551. <? } ?>
  552. </div>
  553. <div id="peers_<?=$TorrentID?>" class="hidden"></div>
  554. <div id="downloads_<?=$TorrentID?>" class="hidden"></div>
  555. <div id="snatches_<?=$TorrentID?>" class="hidden"></div>
  556. <div id="files_<?=$TorrentID?>" class="hidden"><?=$FileTable?></div>
  557. <? if ($Reported) { ?>
  558. <div id="reported_<?=$TorrentID?>" class="hidden"><?=$ReportInfo?></div>
  559. <?
  560. }
  561. if (!empty($Description)) {
  562. echo "\n<blockquote>".Text::full_format($Description).'</blockquote>';
  563. }
  564. if (!empty($MediaInfo)) {
  565. $parsed = MediaInfo::parse($MediaInfo);
  566. echo "\n<blockquote>";
  567. if (!empty($parsed)) {
  568. echo $parsed;
  569. } else {
  570. ?>
  571. <div class="spoilerContainer hideContainer">
  572. <input type="button" class="spoilerButton" onclick="BBCode.spoiler(this);" value="Show MediaInfo" /><blockquote class="spoiler hidden">
  573. <?
  574. echo Text::full_format($MediaInfo);
  575. ?>
  576. </blockquote>
  577. </div>
  578. <?
  579. }
  580. echo "</blockquote>";
  581. }
  582. ?>
  583. </td>
  584. </tr>
  585. <? } ?>
  586. </table>
  587. </div>
  588. <?
  589. $Requests = get_group_requests($GroupID);
  590. if (empty($LoggedUser['DisableRequests']) && count($Requests) > 0) {
  591. ?>
  592. <div class="box">
  593. <div class="head">
  594. <span style="font-weight: bold;">Requests (<?=number_format(count($Requests))?>)</span>
  595. <a toggle-target="#requests" toggle-replace="Hide" style="float: right;" class="brackets">Show</a>
  596. </div>
  597. <table id="requests" class="request_table hidden">
  598. <tr class="colhead">
  599. <td>Description</td>
  600. <td>Votes</td>
  601. <td>Bounty</td>
  602. </tr>
  603. <? foreach ($Requests as $Request) {
  604. $RequestVotes = Requests::get_votes_array($Request['ID']);
  605. $RequestDesc = substr(explode('\n', Text::strip_bbcode($Request['Description']), 2)[0], 0, 70);
  606. if (strlen(explode('\n', Text::strip_bbcode($Request['Description']), 2)[0]) > 70) {
  607. $RequestDesc = substr($RequestDesc, 0, 67) . '...';
  608. }
  609. ?>
  610. <tr class="requestrows row">
  611. <td><a href="requests.php?action=view&amp;id=<?=$Request['ID']?>"><?=$RequestDesc?></a></td>
  612. <td>
  613. <span id="vote_count_<?=$Request['ID']?>"><?=count($RequestVotes['Voters'])?></span>
  614. <? if (check_perms('site_vote')) { ?>
  615. &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$Request['ID']?>)" class="brackets">+</a>
  616. <? } ?>
  617. </td>
  618. <td><?=Format::get_size($RequestVotes['TotalBounty'])?></td>
  619. </tr>
  620. <? } ?>
  621. </table>
  622. </div>
  623. <?
  624. }
  625. $Collages = $Cache->get_value("torrent_collages_$GroupID");
  626. if (!is_array($Collages)) {
  627. $DB->query("
  628. SELECT c.Name, c.NumTorrents, c.ID
  629. FROM collages AS c
  630. JOIN collages_torrents AS ct ON ct.CollageID = c.ID
  631. WHERE ct.GroupID = '$GroupID'
  632. AND Deleted = '0'
  633. AND CategoryID != '0'");
  634. $Collages = $DB->to_array();
  635. $Cache->cache_value("torrent_collages_$GroupID", $Collages, 3600 * 6);
  636. }
  637. if (count($Collages) > 0) {
  638. if (count($Collages) > MAX_COLLAGES) {
  639. // Pick some at random
  640. $Range = range(0, count($Collages) - 1);
  641. shuffle($Range);
  642. $Indices = array_slice($Range, 0, MAX_COLLAGES);
  643. $SeeAll = ' <a toggle-target=".collage_rows">(See all)</a>';
  644. } else {
  645. $Indices = range(0, count($Collages) - 1);
  646. $SeeAll = '';
  647. }
  648. ?>
  649. <table class="box collage_table" id="collages">
  650. <tr class="colhead">
  651. <td width="85%"><a href="#">&uarr;</a>&nbsp;This album is in <?=number_format(count($Collages))?> collage<?=((count($Collages) > 1) ? 's' : '')?><?=$SeeAll?></td>
  652. <td># torrents</td>
  653. </tr>
  654. <? foreach ($Indices as $i) {
  655. list($CollageName, $CollageTorrents, $CollageID) = $Collages[$i];
  656. unset($Collages[$i]);
  657. ?>
  658. <tr>
  659. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  660. <td class="number_column"><?=number_format($CollageTorrents)?></td>
  661. </tr>
  662. <? }
  663. foreach ($Collages as $Collage) {
  664. list($CollageName, $CollageTorrents, $CollageID) = $Collage;
  665. ?>
  666. <tr class="collage_rows hidden">
  667. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  668. <td class="number_column"><?=number_format($CollageTorrents)?></td>
  669. </tr>
  670. <? } ?>
  671. </table>
  672. <?
  673. }
  674. $PersonalCollages = $Cache->get_value("torrent_collages_personal_$GroupID");
  675. if (!is_array($PersonalCollages)) {
  676. $DB->query("
  677. SELECT c.Name, c.NumTorrents, c.ID
  678. FROM collages AS c
  679. JOIN collages_torrents AS ct ON ct.CollageID = c.ID
  680. WHERE ct.GroupID = '$GroupID'
  681. AND Deleted = '0'
  682. AND CategoryID = '0'");
  683. $PersonalCollages = $DB->to_array(false, MYSQLI_NUM);
  684. $Cache->cache_value("torrent_collages_personal_$GroupID", $PersonalCollages, 3600 * 6);
  685. }
  686. if (count($PersonalCollages) > 0) {
  687. if (count($PersonalCollages) > MAX_PERS_COLLAGES) {
  688. // Pick some at random
  689. $Range = range(0,count($PersonalCollages) - 1);
  690. shuffle($Range);
  691. $Indices = array_slice($Range, 0, MAX_PERS_COLLAGES);
  692. $SeeAll = ' <a toggle-target=".personal_rows">(See all)</a>';
  693. } else {
  694. $Indices = range(0, count($PersonalCollages) - 1);
  695. $SeeAll = '';
  696. }
  697. ?>
  698. <table class="box collage_table" id="personal_collages">
  699. <tr class="colhead">
  700. <td width="85%"><a href="#">&uarr;</a>&nbsp;This album is in <?=number_format(count($PersonalCollages))?> personal collage<?=((count($PersonalCollages) > 1) ? 's' : '')?><?=$SeeAll?></td>
  701. <td># torrents</td>
  702. </tr>
  703. <? foreach ($Indices as $i) {
  704. list($CollageName, $CollageTorrents, $CollageID) = $PersonalCollages[$i];
  705. unset($PersonalCollages[$i]);
  706. ?>
  707. <tr>
  708. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  709. <td class="number_column"><?=number_format($CollageTorrents)?></td>
  710. </tr>
  711. <? }
  712. foreach ($PersonalCollages as $Collage) {
  713. list($CollageName, $CollageTorrents, $CollageID) = $Collage;
  714. ?>
  715. <tr class="personal_rows hidden">
  716. <td><a href="collages.php?id=<?=$CollageID?>"><?=$CollageName?></a></td>
  717. <td class="number_column"><?=number_format($CollageTorrents)?></td>
  718. </tr>
  719. <? } ?>
  720. </table>
  721. <?
  722. }
  723. // Matched Votes
  724. include(SERVER_ROOT.'/sections/torrents/voter_picks.php');
  725. ?>
  726. <div class="box torrent_description">
  727. <div class="head"><a href="#">&uarr;</a>&nbsp;<strong><?=(!empty($ReleaseType) ? $ReleaseTypes[$ReleaseType].' info' : 'Info' )?></strong></div>
  728. <div class="body"><? if ($WikiBody != '') { echo $WikiBody; } else { echo 'There is no information on this torrent.'; } ?></div>
  729. </div>
  730. <div class="box torrent_screenshots_box <? if (!count($Screenshots)) echo 'dead'; ?>">
  731. <div class="head"><a href="#">&uarr;</a>&nbsp;<strong>
  732. <?=($GroupCategoryID == 3)?'Samples':'Screenshots'?> (<?=count($Screenshots)?>)</strong>
  733. <?
  734. if (count($Screenshots) > 0) {
  735. ?>
  736. <a style="float: right;" class='brackets' toggle-target=".torrent_screenshots" toggle-replace="Hide">Show</a>
  737. <? }
  738. $DB->query("
  739. SELECT UserID
  740. FROM torrents
  741. WHERE GroupID = $GroupID");
  742. if (in_array($LoggedUser['ID'], $DB->collect('UserID')) || check_perms('torrents_edit') || check_perms('screenshots_add') || check_perms('screenshots_delete')) {
  743. ?>
  744. <a class="brackets" href="torrents.php?action=editgroup&groupid=<?=$GroupID?>#screenshots_section">Add/Remove</a>
  745. <?
  746. }
  747. ?>
  748. </div>
  749. <div class="body torrent_screenshots hidden">
  750. <?
  751. foreach($Screenshots as $Screenshot) {
  752. $SSURL = ImageTools::process($Screenshot['Image'], false)
  753. ?><img class='tooltip lightbox-init' title='<?=Users::format_username($Screenshot['UserID'], false, false, false)?> - <?=time_diff($Screenshot['Time'])?>' src="<?=$SSURL?>" /><?
  754. }
  755. ?>
  756. </div>
  757. <script>try{$('.torrent_screenshots>img').last().raw().style.width=($('.torrent_screenshots>img').length%2+1)*50+'%'}catch(e){}</script>
  758. </div>
  759. <?
  760. // --- Comments ---
  761. $Pages = Format::get_pages($Page, $NumComments, TORRENT_COMMENTS_PER_PAGE, 9, '#comments');
  762. ?>
  763. <div id="torrent_comments">
  764. <div class="linkbox"><a name="comments"></a>
  765. <?=$Pages?>
  766. </div>
  767. <?
  768. CommentsView::render_comments($Thread, $LastRead, "torrents.php?id=$GroupID");
  769. ?>
  770. <div class="linkbox">
  771. <?=$Pages?>
  772. </div>
  773. <?
  774. View::parse('generic/reply/quickreply.php', array(
  775. 'InputName' => 'pageid',
  776. 'InputID' => $GroupID,
  777. 'Action' => 'comments.php?page=torrents',
  778. 'InputAction' => 'take_post',
  779. 'TextareaCols' => 65,
  780. 'SubscribeBox' => true
  781. ));
  782. ?>
  783. </div>
  784. </div>
  785. </div>
  786. <? View::show_footer(); ?>