Gazelle/sections/torrents/takedelete.php

54 lines
1.7 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$TorrentID = $_POST['torrentid'];
2013-05-01 08:00:16 +00:00
if (!$TorrentID || !is_number($TorrentID)) {
error(404);
}
2011-03-28 14:21:28 +00:00
$DB->query("SELECT
t.UserID,
t.GroupID,
t.Size,
t.info_hash,
tg.Name,
ag.Name,
2013-02-22 08:00:24 +00:00
t.Time,
COUNT(x.uid)
2011-03-28 14:21:28 +00:00
FROM torrents AS t
LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
LEFT JOIN artists_group AS ag ON ag.ArtistID=tg.ArtistID
LEFT JOIN xbt_snatched AS x ON x.fid=t.ID
WHERE t.ID='$TorrentID'");
2012-07-25 08:00:15 +00:00
list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false);
2011-03-28 14:21:28 +00:00
2013-05-01 08:00:16 +00:00
if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) {
2011-03-28 14:21:28 +00:00
error(403);
}
2013-05-01 08:00:16 +00:00
if ($ArtistName) {
2011-03-28 14:21:28 +00:00
$Name = $ArtistName.' - '.$Name;
}
2013-05-01 08:00:16 +00:00
if (isset($_SESSION['logged_user']['multi_delete'])) {
if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) {
2011-03-28 14:21:28 +00:00
error('You have recently deleted 3 torrents, please contact a staff member if you need to delete more.');
}
$_SESSION['logged_user']['multi_delete']++;
} else {
$_SESSION['logged_user']['multi_delete'] = 1;
}
$InfoHash = unpack("H*", $InfoHash);
2012-10-11 08:00:15 +00:00
Torrents::delete_torrent($TorrentID, $GroupID);
2013-05-01 08:00:16 +00:00
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']);
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);
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
View::show_header('Torrent deleted');
2011-03-28 14:21:28 +00:00
?>
<div class="thin">
<h3>Torrent was successfully deleted.</h3>
</div>
<?
2012-10-11 08:00:15 +00:00
View::show_footer();