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.

delete_alias.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?
  2. $ArtistID = db_string($_GET['artistid']);
  3. $GroupID = db_string($_GET['groupid']);
  4. if (!is_number($ArtistID) || !is_number($GroupID)) {
  5. error(404);
  6. }
  7. if (!check_perms('torrents_edit')) {
  8. error(403);
  9. }
  10. // Remove artist from this group.
  11. $DB->query("
  12. DELETE FROM torrents_artists
  13. WHERE GroupID = '$GroupID'
  14. AND ArtistID = '$ArtistID'");
  15. $DB->query("
  16. SELECT Name
  17. FROM artists_group
  18. WHERE ArtistID = $ArtistID");
  19. list($ArtistName) = $DB->next_record(MYSQLI_NUM, false);
  20. $DB->query("
  21. SELECT Name
  22. FROM torrents_group
  23. WHERE ID = $GroupID");
  24. if (!$DB->has_results()) {
  25. error(404);
  26. }
  27. list($GroupName) = $DB->next_record(MYSQLI_NUM, false);
  28. // Get a count of how many groups or requests use this artist ID
  29. $DB->query("
  30. SELECT ag.ArtistID
  31. FROM artists_group AS ag
  32. LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID
  33. WHERE ra.ArtistID IS NOT NULL
  34. AND ag.ArtistID = $ArtistID");
  35. $ReqCount = $DB->record_count();
  36. $DB->query("
  37. SELECT ag.ArtistID
  38. FROM artists_group AS ag
  39. LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID
  40. WHERE ta.ArtistID IS NOT NULL
  41. AND ag.ArtistID = $ArtistID");
  42. $GroupCount = $DB->record_count();
  43. if (($ReqCount + $GroupCount) == 0) {
  44. // The only group to use this artist
  45. Artists::delete_artist($ArtistID);
  46. }
  47. $Cache->delete_value("torrents_details_$GroupID"); // Delete torrent group cache
  48. $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache
  49. Misc::write_log("Artist $ArtistID ($ArtistName) was removed from the group $GroupID ($GroupName) by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')');
  50. Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "removed artist $ArtistName", 0);
  51. Torrents::update_hash($GroupID);
  52. $Cache->delete_value("artist_groups_$ArtistID");
  53. header('Location: '.$_SERVER['HTTP_REFERER']);
  54. ?>