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

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