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 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. /*
  19. switch ($Categories[$NewCategoryID-1]) {
  20. case 'Music':
  21. $ArtistName = db_string(trim($_POST['artist']));
  22. $Year = trim($_POST['year']);
  23. $ReleaseType = trim($_POST['releasetype']);
  24. if (empty($Year) || empty($ArtistName) || !is_number($Year) || empty($ReleaseType) || !is_number($ReleaseType)) {
  25. error(0);
  26. }
  27. $DB->query("
  28. SELECT ArtistID, AliasID, Redirect, Name
  29. FROM artists_alias
  30. WHERE Name LIKE '$ArtistName'");
  31. if (!$DB->has_results()) {
  32. $Redirect = 0;
  33. $DB->query("
  34. INSERT INTO artists_group (Name)
  35. VALUES ('$ArtistName')");
  36. $ArtistID = $DB->inserted_id();
  37. $DB->query("
  38. INSERT INTO artists_alias (ArtistID, Name)
  39. VALUES ('$ArtistID', '$ArtistName')");
  40. $AliasID = $DB->inserted_id();
  41. } else {
  42. list($ArtistID, $AliasID, $Redirect, $ArtistName) = $DB->next_record();
  43. if ($Redirect) {
  44. $AliasID = $ArtistID;
  45. }
  46. }
  47. $DB->query("
  48. INSERT INTO torrents_group
  49. (ArtistID, CategoryID, Name, Year, ReleaseType, Time, WikiBody, WikiImage)
  50. VALUES
  51. ($ArtistID, '1', '$Title', '$Year', '$ReleaseType', NOW(), '', '')");
  52. $GroupID = $DB->inserted_id();
  53. $DB->query("
  54. INSERT INTO torrents_artists
  55. (GroupID, ArtistID, AliasID, Importance, UserID)
  56. VALUES
  57. ('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')");
  58. break;
  59. case 'Audiobooks':
  60. case 'Comedy':
  61. $Year = trim($_POST['year']);
  62. if (empty($Year) || !is_number($Year)) {
  63. error(0);
  64. }
  65. $DB->query("
  66. INSERT INTO torrents_group
  67. (CategoryID, Name, Year, Time, WikiBody, WikiImage)
  68. VALUES
  69. ($NewCategoryID, '$Title', '$Year', NOW(), '', '')");
  70. $GroupID = $DB->inserted_id();
  71. break;
  72. case 'Applications':
  73. case 'Comics':
  74. case 'E-Books':
  75. case 'E-Learning Videos':
  76. $DB->query("
  77. INSERT INTO torrents_group
  78. (CategoryID, Name, Time, WikiBody, WikiImage)
  79. VALUES
  80. ($NewCategoryID, '$Title', NOW(), '', '')");
  81. $GroupID = $DB->inserted_id();
  82. break;
  83. }
  84. */
  85. $DB->query("
  86. UPDATE torrents
  87. SET GroupID = '$GroupID'
  88. WHERE ID = '$TorrentID'");
  89. // Delete old group if needed
  90. $DB->query("
  91. SELECT ID
  92. FROM torrents
  93. WHERE GroupID = '$OldGroupID'");
  94. if (!$DB->has_results()) {
  95. $DB->query("
  96. UPDATE comments
  97. SET PageID = '$GroupID'
  98. WHERE Page = 'torrents'
  99. AND PageID = '$OldGroupID'");
  100. Torrents::delete_group($OldGroupID);
  101. $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
  102. } else {
  103. Torrents::update_hash($OldGroupID);
  104. }
  105. Torrents::update_hash($GroupID);
  106. $Cache->delete_value("torrent_download_$TorrentID");
  107. Misc::write_log("Torrent $TorrentID was edited by $LoggedUser[Username]");
  108. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged from group $OldGroupID", 0);
  109. $DB->query("
  110. UPDATE group_log
  111. SET GroupID = $GroupID
  112. WHERE GroupID = $OldGroupID");
  113. header("Location: torrents.php?id=$GroupID");