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.

torrent.php 3.9KB

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