BioTorrents.de’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.

takechangecategory.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. #declare(strict_types=1);
  3. /***************************************************************
  4. * Temp handler for changing the category for a single torrent.
  5. ****************************************************************/
  6. authorize();
  7. if (!check_perms('users_mod')) {
  8. error(403);
  9. }
  10. $OldGroupID = $_POST['oldgroupid'];
  11. $TorrentID = $_POST['torrentid'];
  12. $Title = db_string(trim($_POST['title']));
  13. $OldCategoryID = $_POST['oldcategoryid'];
  14. $NewCategoryID = $_POST['newcategoryid'];
  15. if (!is_number($OldGroupID) || !is_number($TorrentID) || !$OldGroupID || !$TorrentID || empty($Title)) {
  16. error(0);
  17. }
  18. $DB->query("
  19. UPDATE torrents
  20. SET GroupID = '$GroupID'
  21. WHERE ID = '$TorrentID'");
  22. // Delete old group if needed
  23. $DB->query("
  24. SELECT ID
  25. FROM torrents
  26. WHERE GroupID = '$OldGroupID'");
  27. if (!$DB->has_results()) {
  28. $DB->query("
  29. UPDATE comments
  30. SET PageID = '$GroupID'
  31. WHERE Page = 'torrents'
  32. AND PageID = '$OldGroupID'");
  33. Torrents::delete_group($OldGroupID);
  34. $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
  35. } else {
  36. Torrents::update_hash($OldGroupID);
  37. }
  38. Torrents::update_hash($GroupID);
  39. $Cache->delete_value("torrent_download_$TorrentID");
  40. Misc::write_log("Torrent $TorrentID was edited by $LoggedUser[Username]");
  41. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged from group $OldGroupID", 0);
  42. $DB->query("
  43. UPDATE group_log
  44. SET GroupID = $GroupID
  45. WHERE GroupID = $OldGroupID");
  46. header("Location: torrents.php?id=$GroupID");