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.

user_recents.php 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. #declare(strict_types=1);
  3. # todo: Go through line by line
  4. $UserID = (int) $_GET['userid'];
  5. $Limit = (int) $_GET['limit'];
  6. if (empty($UserID) || $Limit > 50) {
  7. json_die('failure', 'bad parameters');
  8. }
  9. if (empty($Limit)) {
  10. $Limit = 15;
  11. }
  12. $Results = [];
  13. if (check_paranoia_here('snatched')) {
  14. $DB->query("
  15. SELECT
  16. g.`id`,
  17. g.`title`,
  18. g.`picture`
  19. FROM
  20. `xbt_snatched` AS s
  21. INNER JOIN `torrents` AS t
  22. ON
  23. t.`ID` = s.`fid`
  24. INNER JOIN `torrents_group` AS g
  25. ON
  26. t.`GroupID` = g.`id`
  27. WHERE
  28. s.`uid` = '$UserID' AND g.`category_id` = '1' AND g.`picture` != ''
  29. GROUP BY
  30. g.`id`
  31. ORDER BY
  32. s.`tstamp`
  33. DESC
  34. LIMIT $Limit
  35. ");
  36. $RecentSnatches = $DB->to_array(false, MYSQLI_ASSOC);
  37. $Artists = Artists::get_artists($DB->collect('ID'));
  38. foreach ($RecentSnatches as $Key => $SnatchInfo) {
  39. $RecentSnatches[$Key]['artists'][] = $Artists[$SnatchInfo['ID']];
  40. $RecentSnatches[$Key]['ID'] = (int)$RecentSnatches[$Key]['ID'];
  41. }
  42. $Results['snatches'] = $RecentSnatches;
  43. } else {
  44. $Results['snatches'] = 'hidden';
  45. }
  46. if (check_paranoia_here('uploads')) {
  47. $DB->query("
  48. SELECT
  49. g.`id`,
  50. g.`title`,
  51. g.`picture`
  52. FROM
  53. `torrents_group` AS g
  54. INNER JOIN `torrents` AS t
  55. ON
  56. t.`GroupID` = g.`id`
  57. WHERE
  58. t.`UserID` = '$UserID' AND g.`category_id` = '1' AND g.`picture` != ''
  59. GROUP BY
  60. g.`id`
  61. ORDER BY
  62. t.`Time`
  63. DESC
  64. LIMIT $Limit
  65. ");
  66. $RecentUploads = $DB->to_array(false, MYSQLI_ASSOC);
  67. $Artists = Artists::get_artists($DB->collect('ID'));
  68. foreach ($RecentUploads as $Key => $UploadInfo) {
  69. $RecentUploads[$Key]['artists'][] = $Artists[$UploadInfo['ID']];
  70. $RecentUploads[$Key]['ID'] = (int)$RecentUploads[$Key]['ID'];
  71. }
  72. $Results['uploads'] = $RecentUploads;
  73. } else {
  74. $Results['uploads'] = 'hidden';
  75. }
  76. json_die('success', $Results);
  77. function check_paranoia_here($Setting)
  78. {
  79. global $Paranoia, $Class, $UserID, $Preview;
  80. if ($Preview == 1) {
  81. return check_paranoia($Setting, $Paranoia, $Class);
  82. } else {
  83. return check_paranoia($Setting, $Paranoia, $Class, $UserID);
  84. }
  85. }