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.

manage_artists_handle.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. #declare(strict_types=1);
  3. authorize();
  4. $CollageID = $_POST['collageid'];
  5. if (!is_number($CollageID)) {
  6. error(404);
  7. }
  8. $DB->query("
  9. SELECT UserID, CategoryID
  10. FROM collages
  11. WHERE ID = '$CollageID'");
  12. list($UserID, $CategoryID) = $DB->next_record();
  13. if ($CategoryID === '0' && $UserID != $LoggedUser['ID'] && !check_perms('site_collages_delete')) {
  14. error(403);
  15. }
  16. if ($CategoryID !== array_search(ARTIST_COLLAGE, $CollageCats)) {
  17. error(403);
  18. }
  19. $ArtistID = $_POST['artistid'];
  20. if (!is_number($ArtistID)) {
  21. error(404);
  22. }
  23. if ($_POST['submit'] === 'Remove') {
  24. $DB->query("
  25. DELETE FROM collages_artists
  26. WHERE CollageID = '$CollageID'
  27. AND ArtistID = '$ArtistID'");
  28. $Rows = $DB->affected_rows();
  29. $DB->query("
  30. UPDATE collages
  31. SET NumTorrents = NumTorrents - $Rows
  32. WHERE ID = '$CollageID'");
  33. $Cache->delete_value("artists_collages_$ArtistID");
  34. $Cache->delete_value("artists_collages_personal_$ArtistID");
  35. } elseif (isset($_POST['drag_drop_collage_sort_order'])) {
  36. @parse_str($_POST['drag_drop_collage_sort_order'], $Series);
  37. $Series = @array_shift($Series);
  38. if (is_array($Series)) {
  39. $SQL = [];
  40. foreach ($Series as $Sort => $ArtistID) {
  41. if (is_number($Sort) && is_number($ArtistID)) {
  42. $Sort = ($Sort + 1) * 10;
  43. $SQL[] = sprintf('(%d, %d, %d)', $ArtistID, $Sort, $CollageID);
  44. }
  45. }
  46. $SQL = '
  47. INSERT INTO collages_artists
  48. (ArtistID, Sort, CollageID)
  49. VALUES
  50. ' . implode(', ', $SQL) . '
  51. ON DUPLICATE KEY UPDATE
  52. Sort = VALUES (Sort)';
  53. $DB->query($SQL);
  54. }
  55. } else {
  56. $Sort = $_POST['sort'];
  57. if (!is_number($Sort)) {
  58. error(404);
  59. }
  60. $DB->query("
  61. UPDATE collages_artists
  62. SET Sort = '$Sort'
  63. WHERE CollageID = '$CollageID'
  64. AND ArtistID = '$ArtistID'");
  65. }
  66. $Cache->delete_value("collage_$CollageID");
  67. header("Location: collages.php?action=manage_artists&collageid=$CollageID");