Gazelle/sections/torrents/nonwikiedit.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
//Set by system
2013-05-01 08:00:16 +00:00
if (!$_POST['groupid'] || !is_number($_POST['groupid'])) {
2011-03-28 14:21:28 +00:00
error(404);
}
$GroupID = $_POST['groupid'];
//Usual perm checks
2013-05-01 08:00:16 +00:00
if (!check_perms('torrents_edit')) {
2011-03-28 14:21:28 +00:00
$DB->query("SELECT UserID FROM torrents WHERE GroupID = ".$GroupID);
2013-05-01 08:00:16 +00:00
if (!in_array($LoggedUser['ID'], $DB->collect('UserID'))) {
2011-03-28 14:21:28 +00:00
error(403);
}
}
2013-05-01 08:00:16 +00:00
if (check_perms('torrents_freeleech') && (isset($_POST['freeleech']) xor isset($_POST['neutralleech']) xor isset($_POST['unfreeleech']))) {
if (isset($_POST['freeleech'])) {
$Free = 1;
2013-05-01 08:00:16 +00:00
} elseif (isset($_POST['neutralleech'])) {
$Free = 2;
} else {
$Free = 0;
}
2013-05-01 08:00:16 +00:00
if (isset($_POST['freeleechtype']) && in_array($_POST['freeleechtype'], array(0,1,2,3))) {
$FreeType = $_POST['freeleechtype'];
} else {
error(404);
2011-03-28 14:21:28 +00:00
}
2012-10-11 08:00:15 +00:00
Torrents::freeleech_groups($GroupID, $Free, $FreeType);
2011-03-28 14:21:28 +00:00
}
//Escape fields
$Year = db_string((int)$_POST['year']);
$RecordLabel = db_string($_POST['record_label']);
$CatalogueNumber = db_string($_POST['catalogue_number']);
2012-02-22 08:00:31 +00:00
// Get some info for the group log
$DB->query("SELECT Year FROM torrents_group WHERE ID = $GroupID");
list($OldYear) = $DB->next_record();
2011-03-28 14:21:28 +00:00
2013-02-22 08:00:24 +00:00
$DB->query("UPDATE torrents_group SET
2011-03-28 14:21:28 +00:00
Year = '$Year',
RecordLabel = '".$RecordLabel."',
CatalogueNumber = '".$CatalogueNumber."'
WHERE ID = ".$GroupID);
2012-02-22 08:00:31 +00:00
if ($OldYear != $Year) {
$DB->query("INSERT INTO group_log (GroupID, UserID, Time, Info)
VALUES ('$GroupID',".$LoggedUser['ID'].",'".sqltime()."','".db_string("Year changed from $OldYear to $Year")."')");
}
2011-03-28 14:21:28 +00:00
$DB->query("SELECT ID FROM torrents WHERE GroupID='$GroupID'");
2013-04-19 08:00:55 +00:00
while (list($TorrentID) = $DB->next_record()) {
2011-03-28 14:21:28 +00:00
$Cache->delete_value('torrent_download_'.$TorrentID);
}
2012-10-11 08:00:15 +00:00
Torrents::update_hash($GroupID);
2011-03-28 14:21:28 +00:00
$Cache->delete_value('torrents_details_'.$GroupID);
header("Location: torrents.php?id=".$GroupID);
?>