query("SELECT ArtistID, AliasID, Redirect, Name FROM artists_alias WHERE Name = '$ArtistName'"); if($DB->record_count() == 0) { $Redirect = 0; $DB->query("INSERT INTO artists_group (Name) VALUES ('$ArtistName')"); $ArtistID = $DB->inserted_id(); $DB->query("INSERT INTO artists_alias (ArtistID, Name) VALUES ('$ArtistID', '$ArtistName')"); list($AliasID) = $DB->next_record(); } else { list($ArtistID, $AliasID, $Redirect, $ArtistName) = $DB->next_record(); if($Redirect) { $AliasID = $Redirect; } } $DB->query("INSERT INTO torrents_group (ArtistID, NumArtists, CategoryID, Name, Year, Time, WikiBody, WikiImage, SearchText) VALUES ($ArtistID, '1', '1', '$Title', '$Year', '".sqltime()."', '', '', '$SearchText')"); $GroupID = $DB->inserted_id(); $DB->query("INSERT INTO torrents_artists (GroupID, ArtistID, AliasID, Importance, UserID) VALUES ('$GroupID', '$ArtistID', '$AliasID', '1', '$LoggedUser[ID]')"); $DB->query("UPDATE torrents SET GroupID='$GroupID' WHERE ID='$TorrentID'"); // Delete old group if needed $DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'"); if($DB->record_count() == 0) { Torrents::delete_group($OldGroupID); } else { Torrents::update_hash($OldGroupID); } Torrents::update_hash($GroupID); $Cache->delete_value('torrent_download_'.$TorrentID); Misc::write_log("Torrent $TorrentID was edited by " . $LoggedUser['Username']); header("Location: torrents.php?id=$GroupID"); ?>