Oppaitime'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 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?
  2. authorize();
  3. $GroupID = $_POST['groupid'];
  4. $OldGroupID = $GroupID;
  5. $NewName = $_POST['name'];
  6. $NewRJ = $_POST['namerj'];
  7. $NewJP = $_POST['namejp'];
  8. $DB->query("
  9. SELECT ID
  10. FROM torrents
  11. WHERE GroupID = " . db_string($GroupID) . "
  12. AND UserID = " . $LoggedUser['ID']);
  13. $Contributed = $DB->has_results();
  14. if (!$GroupID || !is_number($GroupID)) {
  15. error(404);
  16. }
  17. if (!($Contributed || check_perms('torrents_edit'))) {
  18. error(403);
  19. }
  20. if (empty($NewName) && empty($NewRJ) && empty($NewJP)) {
  21. error('Torrent groups must have a name');
  22. }
  23. $DB->query("
  24. UPDATE torrents_group
  25. SET Name = '".db_string($NewName)."',
  26. NameRJ = '".db_string($NewRJ)."',
  27. NameJP = '".db_string($NewJP)."'
  28. WHERE ID = '$GroupID'");
  29. $Cache->delete_value("torrents_details_$GroupID");
  30. Torrents::update_hash($GroupID);
  31. $DB->query("
  32. SELECT Name, NameRJ, NameJP
  33. FROM torrents_group
  34. WHERE ID = $GroupID");
  35. list($OldName, $OldRJ, $OldJP) = $DB->next_record(MYSQLI_NUM, false);
  36. if ($OldName != $NewName) {
  37. Misc::write_log("Torrent Group $GroupID ($OldName)'s title was changed to \"$NewName\" from \"$OldName\" by ".$LoggedUser['Username']);
  38. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "title changed to \"$NewName\" from \"$OldName\"", 0);
  39. }
  40. if ($OldRJ != $NewRJ) {
  41. Misc::write_log("Torrent Group $GroupID ($OldRJ)'s romaji title was changed to \"$NewRJ\" from \"$OldRJ\" by ".$LoggedUser['Username']);
  42. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "romaji title changed to \"$NewRJ\" from \"$OldRJ\"", 0);
  43. }
  44. if ($OldJP != $NewJP) {
  45. Misc::write_log("Torrent Group $GroupID ($OldJP)'s japanese title was changed to \"$NewJP\" from \"$OldJP\" by ".$LoggedUser['Username']);
  46. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "japanese title changed to \"$NewJP\" from \"$OldJP\"", 0);
  47. }
  48. header("Location: torrents.php?id=$GroupID");