query("SELECT aa.AliasID FROM artists_alias AS aa JOIN artists_alias AS aa2 ON aa.ArtistID=aa2.ArtistID WHERE aa.AliasID=".$AliasID); if($DB->record_count() == 1) { //This is the last alias on the artist error("That alias is the last alias for that artist, removing it would cause bad things to happen."); } $DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$AliasID'"); if($DB->record_count() > 0) { list($GroupID) = $DB->next_record(); if($GroupID != 0) { error("That alias still has the group ($GroupID) attached, fix that first."); } } $DB->query("SELECT aa.ArtistID, ag.Name, aa.Name FROM artists_alias AS aa JOIN artists_group AS ag ON aa.ArtistID=ag.ArtistID WHERE aa.AliasID=".$AliasID); list($ArtistID, $ArtistName, $AliasName) = $DB->next_record(MYSQLI_NUM, false); $DB->query("DELETE FROM artists_alias WHERE AliasID='$AliasID'"); $DB->query("UPDATE artists_alias SET Redirect='0' WHERE Redirect='$AliasID'"); write_log("The alias ".$AliasID." (".db_string($AliasName).") was removed from the artist ".$ArtistID." (".db_string($ArtistName).") by user ".$LoggedUser['ID']." (".db_string($LoggedUser['Username']).")"); header('Location: '.$_SERVER['HTTP_REFERER']);