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.

redownload.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?
  2. if (!empty($_GET['userid']) && is_number($_GET['userid'])) {
  3. $UserID = $_GET['userid'];
  4. } else {
  5. error(0);
  6. }
  7. if (!check_perms('zip_downloader')) {
  8. error(403);
  9. }
  10. $User = Users::user_info($UserID);
  11. $Perms = Permissions::get_permissions($User['PermissionID']);
  12. $UserClass = $Perms['Class'];
  13. list($UserID, $Username) = array_values($User);
  14. if (empty($_GET['type'])) {
  15. error(0);
  16. } else {
  17. switch ($_GET['type']) {
  18. case 'uploads':
  19. if (!check_paranoia('uploads', $User['Paranoia'], $UserClass, $UserID)) {
  20. error(403);
  21. }
  22. $SQL = "WHERE t.UserID = '$UserID'";
  23. $Month = "t.Time";
  24. break;
  25. case 'snatches':
  26. if (!check_paranoia('snatched', $User['Paranoia'], $UserClass, $UserID)) {
  27. error(403);
  28. }
  29. $SQL = "
  30. JOIN xbt_snatched AS x ON t.ID = x.fid
  31. WHERE x.uid = '$UserID'";
  32. $Month = "FROM_UNIXTIME(x.tstamp)";
  33. break;
  34. case 'seeding':
  35. if (!check_paranoia('seeding', $User['Paranoia'], $UserClass, $UserID)) {
  36. error(403);
  37. }
  38. $SQL = "
  39. JOIN xbt_files_users AS xfu ON t.ID = xfu.fid
  40. WHERE xfu.uid = '$UserID'
  41. AND xfu.remaining = 0";
  42. $Month = "FROM_UNIXTIME(xfu.mtime)";
  43. break;
  44. default:
  45. error(0);
  46. }
  47. }
  48. $DownloadsQ = $DB->query("
  49. SELECT
  50. t.ID AS TorrentID,
  51. DATE_FORMAT($Month, '%Y - %m') AS Month,
  52. t.GroupID,
  53. t.Media,
  54. t.Container,
  55. t.Codec,
  56. t.Resolution,
  57. t.AudioFormat,
  58. t.Subbing,
  59. t.Language,
  60. t.Subber,
  61. tg.Year,
  62. tg.Name,
  63. t.Size
  64. FROM torrents AS t
  65. JOIN torrents_group AS tg ON t.GroupID = tg.ID
  66. $SQL
  67. GROUP BY TorrentID");
  68. $Collector = new TorrentsDL($DownloadsQ, "$Username's ".ucfirst($_GET['type']));
  69. while (list($Downloads, $GroupIDs) = $Collector->get_downloads('TorrentID')) {
  70. $Artists = Artists::get_artists($GroupIDs);
  71. $TorrentIDs = array_keys($GroupIDs);
  72. foreach ($TorrentIDs as $TorrentID) {
  73. $TorrentFile = file_get_contents(TORRENT_STORE.$TorrentID.'.torrent');
  74. $Download =& $Downloads[$TorrentID];
  75. // unzip(1) corrupts files if an emdash is present. Replace them.
  76. $Download['Artist'] = str_replace('–','-',Artists::display_artists($Artists[$Download['GroupID']], false, true, false));
  77. $Collector->add_file($TorrentFile, $Download, $Download['Month']);
  78. unset($Download);
  79. }
  80. }
  81. $Collector->finalize(false);
  82. define('SKIP_NO_CACHE_HEADERS', 1);