Gazelle/sections/collages/take_delete.php

42 lines
1.3 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$CollageID = $_POST['collageid'];
2013-05-02 08:00:23 +00:00
if (!is_number($CollageID) || !$CollageID) {
2013-02-22 08:00:24 +00:00
error(404);
2011-03-28 14:21:28 +00:00
}
$DB->query("SELECT Name, CategoryID, UserID FROM collages WHERE ID='$CollageID'");
2012-07-25 08:00:15 +00:00
list($Name, $CategoryID, $UserID) = $DB->next_record(MYSQLI_NUM, false);
2011-03-28 14:21:28 +00:00
2013-05-02 08:00:23 +00:00
if (!check_perms('site_collages_delete') && $UserID != $LoggedUser['ID']) {
2011-03-28 14:21:28 +00:00
error(403);
}
$Reason = trim($_POST['reason']);
2013-05-02 08:00:23 +00:00
if (!$Reason) {
error('You must enter a reason!');
2011-03-28 14:21:28 +00:00
}
$DB->query("SELECT GroupID FROM collages_torrents WHERE CollageID='$CollageID'");
2013-05-02 08:00:23 +00:00
while (list($GroupID) = $DB->next_record()) {
2011-03-28 14:21:28 +00:00
$Cache->delete_value('torrents_details_'.$GroupID);
2012-02-20 08:00:22 +00:00
$Cache->delete_value('torrent_collages_'.$GroupID);
$Cache->delete_value('torrent_collages_personal_'.$GroupID);
2011-03-28 14:21:28 +00:00
}
//Personal collages have CategoryID 0
if ($CategoryID == 0) {
2011-03-28 14:21:28 +00:00
$DB->query("DELETE FROM collages WHERE ID='$CollageID'");
$DB->query("DELETE FROM collages_torrents WHERE CollageID='$CollageID'");
$DB->query("DELETE FROM collages_comments WHERE CollageID='$CollageID'");
} else {
$DB->query("UPDATE collages SET Deleted = '1' WHERE ID='$CollageID'");
}
2013-05-02 08:00:23 +00:00
Misc::write_log("Collage $CollageID ($Name) was deleted by ".$LoggedUser['Username'].': '.$Reason);
2011-03-28 14:21:28 +00:00
$Cache->delete_value('collage_'.$CollageID);
header('Location: collages.php');