From d002af2f862927cc50616f79215388b509580d96 Mon Sep 17 00:00:00 2001 From: Git Date: Sun, 5 May 2013 08:00:31 +0000 Subject: [PATCH] Empty commit --- .../class_mass_user_torrents_table_view.php | 14 +- classes/permissions_form.php | 4 +- sections/ajax/announcements.php | 35 ++--- sections/ajax/better/single.php | 15 +- sections/ajax/better/transcode.php | 6 +- sections/ajax/bookmarks/artists.php | 13 +- sections/ajax/checkprivate.php | 2 +- sections/ajax/forum/index.php | 70 ++++----- sections/ajax/giveback_report.php | 11 +- sections/ajax/grab_report.php | 14 +- sections/ajax/inbox/inbox.php | 66 ++++----- sections/ajax/inbox/viewconv.php | 55 +++++--- sections/ajax/notifications.php | 44 +++--- sections/ajax/preview.php | 2 +- sections/ajax/request.php | 4 +- sections/ajax/requests.php | 10 +- sections/ajax/stats.php | 2 +- sections/ajax/tcomments.php | 36 +++-- sections/ajax/top10/tags.php | 53 +++---- sections/api/index.php | 11 +- sections/artist/add_alias.php | 52 ++++--- sections/artist/autocomplete.php | 25 ++-- sections/artist/change_artistid.php | 68 +++++---- sections/artist/delete.php | 42 +++--- sections/artist/delete_similar.php | 4 +- sections/artist/edit.php | 42 +++--- sections/artist/history.php | 6 +- sections/artist/index.php | 63 ++++++--- sections/artist/rename.php | 92 ++++++++---- sections/artist/take_warn.php | 46 +++--- sections/artist/takeedit.php | 38 +++-- sections/artist/vote_similar.php | 18 ++- sections/artist/warn.php | 9 +- sections/better/files.php | 29 ++-- sections/better/folders.php | 29 ++-- sections/better/snatch.php | 18 +-- sections/better/tags.php | 33 +++-- sections/better/transcode.php | 12 +- sections/better/transcode_beta.php | 90 +++++++----- sections/better/upload.php | 18 +-- sections/bookmarks/add.php | 66 ++++++--- sections/bookmarks/artists.php | 28 ++-- sections/bookmarks/edit_torrents.php | 12 +- sections/bookmarks/functions.php | 6 +- sections/bookmarks/remove.php | 11 +- sections/bookmarks/torrents.php | 4 +- sections/chat/index.php | 22 +-- sections/collages/add_comment.php | 8 +- sections/collages/collage.php | 12 +- sections/collages/delete.php | 6 +- sections/collages/delete_comment.php | 4 +- sections/collages/edit.php | 4 +- sections/collages/manage.php | 46 +++--- sections/collages/recover.php | 10 +- sections/collages/takeedit_comment.php | 31 ++-- sections/forums/add_poll_option.php | 13 +- sections/forums/catchup.php | 24 ++-- sections/forums/change_vote.php | 13 +- sections/forums/delete.php | 92 ++++++++---- sections/forums/delete_poll_option.php | 22 +-- sections/forums/edit_rules.php | 25 ++-- sections/forums/main.php | 32 +++-- sections/forums/poll_mod.php | 30 +++- sections/forums/sticky_post.php | 31 ++-- sections/forums/take_reply.php | 129 +++++++++++------ sections/forums/takeedit.php | 53 +++---- sections/forums/thread.php | 133 +++++++++++------- sections/forums/warn.php | 24 ++-- sections/inbox/takecompose.php | 26 ++-- sections/inbox/takeedit.php | 44 +++--- sections/requests/index.php | 69 +++++---- sections/requests/new_edit.php | 3 +- sections/staff/functions.php | 131 +++++++++++++---- sections/staff/index.php | 79 +++-------- sections/torrents/index.php | 17 ++- sections/user/stylesheetgallery.php | 2 +- 76 files changed, 1504 insertions(+), 959 deletions(-) diff --git a/classes/class_mass_user_torrents_table_view.php b/classes/class_mass_user_torrents_table_view.php index 3f0f792c..96f60546 100644 --- a/classes/class_mass_user_torrents_table_view.php +++ b/classes/class_mass_user_torrents_table_view.php @@ -226,10 +226,10 @@ public function row ($Sort, $GroupID, $GroupYear, $DisplayName, $TorrentLink, $D NumGroups?> - - - - + + + + 0) { $DisplayName = Artists::display_artists(array('1'=>$Artists), true, false); } - if ($VanityHouse) $DisplayName .= ' [VH]'; + if ($VanityHouse) { + $DisplayName .= ' [VH]'; + } return $DisplayName; } diff --git a/classes/permissions_form.php b/classes/permissions_form.php index 206cb944..d401f8be 100644 --- a/classes/permissions_form.php +++ b/classes/permissions_form.php @@ -63,7 +63,7 @@ 'users_give_donor' => 'Can give donor access.', 'users_warn' => 'Can warn users.', 'users_disable_users' => 'Can disable users.', - 'users_disable_posts' => 'Can disable users\' posting rights.', + 'users_disable_posts' => 'Can disable users\' posting privileges.', 'users_disable_any' => 'Can disable any users\' rights.', 'users_delete_users' => 'Can delete users.', 'users_view_invites' => 'Can view who user has invited.', @@ -193,7 +193,7 @@ function permissions_form() { ?> - + diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php index a76f57d7..2c92c4a6 100644 --- a/sections/ajax/announcements.php +++ b/sections/ajax/announcements.php @@ -1,20 +1,19 @@ get_value('news')) { - $DB->query("SELECT - ID, - Title, - Body, - Time + $DB->query(" + SELECT + ID, + Title, + Body, + Time FROM news ORDER BY Time DESC LIMIT 5"); $News = $DB->to_array(false,MYSQLI_NUM,false); - $Cache->cache_value('news',$News,3600*24*30); + $Cache->cache_value('news',$News,3600 * 24 * 30); $Cache->cache_value('news_latest_id', $News[0][0], 0); } @@ -26,15 +25,17 @@ $LoggedUser['LastReadNews'] = $News[0][0]; } -if(($Blog = $Cache->get_value('blog')) === false) { - $DB->query("SELECT - b.ID, - um.Username, - b.Title, - b.Body, - b.Time, - b.ThreadID - FROM blog AS b LEFT JOIN users_main AS um ON b.UserID=um.ID +if (($Blog = $Cache->get_value('blog')) === false) { + $DB->query(" + SELECT + b.ID, + um.Username, + b.Title, + b.Body, + b.Time, + b.ThreadID + FROM blog AS b + LEFT JOIN users_main AS um ON b.UserID=um.ID ORDER BY Time DESC LIMIT 20"); $Blog = $DB->to_array(); diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php index 5679df92..b6a67fd5 100644 --- a/sections/ajax/better/single.php +++ b/sections/ajax/better/single.php @@ -1,16 +1,19 @@ get_value('better_single_groupids')) === false) { - $DB->query("SELECT t.ID AS TorrentID, +if (($GroupIDs = $Cache->get_value('better_single_groupids')) === false) { + $DB->query(" + SELECT + t.ID AS TorrentID, t.GroupID AS GroupID FROM xbt_files_users AS x JOIN torrents AS t ON t.ID=x.fid WHERE t.Format='FLAC' GROUP BY x.fid - HAVING COUNT(x.uid) = 1 - ORDER BY t.LogScore DESC, t.Time ASC LIMIT 30"); + HAVING COUNT(x.uid) = 1 + ORDER BY t.LogScore DESC, t.Time ASC + LIMIT 30"); $GroupIDs = $DB->to_array('GroupID'); - $Cache->cache_value('better_single_groupids', $GroupIDs, 30*60); + $Cache->cache_value('better_single_groupids', $GroupIDs, 30 * 60); } $Results = Torrents::get_groups(array_keys($GroupIDs)); @@ -23,7 +26,7 @@ $FlacID = $GroupIDs[$GroupID]['TorrentID']; $JsonArtists = array(); - if(count($Artists)>0) { + if (count($Artists) > 0) { foreach ($Artists as $Artist) { $JsonArtists[] = array( 'id' => (int) $Artist['id'], diff --git a/sections/ajax/better/transcode.php b/sections/ajax/better/transcode.php index 761d21ec..a605d3bf 100644 --- a/sections/ajax/better/transcode.php +++ b/sections/ajax/better/transcode.php @@ -1,5 +1,5 @@ 3) { +if (!isset($_GET['type']) || !is_number($_GET['type']) || $_GET['type'] > 3) { error(0); } @@ -11,7 +11,7 @@ $List = "!(v0 | v2 | 320)"; } else { $List = '!'.$Options[$_GET['type']]; - if($_GET['type'] == 0) { + if ($_GET['type'] == 0) { $_GET['type'] = '0'; } else { $_GET['type'] = display_str($_GET['type']); @@ -25,7 +25,7 @@ ->where_match($List, 'encoding', false) ->order_by('RAND()') ->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); -if(!empty($_GET['search'])) { +if (!empty($_GET['search'])) { $SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)'); } diff --git a/sections/ajax/bookmarks/artists.php b/sections/ajax/bookmarks/artists.php index b7045e84..cb9fcbe1 100644 --- a/sections/ajax/bookmarks/artists.php +++ b/sections/ajax/bookmarks/artists.php @@ -1,7 +1,7 @@ query('SELECT ag.ArtistID, ag.Name +$DB->query(' + SELECT ag.ArtistID, ag.Name FROM bookmarks_artists AS ba - INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID + INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID WHERE ba.UserID = '.$UserID); $ArtistList = $DB->to_array(); $JsonArtists = array(); -foreach($ArtistList as $Artist) { +foreach ($ArtistList as $Artist) { list($ArtistID, $Name) = $Artist; $JsonArtists[] = array( 'artistId' => (int) $ArtistID, diff --git a/sections/ajax/checkprivate.php b/sections/ajax/checkprivate.php index a75c304d..9cacec26 100644 --- a/sections/ajax/checkprivate.php +++ b/sections/ajax/checkprivate.php @@ -9,7 +9,7 @@ } $DB->query("SELECT File FROM torrents_files WHERE TorrentID='$TorrentID'"); -if($DB->record_count() == 0) { +if ($DB->record_count() == 0) { echo('Torrent not found.'); die(); } diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index cdfddf4b..65d3002e 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -21,34 +21,35 @@ } //This variable contains all our lovely forum data - if(!$Forums = $Cache->get_value('forums_list')) { - $DB->query("SELECT - f.ID, - f.CategoryID, - f.Name, - f.Description, - f.MinClassRead, - f.MinClassWrite, - f.MinClassCreate, - f.NumTopics, - f.NumPosts, - f.LastPostID, - f.LastPostAuthorID, - f.LastPostTopicID, - f.LastPostTime, - COUNT(sr.ThreadID) AS SpecificRules, - t.Title, - t.IsLocked, - t.IsSticky + if (!$Forums = $Cache->get_value('forums_list')) { + $DB->query(" + SELECT + f.ID, + f.CategoryID, + f.Name, + f.Description, + f.MinClassRead, + f.MinClassWrite, + f.MinClassCreate, + f.NumTopics, + f.NumPosts, + f.LastPostID, + f.LastPostAuthorID, + f.LastPostTopicID, + f.LastPostTime, + COUNT(sr.ThreadID) AS SpecificRules, + t.Title, + t.IsLocked, + t.IsSticky FROM forums AS f - JOIN forums_categories AS fc ON fc.ID = f.CategoryID - LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID - LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID + JOIN forums_categories AS fc ON fc.ID = f.CategoryID + LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID + LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID GROUP BY f.ID ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort"); $Forums = $DB->to_array('ID', MYSQLI_ASSOC, false); - foreach($Forums as $ForumID => $Forum) { - if(count($Forum['SpecificRules'])) { + foreach ($Forums as $ForumID => $Forum) { + if (count($Forum['SpecificRules'])) { $DB->query("SELECT ThreadID FROM forums_specific_rules WHERE ForumID = ".$ForumID); $ThreadIDs = $DB->collect('ThreadID'); $Forums[$ForumID]['SpecificRules'] = $ThreadIDs; @@ -58,7 +59,7 @@ $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. } - if(empty($_GET['type']) || $_GET['type'] == 'main') { + if (empty($_GET['type']) || $_GET['type'] == 'main') { include(SERVER_ROOT.'/sections/ajax/forum/main.php'); } else { switch ($_GET['type']) { @@ -80,18 +81,19 @@ function get_forum_info($ForumID) { global $DB, $Cache; $Forum = $Cache->get_value('ForumInfo_'.$ForumID); - if(!$Forum) { - $DB->query("SELECT - Name, - MinClassRead, - MinClassWrite, - MinClassCreate, - COUNT(forums_topics.ID) AS Topics + if (!$Forum) { + $DB->query(" + SELECT + Name, + MinClassRead, + MinClassWrite, + MinClassCreate, + COUNT(forums_topics.ID) AS Topics FROM forums - LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID + LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID WHERE forums.ID='$ForumID' GROUP BY ForumID"); - if($DB->record_count() == 0) { + if ($DB->record_count() == 0) { return false; } // Makes an array, with $Forum['Name'], etc. diff --git a/sections/ajax/giveback_report.php b/sections/ajax/giveback_report.php index c76f2095..1908ce03 100644 --- a/sections/ajax/giveback_report.php +++ b/sections/ajax/giveback_report.php @@ -1,15 +1,18 @@ query("SELECT Status FROM reportsv2 WHERE ID=".$_GET['id']); list($Status) = $DB->next_record(); -if(isset($Status)) { - $DB->query("UPDATE reportsv2 SET Status='New', ResolverID = 0 WHERE ID=".$_GET['id']); +if (isset($Status)) { + $DB->query(" + UPDATE reportsv2 + SET Status='New', ResolverID = 0 + WHERE ID=".$_GET['id']); } ?> diff --git a/sections/ajax/grab_report.php b/sections/ajax/grab_report.php index 16521c4a..e527db12 100644 --- a/sections/ajax/grab_report.php +++ b/sections/ajax/grab_report.php @@ -1,16 +1,20 @@ query("UPDATE reportsv2 SET Status='New' WHERE ID=".$_GET['id']." AND Status <> 'Resolved'"); -if($DB->affected_rows() > 0) { +$DB->query(" + UPDATE reportsv2 + SET Status='New' + WHERE ID=".$_GET['id']." + AND Status <> 'Resolved'"); +if ($DB->affected_rows() > 0) { //Win } else { - echo 'You just tried to grab a resolved or non existent report!'; + echo 'You just tried to grab a resolved or non-existent report!'; } ?> diff --git a/sections/ajax/inbox/inbox.php b/sections/ajax/inbox/inbox.php index 2ac43576..8bf6316b 100644 --- a/sections/ajax/inbox/inbox.php +++ b/sections/ajax/inbox/inbox.php @@ -4,11 +4,12 @@ $UserID = $LoggedUser['ID']; -if(empty($_GET['type'])) { $Section = 'inbox'; } -else { +if (empty($_GET['type'])) { + $Section = 'inbox'; +} else { $Section = $_GET['type']; // either 'inbox' or 'sentbox' } -if(!in_array($Section, array('inbox', 'sentbox'))) { +if (!in_array($Section, array('inbox', 'sentbox'))) { print json_encode( array( @@ -22,45 +23,46 @@ $Sort = empty($_GET['sort']) || $_GET['sort'] != "unread" ? "Date DESC" : "cu.Unread = '1' DESC, DATE DESC"; -$sql = "SELECT - SQL_CALC_FOUND_ROWS - c.ID, - c.Subject, - cu.Unread, - cu.Sticky, - cu.ForwardedTo, - um2.Username AS ForwardedName, - cu2.UserID, - um.Username, - ui.Donor, - ui.Warned, - um.Enabled,"; +$sql = " + SELECT + SQL_CALC_FOUND_ROWS + c.ID, + c.Subject, + cu.Unread, + cu.Sticky, + cu.ForwardedTo, + um2.Username AS ForwardedName, + cu2.UserID, + um.Username, + ui.Donor, + ui.Warned, + um.Enabled,"; $sql .= ($Section == 'sentbox')? ' cu.SentDate ' : ' cu.ReceivedDate '; $sql .= "AS Date FROM pm_conversations AS c - LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID' - LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0 - LEFT JOIN users_main AS um ON um.ID=cu2.UserID - LEFT JOIN users_info AS ui ON ui.UserID=um.ID - LEFT JOIN users_main AS um2 ON um2.ID=cu.ForwardedTo"; + LEFT JOIN pm_conversations_users AS cu ON cu.ConvID=c.ID AND cu.UserID='$UserID' + LEFT JOIN pm_conversations_users AS cu2 ON cu2.ConvID=c.ID AND cu2.UserID!='$UserID' AND cu2.ForwardedTo=0 + LEFT JOIN users_main AS um ON um.ID=cu2.UserID + LEFT JOIN users_info AS ui ON ui.UserID=um.ID + LEFT JOIN users_main AS um2 ON um2.ID=cu.ForwardedTo"; -if(!empty($_GET['search']) && $_GET['searchtype'] == "message") { +if (!empty($_GET['search']) && $_GET['searchtype'] == "message") { $sql .= " JOIN pm_messages AS m ON c.ID=m.ConvID"; } $sql .= " WHERE "; -if(!empty($_GET['search'])) { +if (!empty($_GET['search'])) { $Search = db_string($_GET['search']); - if($_GET['searchtype'] == "user") { + if ($_GET['searchtype'] == "user") { $sql .= "um.Username LIKE '".$Search."' AND "; - } elseif($_GET['searchtype'] == "subject") { + } elseif ($_GET['searchtype'] == "subject") { $Words = explode(' ', $Search); $sql .= "c.Subject LIKE '%".implode("%' AND c.Subject LIKE '%", $Words)."%' AND "; - } elseif($_GET['searchtype'] == "message") { + } elseif ($_GET['searchtype'] == "message") { $Words = explode(' ', $Search); $sql .= "m.Body LIKE '%".implode("%' AND m.Body LIKE '%", $Words)."%' AND "; } } -$sql .= ($Section == 'sentbox')? ' cu.InSentbox' : ' cu.InInbox'; +$sql .= ($Section == 'sentbox') ? ' cu.InSentbox' : ' cu.InInbox'; $sql .="='1'"; $sql .=" GROUP BY c.ID @@ -71,16 +73,16 @@ $DB->set_query_id($Results); $CurURL = Format::get_url(array('sort')); -if(empty($CurURL)) { +if (empty($CurURL)) { $CurURL = "inbox.php?"; } else { $CurURL = "inbox.php?".$CurURL."&"; } -$Pages=Format::get_pages($Page,$NumResults,MESSAGES_PER_PAGE,9); +$Pages = Format::get_pages($Page,$NumResults,MESSAGES_PER_PAGE,9); $JsonMessages = array(); -while(list($ConvID, $Subject, $Unread, $Sticky, $ForwardedID, $ForwardedName, $SenderID, $Username, $Donor, $Warned, $Enabled, $Date) = $DB->next_record()) { +while (list($ConvID, $Subject, $Unread, $Sticky, $ForwardedID, $ForwardedName, $SenderID, $Username, $Donor, $Warned, $Enabled, $Date) = $DB->next_record()) { $JsonMessage = array( 'convId' => (int) $ConvID, 'subject' => $Subject, @@ -104,9 +106,9 @@ 'status' => 'success', 'response' => array( 'currentPage' => (int) $Page, - 'pages' => ceil($NumResults/MESSAGES_PER_PAGE), + 'pages' => ceil($NumResults / MESSAGES_PER_PAGE), 'messages' => $JsonMessages ) ) ); -?> \ No newline at end of file +?> diff --git a/sections/ajax/inbox/viewconv.php b/sections/ajax/inbox/viewconv.php index 3b680b2c..7d2608a9 100644 --- a/sections/ajax/inbox/viewconv.php +++ b/sections/ajax/inbox/viewconv.php @@ -3,7 +3,7 @@ $Text = new TEXT; $ConvID = $_GET['id']; -if(!$ConvID || !is_number($ConvID)) { +if (!$ConvID || !is_number($ConvID)) { print json_encode(array('status' => 'failure')); die(); } @@ -11,8 +11,12 @@ $UserID = $LoggedUser['ID']; -$DB->query("SELECT InInbox, InSentbox FROM pm_conversations_users WHERE UserID='$UserID' AND ConvID='$ConvID'"); -if($DB->record_count() == 0) { +$DB->query(" + SELECT InInbox, InSentbox + FROM pm_conversations_users + WHERE UserID='$UserID' + AND ConvID='$ConvID'"); +if ($DB->record_count() == 0) { print json_encode(array('status' => 'failure')); die(); } @@ -27,24 +31,27 @@ } // Get information on the conversation -$DB->query("SELECT - c.Subject, - cu.Sticky, - cu.UnRead, - cu.ForwardedTo, - um.Username +$DB->query(" + SELECT + c.Subject, + cu.Sticky, + cu.UnRead, + cu.ForwardedTo, + um.Username FROM pm_conversations AS c - JOIN pm_conversations_users AS cu ON c.ID=cu.ConvID - LEFT JOIN users_main AS um ON um.ID=cu.ForwardedTo - WHERE c.ID='$ConvID' AND UserID='$UserID'"); + JOIN pm_conversations_users AS cu ON c.ID=cu.ConvID + LEFT JOIN users_main AS um ON um.ID=cu.ForwardedTo + WHERE c.ID='$ConvID' + AND UserID='$UserID'"); list($Subject, $Sticky, $UnRead, $ForwardedID, $ForwardedName) = $DB->next_record(); -$DB->query("SELECT um.ID, Username +$DB->query(" + SELECT um.ID, Username FROM pm_messages AS pm - JOIN users_main AS um ON um.ID=pm.SenderID + JOIN users_main AS um ON um.ID=pm.SenderID WHERE pm.ConvID='$ConvID'"); -while(list($PMUserID, $Username) = $DB->next_record()) { +while (list($PMUserID, $Username) = $DB->next_record()) { $PMUserID = (int)$PMUserID; $Users[$PMUserID]['UserStr'] = Users::format_username($PMUserID, true, true, true, true); $Users[$PMUserID]['Username'] = $Username; @@ -54,18 +61,26 @@ -if($UnRead=='1') { +if ($UnRead == '1') { - $DB->query("UPDATE pm_conversations_users SET UnRead='0' WHERE ConvID='$ConvID' AND UserID='$UserID'"); + $DB->query(" + UPDATE pm_conversations_users + SET UnRead='0' + WHERE ConvID='$ConvID' + AND UserID='$UserID'"); // Clear the caches of the inbox and sentbox $Cache->decrement('inbox_new_'.$UserID); } // Get messages -$DB->query("SELECT SentDate, SenderID, Body, ID FROM pm_messages AS m WHERE ConvID='$ConvID' ORDER BY ID"); +$DB->query(" + SELECT SentDate, SenderID, Body, ID + FROM pm_messages AS m + WHERE ConvID='$ConvID' + ORDER BY ID"); $JsonMessages = array(); -while(list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) { +while (list($SentDate, $SenderID, $Body, $MessageID) = $DB->next_record()) { $JsonMessage = array( 'messageId' => (int) $MessageID, 'senderId' => (int) $SenderID, @@ -83,7 +98,7 @@ 'status' => 'success', 'response' => array( 'convId' => (int) $ConvID, - 'subject' => $Subject.($ForwardedID > 0 ? ' (Forwarded to '.$ForwardedName.')':''), + 'subject' => $Subject.($ForwardedID > 0 ? " (Forwarded to $ForwardedName)" : ''), 'sticky' => $Sticky == 1, 'messages' => $JsonMessages ) diff --git a/sections/ajax/notifications.php b/sections/ajax/notifications.php index 7dd05968..552c445f 100644 --- a/sections/ajax/notifications.php +++ b/sections/ajax/notifications.php @@ -1,32 +1,40 @@ query("SELECT SQL_CALC_FOUND_ROWS unt.TorrentID, unt.UnRead, unt.FilterID, unf.Label, t.GroupID +$Results = $DB->query(" + SELECT SQL_CALC_FOUND_ROWS + unt.TorrentID, + unt.UnRead, + unt.FilterID, + unf.Label, + t.GroupID FROM users_notify_torrents AS unt - JOIN torrents AS t ON t.ID = unt.TorrentID - LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID + JOIN torrents AS t ON t.ID = unt.TorrentID + LEFT JOIN users_notify_filters AS unf ON unf.ID = unt.FilterID WHERE unt.UserID=$LoggedUser[ID]". ((!empty($_GET['filterid']) && is_number($_GET['filterid'])) ? " AND unf.ID='$_GET[filterid]'" - : "")." - ORDER BY TorrentID DESC LIMIT $Limit"); + : '')." + ORDER BY TorrentID DESC + LIMIT $Limit"); $GroupIDs = array_unique($DB->collect('GroupID')); $DB->query('SELECT FOUND_ROWS()'); list($TorrentCount) = $DB->next_record(); -if(count($GroupIDs)) { +if (count($GroupIDs)) { $TorrentGroups = Torrents::get_groups($GroupIDs); $TorrentGroups = $TorrentGroups['matches']; - $DB->query("UPDATE users_notify_torrents SET UnRead='0' WHERE UserID=".$LoggedUser['ID']); + $DB->query(" + UPDATE users_notify_torrents + SET UnRead='0' + WHERE UserID=".$LoggedUser['ID']); $Cache->delete_value('notifications_new_'.$LoggedUser['ID']); } @@ -36,11 +44,11 @@ $NumNew = 0; $FilterGroups = array(); -while($Result = $DB->next_record(MYSQLI_ASSOC)) { - if(!$Result['FilterID']) { +while ($Result = $DB->next_record(MYSQLI_ASSOC)) { + if (!$Result['FilterID']) { $Result['FilterID'] = 0; } - if(!isset($FilterGroups[$Result['FilterID']])) { + if (!isset($FilterGroups[$Result['FilterID']])) { $FilterGroups[$Result['FilterID']] = array(); $FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false; } @@ -48,9 +56,9 @@ } unset($Result); -foreach($FilterGroups as $FilterID => $FilterResults) { +foreach ($FilterGroups as $FilterID => $FilterResults) { unset($FilterResults['FilterLabel']); - foreach($FilterResults as $Result) { + foreach ($FilterResults as $Result) { $TorrentID = $Result['TorrentID']; // $GroupID = $Result['GroupID']; @@ -58,7 +66,9 @@ extract(Torrents::array_group($GroupInfo)); // all group data $TorrentInfo = $GroupInfo['Torrents'][$TorrentID]; - if ($Result['UnRead'] == 1) $NumNew++; + if ($Result['UnRead'] == 1) { + $NumNew++; + } $JsonNotifications[] = array( 'torrentId' => (int) $TorrentID, @@ -95,4 +105,4 @@ 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), 'numNew' => $NumNew, 'results' => $JsonNotifications -)); \ No newline at end of file +)); diff --git a/sections/ajax/preview.php b/sections/ajax/preview.php index 2ec6b0ab..446a2809 100644 --- a/sections/ajax/preview.php +++ b/sections/ajax/preview.php @@ -4,7 +4,7 @@ include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class $Text = new TEXT(true); -if(!empty($_POST['AdminComment'])) { +if (!empty($_POST['AdminComment'])) { echo $Text->full_format($_POST['AdminComment']); } else { $Content = $_REQUEST['body']; // Don't use URL decode. diff --git a/sections/ajax/request.php b/sections/ajax/request.php index adc78b29..e6f38e49 100644 --- a/sections/ajax/request.php +++ b/sections/ajax/request.php @@ -16,7 +16,7 @@ include(SERVER_ROOT.'/classes/class_text.php'); $Text = new TEXT; -if(empty($_GET['id']) || !is_number($_GET['id'])) { +if (empty($_GET['id']) || !is_number($_GET['id'])) { json_die("failure"); } @@ -26,7 +26,7 @@ $Request = Requests::get_requests(array($RequestID)); $Request = $Request['matches'][$RequestID]; -if(empty($Request)) { +if (empty($Request)) { json_die("failure"); } diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index dd78c0cd..960dc821 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -43,7 +43,7 @@ } break; case 'filled': - if(empty($_GET['userid']) || !is_number($_GET['userid'])) { + if (empty($_GET['userid']) || !is_number($_GET['userid'])) { json_die("failure"); } else { if (!check_paranoia('requestsfilled_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { @@ -314,13 +314,13 @@ $VoteCount = count($RequestVotes['Voters']); if ($CategoryID == 0) { - $CategoryName = "Unknown"; + $CategoryName = 'Unknown'; } else { $CategoryName = $Categories[$CategoryID - 1]; } $JsonArtists = array(); - if ($CategoryName == "Music") { + if ($CategoryName == 'Music') { $ArtistForm = get_request_artists($RequestID); $JsonArtists = array_values($ArtistForm); } @@ -350,9 +350,9 @@ 'logCue' => $LogCue, 'isFilled' => ($TorrentID > 0), 'fillerId' => (int) $FillerID, - 'fillerName' => $FillerName == 0 ? "" : $FillerName, + 'fillerName' => $FillerName == 0 ? '' : $FillerName, 'torrentId' => (int) $TorrentID, - 'timeFilled' => $TimeFilled == 0 ? "" : $TimeFilled + 'timeFilled' => $TimeFilled == 0 ? '' : $TimeFilled ); } json_die("success", array( diff --git a/sections/ajax/stats.php b/sections/ajax/stats.php index bb3da2fd..13d3c71e 100644 --- a/sections/ajax/stats.php +++ b/sections/ajax/stats.php @@ -1,5 +1,5 @@ begin_transaction('stats_links'); $Cache->update_row(false, array($_GET['stat'] => '+1')); $Cache->commit_transaction(0); diff --git a/sections/ajax/tcomments.php b/sections/ajax/tcomments.php index 8608b313..f5a9ca0d 100644 --- a/sections/ajax/tcomments.php +++ b/sections/ajax/tcomments.php @@ -7,17 +7,22 @@ $GroupID=ceil($_GET['id']); $Results = $Cache->get_value('torrent_comments_'.$GroupID); -if($Results === false) { - $DB->query("SELECT +if ($Results === false) { + $DB->query(" + SELECT COUNT(c.ID) - FROM torrents_comments as c - WHERE c.GroupID = '$GroupID'"); + FROM torrents_comments as c + WHERE c.GroupID = '$GroupID'"); list($Results) = $DB->next_record(); $Cache->cache_value('torrent_comments_'.$GroupID, $Results, 0); } -if(isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) { - $DB->query("SELECT COUNT(ID) FROM torrents_comments WHERE GroupID = $GroupID AND ID <= $_GET[postid]"); +if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) { + $DB->query(" + SELECT COUNT(ID) + FROM torrents_comments + WHERE GroupID = $GroupID + AND ID <= $_GET[postid]"); list($PostNum) = $DB->next_record(); list($Page,$Limit) = Format::page_limit(TORRENT_COMMENTS_PER_PAGE,$PostNum); } else { @@ -25,15 +30,16 @@ } //Get the cache catalogue -$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE); -$CatalogueLimit=$CatalogueID*THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE; +$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE); +$CatalogueLimit = $CatalogueID * THREAD_CATALOGUE . ', ' . THREAD_CATALOGUE; //---------- Get some data to start processing // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page $Catalogue = $Cache->get_value('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID); -if($Catalogue === false) { - $DB->query("SELECT +if ($Catalogue === false) { + $DB->query(" + SELECT c.ID, c.AuthorID, c.AddedTime, @@ -41,17 +47,17 @@ c.EditedUserID, c.EditedTime, u.Username - FROM torrents_comments as c + FROM torrents_comments as c LEFT JOIN users_main AS u ON u.ID=c.EditedUserID - WHERE c.GroupID = '$GroupID' - ORDER BY c.ID - LIMIT $CatalogueLimit"); + WHERE c.GroupID = '$GroupID' + ORDER BY c.ID + LIMIT $CatalogueLimit"); $Catalogue = $DB->to_array(false,MYSQLI_ASSOC); $Cache->cache_value('torrent_comments_'.$GroupID.'_catalogue_'.$CatalogueID, $Catalogue, 0); } //This is a hybrid to reduce the catalogue down to the page elements: We use the page limit % catalogue -$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)%THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true); +$Thread = array_slice($Catalogue,((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) % THREAD_CATALOGUE),TORRENT_COMMENTS_PER_PAGE,true); //---------- Begin printing $JsonComments = array(); diff --git a/sections/ajax/top10/tags.php b/sections/ajax/top10/tags.php index 20745edd..4ed5ce64 100644 --- a/sections/ajax/top10/tags.php +++ b/sections/ajax/top10/tags.php @@ -2,8 +2,8 @@ // error out on invalid requests (before caching) -if(isset($_GET['details'])) { - if(in_array($_GET['details'],array('ut','ur','v'))) { +if (isset($_GET['details'])) { + if (in_array($_GET['details'],array('ut','ur','v'))) { $Details = $_GET['details']; } else { print json_encode(array('status' => 'failure')); @@ -20,19 +20,20 @@ if ($Details == 'all' || $Details == 'ut') { if (!$TopUsedTags = $Cache->get_value('topusedtag_'.$Limit)) { - $DB->query("SELECT - t.ID, - t.Name, - COUNT(tt.GroupID) AS Uses, - SUM(tt.PositiveVotes-1) AS PosVotes, - SUM(tt.NegativeVotes-1) AS NegVotes + $DB->query(" + SELECT + t.ID, + t.Name, + COUNT(tt.GroupID) AS Uses, + SUM(tt.PositiveVotes-1) AS PosVotes, + SUM(tt.NegativeVotes-1) AS NegVotes FROM tags AS t - JOIN torrents_tags AS tt ON tt.TagID=t.ID + JOIN torrents_tags AS tt ON tt.TagID=t.ID GROUP BY tt.TagID ORDER BY Uses DESC LIMIT $Limit"); $TopUsedTags = $DB->to_array(); - $Cache->cache_value('topusedtag_'.$Limit,$TopUsedTags,3600*12); + $Cache->cache_value('topusedtag_'.$Limit,$TopUsedTags,3600 * 12); } $OuterResults[] = generate_tag_json('Most Used Torrent Tags', 'ut', $TopUsedTags, $Limit); @@ -40,18 +41,19 @@ if ($Details == 'all' || $Details == 'ur') { if (!$TopRequestTags = $Cache->get_value('toprequesttag_'.$Limit)) { - $DB->query("SELECT - t.ID, - t.Name, - COUNT(r.RequestID) AS Uses, - '','' + $DB->query(" + SELECT + t.ID, + t.Name, + COUNT(r.RequestID) AS Uses, + '','' FROM tags AS t - JOIN requests_tags AS r ON r.TagID=t.ID + JOIN requests_tags AS r ON r.TagID=t.ID GROUP BY r.TagID ORDER BY Uses DESC LIMIT $Limit"); $TopRequestTags = $DB->to_array(); - $Cache->cache_value('toprequesttag_'.$Limit,$TopRequestTags,3600*12); + $Cache->cache_value('toprequesttag_'.$Limit,$TopRequestTags,3600 * 12); } $OuterResults[] = generate_tag_json('Most Used Request Tags', 'ur', $TopRequestTags, $Limit); @@ -59,19 +61,20 @@ if ($Details == 'all' || $Details == 'v') { if (!$TopVotedTags = $Cache->get_value('topvotedtag_'.$Limit)) { - $DB->query("SELECT - t.ID, - t.Name, - COUNT(tt.GroupID) AS Uses, - SUM(tt.PositiveVotes-1) AS PosVotes, - SUM(tt.NegativeVotes-1) AS NegVotes + $DB->query(" + SELECT + t.ID, + t.Name, + COUNT(tt.GroupID) AS Uses, + SUM(tt.PositiveVotes-1) AS PosVotes, + SUM(tt.NegativeVotes-1) AS NegVotes FROM tags AS t - JOIN torrents_tags AS tt ON tt.TagID=t.ID + JOIN torrents_tags AS tt ON tt.TagID=t.ID GROUP BY tt.TagID ORDER BY PosVotes DESC LIMIT $Limit"); $TopVotedTags = $DB->to_array(); - $Cache->cache_value('topvotedtag_'.$Limit,$TopVotedTags,3600*12); + $Cache->cache_value('topvotedtag_'.$Limit,$TopVotedTags,3600 * 12); } $OuterResults[] = generate_tag_json('Most Highly Voted Tags', 'v', $TopVotedTags, $Limit); diff --git a/sections/api/index.php b/sections/api/index.php index 2978ea89..b7e0bc04 100644 --- a/sections/api/index.php +++ b/sections/api/index.php @@ -2,7 +2,6 @@ $Available = array( 'access_request', 'access_state', - 'user_stats_ratio', 'user_stats_torrent', 'user_stats_comumnity', @@ -25,7 +24,7 @@ $UserID = $_GET['uid']; $App = $Cache->get_value('api_apps_'.$AppID); -if(!is_array($App)) { +if (!is_array($App)) { if (!isset($DB)) { require(SERVER_ROOT.'/classes/class_mysql.php'); $DB = new DB_MYSQL; @@ -43,12 +42,16 @@ } } else { $User = $Cache->get_value('api_users_'.$UserID); - if(!is_array($User)) { + if (!is_array($User)) { if (!isset($DB)) { require(SERVER_ROOT.'/classes/class_mysql.php'); $DB = new DB_MYSQL; } - $DB->query("SELECT AppID, Token, State, Time, Access FROM api_users WHERE UserID='$UserID' LIMIT 1"); //int, no db_string + $DB->query(" + SELECT AppID, Token, State, Time, Access + FROM api_users + WHERE UserID='$UserID' + LIMIT 1"); //int, no db_string $User = $DB->to_array('AppID',MYSQLI_ASSOC); $Cache->cache_value('api_users_'.$UserID, $User, 0); } diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php index 05d191ac..00ece71d 100644 --- a/sections/artist/add_alias.php +++ b/sections/artist/add_alias.php @@ -1,18 +1,22 @@ query("SELECT AliasID, ArtistID, Name, Redirect FROM artists_alias WHERE Name = '".$DBAliasName."'"); -if($DB->record_count()) { - while(list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) { - if(!strcasecmp($CloneAliasName, $AliasName)) { +$DB->query(" + SELECT AliasID, ArtistID, Name, Redirect + FROM artists_alias + WHERE Name = '".$DBAliasName."'"); +if ($DB->record_count()) { + while (list($CloneAliasID, $CloneArtistID, $CloneAliasName, $CloneRedirect) = $DB->next_record(MYSQLI_NUM, false)) { + if (!strcasecmp($CloneAliasName, $AliasName)) { break; } } - if($CloneAliasID) { - if($ArtistID == $CloneArtistID && $Redirect == 0) { - if($CloneRedirect != 0) { - $DB->query("UPDATE artists_alias SET ArtistID='".$ArtistID."', Redirect=0 WHERE AliasID='".$CloneAliasID."'"); + if ($CloneAliasID) { + if ($ArtistID == $CloneArtistID && $Redirect == 0) { + if ($CloneRedirect != 0) { + $DB->query(" + UPDATE artists_alias + 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.'); @@ -44,29 +54,29 @@ } } } -if(!$CloneAliasID) { - if($Redirect) { +if (!$CloneAliasID) { + if ($Redirect) { $DB->query("SELECT ArtistID, Redirect FROM artists_alias WHERE AliasID = $Redirect"); - if(!$DB->record_count()) { + if (!$DB->record_count()) { error('Cannot redirect to a nonexistent artist alias.'); } list($FoundArtistID, $FoundRedirect) = $DB->next_record(); - if($ArtistID != $FoundArtistID) { + if ($ArtistID != $FoundArtistID) { error('Redirection must target an alias for the current artist.'); } - if($FoundRedirect != 0) { + if ($FoundRedirect != 0) { $Redirect = $FoundRedirect; } } - $DB->query("INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID) - VALUES - (".$ArtistID.", '".$DBAliasName."', ".$Redirect.", ".$LoggedUser['ID'].")"); + $DB->query(" + INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID) + VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')'); $AliasID = $DB->inserted_id(); $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'].")"); + Misc::write_log("The alias $AliasID ($DBAliasName) was added to the artist $ArtistID (".db_string($ArtistName).") by user ".$LoggedUser['ID'].' ('.$LoggedUser['Username'].')'); } header('Location: '.$_SERVER['HTTP_REFERER']); ?> diff --git a/sections/artist/autocomplete.php b/sections/artist/autocomplete.php index 24155278..519e7ab0 100644 --- a/sections/artist/autocomplete.php +++ b/sections/artist/autocomplete.php @@ -2,7 +2,9 @@ header('Content-type: application/x-suggestions+json'); require('classes/ajax_start.php'); -if(empty($_GET['name'])) { die('["",[],[],[]]'); } +if (empty($_GET['name'])) { + die('["",[],[],[]]'); +} $FullName = rawurldecode($_GET['name']); @@ -14,25 +16,26 @@ $Letters = strtolower(substr($FullName,0,$KeySize)); $AutoSuggest = $Cache->get('autocomplete_artist_'.$KeySize.'_'.$Letters); -if(!is_array($AutoSuggest)) { - if(!isset($DB) || !is_object($DB)) { +if (!is_array($AutoSuggest)) { + if (!isset($DB) || !is_object($DB)) { require(SERVER_ROOT.'/classes/class_mysql.php'); //Require the database wrapper $DB=NEW DB_MYSQL; //Load the database wrapper } - $Limit = (($KeySize === $MaxKeySize)?250:10); - $DB->query("SELECT - a.ArtistID, - a.Name, - SUM(t.Snatched) AS Snatches + $Limit = (($KeySize === $MaxKeySize) ? 250 : 10); + $DB->query(" + SELECT + a.ArtistID, + a.Name, + SUM(t.Snatched) AS Snatches FROM artists_group AS a - INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID - INNER JOIN torrents AS t ON t.GroupID=ta.GroupID + INNER JOIN torrents_artists AS ta ON ta.ArtistID=a.ArtistID + INNER JOIN torrents AS t ON t.GroupID=ta.GroupID WHERE a.Name LIKE '".db_string(str_replace('\\','\\\\',$Letters),true)."%' GROUP BY ta.ArtistID ORDER BY Snatches DESC LIMIT $Limit"); $AutoSuggest = $DB->to_array(false,MYSQLI_NUM,false); - $Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800+7200*($MaxKeySize-$KeySize)); // Can't cache things for too long in case names are edited + $Cache->cache_value('autocomplete_artist_'.$KeySize.'_'.$Letters,$AutoSuggest,1800 + 7200 * ($MaxKeySize - $KeySize)); // Can't cache things for too long in case names are edited } $Matched = 0; diff --git a/sections/artist/change_artistid.php b/sections/artist/change_artistid.php index 20bc7a5d..1d2a9890 100644 --- a/sections/artist/change_artistid.php +++ b/sections/artist/change_artistid.php @@ -1,9 +1,11 @@ query("SELECT Name FROM artists_group WHERE ArtistID = $ArtistID LIMIT 1"); -if(!(list($ArtistName) = $DB->next_record(MYSQLI_NUM, false))) { +if (!(list($ArtistName) = $DB->next_record(MYSQLI_NUM, false))) { error('An error has occured.'); } if ($NewArtistID > 0) { // Make sure that's a real artist ID number, and grab the name $DB->query("SELECT Name FROM artists_group WHERE ArtistID = $NewArtistID LIMIT 1"); - if(!(list($NewArtistName) = $DB->next_record())) { + if (!(list($NewArtistName) = $DB->next_record())) { error('Please enter a valid artist ID number.'); } } else { // Didn't give an ID, so try to grab based on the name $DB->query("SELECT ArtistID FROM artists_alias WHERE Name = '".db_string($NewArtistName)."' LIMIT 1"); - if(!(list($NewArtistID) = $DB->next_record())) { + if (!(list($NewArtistID) = $DB->next_record())) { error('No artist by that name was found.'); } } @@ -47,10 +49,11 @@ $Requests = $DB->collect('RequestID'); $DB->query("SELECT DISTINCT UserID FROM bookmarks_artists WHERE ArtistID = $ArtistID"); $BookmarkUsers = $DB->collect('UserID'); - $DB->query("SELECT DISTINCT ct.CollageID - FROM collages_torrents AS ct - JOIN torrents_artists AS ta ON ta.GroupID = ct.GroupID - WHERE ta.ArtistID = $ArtistID"); + $DB->query(" + SELECT DISTINCT ct.CollageID + FROM collages_torrents AS ct + JOIN torrents_artists AS ta ON ta.GroupID = ct.GroupID + WHERE ta.ArtistID = $ArtistID"); $Collages = $DB->collect('CollageID'); // And the info to avoid double-listing an artist if it and the target are on the same group @@ -70,42 +73,51 @@ $NewArtistBookmarks = implode(',',$NewArtistBookmarks); // Merge all of this artist's aliases onto the new artist - $DB->query("UPDATE artists_alias SET ArtistID = $NewArtistID WHERE ArtistID = $ArtistID"); + $DB->query(" + UPDATE artists_alias + SET ArtistID = $NewArtistID + WHERE ArtistID = $ArtistID"); // Update the torrent groups, requests, and bookmarks - $DB->query("UPDATE IGNORE torrents_artists SET ArtistID = $NewArtistID - WHERE ArtistID = $ArtistID - AND GroupID NOT IN ($NewArtistGroups)"); + $DB->query(" + UPDATE IGNORE torrents_artists + SET ArtistID = $NewArtistID + WHERE ArtistID = $ArtistID + AND GroupID NOT IN ($NewArtistGroups)"); $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(" + 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("UPDATE IGNORE bookmarks_artists SET ArtistID = $NewArtistID - WHERE ArtistID = $ArtistID - AND UserID NOT IN ($NewArtistBookmarks)"); + $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"); // Cache clearing - if(!empty($Groups)) { - foreach($Groups as $GroupID) { + if (!empty($Groups)) { + foreach ($Groups as $GroupID) { $Cache->delete_value('groups_artists_'.$GroupID); Torrents::update_hash($GroupID); } } - if(!empty($Requests)) { - foreach($Requests as $RequestID) { + if (!empty($Requests)) { + foreach ($Requests as $RequestID) { $Cache->delete_value('request_artist_'.$RequestID); Requests::update_sphinx_requests($RequestID); } } - if(!empty($BookmarkUsers)) { - foreach($BookmarkUsers as $UserID) { + if (!empty($BookmarkUsers)) { + foreach ($BookmarkUsers as $UserID) { $Cache->delete_value('notify_artists_'.$UserID); } } - if(!empty($Collages)) { - foreach($Collages as $CollageID) { + if (!empty($Collages)) { + foreach ($Collages as $CollageID) { $Cache->delete_value('collage_'.$CollageID); } } @@ -118,7 +130,7 @@ // Delete the old artist $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'].")"); + Misc::write_log("The artist $ArtistID ($ArtistName) was made into a non-redirecting alias of artist $NewArtistID ($NewArtistName) by user ".$LoggedUser['ID']." (".$LoggedUser['Username'].')'); header("Location: artist.php?action=edit&artistid=$NewArtistID"); } else { diff --git a/sections/artist/delete.php b/sections/artist/delete.php index 947dcdf5..4d75a37a 100644 --- a/sections/artist/delete.php +++ b/sections/artist/delete.php @@ -10,22 +10,26 @@ authorize(); $ArtistID = $_GET['artistid']; -if(!is_number($ArtistID) || empty($ArtistID)) { error(0); } +if (!is_number($ArtistID) || empty($ArtistID)) { + error(0); +} -if(!check_perms('site_delete_artist') || !check_perms('torrents_delete')) { error(403); } +if (!check_perms('site_delete_artist') || !check_perms('torrents_delete')) { + error(403); +} View::show_header('Artist deleted'); $DB->query('SELECT Name FROM artists_group WHERE ArtistID='.$ArtistID); list($Name) = $DB->next_record(); -$DB->query('SELECT tg.Name, - tg.ID - FROM torrents_group AS tg - LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID - WHERE ta.ArtistID='.$ArtistID); +$DB->query(' + SELECT tg.Name, tg.ID + FROM torrents_group AS tg + LEFT JOIN torrents_artists AS ta ON ta.GroupID=tg.ID + WHERE ta.ArtistID='.$ArtistID); $Count = $DB->record_count(); -if($DB->record_count() > 0) { +if ($DB->record_count() > 0) { ?>
There are still torrents that have as an artist.
@@ -33,7 +37,7 @@
    next_record(MYSQLI_NUM, true)) { + while (list($GroupName, $GroupID) = $DB->next_record(MYSQLI_NUM, true)) { ?>
  • @@ -47,13 +51,13 @@ query('SELECT r.Title, - r.ID - FROM requests AS r - LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID - WHERE ra.ArtistID='.$ArtistID); +$DB->query(' + SELECT r.Title, r.ID + FROM requests AS r + LEFT JOIN requests_artists AS ra ON ra.RequestID=r.ID + WHERE ra.ArtistID='.$ArtistID); $Count += $DB->record_count(); -if($DB->record_count() > 0) { +if ($DB->record_count() > 0) { ?>
    There are still requests that have as an artist.
    @@ -61,7 +65,7 @@
      next_record(MYSQLI_NUM, true)) { + while (list($RequestName, $RequestID) = $DB->next_record(MYSQLI_NUM, true)) { ?>
    • @@ -75,10 +79,12 @@ -
      Artist deleted!
      +
      + Artist "" deleted! +
      diff --git a/sections/artist/delete_similar.php b/sections/artist/delete_similar.php index 0e45ab9a..6ff285b4 100644 --- a/sections/artist/delete_similar.php +++ b/sections/artist/delete_similar.php @@ -2,10 +2,10 @@ authorize(); $SimilarID = db_string($_GET['similarid']); -if(!is_number($SimilarID) || !$SimilarID) { +if (!is_number($SimilarID) || !$SimilarID) { error(404); } -if(!check_perms('site_delete_tag')) { +if (!check_perms('site_delete_tag')) { error(403); } $DB->query("SELECT ArtistID FROM artists_similar WHERE SimilarID='$SimilarID'"); diff --git a/sections/artist/edit.php b/sections/artist/edit.php index 1e0d4f38..db15ae01 100644 --- a/sections/artist/edit.php +++ b/sections/artist/edit.php @@ -11,19 +11,22 @@ ************************************************************************/ $ArtistID = $_GET['artistid']; -if(!is_number($ArtistID)) { error(0); } +if (!is_number($ArtistID)) { + error(0); +} // Get the artist name and the body of the last revision -$DB->query("SELECT - Name, - Image, - Body, - VanityHouse +$DB->query(" + SELECT + Name, + Image, + Body, + VanityHouse FROM artists_group AS a - LEFT JOIN wiki_artists ON wiki_artists.RevisionID=a.RevisionID + LEFT JOIN wiki_artists ON wiki_artists.RevisionID=a.RevisionID WHERE a.ArtistID='$ArtistID'"); -if($DB->record_count() < 1) { +if ($DB->record_count() < 1) { error("Cannot find the artist with the ID ".$ArtistID.': See the log.'); } @@ -46,7 +49,7 @@

      Artist info


      -

      Vanity House />

      +

      Vanity House />

      Edit summary


      @@ -55,7 +58,7 @@
    - +

    Rename

    @@ -97,13 +100,20 @@ query("SELECT AliasID, Name, UserID, Redirect FROM artists_alias WHERE ArtistID='$ArtistID'"); - while(list($AliasID, $AliasName, $User, $Redirect) = $DB->next_record(MYSQLI_NUM, true)) { - if($AliasName == $Name) { $DefaultRedirectID = $AliasID; } + while (list($AliasID, $AliasName, $User, $Redirect) = $DB->next_record(MYSQLI_NUM, true)) { + if ($AliasName == $Name) { + $DefaultRedirectID = $AliasID; + } ?> -
  • . - User (writes redirect to ) - X +
  • + . + + User + + (writes redirect to ) + + X
  • diff --git a/sections/artist/history.php b/sections/artist/history.php index 34aa6178..c727a8e8 100644 --- a/sections/artist/history.php +++ b/sections/artist/history.php @@ -12,7 +12,9 @@ ************************************************************************/ $ArtistID = $_GET['artistid']; -if(!is_number($ArtistID)) { error(0); } +if (!is_number($ArtistID)) { + error(0); +} include(SERVER_ROOT.'/classes/class_wiki.php'); // Wiki class $Wiki = new WIKI('wiki_artists', $ArtistID, "artist.php?id=$ArtistID"); @@ -21,7 +23,7 @@ $DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'"); list($Name) = $DB->next_record(MYSQLI_NUM, true); -View::show_header("Revision history for ".$Name); // Set title +View::show_header("Revision history for $Name"); // Set title // Start printing form ?> diff --git a/sections/artist/index.php b/sections/artist/index.php index cc9f608e..2c2ee2b2 100644 --- a/sections/artist/index.php +++ b/sections/artist/index.php @@ -41,7 +41,7 @@ error(0); } if ($LoggedUser['DisablePosting']) { - error('Your posting rights have been removed.'); + error('Your posting privileges have been removed.'); } $ArtistID = $_POST['artistid']; @@ -49,11 +49,19 @@ error(404); } - $DB->query("SELECT CEIL((SELECT COUNT(ID)+1 FROM artist_comments AS ac WHERE ac.ArtistID='" . db_string($ArtistID) . "')/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages"); + $DB->query(" + SELECT + CEIL(( + SELECT COUNT(ID)+1 + FROM artist_comments AS ac + WHERE ac.ArtistID='" . db_string($ArtistID) . "' + )/" . TORRENT_COMMENTS_PER_PAGE . " + ) AS Pages"); list($Pages) = $DB->next_record(); - $DB->query("INSERT INTO artist_comments (ArtistID,AuthorID,AddedTime,Body) VALUES ( - '" . db_string($ArtistID) . "', '" . db_string($LoggedUser['ID']) . "','" . sqltime() . "','" . db_string($_POST['body']) . "')"); + $DB->query(" + INSERT INTO artist_comments (ArtistID,AuthorID,AddedTime,Body) + VALUES ('" . db_string($ArtistID) . "', '" . db_string($LoggedUser['ID']) . "','" . sqltime() . "','" . db_string($_POST['body']) . "')"); $PostID = $DB->inserted_id(); $CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Pages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE); @@ -113,12 +121,17 @@ } // Get topicid, forumid, number of pages - $DB->query("SELECT - ArtistID, - CEIL(COUNT(ac.ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages, - CEIL(SUM(IF(ac.ID<=" . $_GET['postid'] . ",1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page + $DB->query(" + SELECT + ArtistID, + CEIL(COUNT(ac.ID)/" . TORRENT_COMMENTS_PER_PAGE . ") AS Pages, + CEIL(SUM(IF(ac.ID<=" . $_GET['postid'] . ",1,0))/" . TORRENT_COMMENTS_PER_PAGE . ") AS Page FROM artist_comments AS ac - WHERE ac.ArtistID=(SELECT ArtistID FROM artist_comments WHERE ID=" . $_GET['postid'] . ") + WHERE ac.ArtistID=( + SELECT ArtistID + FROM artist_comments + WHERE ID=" . $_GET['postid'] . " + ) GROUP BY ac.ArtistID"); list($ArtistID, $Pages, $Page) = $DB->next_record(); @@ -152,16 +165,21 @@ } // Mainly - $DB->query("SELECT - ac.Body, - ac.AuthorID, - ac.ArtistID, - ac.AddedTime + $DB->query(" + SELECT + ac.Body, + ac.AuthorID, + ac.ArtistID, + ac.AddedTime FROM artist_comments AS ac WHERE ac.ID='" . db_string($_POST['post']) . "'"); list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record(); - $DB->query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page FROM artist_comments WHERE ArtistID = $ArtistID AND ID <= $_POST[post]"); + $DB->query(" + SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page + FROM artist_comments + WHERE ArtistID = $ArtistID + AND ID <= $_POST[post]"); list($Page) = $DB->next_record(); if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) { @@ -172,10 +190,12 @@ } // Perform the update - $DB->query("UPDATE artist_comments SET - Body = '" . db_string($_POST['body']) . "', - EditedUserID = '" . db_string($LoggedUser['ID']) . "', - EditedTime = '" . sqltime() . "' + $DB->query(" + UPDATE artist_comments + SET + Body = '" . db_string($_POST['body']) . "', + EditedUserID = '" . db_string($LoggedUser['ID']) . "', + EditedTime = '" . sqltime() . "' WHERE ID='" . db_string($_POST['post']) . "'"); // Update the cache @@ -193,8 +213,9 @@ )); $Cache->commit_transaction(0); - $DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) - VALUES ('artist', " . db_string($_POST['post']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')"); + $DB->query(" + INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) + VALUES ('artist', " . db_string($_POST['post']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')"); // This gets sent to the browser, which echoes it in place of the old body echo $Text->full_format($_POST['body']); diff --git a/sections/artist/rename.php b/sections/artist/rename.php index 9cd0ada5..ca3d4f7e 100644 --- a/sections/artist/rename.php +++ b/sections/artist/rename.php @@ -25,25 +25,44 @@ $ArtistID = $_POST['artistid']; $NewName = Artists::normalise_artist_name($_POST['name']); -if(!$ArtistID || !is_number($ArtistID)) { error(404); } +if (!$ArtistID || !is_number($ArtistID)) { + error(404); +} -if(!check_perms('torrents_edit')) { error(403); } +if (!check_perms('torrents_edit')) { + error(403); +} $DB->query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'"); -if($DB->record_count()==0) { error(404); } +if ($DB->record_count() == 0) { + error(404); +} list($OldName) = $DB->next_record(MYSQLI_NUM, false); -if($OldName == $NewName) { error('The new name is identical to the old name.'); } +if ($OldName == $NewName) { + error('The new name is identical to the old name.'); +} -$DB->query("SELECT AliasID FROM artists_alias WHERE Name='".db_string($OldName)."' AND ArtistID='$ArtistID'"); +$DB->query(" + SELECT AliasID + FROM artists_alias + WHERE Name='".db_string($OldName)."' + AND ArtistID='$ArtistID'"); list($OldAliasID) = $DB->next_record(MYSQLI_NUM, false); -if(!$OldAliasID) { error('Could not find old alias ID'); } +if (!$OldAliasID) { + error('Could not find old alias ID'); +} -$DB->query("SELECT AliasID, ArtistID FROM artists_alias WHERE name LIKE '".db_string($NewName, true)."'"); +$DB->query(" + SELECT AliasID, ArtistID + FROM artists_alias + WHERE name LIKE '".db_string($NewName, true)."'"); list($TargetAliasID, $TargetArtistID) = $DB->next_record(MYSQLI_NUM, false); -if(!$TargetAliasID || $TargetAliasID==$OldAliasID) { +if (!$TargetAliasID || $TargetAliasID==$OldAliasID) { // no merge, just rename - $DB->query("INSERT INTO artists_alias (ArtistID, Name, Redirect, UserID) VALUES ($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')"); + $DB->query(" + INSERT INTO artists_alias (ArtistID, Name, Redirect, UserID) + VALUES ($ArtistID, '".db_string($NewName)."', '0', '$LoggedUser[ID]')"); $TargetAliasID = $DB->inserted_id(); $DB->query("UPDATE artists_alias SET Redirect='$TargetAliasID' WHERE AliasID='$OldAliasID'"); @@ -53,8 +72,8 @@ $Groups = $DB->collect('GroupID'); $DB->query("UPDATE IGNORE torrents_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'"); $DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'"); - if(!empty($Groups)) { - foreach($Groups as $GroupID) { + if (!empty($Groups)) { + foreach ($Groups as $GroupID) { $Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache Torrents::update_hash($GroupID); } @@ -64,8 +83,8 @@ $Requests = $DB->collect('RequestID'); $DB->query("UPDATE IGNORE requests_artists SET AliasID='$TargetAliasID' WHERE AliasID='$OldAliasID'"); $DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'"); - if(!empty($Requests)) { - foreach($Requests as $RequestID) { + if (!empty($Requests)) { + foreach ($Requests as $RequestID) { $Cache->delete_value('request_artists_'.$RequestID); // Delete request artist cache Requests::update_sphinx_requests($RequestID); } @@ -73,9 +92,12 @@ $TargetArtistID = $ArtistID; } else { // Merge stuff - $DB->query("UPDATE artists_alias SET Redirect='$TargetAliasID',ArtistID='$TargetArtistID' WHERE AliasID='$OldAliasID'"); + $DB->query(" + UPDATE artists_alias + SET Redirect='$TargetAliasID', ArtistID='$TargetArtistID' + WHERE AliasID='$OldAliasID'"); $DB->query("UPDATE artists_alias SET Redirect='0' WHERE AliasID='$TargetAliasID'"); - if($ArtistID != $TargetArtistID) { + if ($ArtistID != $TargetArtistID) { $DB->query("UPDATE artists_alias SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'"); $DB->query("DELETE FROM artists_group WHERE ArtistID='$ArtistID'"); } else { @@ -84,10 +106,13 @@ $DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); $Groups = $DB->collect('GroupID'); - $DB->query("UPDATE IGNORE torrents_artists SET AliasID='$TargetAliasID',ArtistID='$TargetArtistID' WHERE AliasID='$OldAliasID'"); + $DB->query(" + UPDATE IGNORE torrents_artists + SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID' + WHERE AliasID='$OldAliasID'"); $DB->query("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'"); - if(!empty($Groups)) { - foreach($Groups as $GroupID) { + if (!empty($Groups)) { + foreach ($Groups as $GroupID) { $Cache->delete_value('groups_artists_'.$GroupID); Torrents::update_hash($GroupID); } @@ -95,22 +120,28 @@ $DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'"); $Requests = $DB->collect('RequestID'); - $DB->query("UPDATE IGNORE requests_artists SET AliasID='$TargetAliasID',ArtistID='$TargetArtistID' WHERE AliasID='$OldAliasID'"); + $DB->query(" + UPDATE IGNORE requests_artists + SET AliasID='$TargetAliasID', ArtistID='$TargetArtistID' + WHERE AliasID='$OldAliasID'"); $DB->query("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'"); - if(!empty($Requests)) { - foreach($Requests as $RequestID) { + if (!empty($Requests)) { + foreach ($Requests as $RequestID) { $Cache->delete_value('request_artists_'.$RequestID); Requests::update_sphinx_requests($RequestID); } } - if($ArtistID != $TargetArtistID) { + if ($ArtistID != $TargetArtistID) { $DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); $Groups = $DB->collect('GroupID'); - $DB->query("UPDATE IGNORE torrents_artists SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'"); + $DB->query(" + UPDATE IGNORE torrents_artists + SET ArtistID='$TargetArtistID' + WHERE ArtistID='$ArtistID'"); $DB->query("DELETE FROM torrents_artists WHERE ArtistID='$ArtistID'"); - if(!empty($Groups)) { - foreach($Groups as $GroupID) { + if (!empty($Groups)) { + foreach ($Groups as $GroupID) { $Cache->delete_value('groups_artists_'.$GroupID); Torrents::update_hash($GroupID); } @@ -118,10 +149,13 @@ $DB->query("SELECT RequestID FROM requests_artists WHERE ArtistID='$ArtistID'"); $Requests = $DB->collect('RequestID'); - $DB->query("UPDATE IGNORE requests_artists SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'"); + $DB->query(" + UPDATE IGNORE requests_artists + SET ArtistID='$TargetArtistID' + WHERE ArtistID='$ArtistID'"); $DB->query("DELETE FROM requests_artists WHERE ArtistID='$ArtistID'"); - if(!empty($Requests)) { - foreach($Requests as $RequestID) { + if (!empty($Requests)) { + foreach ($Requests as $RequestID) { $Cache->delete_value('request_artists_'.$RequestID); Requests::update_sphinx_requests($RequestID); } @@ -131,7 +165,7 @@ // Clear torrent caches $DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); -while(list($GroupID) = $DB->next_record()) { +while (list($GroupID) = $DB->next_record()) { $Cache->delete_value('torrents_details_'.$GroupID); } diff --git a/sections/artist/take_warn.php b/sections/artist/take_warn.php index 2a86d7df..654678c4 100644 --- a/sections/artist/take_warn.php +++ b/sections/artist/take_warn.php @@ -13,46 +13,55 @@ $Key = (int)$_POST['key']; $SQLTime = sqltime(); $UserInfo = Users::user_info($UserID); -if($UserInfo['Class'] > $LoggedUser['Class']) { +if ($UserInfo['Class'] > $LoggedUser['Class']) { error(403); } $URL = "https://". SSL_SITE_URL."/artist.php?id=$ArtistID&postid=$PostID#post$PostID"; if ($Length != 'verbal') { $Time = ((int)$Length) * (7 * 24 * 60 * 60); Tools::warn_user($UserID, $Time, "$URL - ". $Reason); - $Subject = "You have received a warning"; + $Subject = 'You have received a warning'; $PrivateMessage = "You have received a $Length week warning for [url=$URL]this artist comment.[/url]\n\n" . $PrivateMessage; $WarnTime = time_plus($Time); - $AdminComment = date("Y-m-d").' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $URL - $Reason\n\n"; + $AdminComment = date('Y-m-d').' - Warned until '.$WarnTime.' by '.$LoggedUser['Username']."\nReason: $URL - $Reason\n\n"; } else { - $Subject = "You have received a verbal warning"; + $Subject = 'You have received a verbal warning'; $PrivateMessage = "You have received a verbal warning for [url=$URL]this post.[/url]\n\n" . $PrivateMessage; - $AdminComment = date("Y-m-d") . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n"; + $AdminComment = date('Y-m-d') . ' - Verbally warned by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n"; } -$DB->query("INSERT INTO users_warnings_forums (UserID, Comment) VALUES('$UserID', '" . db_string($AdminComment) . "') +$DB->query(" + INSERT INTO users_warnings_forums (UserID, Comment) + VALUES('$UserID', '" . db_string($AdminComment) . "') ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)"); Tools::update_user_notes($UserID,$AdminComment); Misc::send_pm($UserID, $LoggedUser['ID'], $Subject, $PrivateMessage); // Mainly -$DB->query("SELECT - ac.Body, - ac.AuthorID, - ac.ArtistID, - ac.AddedTime +$DB->query(" + SELECT + ac.Body, + ac.AuthorID, + ac.ArtistID, + ac.AddedTime FROM artist_comments AS ac WHERE ac.ID='$PostID'"); list($OldBody, $AuthorID, $ArtistID, $AddedTime) = $DB->next_record(); -$DB->query("SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page FROM artist_comments WHERE ArtistID = $ArtistID AND ID <= $PostID"); +$DB->query(" + SELECT ceil(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page + FROM artist_comments + WHERE ArtistID = $ArtistID + AND ID <= $PostID"); list($Page) = $DB->next_record(); // Perform the update -$DB->query("UPDATE artist_comments SET - Body = '" . db_string($Body) . "', - EditedUserID = '" . db_string($LoggedUser['ID']) . "', - EditedTime = '" . sqltime() . "' +$DB->query(" + UPDATE artist_comments + SET + Body = '" . db_string($Body) . "', + EditedUserID = '" . db_string($LoggedUser['ID']) . "', + EditedTime = '" . sqltime() . "' WHERE ID='$PostID'"); // Update the cache @@ -62,8 +71,9 @@ $Cache->update_row($_POST['key'], array('ID' => $_POST['postid'], 'AuthorID' => $AuthorID, 'AddedTime' => $AddedTime, 'Body' => $Body, 'EditedUserID' => db_string($LoggedUser['ID']), 'EditedTime' => sqltime(), 'Username' => $LoggedUser['Username'])); $Cache->commit_transaction(0); -$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) - VALUES ('artist', " . db_string($_POST['postid']) . ", " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')"); +$DB->query(" + INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) + VALUES ('artist', " . db_string($_POST['postid']) . ', ' . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')"); header("Location: artist.php?id=$ArtistID&postid=$PostID#post$PostID"); ?> diff --git a/sections/artist/takeedit.php b/sections/artist/takeedit.php index ad7cd301..90555bfa 100644 --- a/sections/artist/takeedit.php +++ b/sections/artist/takeedit.php @@ -5,52 +5,60 @@ authorize(); -if(!$_REQUEST['artistid'] || !is_number($_REQUEST['artistid'])) { +if (!$_REQUEST['artistid'] || !is_number($_REQUEST['artistid'])) { error(404); } -if(!check_perms('site_edit_wiki')) { error(403); } +if (!check_perms('site_edit_wiki')) { + error(403); +} // Variables for database input $UserID = $LoggedUser['ID']; $ArtistID = $_REQUEST['artistid']; -if ( check_perms('artist_edit_vanityhouse') ) { +if (check_perms('artist_edit_vanityhouse')) { $VanityHouse = ( isset($_POST['vanity_house']) ? 1 : 0 ); } -if($_GET['action'] == 'revert') { // if we're reverting to a previous revision +if ($_GET['action'] == 'revert') { // if we're reverting to a previous revision authorize(); $RevisionID=$_GET['revisionid']; - if(!is_number($RevisionID)) { error(0); } + if (!is_number($RevisionID)) { + error(0); + } } else { // with edit, the variables are passed with POST $Body = db_string($_POST['body']); $Summary = db_string($_POST['summary']); $Image = db_string($_POST['image']); ImageTools::blacklisted($Image); // Trickery - if(!preg_match("/^".IMAGE_REGEX."$/i", $Image)) { + if (!preg_match("/^".IMAGE_REGEX."$/i", $Image)) { $Image = ''; } } // Insert revision -if(!$RevisionID) { // edit - $DB->query("INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) - VALUES ('$ArtistID', '$Body', '$Image', '$UserID', '$Summary', '".sqltime()."')"); +if (!$RevisionID) { // edit + $DB->query(" + INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) + VALUES ('$ArtistID', '$Body', '$Image', '$UserID', '$Summary', '".sqltime()."')"); } else { // revert - $DB->query("INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) + $DB->query(" + INSERT INTO wiki_artists (PageID, Body, Image, UserID, Summary, Time) SELECT '$ArtistID', Body, Image, '$UserID', 'Reverted to revision $RevisionID', '".sqltime()."' - FROM wiki_artists WHERE RevisionID='$RevisionID'"); + FROM wiki_artists + WHERE RevisionID='$RevisionID'"); } -$RevisionID=$DB->inserted_id(); +$RevisionID = $DB->inserted_id(); // Update artists table (technically, we don't need the RevisionID column, but we can use it for a join which is nice and fast) -$DB->query("UPDATE artists_group +$DB->query(" + UPDATE artists_group SET - ". ( isset($VanityHouse) ? "VanityHouse='$VanityHouse'," : '' ) ." - RevisionID='$RevisionID' + ". (isset($VanityHouse) ? "VanityHouse='$VanityHouse'," : '') ." + RevisionID='$RevisionID' WHERE ArtistID='$ArtistID'"); // There we go, all done! diff --git a/sections/artist/vote_similar.php b/sections/artist/vote_similar.php index 9fb2b54d..c64d0a25 100644 --- a/sections/artist/vote_similar.php +++ b/sections/artist/vote_similar.php @@ -11,17 +11,27 @@ error(404); } -$DB->query("SELECT SimilarID FROM artists_similar_votes WHERE SimilarID='$SimilarID' AND UserID='$UserID' AND Way='$Way'"); +$DB->query(" + SELECT SimilarID + FROM artists_similar_votes + WHERE SimilarID='$SimilarID' + AND UserID='$UserID' + AND Way='$Way'"); if ($DB->record_count() == 0) { if ($Way == 'down') { $Score = 'Score-100'; - } elseif($Way == 'up') { + } elseif ($Way == 'up') { $Score = 'Score+100'; } else { // Nothing is impossible! $Score = 'Score'; } - $DB->query("UPDATE artists_similar_scores SET Score=$Score WHERE SimilarID='$SimilarID'"); - $DB->query("INSERT iNTO artists_similar_votes (SimilarID, UserID, Way) VALUES ('$SimilarID', '$UserID', '$Way')"); + $DB->query(" + UPDATE artists_similar_scores + SET Score=$Score + WHERE SimilarID='$SimilarID'"); + $DB->query(" + INSERT INTO artists_similar_votes (SimilarID, UserID, Way) + VALUES ('$SimilarID', '$UserID', '$Way')"); $Cache->delete_value('artist_'.$ArtistID); // Delete artist cache } header('Location: '.$_SERVER['HTTP_REFERER']); diff --git a/sections/artist/warn.php b/sections/artist/warn.php index 53afa049..14929035 100644 --- a/sections/artist/warn.php +++ b/sections/artist/warn.php @@ -9,9 +9,10 @@ $UserID = (int) $_POST['userid']; $Key = (int) $_POST['key']; $UserInfo = Users::user_info($UserID); -$DB -> query("SELECT - ac.Body, - ac.AddedTime +$DB -> query(" + SELECT + ac.Body, + ac.AddedTime FROM artist_comments AS ac WHERE ac.ID='" . db_string($PostID) . "'"); list($PostBody) = $DB -> next_record(); @@ -45,7 +46,7 @@ - + diff --git a/sections/better/files.php b/sections/better/files.php index 7487e0e6..b673d489 100644 --- a/sections/better/files.php +++ b/sections/better/files.php @@ -1,6 +1,6 @@ query("DELETE FROM torrents_bad_files WHERE TorrentID = ".$_GET['remove']); $DB->query("SELECT GroupID FROM torrents WHERE ID = ".$_GET['remove']); list($GroupID) = $DB->next_record(); @@ -8,8 +8,8 @@ } -if(!empty($_GET['filter']) && $_GET['filter'] == "all") { - $Join = ""; +if (!empty($_GET['filter']) && $_GET['filter'] == 'all') { + $Join = ''; $All = true; } else { $Join = "JOIN xbt_snatched as x ON x.fid=tfi.TorrentID AND x.uid = ".$LoggedUser['ID']; @@ -17,16 +17,21 @@ } View::show_header('Torrents with bad file names'); -$DB->query("SELECT tfi.TorrentID, t.GroupID FROM torrents_bad_files AS tfi JOIN torrents AS t ON t.ID = tfi.TorrentID ".$Join." ORDER BY tfi.TimeAdded ASC"); +$DB->query(" + SELECT tfi.TorrentID, t.GroupID + FROM torrents_bad_files AS tfi + JOIN torrents AS t ON t.ID = tfi.TorrentID + $Join + ORDER BY tfi.TimeAdded ASC"); $TorrentsInfo = $DB->to_array('TorrentID', MYSQLI_ASSOC); -foreach($TorrentsInfo as $Torrent) { +foreach ($TorrentsInfo as $Torrent) { $GroupIDs[] = $Torrent['GroupID']; } $Results = Torrents::get_groups($GroupIDs); $Results = $Results['matches']; ?>
    - +

    All torrents trumpable for bad file names

    Torrents trumpable for bad file names that you have snatched

    @@ -34,7 +39,7 @@