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.

editgroupid.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?
  2. #declare(strict_types = 1);
  3. /***************************************************************
  4. * This page handles the backend of the "edit group ID" function
  5. * (found on edit.php). It simply changes the group ID of a
  6. * torrent.
  7. ****************************************************************/
  8. if (!check_perms('torrents_edit')) {
  9. error(403);
  10. }
  11. $OldGroupID = $_POST['oldgroupid'];
  12. $GroupID = $_POST['groupid'];
  13. $TorrentID = $_POST['torrentid'];
  14. if (!is_number($OldGroupID) || !is_number($GroupID) || !is_number($TorrentID) || !$OldGroupID || !$GroupID || !$TorrentID) {
  15. error(0);
  16. }
  17. if ($OldGroupID == $GroupID) {
  18. header('Location: '.$_SERVER['HTTP_REFERER']);
  19. error();
  20. }
  21. //Everything is legit, let's just confim they're not retarded
  22. if (empty($_POST['confirm'])) {
  23. $DB->query("
  24. SELECT Name
  25. FROM torrents_group
  26. WHERE ID = $OldGroupID");
  27. if (!$DB->has_results()) {
  28. //Trying to move to an empty group? I think not!
  29. set_message('The destination torrent group does not exist!');
  30. header('Location: '.$_SERVER['HTTP_REFERER']);
  31. error();
  32. }
  33. list($Name) = $DB->next_record();
  34. $DB->query("
  35. SELECT CategoryID, Name
  36. FROM torrents_group
  37. WHERE ID = $GroupID");
  38. list($CategoryID, $NewName) = $DB->next_record();
  39. $Artists = Artists::get_artists(array($OldGroupID, $GroupID));
  40. View::show_header();
  41. ?>
  42. <div>
  43. <div class="header">
  44. <h2>Torrent Group ID Change Confirmation</h2>
  45. </div>
  46. <div class="box pad">
  47. <form class="confirm_form" name="torrent_group" action="torrents.php" method="post">
  48. <input type="hidden" name="action" value="editgroupid" />
  49. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  50. <input type="hidden" name="confirm" value="true" />
  51. <input type="hidden" name="torrentid" value="<?=$TorrentID?>" />
  52. <input type="hidden" name="oldgroupid" value="<?=$OldGroupID?>" />
  53. <input type="hidden" name="groupid" value="<?=$GroupID?>" />
  54. <h3>You are attempting to move the torrent with ID <?=$TorrentID?> from the group:</h3>
  55. <ul>
  56. <li><?= Artists::display_artists($Artists[$OldGroupID], true, false)?> - <a href="torrents.php?id=<?=$OldGroupID?>"><?=$Name?></a></li>
  57. </ul>
  58. <h3>Into the group:</h3>
  59. <ul>
  60. <li><?= Artists::display_artists($Artists[$GroupID], true, false)?> - <a href="torrents.php?id=<?=$GroupID?>"><?=$NewName?></a></li>
  61. </ul>
  62. <input type="submit" value="Confirm" />
  63. </form>
  64. </div>
  65. </div>
  66. <?
  67. View::show_footer();
  68. } else {
  69. authorize();
  70. $DB->query("
  71. UPDATE torrents
  72. SET GroupID = '$GroupID'
  73. WHERE ID = $TorrentID");
  74. // Delete old torrent group if it's empty now
  75. $DB->query("
  76. SELECT COUNT(ID)
  77. FROM torrents
  78. WHERE GroupID = '$OldGroupID'");
  79. list($TorrentsInGroup) = $DB->next_record();
  80. if ($TorrentsInGroup == 0) {
  81. $DB->query("
  82. UPDATE comments
  83. SET PageID = '$GroupID'
  84. WHERE Page = 'torrents'
  85. AND PageID = '$OldGroupID'");
  86. $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
  87. $Cache->delete_value("torrent_comments_$GroupID");
  88. Torrents::delete_group($OldGroupID);
  89. } else {
  90. Torrents::update_hash($OldGroupID);
  91. }
  92. Torrents::update_hash($GroupID);
  93. Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); // TODO: this is probably broken
  94. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group $OldGroupID", 0);
  95. $DB->query("
  96. UPDATE group_log
  97. SET GroupID = $GroupID
  98. WHERE GroupID = $OldGroupID");
  99. $Cache->delete_value("torrents_details_$GroupID");
  100. $Cache->delete_value("torrent_download_$TorrentID");
  101. header("Location: torrents.php?id=$GroupID");
  102. }
  103. ?>