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.

rename.php 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. $GroupID = $_POST['groupid'];
  5. $NewTitle1 = $_POST['name'];
  6. $NewTitle2 = $_POST['Title2'];
  7. $NewTitle3 = $_POST['namejp'];
  8. $DB->query(
  9. "
  10. SELECT
  11. `ID`
  12. FROM
  13. `torrents`
  14. WHERE
  15. `GroupID` = ".db_string($GroupID)."
  16. AND `UserID` = ".$LoggedUser['ID']
  17. );
  18. $Contributed = $DB->has_results();
  19. if (!$GroupID || !is_number($GroupID)) {
  20. error(404);
  21. }
  22. if (!($Contributed || check_perms('torrents_edit'))) {
  23. error(403);
  24. }
  25. #if (empty($NewName) && empty($NewRJ) && empty($NewJP)) {
  26. if (empty($NewTitle1)) { # Title2, Title3 optional
  27. error('Torrent groups must have a name');
  28. }
  29. $DB->query("
  30. UPDATE
  31. `torrents_group`
  32. SET
  33. `Name` = '".db_string($NewTitle1)."',
  34. `Title2` = '".db_string($NewTitle2)."',
  35. `NameJP` = '".db_string($NewTitle3)."'
  36. WHERE
  37. `ID` = '$GroupID'
  38. ");
  39. $Cache->delete_value("torrents_details_$GroupID");
  40. Torrents::update_hash($GroupID);
  41. $DB->query("
  42. SELECT `Name`, `Title2`, `NameJP`
  43. FROM `torrents_group`
  44. WHERE `ID` = '$GroupID'
  45. ");
  46. list($OldName, $OldRJ, $OldJP) = $DB->next_record(MYSQLI_NUM, false);
  47. # Map metadata over generic database fields
  48. # todo: Work into $ENV in classes/config.php
  49. $Title1 = 'Title';
  50. $Title2 = 'Organism';
  51. $Title3 = 'Strain/Variety';
  52. if ($OldName !== $NewTitle1) {
  53. Misc::write_log("Torrent Group $GroupID ($OldName)'s $Title1 was changed to '$NewTitle1' from '$OldName' by ".$LoggedUser['Username']);
  54. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "$Title1 changed to '$NewTitle1' from '$OldName'", 0);
  55. }
  56. if ($OldRJ !== $NewTitle2) {
  57. Misc::write_log("Torrent Group $GroupID ($OldRJ)'s $Title2 was changed to '$NewTitle2' from '$OldRJ' by ".$LoggedUser['Username']);
  58. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "$Title2 changed to '$NewTitle2' from '$OldRJ'", 0);
  59. }
  60. if ($OldJP !== $NewTitle3) {
  61. Misc::write_log("Torrent Group $GroupID ($OldJP)'s $Title3 was changed to '$NewTitle3' from '$OldJP' by ".$LoggedUser['Username']);
  62. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "$Title3 changed to '$NewTitle3' from '$OldJP'", 0);
  63. }
  64. header("Location: torrents.php?id=$GroupID");