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.

takedelete.php 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?
  2. #declare(strict_types = 1);
  3. authorize();
  4. $TorrentID = $_POST['torrentid'];
  5. if (!$TorrentID || !is_number($TorrentID)) {
  6. error(404);
  7. }
  8. if ($Cache->get_value("torrent_{$TorrentID}_lock")) {
  9. error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
  10. }
  11. $DB->query("
  12. SELECT
  13. t.UserID,
  14. t.GroupID,
  15. t.Size,
  16. t.info_hash,
  17. tg.Name,
  18. ag.Name,
  19. t.Time,
  20. COUNT(x.uid)
  21. FROM torrents AS t
  22. LEFT JOIN torrents_artists AS ta ON ta.GroupID = t.GroupID
  23. LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
  24. LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
  25. LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
  26. WHERE t.ID = '$TorrentID'");
  27. list($UploaderID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
  28. if ($LoggedUser['ID'] != $UploaderID && !check_perms('torrents_delete')) {
  29. error(403);
  30. }
  31. if (time_ago($Time) > 3600 * 24 * 7 && !check_perms('torrents_delete')) {
  32. error('Torrent cannot be deleted because it is over one week old. If you think there is a problem, contact staff.');
  33. }
  34. if ($Snatches > 4 && !check_perms('torrents_delete')) {
  35. error('Torrent cannot be deleted because it has been snatched by more than 4 people. If you think there is a problem, contact staff.');
  36. }
  37. if ($ArtistName) {
  38. $Name = "$ArtistName - $Name";
  39. }
  40. if (isset($_SESSION['logged_user']['multi_delete'])) {
  41. if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
  42. error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
  43. }
  44. $_SESSION['logged_user']['multi_delete']++;
  45. } else {
  46. $_SESSION['logged_user']['multi_delete'] = 1;
  47. }
  48. $InfoHash = unpack('H*', $InfoHash);
  49. Torrents::delete_torrent($TorrentID, $GroupID);
  50. Misc::write_log("Torrent $TorrentID ($Name) (".number_format($Size / (1024 * 1024), 2).' MB) ('.strtoupper($InfoHash[1]).') was deleted by '.$LoggedUser['Username'].': ' .$_POST['reason'].' '.$_POST['extra']);
  51. Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'deleted torrent ('.number_format($Size / (1024 * 1024), 2).' MB, '.strtoupper($InfoHash[1]).') for reason: '.$_POST['reason'].' '.$_POST['extra'], 0);
  52. View::show_header('Torrent deleted');
  53. ?>
  54. <div>
  55. <h3>Torrent was successfully deleted.</h3>
  56. </div>
  57. <?
  58. View::show_footer();