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.

takedelete.php 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?
  2. authorize();
  3. $TorrentID = $_POST['torrentid'];
  4. if (!$TorrentID || !is_number($TorrentID)) {
  5. error(404);
  6. }
  7. if ($Cache->get_value("torrent_{$TorrentID}_lock")) {
  8. error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.');
  9. }
  10. $DB->query("
  11. SELECT
  12. t.UserID,
  13. t.GroupID,
  14. t.Size,
  15. t.info_hash,
  16. tg.Name,
  17. ag.Name,
  18. t.Time,
  19. COUNT(x.uid)
  20. FROM torrents AS t
  21. LEFT JOIN torrents_artists AS ta ON ta.GroupID = t.GroupID
  22. LEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID
  23. LEFT JOIN artists_group AS ag ON ag.ArtistID = ta.ArtistID
  24. LEFT JOIN xbt_snatched AS x ON x.fid = t.ID
  25. WHERE t.ID = '$TorrentID'");
  26. list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
  27. if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) {
  28. error(403);
  29. }
  30. if ($ArtistName) {
  31. $Name = "$ArtistName - $Name";
  32. }
  33. if (isset($_SESSION['logged_user']['multi_delete'])) {
  34. if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
  35. error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.');
  36. }
  37. $_SESSION['logged_user']['multi_delete']++;
  38. } else {
  39. $_SESSION['logged_user']['multi_delete'] = 1;
  40. }
  41. $InfoHash = unpack('H*', $InfoHash);
  42. Torrents::delete_torrent($TorrentID, $GroupID);
  43. 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']);
  44. 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);
  45. View::show_header('Torrent deleted');
  46. ?>
  47. <div class="thin">
  48. <h3>Torrent was successfully deleted.</h3>
  49. </div>
  50. <?
  51. View::show_footer();