BioTorrents.de’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 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. #declare(strict_types=1);
  3. ini_set('memory_limit', -1);
  4. function compare($X, $Y)
  5. {
  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
  18. `Username`
  19. FROM
  20. `users_main`
  21. WHERE
  22. `ID` = '$UserID'
  23. ");
  24. list($Username) = $DB->next_record();
  25. } else {
  26. $UserID = $LoggedUser['ID'];
  27. }
  28. $Sneaky = ($UserID !== $LoggedUser['ID']);
  29. $JsonBookmarks = [];
  30. list($GroupIDs, $CollageDataList, $GroupList) = Users::get_bookmarks($UserID);
  31. foreach ($GroupIDs as $GroupID) {
  32. if (!isset($GroupList[$GroupID])) {
  33. continue;
  34. }
  35. $Group = $GroupList[$GroupID];
  36. $JsonTorrents = [];
  37. foreach ($Group['Torrents'] as $Torrent) {
  38. $JsonTorrents[] = array(
  39. 'id' => (int) $Torrent['ID'],
  40. 'groupId' => (int) $Torrent['GroupID'],
  41. 'platform' => $Torrent['Media'],
  42. 'fileCount' => (int) $Torrent['FileCount'],
  43. 'freeTorrent' => $Torrent['FreeTorrent'] === 1,
  44. 'size' => (float) $Torrent['Size'],
  45. 'leechers' => (int) $Torrent['Leechers'],
  46. 'seeders' => (int) $Torrent['Seeders'],
  47. 'snatched' => (int) $Torrent['Snatched'],
  48. 'time' => $Torrent['Time'],
  49. 'hasFile' => (int) $Torrent['HasFile']
  50. );
  51. /*
  52. $JsonTorrents[] = array(
  53. 'id' => (int) $Torrent['ID'],
  54. 'groupId' => (int) $Torrent['GroupID'],
  55. 'media' => $Torrent['Media'],
  56. 'format' => $Torrent['Format'],
  57. 'encoding' => $Torrent['Encoding'],
  58. 'remasterYear' => (int) $Torrent['RemasterYear'],
  59. 'remastered' => $Torrent['Remastered'] == 1,
  60. 'remasterTitle' => $Torrent['RemasterTitle'],
  61. 'remasterRecordLabel' => $Torrent['RemasterRecordLabel'],
  62. 'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'],
  63. 'scene' => $Torrent['Scene'] === 1,
  64. 'hasLog' => $Torrent['HasLog'] === 1,
  65. 'hasCue' => $Torrent['HasCue'] === 1,
  66. 'logScore' => (float) $Torrent['LogScore'],
  67. 'fileCount' => (int) $Torrent['FileCount'],
  68. 'freeTorrent' => $Torrent['FreeTorrent'] === 1,
  69. 'size' => (float) $Torrent['Size'],
  70. 'leechers' => (int) $Torrent['Leechers'],
  71. 'seeders' => (int) $Torrent['Seeders'],
  72. 'snatched' => (int) $Torrent['Snatched'],
  73. 'time' => $Torrent['Time'],
  74. 'hasFile' => (int) $Torrent['HasFile']
  75. );
  76. */
  77. }
  78. $JsonBookmarks[] = array(
  79. 'id' => (int) $Group['ID'],
  80. 'name' => $Group['Name'],
  81. 'year' => (int) $Group['Year'],
  82. 'accession' => $Group['CatalogueNumber'],
  83. 'tagList' => $Group['TagList'],
  84. 'vanityHouse' => $Group['VanityHouse'] === 1,
  85. 'picture' => $Group['WikiImage'],
  86. 'torrents' => $JsonTorrents
  87. );
  88. /*
  89. $JsonBookmarks[] = array(
  90. 'id' => (int) $Group['ID'],
  91. 'name' => $Group['Name'],
  92. 'year' => (int) $Group['Year'],
  93. 'recordLabel' => $Group['RecordLabel'],
  94. 'catalogueNumber' => $Group['CatalogueNumber'],
  95. 'tagList' => $Group['TagList'],
  96. 'releaseType' => $Group['ReleaseType'],
  97. 'vanityHouse' => $Group['VanityHouse'] === 1,
  98. 'image' => $Group['WikiImage'],
  99. 'torrents' => $JsonTorrents
  100. );
  101. */
  102. }
  103. print
  104. json_encode(
  105. array(
  106. 'status' => 'success',
  107. 'response' => array(
  108. 'bookmarks' => $JsonBookmarks
  109. )
  110. )
  111. );