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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.Name,
  18. g.WikiImage
  19. FROM xbt_snatched AS s
  20. INNER JOIN torrents AS t ON t.ID = s.fid
  21. INNER JOIN torrents_group AS g ON t.GroupID = g.ID
  22. WHERE s.uid = '$UserID'
  23. AND g.CategoryID = '1'
  24. AND g.WikiImage != ''
  25. GROUP BY g.ID
  26. ORDER BY s.tstamp DESC
  27. LIMIT $Limit");
  28. $RecentSnatches = $DB->to_array(false, MYSQLI_ASSOC);
  29. $Artists = Artists::get_artists($DB->collect('ID'));
  30. foreach ($RecentSnatches as $Key => $SnatchInfo) {
  31. $RecentSnatches[$Key]['artists'][] = $Artists[$SnatchInfo['ID']];
  32. $RecentSnatches[$Key]['ID'] = (int)$RecentSnatches[$Key]['ID'];
  33. }
  34. $Results['snatches'] = $RecentSnatches;
  35. } else {
  36. $Results['snatches'] = 'hidden';
  37. }
  38. if (check_paranoia_here('uploads')) {
  39. $DB->query("
  40. SELECT
  41. g.ID,
  42. g.Name,
  43. g.WikiImage
  44. FROM torrents_group AS g
  45. INNER JOIN torrents AS t ON t.GroupID = g.ID
  46. WHERE t.UserID = '$UserID'
  47. AND g.CategoryID = '1'
  48. AND g.WikiImage != ''
  49. GROUP BY g.ID
  50. ORDER BY t.Time DESC
  51. LIMIT $Limit");
  52. $RecentUploads = $DB->to_array(false, MYSQLI_ASSOC);
  53. $Artists = Artists::get_artists($DB->collect('ID'));
  54. foreach ($RecentUploads as $Key => $UploadInfo) {
  55. $RecentUploads[$Key]['artists'][] = $Artists[$UploadInfo['ID']];
  56. $RecentUploads[$Key]['ID'] = (int)$RecentUploads[$Key]['ID'];
  57. }
  58. $Results['uploads'] = $RecentUploads;
  59. } else {
  60. $Results['uploads'] = 'hidden';
  61. }
  62. json_die('success', $Results);
  63. function check_paranoia_here($Setting)
  64. {
  65. global $Paranoia, $Class, $UserID, $Preview;
  66. if ($Preview == 1) {
  67. return check_paranoia($Setting, $Paranoia, $Class);
  68. } else {
  69. return check_paranoia($Setting, $Paranoia, $Class, $UserID);
  70. }
  71. }