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 4.0KB

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