diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php index d4c8ad83..06f9ffb8 100644 --- a/sections/artist/add_alias.php +++ b/sections/artist/add_alias.php @@ -31,7 +31,7 @@ $DB->query(" SELECT AliasID, ArtistID, Name, Redirect FROM artists_alias - WHERE Name = '".$DBAliasName."'"); + WHERE Name = '$DBAliasName'"); if ($DB->has_results()) { while (list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) { if (!strcasecmp($CloneAliasName, $AliasName)) { @@ -43,8 +43,8 @@ if ($CloneRedirect != 0) { $DB->query(" UPDATE artists_alias - SET ArtistID='".$ArtistID."', Redirect=0 - WHERE AliasID='".$CloneAliasID."'"); + SET ArtistID = '$ArtistID', Redirect=0 + WHERE AliasID = '$CloneAliasID'"); Misc::write_log("Redirection for the alias $CloneAliasID ($DBAliasName) for the artist $ArtistID was removed by user $LoggedUser[ID] ($LoggedUser[Username])"); } else { error('No changes were made as the target alias did not redirect anywhere.'); @@ -56,7 +56,10 @@ } if (!$CloneAliasID) { if ($Redirect) { - $DB->query("SELECT ArtistID, Redirect FROM artists_alias WHERE AliasID = $Redirect"); + $DB->query(" + SELECT ArtistID, Redirect + FROM artists_alias + WHERE AliasID = $Redirect"); if (!$DB->has_results()) { error('Cannot redirect to a nonexistent artist alias.'); } @@ -73,7 +76,10 @@ VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')'); $AliasID = $DB->inserted_id(); - $DB->query("SELECT Name FROM artists_group WHERE ArtistID = ".$ArtistID); + $DB->query(" + SELECT Name + FROM artists_group + WHERE ArtistID = $ArtistID"); list($ArtistName) = $DB->next_record(MYSQLI_NUM, false); Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).") by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')'); diff --git a/sections/artist/add_similar.php b/sections/artist/add_similar.php index ee2f02cd..05aa250c 100644 --- a/sections/artist/add_similar.php +++ b/sections/artist/add_similar.php @@ -13,39 +13,58 @@ error('Blank artist name.'); } -$DB->query("SELECT ag.ArtistID FROM artists_group AS ag WHERE ag.Name LIKE '$Artist2Name'"); +$DB->query(" + SELECT ag.ArtistID + FROM artists_group AS ag + WHERE ag.Name LIKE '$Artist2Name'"); list($Artist2ID) = $DB->next_record(); if (!empty($Artist2ID)) { // artist was found in the database // Let's see if there's already a similar artists field for these two - $DB->query("SELECT - s1.SimilarID + $DB->query(" + SELECT s1.SimilarID FROM artists_similar AS s1 - JOIN artists_similar AS s2 ON s1.SimilarID=s2.SimilarID - WHERE s1.ArtistID='$Artist1ID' AND s2.ArtistID='$Artist2ID'"); + JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID + WHERE s1.ArtistID = '$Artist1ID' + AND s2.ArtistID = '$Artist2ID'"); list($SimilarID) = $DB->next_record(); if ($SimilarID) { // The similar artists field already exists, just update the score - $DB->query("UPDATE artists_similar_scores SET Score=Score+200 WHERE SimilarID='$SimilarID'"); + $DB->query(" + UPDATE artists_similar_scores + SET Score = Score + 200 + WHERE SimilarID = '$SimilarID'"); } else { // No, it doesn't exist - create it - $DB->query("INSERT INTO artists_similar_scores (Score) VALUES ('200')"); + $DB->query(" + INSERT INTO artists_similar_scores (Score) + VALUES ('200')"); $SimilarID = $DB->inserted_id(); - $DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist1ID', '$SimilarID')"); - $DB->query("INSERT INTO artists_similar (ArtistID, SimilarID) VALUES ('$Artist2ID', '$SimilarID')"); + $DB->query(" + INSERT INTO artists_similar (ArtistID, SimilarID) + VALUES ('$Artist1ID', '$SimilarID')"); + $DB->query(" + INSERT INTO artists_similar (ArtistID, SimilarID) + VALUES ('$Artist2ID', '$SimilarID')"); } - $DB->query("SELECT SimilarID FROM artists_similar_votes WHERE SimilarID='$SimilarID' AND UserID='$UserID' AND Way='up'"); + $DB->query(" + SELECT SimilarID + FROM artists_similar_votes + WHERE SimilarID = '$SimilarID' + AND UserID = '$UserID' + AND Way = 'up'"); if (!$DB->has_results()) { - $DB->query("INSERT INTO artists_similar_votes (SimilarID, UserID, way) VALUES ('$SimilarID', '$UserID', 'up')"); + $DB->query(" + INSERT INTO artists_similar_votes (SimilarID, UserID, way) + VALUES ('$SimilarID', '$UserID', 'up')"); } - $Cache->delete_value('artist_'.$Artist1ID); // Delete artist cache - $Cache->delete_value('artist_'.$Artist2ID); // Delete artist cache - $Cache->delete_value('similar_positions_'.$Artist1ID); // Delete artist's similar map cache - $Cache->delete_value('similar_positions_'.$Artist2ID); // Delete artist's similar map cache + $Cache->delete_value("artist_$Artist1ID"); // Delete artist cache + $Cache->delete_value("artist_$Artist2ID"); // Delete artist cache + $Cache->delete_value("similar_positions_$Artist1ID"); // Delete artist's similar map cache + $Cache->delete_value("similar_positions_$Artist2ID"); // Delete artist's similar map cache } - header('Location: '.$_SERVER['HTTP_REFERER']); ?> diff --git a/sections/artist/change_artistid.php b/sections/artist/change_artistid.php index 474c9000..c02a3a01 100644 --- a/sections/artist/change_artistid.php +++ b/sections/artist/change_artistid.php @@ -51,15 +51,24 @@ } if ($ArtistID == $NewArtistID) { - error("You cannot merge an artist with itself."); + error('You cannot merge an artist with itself.'); } if (isset($_POST['confirm'])) { // Get the information for the cache update - $DB->query("SELECT DISTINCT GroupID FROM torrents_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + SELECT DISTINCT GroupID + FROM torrents_artists + WHERE ArtistID = $ArtistID"); $Groups = $DB->collect('GroupID'); - $DB->query("SELECT DISTINCT RequestID FROM requests_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + SELECT DISTINCT RequestID + FROM requests_artists + WHERE ArtistID = $ArtistID"); $Requests = $DB->collect('RequestID'); - $DB->query("SELECT DISTINCT UserID FROM bookmarks_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + SELECT DISTINCT UserID + FROM bookmarks_artists + WHERE ArtistID = $ArtistID"); $BookmarkUsers = $DB->collect('UserID'); $DB->query(" SELECT DISTINCT ct.CollageID @@ -75,7 +84,7 @@ WHERE ArtistID = $NewArtistID"); $NewArtistGroups = $DB->collect('GroupID'); $NewArtistGroups[] = '0'; - $NewArtistGroups = implode(',',$NewArtistGroups); + $NewArtistGroups = implode(',', $NewArtistGroups); $DB->query(" SELECT DISTINCT RequestID @@ -83,7 +92,7 @@ WHERE ArtistID = $NewArtistID"); $NewArtistRequests = $DB->collect('RequestID'); $NewArtistRequests[] = '0'; - $NewArtistRequests = implode(',',$NewArtistRequests); + $NewArtistRequests = implode(',', $NewArtistRequests); $DB->query(" SELECT DISTINCT UserID @@ -91,7 +100,7 @@ WHERE ArtistID = $NewArtistID"); $NewArtistBookmarks = $DB->collect('UserID'); $NewArtistBookmarks[] = '0'; - $NewArtistBookmarks = implode(',',$NewArtistBookmarks); + $NewArtistBookmarks = implode(',', $NewArtistBookmarks); // Merge all of this artist's aliases onto the new artist $DB->query(" @@ -105,51 +114,59 @@ SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID AND GroupID NOT IN ($NewArtistGroups)"); - $DB->query("DELETE FROM torrents_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + DELETE FROM torrents_artists + WHERE ArtistID = $ArtistID"); $DB->query(" UPDATE IGNORE requests_artists SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID AND RequestID NOT IN ($NewArtistRequests)"); - $DB->query("DELETE FROM requests_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + DELETE FROM requests_artists + WHERE ArtistID = $ArtistID"); $DB->query(" UPDATE IGNORE bookmarks_artists SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID AND UserID NOT IN ($NewArtistBookmarks)"); - $DB->query("DELETE FROM bookmarks_artists WHERE ArtistID = $ArtistID"); + $DB->query(" + DELETE FROM bookmarks_artists + WHERE ArtistID = $ArtistID"); // Cache clearing if (!empty($Groups)) { foreach ($Groups as $GroupID) { - $Cache->delete_value('groups_artists_'.$GroupID); + $Cache->delete_value("groups_artists_$GroupID"); Torrents::update_hash($GroupID); } } if (!empty($Requests)) { foreach ($Requests as $RequestID) { - $Cache->delete_value('request_artist_'.$RequestID); + $Cache->delete_value("request_artist_$RequestID"); Requests::update_sphinx_requests($RequestID); } } if (!empty($BookmarkUsers)) { foreach ($BookmarkUsers as $UserID) { - $Cache->delete_value('notify_artists_'.$UserID); + $Cache->delete_value("notify_artists_$UserID"); } } if (!empty($Collages)) { foreach ($Collages as $CollageID) { - $Cache->delete_value('collage_'.$CollageID); + $Cache->delete_value("collage_$CollageID"); } } - $Cache->delete_value('artist_'.$ArtistID); - $Cache->delete_value('artist_'.$NewArtistID); - $Cache->delete_value('artist_groups_'.$ArtistID); - $Cache->delete_value('artist_groups_'.$NewArtistID); + $Cache->delete_value("artist_$ArtistID"); + $Cache->delete_value("artist_$NewArtistID"); + $Cache->delete_value("artist_groups_$ArtistID"); + $Cache->delete_value("artist_groups_$NewArtistID"); // Delete the old artist - $DB->query("DELETE FROM artists_group WHERE ArtistID = $ArtistID"); + $DB->query(" + DELETE FROM artists_group + WHERE ArtistID = $ArtistID"); Misc::write_log("The artist $ArtistID ($ArtistName) was made into a non-redirecting alias of artist $NewArtistID ($NewArtistName) by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].')'); diff --git a/sections/collages/edit.php b/sections/collages/edit.php index 7257c220..57fd3e4c 100644 --- a/sections/collages/edit.php +++ b/sections/collages/edit.php @@ -6,7 +6,10 @@ error(0); } -$DB->query("SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured FROM collages WHERE ID='$CollageID'"); +$DB->query(" + SELECT Name, Description, TagList, UserID, CategoryID, Locked, MaxGroups, MaxGroupsPerUser, Featured + FROM collages + WHERE ID = '$CollageID'"); list($Name, $Description, $TagList, $UserID, $CategoryID, $Locked, $MaxGroups, $MaxGroupsPerUser, $Featured) = $DB->next_record(); $TagList = implode(', ', explode(' ', $TagList)); @@ -33,18 +36,20 @@ - + - 0 || check_perms('site_collages_delete')) { ?> - + - + -
Name
Category
Description @@ -66,12 +71,13 @@ Tags
Featured />
Locked