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.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. #declare(strict_types = 1);
  3. if (empty($_POST['importance']) || empty($_POST['artists']) || empty($_POST['groupid']) || !is_number($_POST['importance']) || !is_number($_POST['groupid'])) {
  4. error(0);
  5. }
  6. if (!check_perms('torrents_edit')) {
  7. error(403);
  8. }
  9. authorize();
  10. $GroupID = $_POST['groupid'];
  11. $Artists = explode(',', $_POST['artists']);
  12. $CleanArtists = [];
  13. $ArtistIDs = [];
  14. $ArtistsString = '0';
  15. foreach ($Artists as $i => $Artist) {
  16. list($Importance, $ArtistID) = explode(';', $Artist);
  17. if (is_number($ArtistID) && is_number($Importance)) {
  18. $CleanArtists[] = array($Importance, $ArtistID);
  19. $ArtistIDs[] = $ArtistID;
  20. }
  21. }
  22. if (count($CleanArtists) > 0) {
  23. $ArtistsString = implode(',', $ArtistIDs);
  24. if ($_POST['manager_action'] == 'delete') {
  25. $DB->query("
  26. SELECT Name
  27. FROM torrents_group
  28. WHERE ID = '".$_POST['groupid']."'");
  29. list($GroupName) = $DB->next_record();
  30. $DB->query("
  31. SELECT ArtistID, Name
  32. FROM artists_group
  33. WHERE ArtistID IN ($ArtistsString)");
  34. $ArtistNames = $DB->to_array('ArtistID', MYSQLI_ASSOC, false);
  35. foreach ($CleanArtists as $Artist) {
  36. list($Importance, $ArtistID) = $Artist;
  37. Misc::write_log("Artist $ArtistID (".$ArtistNames[$ArtistID]['Name'].") was removed from the group ".$_POST['groupid']." ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
  38. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "Removed artist ".$ArtistNames[$ArtistID]['Name'], 0);
  39. $DB->query("
  40. DELETE FROM torrents_artists
  41. WHERE GroupID = '$GroupID'
  42. AND ArtistID = '$ArtistID'
  43. AND Importance = '$Importance'");
  44. $Cache->delete_value("artist_groups_$ArtistID");
  45. }
  46. $DB->query("
  47. SELECT ArtistID
  48. FROM requests_artists
  49. WHERE ArtistID IN ($ArtistsString)
  50. UNION
  51. SELECT ArtistID
  52. FROM torrents_artists
  53. WHERE ArtistID IN ($ArtistsString)");
  54. $Items = $DB->collect('ArtistID');
  55. $EmptyArtists = array_diff($ArtistIDs, $Items);
  56. foreach ($EmptyArtists as $ArtistID) {
  57. Artists::delete_artist($ArtistID);
  58. }
  59. } else {
  60. $DB->query("
  61. UPDATE IGNORE torrents_artists
  62. SET Importance = '".$_POST['importance']."'
  63. WHERE GroupID = '$GroupID'
  64. AND ArtistID IN ($ArtistsString)");
  65. }
  66. $Cache->delete_value("groups_artists_$GroupID");
  67. Torrents::update_hash($GroupID);
  68. header("Location: torrents.php?id=$GroupID");
  69. }