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.5KB

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