Gazelle/sections/torrents/rename.php

38 lines
872 B
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$GroupID = $_POST['groupid'];
$OldGroupID = $GroupID;
2012-07-25 08:00:15 +00:00
$NewName = $_POST['name'];
2011-03-28 14:21:28 +00:00
2013-05-01 08:00:16 +00:00
if (!$GroupID || !is_number($GroupID)) {
error(404);
}
2011-03-28 14:21:28 +00:00
2013-05-01 08:00:16 +00:00
if (empty($NewName)) {
2013-06-19 08:01:09 +00:00
error('Torrent groups must have a name');
2011-03-28 14:21:28 +00:00
}
2013-05-01 08:00:16 +00:00
if (!check_perms('torrents_edit')) {
error(403);
}
2011-03-28 14:21:28 +00:00
2013-06-19 08:01:09 +00:00
$DB->query("
SELECT Name
FROM torrents_group
WHERE ID = $GroupID");
2012-07-25 08:00:15 +00:00
list($OldName) = $DB->next_record(MYSQLI_NUM, false);
2011-03-28 14:21:28 +00:00
2013-06-19 08:01:09 +00:00
$DB->query("
UPDATE torrents_group
SET Name = '".db_string($NewName)."'
WHERE ID = '$GroupID'");
$Cache->delete_value("torrents_details_$GroupID");
2011-03-28 14:21:28 +00:00
2012-10-11 08:00:15 +00:00
Torrents::update_hash($GroupID);
2011-03-28 14:21:28 +00:00
2013-10-27 08:01:08 +00:00
Misc::write_log("Torrent Group $GroupID ($OldName) was renamed to \"$NewName\" from \"$OldName\" by ".$LoggedUser['Username']);
Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "renamed to \"$NewName\" from \"$OldName\"", 0);
2011-03-28 14:21:28 +00:00
2013-06-19 08:01:09 +00:00
header("Location: torrents.php?id=$GroupID");