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.0KB

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