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.

torrentgroup.php 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. require(SERVER_ROOT.'/sections/torrents/functions.php');
  3. $GroupID = (int)$_GET['id'];
  4. $TorrentHash = (string)$_GET['hash'];
  5. if ($GroupID && $TorrentHash) {
  6. json_die("failure", "bad parameters");
  7. }
  8. if ($TorrentHash) {
  9. if (!is_valid_torrenthash($TorrentHash)) {
  10. json_die("failure", "bad hash parameter");
  11. } else {
  12. $GroupID = (int)torrenthash_to_groupid($TorrentHash);
  13. if (!$GroupID) {
  14. json_die("failure", "bad hash parameter");
  15. }
  16. }
  17. }
  18. if ($GroupID <= 0) {
  19. json_die("failure", "bad id parameter");
  20. }
  21. $TorrentCache = get_group_info($GroupID, true, 0, true, true);
  22. if (!$TorrentCache) {
  23. json_die("failure", "bad id parameter");
  24. }
  25. list($TorrentDetails, $TorrentList) = $TorrentCache;
  26. $Artists = pullmediainfo(Artists::get_artist($GroupID));
  27. if ($TorrentDetails['CategoryID'] == 0) {
  28. $CategoryName = 'Unknown';
  29. } else {
  30. $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1];
  31. }
  32. $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']);
  33. $JsonTorrentDetails = [
  34. 'wikiBody' => Text::full_format($TorrentDetails['WikiBody']),
  35. 'wikiImage' => $TorrentDetails['WikiImage'],
  36. 'id' => (int)$TorrentDetails['ID'],
  37. 'name' => $TorrentDetails['Name'],
  38. 'namejp' => $TorrentDetails['NameJP'],
  39. 'artists' => $Artists,
  40. 'year' => (int)$TorrentDetails['Year'],
  41. 'catalogueNumber' => $TorrentDetails['CatalogueNumber'],
  42. 'pages' => (int)$TorrentDetails['Pages'],
  43. 'categoryId' => (int)$TorrentDetails['CategoryID'],
  44. 'categoryName' => $CategoryName,
  45. 'dlsiteId' => $TorrentDetails['DLSiteID'],
  46. 'time' => $TorrentDetails['Time'],
  47. 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID),
  48. 'tags' => $TagList
  49. ];
  50. $JsonTorrentList = [];
  51. foreach ($TorrentList as $Torrent) {
  52. // Convert file list back to the old format
  53. $FileList = explode("\n", $Torrent['FileList']);
  54. foreach ($FileList as &$File) {
  55. $File = Torrents::filelist_old_format($File);
  56. }
  57. unset($File);
  58. $FileList = implode('|||', $FileList);
  59. $Userinfo = Users::user_info($Torrent['UserID']);
  60. $Reports = Torrents::get_reports($Torrent['ID']);
  61. $Torrent['Reported'] = count($Reports) > 0;
  62. $JsonTorrentList[] = [
  63. 'id' => (int)$Torrent['ID'],
  64. 'infoHash' => $Torrent['InfoHash'],
  65. 'media' => $Torrent['Media'],
  66. 'container' => $Torrent['Container'],
  67. 'codec' => $Torrent['Codec'],
  68. 'resolution' => $Torrent['Resolution'],
  69. 'audioFormat' => $Torrent['AudioFormat'],
  70. 'subbing' => $Torrent['Subbing'],
  71. 'subber' => $Torrent['Subber'],
  72. 'language' => $Torrent['Language'],
  73. 'censored' => (bool)$Torrent['Censored'],
  74. 'archive' => $Torrent['Archive'],
  75. 'fileCount' => (int)$Torrent['FileCount'],
  76. 'size' => (int)$Torrent['Size'],
  77. 'seeders' => (int)$Torrent['Seeders'],
  78. 'leechers' => (int)$Torrent['Leechers'],
  79. 'snatched' => (int)$Torrent['Snatched'],
  80. 'freeTorrent' => $Torrent['FreeTorrent'] == 1,
  81. 'reported' => $Torrent['Reported'],
  82. 'time' => $Torrent['Time'],
  83. 'description' => $Torrent['Description'],
  84. 'mediaInfo' => $Torrent['MediaInfo'],
  85. 'fileList' => $FileList,
  86. 'filePath' => $Torrent['FilePath'],
  87. 'userId' => (int)($Torrent['Anonymous'] ? 0 : $Torrent['UserID']),
  88. 'username' => ($Torrent['Anonymous'] ? 'Anonymous' : $Userinfo['Username'])
  89. ];
  90. }
  91. json_die("success", ['group' => $JsonTorrentDetails, 'torrents' => $JsonTorrentList]);