From 8f5fb0f429201a83016accefc974cfa539748e24 Mon Sep 17 00:00:00 2001 From: Git Date: Sat, 13 Jul 2013 08:00:46 +0000 Subject: [PATCH] Empty commit --- classes/mysql.class.php | 4 + sections/ajax/bookmarks/artists.php | 9 +- sections/ajax/bookmarks/torrents.php | 5 +- sections/ajax/forum/thread.php | 27 +-- sections/ajax/send_recommendation.php | 40 ++-- sections/ajax/userhistory/post_history.php | 141 +++++++------- sections/artist/add_alias.php | 10 +- sections/artist/download.php | 127 +++++++------ sections/artist/notifyremove.php | 36 +++- sections/artist/rename.php | 195 +++++++++++++------- sections/bookmarks/artists.php | 27 +-- sections/bookmarks/edit_torrents.php | 5 +- sections/bookmarks/index.php | 27 ++- sections/bookmarks/remove.php | 15 +- sections/bookmarks/torrents.php | 68 ++++--- sections/collages/all_comments.php | 18 +- sections/collages/browse.php | 45 ++--- sections/collages/collage.php | 34 ++-- sections/collages/delete_comment.php | 25 ++- sections/collages/download.php | 120 ++++++------ sections/collages/manage_artists.php | 20 +- sections/collages/manage_artists_handle.php | 44 +++-- sections/collages/manage_handle.php | 44 +++-- sections/collages/new_handle.php | 54 ++++-- sections/collages/take_delete.php | 41 ++-- sections/log/sql.php | 6 +- sections/tools/data/donation_log.php | 6 +- sections/tools/data/invite_pool.php | 15 +- sections/tools/data/registration_log.php | 20 +- sections/tools/data/upscale_pool.php | 15 +- sections/tools/data/user_flow.php | 50 ++--- 31 files changed, 780 insertions(+), 513 deletions(-) diff --git a/classes/mysql.class.php b/classes/mysql.class.php index f62d3d7c..cc67628b 100644 --- a/classes/mysql.class.php +++ b/classes/mysql.class.php @@ -294,6 +294,10 @@ function close() { } } + /* + * returns an integer with the number of rows found + * returns a string if the number of rows found exceeds MAXINT + */ function record_count() { if ($this->QueryID) { return mysqli_num_rows($this->QueryID); diff --git a/sections/ajax/bookmarks/artists.php b/sections/ajax/bookmarks/artists.php index cb9fcbe1..e62e9b77 100644 --- a/sections/ajax/bookmarks/artists.php +++ b/sections/ajax/bookmarks/artists.php @@ -21,7 +21,10 @@ ); die(); } - $DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); + $DB->query(" + SELECT Username + FROM users_main + WHERE ID = '$UserID'"); list($Username) = $DB->next_record(); } else { $UserID = $LoggedUser['ID']; @@ -31,11 +34,11 @@ //$ArtistList = Bookmarks::all_bookmarks('artist', $UserID); -$DB->query(' +$DB->query(" SELECT ag.ArtistID, ag.Name FROM bookmarks_artists AS ba INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID - WHERE ba.UserID = '.$UserID); + WHERE ba.UserID = $UserID"); $ArtistList = $DB->to_array(); diff --git a/sections/ajax/bookmarks/torrents.php b/sections/ajax/bookmarks/torrents.php index d1f10fb2..1f0fa3ff 100644 --- a/sections/ajax/bookmarks/torrents.php +++ b/sections/ajax/bookmarks/torrents.php @@ -16,7 +16,10 @@ function compare($X, $Y) { if (!is_number($UserID)) { error(404); } - $DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); + $DB->query(" + SELECT Username + FROM users_main + WHERE ID = '$UserID'"); list($Username) = $DB->next_record(); } else { $UserID = $LoggedUser['ID']; diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 0f28a260..b7af44bc 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -19,7 +19,10 @@ if (isset($_GET['topicid']) && is_number($_GET['topicid'])) { $ThreadID = $_GET['topicid']; } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) { - $DB->query("SELECT TopicID FROM forums_posts WHERE ID = $_GET[postid]"); + $DB->query(" + SELECT TopicID + FROM forums_posts + WHERE ID = $_GET[postid]"); list($ThreadID) = $DB->next_record(); if ($ThreadID) { //Redirect postid to threadid when necessary. @@ -84,7 +87,7 @@ list($CatalogueID,$CatalogueLimit) = Format::catalogue_limit($Page, $PerPage, THREAD_CATALOGUE); // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page -if (!$Catalogue = $Cache->get_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID)) { +if (!$Catalogue = $Cache->get_value("thread_$ThreadID"."_catalogue_$CatalogueID")) { $DB->query(" SELECT p.ID, @@ -97,14 +100,14 @@ WHERE p.TopicID = '$ThreadID' AND p.ID != '".$ThreadInfo['StickyPostID']."' LIMIT $CatalogueLimit"); - $Catalogue = $DB->to_array(false,MYSQLI_ASSOC); + $Catalogue = $DB->to_array(false, MYSQLI_ASSOC); if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { - $Cache->cache_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID, $Catalogue, 0); + $Cache->cache_value("thread_$ThreadID"."_catalogue_$CatalogueID", $Catalogue, 0); } } $Thread = Format::catalogue_select($Catalogue, $Page, $PerPage, THREAD_CATALOGUE); -if ($_GET['updatelastread'] != '0') { +if ($_GET['updatelastread'] !== '0') { $LastPost = end($Thread); $LastPost = $LastPost['ID']; reset($Thread); @@ -116,8 +119,8 @@ $DB->query(" SELECT PostID FROM forums_last_read_topics - WHERE UserID='$LoggedUser[ID]' - AND TopicID='$ThreadID'"); + WHERE UserID = '$LoggedUser[ID]' + AND TopicID = '$ThreadID'"); list($LastRead) = $DB->next_record(); if ($LastRead < $LastPost) { $DB->query(" @@ -125,7 +128,7 @@ (UserID, TopicID, PostID) VALUES ('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."') - ON DUPLICATE KEY UPDATE PostID='$LastPost'"); + ON DUPLICATE KEY UPDATE PostID = '$LastPost'"); } } } @@ -260,11 +263,11 @@ 'authorId' => (int) $AuthorID, 'authorName' => $Username, 'paranoia' => $Paranoia, - 'artist' => ($Artist == 1), - 'donor' => ($Donor == 1), - 'warned' => ($Warned != '0000-00-00 00:00:00'), + 'artist' => ($Artist === '1'), + 'donor' => ($Donor === '1'), + 'warned' => ($Warned !== '0000-00-00 00:00:00'), 'avatar' => $Avatar, - 'enabled' => (($Enabled == 2) ? false : true), + 'enabled' => (($Enabled === '2') ? false : true), 'userTitle' => $UserTitle ), diff --git a/sections/ajax/send_recommendation.php b/sections/ajax/send_recommendation.php index 649ca433..e7b63cdc 100644 --- a/sections/ajax/send_recommendation.php +++ b/sections/ajax/send_recommendation.php @@ -5,14 +5,12 @@ $Note = $_POST['note']; if (empty($FriendID) || empty($Type) || empty($ID)) { - echo json_encode(array("status" => "error", "response" => "Error.")); + echo json_encode(array('status' => 'error', 'response' => 'Error.')); die(); } // Make sure the recipient is on your friends list and not some random dude. $DB->query(" - SELECT - f.FriendID, - u.Username + SELECT f.FriendID, u.Username FROM friends AS f RIGHT JOIN users_enable_recommendations AS r ON r.ID = f.FriendID AND r.Enable = 1 @@ -22,7 +20,7 @@ AND f.FriendID = '$FriendID'"); if (!$DB->has_results()) { - echo json_encode(array("status" => "error", "response" => "Not on friend list.")); + echo json_encode(array('status' => 'error', 'response' => 'Not on friend list.')); die(); } @@ -33,27 +31,35 @@ $Article = 'a'; switch ($Type) { case 'torrent': - $Link = "torrents.php?id=".$ID; - $DB->query("SELECT Name FROM torrents_group WHERE ID = '$ID'"); + $Link = "torrents.php?id=$ID"; + $DB->query(" + SELECT Name + FROM torrents_group + WHERE ID = '$ID'"); break; case 'artist': - $Article = "an"; - $Link = "artist.php?id=".$ID; - $DB->query("SELECT Name FROM artists_group WHERE ArtistID = '$ID'"); + $Article = 'an'; + $Link = "artist.php?id=$ID"; + $DB->query(" + SELECT Name + FROM artists_group + WHERE ArtistID = '$ID'"); break; case 'collage': - $Link = "collages.php?id=".$ID; - $DB->query("SELECT Name FROM collages WHERE ID = '$ID'"); + $Link = "collages.php?id=$ID"; + $DB->query(" + SELECT Name + FROM collages + WHERE ID = '$ID'"); break; } list($Name) = $DB->next_record(); -$Subject = $LoggedUser['Username'] . " recommended you $Article " . $Type . "!"; -$Body = $LoggedUser['Username'] . " recommended you the ".$Type." [url=https://".SSL_SITE_URL."/$Link]$Name".'[/url].'; +$Subject = $LoggedUser['Username'] . " recommended you $Article $Type!"; +$Body = $LoggedUser['Username'] . " recommended you the $Type [url=https://".SSL_SITE_URL."/$Link]$Name".'[/url].'; if (!empty($Note)) { - $Body = $Body . "\n\n". $Note; + $Body = "$Body\n\n$Note"; } Misc::send_pm($FriendID, $LoggedUser['ID'], $Subject, $Body); -echo json_encode(array("status" => "success", "response" => "Sent!")); +echo json_encode(array('status' => 'success', 'response' => 'Sent!')); die(); - diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php index 5f18d62a..e180a68a 100644 --- a/sections/ajax/userhistory/post_history.php +++ b/sections/ajax/userhistory/post_history.php @@ -5,7 +5,7 @@ function error_out($reason = '') { $error = array('status' => 'failure'); - if ($reason != '') + if ($reason !== '') $error['reason'] = $reason; print $error; die(); @@ -41,11 +41,12 @@ function error_out($reason = '') { $RestrictedForums = implode("','", array_keys($LoggedUser['CustomForums'], 0)); $PermittedForums = implode("','", array_keys($LoggedUser['CustomForums'], 1)); } -$ViewingOwn = ($UserID == $LoggedUser['ID']); +$ViewingOwn = ($UserID === $LoggedUser['ID']); $ShowUnread = ($ViewingOwn && (!isset($_GET['showunread']) || !!$_GET['showunread'])); $ShowGrouped = ($ViewingOwn && (!isset($_GET['group']) || !!$_GET['group'])); if ($ShowGrouped) { - $sql = 'SELECT + $sql = ' + SELECT SQL_CALC_FOUND_ROWS MAX(p.ID) AS ID FROM forums_posts AS p @@ -73,103 +74,115 @@ function error_out($reason = '') { AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostIDquery($sql); - $DB->query("SELECT FOUND_ROWS()"); + $DB->query('SELECT FOUND_ROWS()'); list($Results) = $DB->next_record(); if ($Results > $PerPage * ($Page - 1)) { $DB->set_query_id($PostIDs); $PostIDs = $DB->collect('ID'); - $sql = 'SELECT - p.ID, - p.AddedTime, - p.Body, - p.EditedUserID, - p.EditedTime, - ed.Username, - p.TopicID, - t.Title, - t.LastPostID, - l.PostID AS LastRead, - t.IsLocked, - t.IsSticky + $sql = " + SELECT + p.ID, + p.AddedTime, + p.Body, + p.EditedUserID, + p.EditedTime, + ed.Username, + p.TopicID, + t.Title, + t.LastPostID, + l.PostID AS LastRead, + t.IsLocked, + t.IsSticky FROM forums_posts as p LEFT JOIN users_main AS um ON um.ID = p.AuthorID LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID JOIN forums_topics AS t ON t.ID = p.TopicID JOIN forums AS f ON f.ID = t.ForumID - LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID - WHERE p.ID IN ('.implode(',',$PostIDs).') + LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID + WHERE p.ID IN (".implode(',', $PostIDs).') ORDER BY p.ID DESC'; $Posts = $DB->query($sql); } } else { - $sql = 'SELECT - SQL_CALC_FOUND_ROWS'; + $sql = ' + SELECT + SQL_CALC_FOUND_ROWS'; if ($ShowGrouped) { - $sql.=' * FROM (SELECT'; - } - $sql .= ' - p.ID, - p.AddedTime, - p.Body, - p.EditedUserID, - p.EditedTime, - ed.Username, - p.TopicID, - t.Title, - t.LastPostID,'; - if ($UserID == $LoggedUser['ID']) { $sql .= ' - l.PostID AS LastRead,'; + * + FROM ( + SELECT'; } $sql .= ' - t.IsLocked, - t.IsSticky - FROM forums_posts as p - LEFT JOIN users_main AS um ON um.ID = p.AuthorID - LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID - LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID - JOIN forums_topics AS t ON t.ID = p.TopicID - JOIN forums AS f ON f.ID = t.ForumID - LEFT JOIN forums_last_read_topics AS l ON l.UserID = '.$UserID.' AND l.TopicID = t.ID - WHERE p.AuthorID = '.$UserID.' - AND ((f.MinClassRead <= '.$LoggedUser['Class']; + p.ID, + p.AddedTime, + p.Body, + p.EditedUserID, + p.EditedTime, + ed.Username, + p.TopicID, + t.Title, + t.LastPostID,'; + if ($UserID === $LoggedUser['ID']) { + $sql .= ' + l.PostID AS LastRead,'; + } + $sql .= " + t.IsLocked, + t.IsSticky + FROM forums_posts as p + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID + LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID + JOIN forums_topics AS t ON t.ID = p.TopicID + JOIN forums AS f ON f.ID = t.ForumID + LEFT JOIN forums_last_read_topics AS l ON l.UserID = $UserID AND l.TopicID = t.ID + WHERE p.AuthorID = $UserID + AND ((f.MinClassRead <= ".$LoggedUser['Class']; if (!empty($RestrictedForums)) { - $sql.=' - AND f.ID NOT IN (\''.$RestrictedForums.'\')'; + $sql .= " + AND f.ID NOT IN ('$RestrictedForums')"; } - $sql .= ')'; + $sql .= ' + )'; if (!empty($PermittedForums)) { - $sql.=' - OR f.ID IN (\''.$PermittedForums.'\')'; + $sql .= " + OR f.ID IN ('$PermittedForums')"; } - $sql .= ')'; + $sql .= ' + )'; if ($ShowUnread) { - $sql.=' - AND ((t.IsLocked=\'0\' OR t.IsSticky=\'1\') AND (l.PostIDquery($sql); - $DB->query("SELECT FOUND_ROWS()"); + $DB->query('SELECT FOUND_ROWS()'); list($Results) = $DB->next_record(); $DB->set_query_id($Posts); @@ -183,8 +196,8 @@ function error_out($reason = '') { 'threadTitle' => $ThreadTitle, 'lastPostId' => (int) $LastPostID, 'lastRead' => (int) $LastRead, - 'locked' => $Locked == 1, - 'sticky' => $Sticky == 1, + 'locked' => $Locked === '1', + 'sticky' => $Sticky === '1', 'addedTime' => $AddedTime, 'body' => $Text->full_format($Body), 'bbbody' => $Body, @@ -199,7 +212,7 @@ function error_out($reason = '') { 'status' => 'success', 'response' => array( 'currentPage' => (int) $Page, - 'pages' => ceil($Results/$PerPage), + 'pages' => ceil($Results / $PerPage), 'threads' => $JsonResults ) ) diff --git a/sections/artist/add_alias.php b/sections/artist/add_alias.php index 06f9ffb8..e94a6fb5 100644 --- a/sections/artist/add_alias.php +++ b/sections/artist/add_alias.php @@ -43,7 +43,7 @@ if ($CloneRedirect != 0) { $DB->query(" UPDATE artists_alias - SET ArtistID = '$ArtistID', Redirect=0 + 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 { @@ -72,8 +72,10 @@ } } $DB->query(" - INSERT INTO artists_alias(ArtistID, Name, Redirect, UserID) - VALUES ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')'); + INSERT INTO artists_alias + (ArtistID, Name, Redirect, UserID) + VALUES + ($ArtistID, '$DBAliasName', $Redirect, ".$LoggedUser['ID'].')'); $AliasID = $DB->inserted_id(); $DB->query(" @@ -82,7 +84,7 @@ 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/download.php b/sections/artist/download.php index f3599adb..9bffe65e 100644 --- a/sections/artist/download.php +++ b/sections/artist/download.php @@ -27,32 +27,34 @@ SQL template: SELECT CASE - WHEN t.Format='MP3' AND t.Encoding='V0 (VBR)' THEN 1 - WHEN t.Format='MP3' AND t.Encoding='V2 (VBR)' THEN 2 - ELSE 100 + WHEN t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)' + THEN 1 + WHEN t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)' + THEN 2 + ELSE 100 END AS Rank, t.GroupID, t.Media, t.Format, t.Encoding, - IF(t.Year=0,tg.Year,t.Year), + IF(t.Year = 0, tg.Year, t.Year), tg.Name, a.Name, t.Size FROM torrents AS t -INNER JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' -INNER JOIN artists_group AS a ON a.ArtistID=tg.ArtistID AND a.ArtistID='59721' -LEFT JOIN torrents_files AS f ON t.ID=f.TorrentID + INNER JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1' + INNER JOIN artists_group AS a ON a.ArtistID = tg.ArtistID AND a.ArtistID = '59721' + LEFT JOIN torrents_files AS f ON t.ID = f.TorrentID ORDER BY t.GroupID ASC, Rank DESC, t.Seeders ASC */ if ( - !isset($_REQUEST['artistid']) || - !isset($_REQUEST['preference']) || - !is_number($_REQUEST['preference']) || - !is_number($_REQUEST['artistid']) || - $_REQUEST['preference'] > 2 || - count($_REQUEST['list']) == 0 + !isset($_REQUEST['artistid']) + || !isset($_REQUEST['preference']) + || !is_number($_REQUEST['preference']) + || !is_number($_REQUEST['artistid']) + || $_REQUEST['preference'] > 2 + || count($_REQUEST['list']) == 0 ) { error(0); } @@ -66,73 +68,84 @@ $ArtistID = $_REQUEST['artistid']; $Preference = $Preferences[$_REQUEST['preference']]; -$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); -$DB->query("SELECT GroupID, Importance FROM torrents_artists WHERE ArtistID='$ArtistID'"); +$DB->query(" + SELECT GroupID, Importance + FROM torrents_artists + WHERE ArtistID = '$ArtistID'"); if (!$DB->has_results()) { error(404); } $Releases = $DB->to_array('GroupID', MYSQLI_ASSOC, false); $GroupIDs = array_keys($Releases); -$SQL = "SELECT CASE "; +$SQL = 'SELECT CASE '; foreach ($_REQUEST['list'] as $Priority => $Selection) { if (!is_number($Priority)) { continue; } - $SQL .= "WHEN "; + $SQL .= 'WHEN '; switch ($Selection) { - case '00': $SQL .= "t.Format='MP3' AND t.Encoding='V0 (VBR)'"; break; - case '01': $SQL .= "t.Format='MP3' AND t.Encoding='APX (VBR)'"; break; - case '02': $SQL .= "t.Format='MP3' AND t.Encoding='256 (VBR)'"; break; - case '03': $SQL .= "t.Format='MP3' AND t.Encoding='V1 (VBR)'"; break; - case '10': $SQL .= "t.Format='MP3' AND t.Encoding='224 (VBR)'"; break; - case '11': $SQL .= "t.Format='MP3' AND t.Encoding='V2 (VBR)'"; break; - case '12': $SQL .= "t.Format='MP3' AND t.Encoding='APS (VBR)'"; break; - case '13': $SQL .= "t.Format='MP3' AND t.Encoding='192 (VBR)'"; break; - case '20': $SQL .= "t.Format='MP3' AND t.Encoding='320'"; break; - case '21': $SQL .= "t.Format='MP3' AND t.Encoding='256'"; break; - case '22': $SQL .= "t.Format='MP3' AND t.Encoding='224'"; break; - case '23': $SQL .= "t.Format='MP3' AND t.Encoding='192'"; break; - case '30': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='Vinyl'"; break; - case '31': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='DVD'"; break; - case '32': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='SACD'"; break; - case '33': $SQL .= "t.Format='FLAC' AND t.Encoding='24bit Lossless' AND t.Media='WEB'"; break; - case '34': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100' AND HasCue='1'"; break; - case '35': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1' AND LogScore='100'"; break; - case '36': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless' AND HasLog='1'"; break; - case '37': $SQL .= "t.Format='FLAC' AND t.Encoding='Lossless'"; break; - case '40': $SQL .= "t.Format='DTS'"; break; - case '42': $SQL .= "t.Format='AAC' AND t.Encoding='320'"; break; - case '43': $SQL .= "t.Format='AAC' AND t.Encoding='256'"; break; - case '44': $SQL .= "t.Format='AAC' AND t.Encoding='q5.5'"; break; - case '45': $SQL .= "t.Format='AAC' AND t.Encoding='q5'"; break; - case '46': $SQL .= "t.Format='AAC' AND t.Encoding='192'"; break; + case '00': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V0 (VBR)'"; break; + case '01': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APX (VBR)'"; break; + case '02': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256 (VBR)'"; break; + case '03': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V1 (VBR)'"; break; + case '10': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224 (VBR)'"; break; + case '11': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'V2 (VBR)'"; break; + case '12': $SQL .= "t.Format = 'MP3' AND t.Encoding = 'APS (VBR)'"; break; + case '13': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192 (VBR)'"; break; + case '20': $SQL .= "t.Format = 'MP3' AND t.Encoding = '320'"; break; + case '21': $SQL .= "t.Format = 'MP3' AND t.Encoding = '256'"; break; + case '22': $SQL .= "t.Format = 'MP3' AND t.Encoding = '224'"; break; + case '23': $SQL .= "t.Format = 'MP3' AND t.Encoding = '192'"; break; + case '30': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'Vinyl'"; break; + case '31': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'DVD'"; break; + case '32': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'SACD'"; break; + case '33': $SQL .= "t.Format = 'FLAC' AND t.Encoding = '24bit Lossless' AND t.Media = 'WEB'"; break; + case '34': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100' AND HasCue = '1'"; break; + case '35': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1' AND LogScore = '100'"; break; + case '36': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless' AND HasLog = '1'"; break; + case '37': $SQL .= "t.Format = 'FLAC' AND t.Encoding = 'Lossless'"; break; + case '40': $SQL .= "t.Format = 'DTS'"; break; + case '42': $SQL .= "t.Format = 'AAC' AND t.Encoding = '320'"; break; + case '43': $SQL .= "t.Format = 'AAC' AND t.Encoding = '256'"; break; + case '44': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5.5'"; break; + case '45': $SQL .= "t.Format = 'AAC' AND t.Encoding = 'q5'"; break; + case '46': $SQL .= "t.Format = 'AAC' AND t.Encoding = '192'"; break; default: error(0); } $SQL .= " THEN $Priority "; } -$SQL .= "ELSE 100 END AS Rank, -t.GroupID, -t.ID AS TorrentID, -t.Media, -t.Format, -t.Encoding, -tg.ReleaseType, -IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year, -tg.Name, -t.Size +$SQL .= " + ELSE 100 + END AS Rank, + t.GroupID, + t.ID AS TorrentID, + t.Media, + t.Format, + t.Encoding, + tg.ReleaseType, + IF(t.RemasterYear = 0, tg.Year, t.RemasterYear) AS Year, + tg.Name, + t.Size FROM torrents AS t -JOIN torrents_group AS tg ON tg.ID=t.GroupID AND tg.CategoryID='1' AND tg.ID IN (".implode(',',$GroupIDs).") + JOIN torrents_group AS tg ON tg.ID = t.GroupID AND tg.CategoryID = '1' AND tg.ID IN (".implode(',', $GroupIDs).") ORDER BY t.GroupID ASC, Rank DESC, t.$Preference"; $DownloadsQ = $DB->query($SQL); $Collector = new TorrentsDL($DownloadsQ, $ArtistName); while (list($Downloads, $GroupIDs) = $Collector->get_downloads('GroupID')) { $Artists = Artists::get_artists($GroupIDs); - $TorrentFilesQ = $DB->query("SELECT TorrentID, File FROM torrents_files WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).")", false); + $TorrentFilesQ = $DB->query(" + SELECT TorrentID, File + FROM torrents_files + WHERE TorrentID IN (".implode(',', array_keys($GroupIDs)).')', false); if (is_int($TorrentFilesQ)) { // Query failed. Let's not create a broken zip archive foreach ($GroupIDs as $GroupID) { @@ -153,9 +166,9 @@ if ($Releases[$GroupID]['Importance'] == 1) { $ReleaseTypeName = $ReleaseTypes[$Download['ReleaseType']]; } else if ($Releases[$GroupID]['Importance'] == 2) { - $ReleaseTypeName = "Guest Appearance"; + $ReleaseTypeName = 'Guest Appearance'; } else if ($Releases[$GroupID]['Importance'] == 3) { - $ReleaseTypeName = "Remixed By"; + $ReleaseTypeName = 'Remixed By'; } $Collector->add_file($TorrentFile, $Download, $ReleaseTypeName); unset($Download); diff --git a/sections/artist/notifyremove.php b/sections/artist/notifyremove.php index c568b8f6..1f7ebfbd 100644 --- a/sections/artist/notifyremove.php +++ b/sections/artist/notifyremove.php @@ -9,21 +9,39 @@ } if (($Notify = $Cache->get_value('notify_artists_'.$LoggedUser['ID'])) === false) { - $DB->query("SELECT ID, Artists FROM users_notify_filters WHERE Label='Artist notifications' AND UserID='$LoggedUser[ID]' ORDER BY ID LIMIT 1"); + $DB->query(" + SELECT ID, Artists + FROM users_notify_filters + WHERE Label = 'Artist notifications' + AND UserID = '$LoggedUser[ID]' + ORDER BY ID + LIMIT 1"); } else { - $DB->query("SELECT ID, Artists FROM users_notify_filters WHERE ID='$Notify[ID]'"); + $DB->query(" + SELECT ID, Artists + FROM users_notify_filters + WHERE ID = '$Notify[ID]'"); } -list($ID,$Artists) = $DB->next_record(MYSQLI_NUM, FALSE); -$DB->query("SELECT Name FROM artists_alias WHERE ArtistID = '$ArtistID' AND Redirect=0"); -while (list($Alias) = $DB->next_record(MYSQLI_NUM, FALSE)) { - while (stripos($Artists, '|'.$Alias.'|') !== false) { - $Artists = str_ireplace('|'.$Alias.'|', '|', $Artists); +list($ID, $Artists) = $DB->next_record(MYSQLI_NUM, false); +$DB->query(" + SELECT Name + FROM artists_alias + WHERE ArtistID = '$ArtistID' + AND Redirect = 0"); +while (list($Alias) = $DB->next_record(MYSQLI_NUM, false)) { + while (stripos($Artists, "|$Alias|") !== false) { + $Artists = str_ireplace("|$Alias|", '|', $Artists); } } if ($Artists == '|') { - $DB->query("DELETE FROM users_notify_filters WHERE ID=$ID"); + $DB->query(" + DELETE FROM users_notify_filters + WHERE ID = $ID"); } else { - $DB->query("UPDATE users_notify_filters SET Artists='".db_string($Artists)."' WHERE ID='$ID'"); + $DB->query(" + UPDATE users_notify_filters + SET Artists = '".db_string($Artists)."' + WHERE ID = '$ID'"); } $Cache->delete_value('notify_filters_'.$LoggedUser['ID']); $Cache->delete_value('notify_artists_'.$LoggedUser['ID']); diff --git a/sections/artist/rename.php b/sections/artist/rename.php index 0a252c42..7f66c08d 100644 --- a/sections/artist/rename.php +++ b/sections/artist/rename.php @@ -1,23 +1,23 @@ -query("SELECT Name FROM artists_group WHERE ArtistID='$ArtistID'"); +$DB->query(" + SELECT Name + FROM artists_group + WHERE ArtistID = '$ArtistID'"); if (!$DB->has_results()) { error(404); } @@ -45,8 +48,8 @@ $DB->query(" SELECT AliasID FROM artists_alias - WHERE Name='".db_string($OldName)."' - AND ArtistID='$ArtistID'"); + 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'); @@ -58,34 +61,58 @@ 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]')"); + 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'"); - $DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'"); + $DB->query(" + UPDATE artists_alias + SET Redirect = '$TargetAliasID' + WHERE AliasID = '$OldAliasID'"); + $DB->query(" + UPDATE artists_group + SET Name = '".db_string($NewName)."' + WHERE ArtistID = '$ArtistID'"); - $DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); + $DB->query(" + SELECT GroupID + FROM torrents_artists + WHERE AliasID = '$OldAliasID'"); $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'"); + $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) { - $Cache->delete_value('groups_artists_'.$GroupID); // Delete group artist cache + $Cache->delete_value("groups_artists_$GroupID"); // Delete group artist cache Torrents::update_hash($GroupID); } } - $DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'"); + $DB->query(" + SELECT RequestID + FROM requests_artists + WHERE AliasID = '$OldAliasID'"); $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'"); + $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) { - $Cache->delete_value('request_artists_'.$RequestID); // Delete request artist cache + $Cache->delete_value("request_artists_$RequestID"); // Delete request artist cache Requests::update_sphinx_requests($RequestID); } } @@ -94,69 +121,100 @@ } else { // Merge stuff $DB->query(" UPDATE artists_alias - SET Redirect='$TargetAliasID', ArtistID='$TargetArtistID' - WHERE AliasID='$OldAliasID'"); - $DB->query("UPDATE artists_alias SET Redirect='0' WHERE AliasID='$TargetAliasID'"); + SET Redirect = '$TargetAliasID', ArtistID = '$TargetArtistID' + WHERE AliasID = '$OldAliasID'"); + $DB->query(" + UPDATE artists_alias + SET Redirect = '0' + WHERE AliasID = '$TargetAliasID'"); if ($ArtistID != $TargetArtistID) { - $DB->query("UPDATE artists_alias SET ArtistID='$TargetArtistID' WHERE ArtistID='$ArtistID'"); - $DB->query("DELETE FROM artists_group WHERE ArtistID='$ArtistID'"); + $DB->query(" + UPDATE artists_alias + SET ArtistID = '$TargetArtistID' + WHERE ArtistID = '$ArtistID'"); + $DB->query(" + DELETE FROM artists_group + WHERE ArtistID = '$ArtistID'"); } else { - $DB->query("UPDATE artists_group SET Name='".db_string($NewName)."' WHERE ArtistID='$ArtistID'"); + $DB->query(" + UPDATE artists_group + SET Name = '".db_string($NewName)."' + WHERE ArtistID = '$ArtistID'"); } - $DB->query("SELECT GroupID FROM torrents_artists WHERE AliasID='$OldAliasID'"); + $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("DELETE FROM torrents_artists WHERE AliasID='$OldAliasID'"); + SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID' + WHERE AliasID = '$OldAliasID'"); + $DB->query(" + DELETE FROM torrents_artists + WHERE AliasID = '$OldAliasID'"); if (!empty($Groups)) { foreach ($Groups as $GroupID) { - $Cache->delete_value('groups_artists_'.$GroupID); + $Cache->delete_value("groups_artists_$GroupID"); Torrents::update_hash($GroupID); } } - $DB->query("SELECT RequestID FROM requests_artists WHERE AliasID='$OldAliasID'"); + $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("DELETE FROM requests_artists WHERE AliasID='$OldAliasID'"); + SET AliasID = '$TargetAliasID', ArtistID = '$TargetArtistID' + WHERE AliasID = '$OldAliasID'"); + $DB->query(" + DELETE FROM requests_artists + WHERE AliasID = '$OldAliasID'"); if (!empty($Requests)) { foreach ($Requests as $RequestID) { - $Cache->delete_value('request_artists_'.$RequestID); + $Cache->delete_value("request_artists_$RequestID"); Requests::update_sphinx_requests($RequestID); } } if ($ArtistID != $TargetArtistID) { - $DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); + $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("DELETE FROM torrents_artists WHERE ArtistID='$ArtistID'"); + SET ArtistID = '$TargetArtistID' + WHERE ArtistID = '$ArtistID'"); + $DB->query(" + DELETE FROM torrents_artists + WHERE ArtistID = '$ArtistID'"); if (!empty($Groups)) { foreach ($Groups as $GroupID) { - $Cache->delete_value('groups_artists_'.$GroupID); + $Cache->delete_value("groups_artists_$GroupID"); Torrents::update_hash($GroupID); } } - $DB->query("SELECT RequestID FROM requests_artists WHERE ArtistID='$ArtistID'"); + $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("DELETE FROM requests_artists WHERE ArtistID='$ArtistID'"); + SET ArtistID = '$TargetArtistID' + WHERE ArtistID = '$ArtistID'"); + $DB->query(" + DELETE FROM requests_artists + WHERE ArtistID = '$ArtistID'"); if (!empty($Requests)) { foreach ($Requests as $RequestID) { - $Cache->delete_value('request_artists_'.$RequestID); + $Cache->delete_value("request_artists_$RequestID"); Requests::update_sphinx_requests($RequestID); } } @@ -164,16 +222,19 @@ } // Clear torrent caches -$DB->query("SELECT GroupID FROM torrents_artists WHERE ArtistID='$ArtistID'"); +$DB->query(" + SELECT GroupID + FROM torrents_artists + WHERE ArtistID = '$ArtistID'"); while (list($GroupID) = $DB->next_record()) { - $Cache->delete_value('torrents_details_'.$GroupID); + $Cache->delete_value("torrents_details_$GroupID"); } -$Cache->delete_value('artist_'.$ArtistID); -$Cache->delete_value('artist_'.$TargetArtistID); -$Cache->delete_value('artists_requests_'.$TargetArtistID); -$Cache->delete_value('artists_requests_'.$ArtistID); +$Cache->delete_value("artist_$ArtistID"); +$Cache->delete_value("artist_$TargetArtistID"); +$Cache->delete_value("artists_requests_$TargetArtistID"); +$Cache->delete_value("artists_requests_$ArtistID"); -header('Location: artist.php?id='.$TargetArtistID); +header("Location: artist.php?id=$TargetArtistID"); ?> diff --git a/sections/bookmarks/artists.php b/sections/bookmarks/artists.php index 9678699a..cc65e072 100644 --- a/sections/bookmarks/artists.php +++ b/sections/bookmarks/artists.php @@ -5,32 +5,35 @@ error(403); } $UserID = $_GET['userid']; - $Sneaky = ($UserID != $LoggedUser['ID']); + $Sneaky = ($UserID !== $LoggedUser['ID']); if (!is_number($UserID)) { error(404); } - $DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); + $DB->query(" + SELECT Username + FROM users_main + WHERE ID = '$UserID'"); list($Username) = $DB->next_record(); } else { $UserID = $LoggedUser['ID']; } -$Sneaky = ($UserID != $LoggedUser['ID']); +$Sneaky = ($UserID !== $LoggedUser['ID']); //$ArtistList = Bookmarks::all_bookmarks('artist', $UserID); -$DB->query(' +$DB->query(" SELECT ag.ArtistID, ag.Name FROM bookmarks_artists AS ba INNER JOIN artists_group AS ag ON ba.ArtistID = ag.ArtistID - WHERE ba.UserID = '.$UserID.' - ORDER BY ag.Name'); + WHERE ba.UserID = $UserID + ORDER BY ag.Name"); $ArtistList = $DB->to_array(); $Title = ($Sneaky) ? "$Username's bookmarked artists" : 'Your bookmarked artists'; -View::show_header($Title,'browse'); +View::show_header($Title, 'browse'); ?>
@@ -59,7 +62,7 @@ @@ -72,13 +75,13 @@ $DB->query(" SELECT ID, Artists FROM users_notify_filters - WHERE UserID='$LoggedUser[ID]' - AND Label='Artist notifications' + WHERE UserID = '$LoggedUser[ID]' + AND Label = 'Artist notifications' LIMIT 1"); $Notify = $DB->next_record(MYSQLI_ASSOC); $Cache->cache_value('notify_artists_'.$LoggedUser['ID'], $Notify, 0); } - if (stripos($Notify['Artists'], '|'.$Name.'|') === false) { + if (stripos($Notify['Artists'], "|$Name|") === false) { ?> Notify of new uploads - Remove bookmark + Remove bookmark diff --git a/sections/bookmarks/edit_torrents.php b/sections/bookmarks/edit_torrents.php index 4516ce9d..8c1e39bb 100644 --- a/sections/bookmarks/edit_torrents.php +++ b/sections/bookmarks/edit_torrents.php @@ -8,7 +8,10 @@ if (!is_number($UserID)) { error(404); } - $DB->query("SELECT Username FROM users_main WHERE ID='$UserID'"); + $DB->query(" + SELECT Username + FROM users_main + WHERE ID = '$UserID'"); list($Username) = $DB->next_record(); } else { $UserID = $LoggedUser['ID']; diff --git a/sections/bookmarks/index.php b/sections/bookmarks/index.php index 155ea6b8..074f5526 100644 --- a/sections/bookmarks/index.php +++ b/sections/bookmarks/index.php @@ -24,10 +24,22 @@ case 'remove_snatched': authorize(); - $DB->query("CREATE TEMPORARY TABLE snatched_groups_temp (GroupID int PRIMARY KEY)"); - $DB->query("INSERT INTO snatched_groups_temp SELECT DISTINCT GroupID FROM torrents AS t JOIN xbt_snatched AS s ON s.fid=t.ID WHERE s.uid='$LoggedUser[ID]'"); - $DB->query("DELETE b FROM bookmarks_torrents AS b JOIN snatched_groups_temp AS s USING(GroupID) WHERE b.UserID='$LoggedUser[ID]'"); - $Cache->delete_value('bookmarks_group_ids_' . $UserID); + $DB->query(" + CREATE TEMPORARY TABLE snatched_groups_temp + (GroupID int PRIMARY KEY)"); + $DB->query(" + INSERT INTO snatched_groups_temp + SELECT DISTINCT GroupID + FROM torrents AS t + JOIN xbt_snatched AS s ON s.fid = t.ID + WHERE s.uid = '$LoggedUser[ID]'"); + $DB->query(" + DELETE b + FROM bookmarks_torrents AS b + JOIN snatched_groups_temp AS s + USING(GroupID) + WHERE b.UserID = '$LoggedUser[ID]'"); + $Cache->delete_value("bookmarks_group_ids_$UserID"); header('Location: bookmarks.php'); die(); break; @@ -40,11 +52,11 @@ case 'torrents': require(SERVER_ROOT.'/sections/bookmarks/edit_torrents.php'); break; - default : error(404); + default: + error(404); } break; - case 'view': if (empty($_REQUEST['type'])) { $_REQUEST['type'] = 'torrents'; @@ -57,7 +69,7 @@ require(SERVER_ROOT.'/sections/bookmarks/artists.php'); break; case 'collages': - $_GET['bookmarks'] = 1; + $_GET['bookmarks'] = '1'; require(SERVER_ROOT.'/sections/collages/browse.php'); break; case 'requests': @@ -68,6 +80,7 @@ error(404); } break; + default: error(404); } diff --git a/sections/bookmarks/remove.php b/sections/bookmarks/remove.php index 47be7d8c..4da74b8c 100644 --- a/sections/bookmarks/remove.php +++ b/sections/bookmarks/remove.php @@ -1,4 +1,4 @@ -query(" DELETE FROM $Table - WHERE UserID='".$LoggedUser['ID']."' - AND $Col='".db_string($_GET['id'])."'"); -$Cache->delete_value('bookmarks_'.$Type.'_'.$UserID); + WHERE UserID = '".$LoggedUser['ID']."' + AND $Col = '".db_string($_GET['id'])."'"); +$Cache->delete_value("bookmarks_$Type"."_$UserID"); if ($Type === 'torrent') { - $Cache->delete_value('bookmarks_group_ids_' . $UserID); + $Cache->delete_value("bookmarks_group_ids_$UserID"); } elseif ($Type === 'request') { - $DB->query("SELECT UserID FROM $Table WHERE $Col='".db_string($_GET['id'])."'"); + $DB->query(" + SELECT UserID + FROM $Table + WHERE $Col = '".db_string($_GET['id'])."'"); $Bookmarkers = $DB->collect('UserID'); $SS->UpdateAttributes('requests requests_delta', array('bookmarker'), array($_GET['id'] => array($Bookmarkers)), true); } diff --git a/sections/bookmarks/torrents.php b/sections/bookmarks/torrents.php index bd366921..6c024e5c 100644 --- a/sections/bookmarks/torrents.php +++ b/sections/bookmarks/torrents.php @@ -1,5 +1,5 @@ -query("SELECT Username FROM users_main WHERE ID='$UserID'"); + $DB->query(" + SELECT Username + FROM users_main + WHERE ID = '$UserID'"); list($Username) = $DB->next_record(); } else { $UserID = $LoggedUser['ID']; } -$Sneaky = $UserID != $LoggedUser['ID']; +$Sneaky = $UserID !== $LoggedUser['ID']; $Title = $Sneaky ? "$Username's bookmarked torrents" : 'Your bookmarked torrents'; // Loop through the result set, building up $Collage and $TorrentTable @@ -44,7 +47,7 @@ function compare($X, $Y) { if ($Artists) { foreach ($Artists as $Artist) { if (!isset($ArtistCount[$Artist['id']])) { - $ArtistCount[$Artist['id']] = array('name'=>$Artist['name'], 'count'=>1); + $ArtistCount[$Artist['id']] = array('name' => $Artist['name'], 'count' => 1); } else { $ArtistCount[$Artist['id']]['count']++; } @@ -58,13 +61,13 @@ function compare($X, $Y) { unset($ExtendedArtists[3]); $DisplayName = Artists::display_artists($ExtendedArtists); } elseif (count($Artists) > 0) { - $DisplayName = Artists::display_artists(array('1'=>$Artists)); + $DisplayName = Artists::display_artists(array('1' => $Artists)); } else { $DisplayName = ''; } $DisplayName .= ''.$GroupName.''; if ($GroupYear > 0) { - $DisplayName = $DisplayName . " [$GroupYear]"; + $DisplayName = "$DisplayName [$GroupYear]"; } if ($GroupVanityHouse) { $DisplayName .= ' [VH]'; @@ -75,12 +78,12 @@ function compare($X, $Y) { ob_start(); if (count($Torrents) > 1 || $GroupCategoryID == 1) { // Grouped torrents - $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] == 1); + $ShowGroups = !(!empty($LoggedUser['TorrentGrouping']) && $LoggedUser['TorrentGrouping'] === 1); ?>
- +
@@ -89,10 +92,10 @@ function compare($X, $Y) { - + Unbookmark
- +
format()?>
@@ -115,12 +118,17 @@ function compare($X, $Y) { } $SnatchedTorrentClass = $Torrent['IsSnatched'] ? ' snatched_torrent' : ''; - if ($Torrent['RemasterTitle'] != $LastRemasterTitle || $Torrent['RemasterYear'] != $LastRemasterYear || - $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber || $FirstUnknown || $Torrent['Media'] != $LastMedia) { - + if ( + $Torrent['RemasterTitle'] != $LastRemasterTitle + || $Torrent['RemasterYear'] != $LastRemasterYear + || $Torrent['RemasterRecordLabel'] != $LastRemasterRecordLabel + || $Torrent['RemasterCatalogueNumber'] != $LastRemasterCatalogueNumber + || $FirstUnknown + || $Torrent['Media'] != $LastMedia + ) { $EditionID++; ?> - + - + [ DL @@ -158,9 +166,9 @@ function compare($X, $Y) { if ($Torrent['IsSnatched']) { $DisplayName .= ' ' . Format::torrent_label('Snatched!'); } - if ($Torrent['FreeTorrent'] == '1') { + if ($Torrent['FreeTorrent'] === '1') { $DisplayName .= ' ' . Format::torrent_label('Freeleech!'); - } elseif ($Torrent['FreeTorrent'] == '2') { + } elseif ($Torrent['FreeTorrent'] === '2') { $DisplayName .= ' ' . Format::torrent_label('Neutral leech!'); } elseif ($Torrent['PersonalFL']) { $DisplayName .= ' ' . Format::torrent_label('Personal Freeleech!'); @@ -183,9 +191,9 @@ function compare($X, $Y) {
format()?>
- + Unbookmark - + @@ -196,7 +204,7 @@ function compare($X, $Y) { 0) { - $DisplayName .= Artists::display_artists(array('1'=>$Artists), false); + $DisplayName .= Artists::display_artists(array('1' => $Artists), false); } $DisplayName .= $GroupName; if ($GroupYear > 0) { - $DisplayName = $DisplayName . " [$GroupYear]"; + $DisplayName = "$DisplayName [$GroupYear]"; } ?>
  • @@ -229,7 +237,7 @@ function compare($X, $Y) { } -$CollageCovers = isset($LoggedUser['CollageCovers']) ? $LoggedUser['CollageCovers'] : 25; +$CollageCovers = isset($LoggedUser['CollageCovers']) ? (int)$LoggedUser['CollageCovers'] : 25; $CollagePages = array(); for ($i = 0; $i < $NumGroups / $CollageCovers; $i++) { $Groups = array_slice($Collage, $i * $CollageCovers, $CollageCovers); @@ -257,7 +265,7 @@ function compare($X, $Y) {
  • - +

    You have not bookmarked any torrents.

    @@ -271,7 +279,9 @@ function compare($X, $Y) {
    Stats
    • Torrents:
    • - 0) { ?>
    • Artists:
    • + 0) { ?> +
    • Artists:
    • +
    @@ -305,7 +315,7 @@ function compare($X, $Y) {
    +if ($CollageCovers !== 0) { ?>
    Cover art