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.

edit_handle.php 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. declare(strict_types=1);
  3. authorize();
  4. $CollageID = $_POST['collageid'];
  5. if (!is_number($CollageID)) {
  6. error(0);
  7. }
  8. $DB->query("
  9. SELECT UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser
  10. FROM collages
  11. WHERE ID = '$CollageID'");
  12. list($UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser) = $DB->next_record();
  13. if ($CategoryID === 0
  14. && $UserID !== $LoggedUser['ID']
  15. && !check_perms('site_collages_delete')) {
  16. error(403);
  17. }
  18. if (isset($_POST['name'])) {
  19. $DB->query("
  20. SELECT ID, Deleted
  21. FROM collages
  22. WHERE Name = '".db_string($_POST['name'])."'
  23. AND ID != '$CollageID'
  24. LIMIT 1");
  25. if ($DB->has_results()) {
  26. list($ID, $Deleted) = $DB->next_record();
  27. if ($Deleted) {
  28. $Err = 'A collage with that name already exists but needs to be recovered, please <a href="staffpm.php">contact</a> the staff team!';
  29. } else {
  30. $Err = "A collage with that name already exists: <a href='/collages.php?id=$ID'>$_POST[name]</a>.";
  31. }
  32. $ErrNoEscape = true;
  33. include(SERVER_ROOT.'/sections/collages/edit.php');
  34. error();
  35. }
  36. }
  37. $TagList = explode(',', $_POST['tags']);
  38. foreach ($TagList as $ID => $Tag) {
  39. $TagList[$ID] = Misc::sanitize_tag($Tag);
  40. }
  41. $TagList = implode(' ', $TagList);
  42. $Updates = array("Description='".db_string($_POST['description'])."', TagList='".db_string($TagList)."'");
  43. if (!check_perms('site_collages_delete')
  44. && ($CategoryID === 0
  45. && $UserID === $LoggedUser['ID']
  46. && check_perms('site_collages_renamepersonal'))) {
  47. if (!stristr($_POST['name'], $LoggedUser['Username'])) {
  48. error("Your personal collage's title must include your username.");
  49. }
  50. }
  51. if (isset($_POST['featured'])
  52. && $CategoryID === 0
  53. && (($LoggedUser['ID'] === $UserID
  54. && check_perms('site_collages_personal'))
  55. || check_perms('site_collages_delete'))) {
  56. $DB->query("
  57. UPDATE collages
  58. SET Featured = 0
  59. WHERE CategoryID = 0
  60. AND UserID = $UserID");
  61. $Updates[] = 'Featured = 1';
  62. }
  63. if (check_perms('site_collages_delete')
  64. || ($CategoryID === 0
  65. && $UserID === $LoggedUser['ID']
  66. && check_perms('site_collages_renamepersonal'))) {
  67. $Updates[] = "Name = '".db_string($_POST['name'])."'";
  68. }
  69. if (isset($_POST['category'])
  70. && !empty($CollageCats[$_POST['category']])
  71. && $_POST['category'] !== $CategoryID
  72. && ($_POST['category'] !== 0
  73. || check_perms('site_collages_delete'))) {
  74. $Updates[] = 'CategoryID = '.$_POST['category'];
  75. }
  76. if (check_perms('site_collages_delete')) {
  77. if (isset($_POST['locked']) !== $Locked) {
  78. $Updates[] = 'Locked = ' . ($Locked ? "'0'" : "'1'");
  79. }
  80. if (isset($_POST['maxgroups']) && ($_POST['maxgroups'] === 0 || is_number($_POST['maxgroups'])) && $_POST['maxgroups'] !== $MaxGroups) {
  81. $Updates[] = 'MaxGroups = ' . $_POST['maxgroups'];
  82. }
  83. if (isset($_POST['maxgroups']) && ($_POST['maxgroupsperuser'] === 0 || is_number($_POST['maxgroupsperuser'])) && $_POST['maxgroupsperuser'] !== $MaxGroupsPerUser) {
  84. $Updates[] = 'MaxGroupsPerUser = ' . $_POST['maxgroupsperuser'];
  85. }
  86. }
  87. if (!empty($Updates)) {
  88. $DB->query('
  89. UPDATE collages
  90. SET '.implode(', ', $Updates)."
  91. WHERE ID = $CollageID");
  92. }
  93. $Cache->delete_value('collage_'.$CollageID);
  94. header('Location: collages.php?id='.$CollageID);