diff --git a/classes/class_votes.php b/classes/class_votes.php index d881b7f2..5f2cfbf1 100644 --- a/classes/class_votes.php +++ b/classes/class_votes.php @@ -61,7 +61,7 @@ public static function get_group_votes($GroupID) { } else { $GroupVotes = $DB->next_record(MYSQLI_ASSOC, false); } - $Cache->cache_value('votes_'.$GroupID, $GroupVotes, 259200); + $Cache->cache_value('votes_'.$GroupID, $GroupVotes, 259200); // 3 days } return $GroupVotes; } @@ -211,7 +211,7 @@ public static function get_rank_all($GroupID) { while (list($GID) = $DB->next_record()) { $Rankings[$GID] = ++$i; } - $Cache->cache_value('voting_ranks_overall', $Rankings, 259200); + $Cache->cache_value('voting_ranks_overall', $Rankings, 259200); // 3 days } return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false; @@ -246,7 +246,7 @@ public static function get_rank_year($GroupID, $Year) { while (list($GID) = $DB->next_record()) { $Rankings[$GID] = ++$i; } - $Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); + $Cache->cache_value('voting_ranks_year_'.$Year , $Rankings, 259200); // 3 days } return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false; @@ -286,7 +286,7 @@ public static function get_rank_decade($GroupID, $Year) { while (list($GID) = $DB->next_record()) { $Rankings[$GID] = ++$i; } - $Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); + $Cache->cache_value('voting_ranks_decade_'.$Year , $Rankings, 259200); // 3 days } return isset($Rankings[$GroupID])?$Rankings[$GroupID]:false; diff --git a/classes/util.php b/classes/util.php index 70b6119f..63988c9f 100644 --- a/classes/util.php +++ b/classes/util.php @@ -102,13 +102,13 @@ function check_perms($PermissionName, $MinClass = 0) { */ function json_die($Status, $Message) { - if ($Status == "success" && $Message) { - print json_encode(array('status' => $Status, 'response' => $Message)); - } else if ($Message) { - print json_encode(array('status' => $Status, 'error' => $Message)); - } else { - print json_encode(array('status' => $Status)); - } - die(); + if ($Status == "success" && $Message) { + print json_encode(array('status' => $Status, 'response' => $Message)); + } else if ($Message) { + print json_encode(array('status' => $Status, 'error' => $Message)); + } else { + print json_encode(array('status' => $Status)); + } + die(); } ?> diff --git a/sections/ajax/announcements.php b/sections/ajax/announcements.php index 2c92c4a6..f41aab6a 100644 --- a/sections/ajax/announcements.php +++ b/sections/ajax/announcements.php @@ -75,8 +75,8 @@ } json_die("success", array( - 'announcements' => $JsonAnnouncements, - 'blogPosts' => $JsonBlog + 'announcements' => $JsonAnnouncements, + 'blogPosts' => $JsonBlog )); ?> diff --git a/sections/ajax/artist.php b/sections/ajax/artist.php index 13898656..0383ef57 100644 --- a/sections/ajax/artist.php +++ b/sections/ajax/artist.php @@ -8,12 +8,12 @@ function compare($X, $Y) { $Text = new TEXT; if ($_GET['id'] && $_GET['artistname']) { - json_die("failure", "bad parameters"); + json_die("failure", "bad parameters"); } $ArtistID = $_GET['id']; if ($ArtistID && !is_number($ArtistID)) { - json_die("failure"); + json_die("failure"); } if (empty($ArtistID)) { @@ -21,8 +21,7 @@ function compare($X, $Y) { $Name = db_string(trim($_GET['artistname'])); $DB->query("SELECT ArtistID FROM artists_alias WHERE Name LIKE '$Name'"); if (!(list($ArtistID) = $DB->next_record(MYSQLI_NUM, false))) { - //if (list($ID) = $DB->next_record(MYSQLI_NUM, false)) { - json_die("failure"); + json_die("failure"); } // If we get here, we got the ID! } @@ -70,7 +69,7 @@ function compare($X, $Y) { $DB->query($sql); if ($DB->record_count() == 0) { - json_die("failure"); + json_die("failure"); } list($Name, $Image, $Body, $VanityHouseArtist) = $DB->next_record(MYSQLI_NUM, array(0)); @@ -260,8 +259,8 @@ function compare($X, $Y) { } $NumSimilar = count($SimilarArray); } else { - //If data already exists, use it - foreach ($SimilarArray as $Similar) { + //If data already exists, use it + foreach ($SimilarArray as $Similar) { $JsonSimilar[] = array( 'artistId' => (int) $Similar['ArtistID'], 'name' => $Similar['Name'], @@ -313,24 +312,24 @@ function compare($X, $Y) { $Cache->cache_value($Key, $Data, 3600); json_die("success", array( - 'id' => (int) $ArtistID, - 'name' => $Name, - 'notificationsEnabled' => $notificationsEnabled, - 'hasBookmarked' => Bookmarks::has_bookmarked('artist', $ArtistID), - 'image' => $Image, - 'body' => $Text->full_format($Body), - 'vanityHouse' => $VanityHouseArtist == 1, - 'tags' => array_values($Tags), - 'similarArtists' => $JsonSimilar, - 'statistics' => array( - 'numGroups' => $NumGroups, - 'numTorrents' => $NumTorrents, - 'numSeeders' => $NumSeeders, - 'numLeechers' => $NumLeechers, - 'numSnatches' => $NumSnatches - ), - 'torrentgroup' => $JsonTorrents, - 'requests' => $JsonRequests + 'id' => (int) $ArtistID, + 'name' => $Name, + 'notificationsEnabled' => $notificationsEnabled, + 'hasBookmarked' => Bookmarks::has_bookmarked('artist', $ArtistID), + 'image' => $Image, + 'body' => $Text->full_format($Body), + 'vanityHouse' => $VanityHouseArtist == 1, + 'tags' => array_values($Tags), + 'similarArtists' => $JsonSimilar, + 'statistics' => array( + 'numGroups' => $NumGroups, + 'numTorrents' => $NumTorrents, + 'numSeeders' => $NumSeeders, + 'numLeechers' => $NumLeechers, + 'numSnatches' => $NumSnatches + ), + 'torrentgroup' => $JsonTorrents, + 'requests' => $JsonRequests )); ?> diff --git a/sections/ajax/better/single.php b/sections/ajax/better/single.php index b6a67fd5..ca7dcc13 100644 --- a/sections/ajax/better/single.php +++ b/sections/ajax/better/single.php @@ -3,7 +3,7 @@ $DB->query(" SELECT t.ID AS TorrentID, - t.GroupID AS GroupID + t.GroupID AS GroupID FROM xbt_files_users AS x JOIN torrents AS t ON t.ID=x.fid WHERE t.Format='FLAC' diff --git a/sections/ajax/browse.php b/sections/ajax/browse.php index 5912abac..fa8174ee 100644 --- a/sections/ajax/browse.php +++ b/sections/ajax/browse.php @@ -515,10 +515,10 @@ function header_link($SortKey,$DefaultWay = 'desc') { } - json_die("success", array( - 'results' => array(), - 'youMightLike' => $JsonYouMightLike - )); + json_die("success", array( + 'results' => array(), + 'youMightLike' => $JsonYouMightLike + )); } $Bookmarks = Bookmarks::all_bookmarks('torrent'); @@ -710,7 +710,7 @@ function header_link($SortKey,$DefaultWay = 'desc') { } json_die("success", array( - 'currentPage' => intval($Page), - 'pages' => ceil($TorrentCount / TORRENTS_PER_PAGE), - 'results' => $JsonGroups + 'currentPage' => intval($Page), + 'pages' => ceil($TorrentCount / TORRENTS_PER_PAGE), + 'results' => $JsonGroups )); diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 7aa1f803..6aba9c6a 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -60,16 +60,16 @@ } if (!isset($Forums[$ForumID])) { - json_die("failure"); + json_die("failure"); } // Make sure they're allowed to look at the page if (!check_perms('site_moderate_forums')) { if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] === 0) { - json_die("failure", "unsufficient permissions to view page"); - } + json_die("failure", "unsufficient permissions to view page"); + } } if ($LoggedUser['CustomForums'][$ForumID] != 1 && $Forums[$ForumID]['MinClassRead'] > $LoggedUser['Class']) { - json_die("failure", "unsufficient permissions to view page"); + json_die("failure", "unsufficient permissions to view page"); } $ForumName = display_str($Forums[$ForumID]['Name']); diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 840c21df..7ba90ff3 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -24,7 +24,7 @@ $DB->query("SELECT TopicID FROM forums_posts WHERE ID = $_GET[postid]"); list($ThreadID) = $DB->next_record(); if ($ThreadID) { - //Redirect postid to threadid when necessary. + //Redirect postid to threadid when necessary. header("Location: ajax.php?action=forum&type=viewthread&threadid=$ThreadID&postid=$_GET[postid]"); die(); } else { diff --git a/sections/ajax/index.php b/sections/ajax/index.php index 43fea83b..e7a49aed 100644 --- a/sections/ajax/index.php +++ b/sections/ajax/index.php @@ -16,7 +16,7 @@ $Limited_Pages = array('tcomments','user','forum','top10','browse','usersearch','requests','artist','inbox','subscriptions','bookmarks','announcements','notifications','request','better','similar_artists','userhistory','votefavorite','wiki','torrentgroup'); header('Content-Type: application/json; charset=utf-8'); - + // Enforce rate limiting everywhere except info.php if (isset($_GET['action']) && in_array($_GET['action'],$Limited_Pages)) { if (!$userrequests = $Cache->get_value('ajax_requests_'.$UserID)) { diff --git a/sections/ajax/info.php b/sections/ajax/info.php index 2c3751cd..efbba28c 100644 --- a/sections/ajax/info.php +++ b/sections/ajax/info.php @@ -92,24 +92,24 @@ } json_die("success", array( - 'username' => $LoggedUser['Username'], - 'id' => (int) $LoggedUser['ID'], - 'authkey' => $LoggedUser['AuthKey'], - 'passkey' => $LoggedUser['torrent_pass'], - 'notifications' => array( - 'messages' => (int) $NewMessages, - 'notifications' => (int) $NewNotifications, - 'newAnnouncement' => $MyNews < $CurrentNews, - 'newBlog' => $MyBlog < $CurrentBlog, - 'newSubscriptions' => $NewSubscriptions == 1 - ), - 'userstats' => array( - 'uploaded' => (int) $LoggedUser['BytesUploaded'], - 'downloaded' => (int) $LoggedUser['BytesDownloaded'], - 'ratio' => (float) $Ratio, - 'requiredratio' => (float) $LoggedUser['RequiredRatio'], - 'class' => $ClassLevels[$LoggedUser['Class']]['Name'] - ) + 'username' => $LoggedUser['Username'], + 'id' => (int) $LoggedUser['ID'], + 'authkey' => $LoggedUser['AuthKey'], + 'passkey' => $LoggedUser['torrent_pass'], + 'notifications' => array( + 'messages' => (int) $NewMessages, + 'notifications' => (int) $NewNotifications, + 'newAnnouncement' => $MyNews < $CurrentNews, + 'newBlog' => $MyBlog < $CurrentBlog, + 'newSubscriptions' => $NewSubscriptions == 1 + ), + 'userstats' => array( + 'uploaded' => (int) $LoggedUser['BytesUploaded'], + 'downloaded' => (int) $LoggedUser['BytesDownloaded'], + 'ratio' => (float) $Ratio, + 'requiredratio' => (float) $LoggedUser['RequiredRatio'], + 'class' => $ClassLevels[$LoggedUser['Class']]['Name'] + ) )); ?> diff --git a/sections/ajax/notifications.php b/sections/ajax/notifications.php index 552c445f..23c6ba09 100644 --- a/sections/ajax/notifications.php +++ b/sections/ajax/notifications.php @@ -1,6 +1,6 @@ if (!check_perms('site_torrents_notify')) { - json_die("failure"); + json_die("failure"); } define('NOTIFICATIONS_PER_PAGE', 50); @@ -101,8 +101,8 @@ } json_die("success", array( - 'currentPages' => intval($Page), - 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), - 'numNew' => $NumNew, - 'results' => $JsonNotifications + 'currentPages' => intval($Page), + 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), + 'numNew' => $NumNew, + 'results' => $JsonNotifications )); diff --git a/sections/ajax/request.php b/sections/ajax/request.php index b39588a7..e5c5915d 100644 --- a/sections/ajax/request.php +++ b/sections/ajax/request.php @@ -101,7 +101,7 @@ 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7]) ); } else { - $JsonMusicInfo = new stdClass; //json_encodes into an empty object: {} + $JsonMusicInfo = new stdClass; //json_encodes into an empty object: {} } $JsonTopContributors = array(); @@ -185,42 +185,42 @@ } json_die("success", array( - 'requestId' => (int) $RequestID, - 'requestorId' => (int) $RequestorID, - 'requestorName' => $RequestorName, + 'requestId' => (int) $RequestID, + 'requestorId' => (int) $RequestorID, + 'requestorName' => $RequestorName, 'isBookmarked' => Bookmarks::has_bookmarked('request', $RequestID), - 'requestTax' => $RequestTax, - 'timeAdded' => $TimeAdded, - 'canEdit' => $CanEdit, - 'canVote' => $CanVote, - 'minimumVote' => $MinimumVote, - 'voteCount' => $VoteCount, - 'lastVote' => $LastVote, - 'topContributors' => $JsonTopContributors, - 'totalBounty' => (int) $RequestVotes['TotalBounty'], - 'categoryId' => (int) $CategoryID, - 'categoryName' => $CategoryName, - 'title' => $Title, - 'year' => (int) $Year, - 'image' => $Image, - 'description' => $Text->full_format($Description), - 'musicInfo' => $JsonMusicInfo, - 'catalogueNumber' => $CatalogueNumber, - 'releaseType' => (int) $ReleaseType, - 'releaseName' => $ReleaseName, - 'bitrateList' => $BitrateList, - 'formatList' => $FormatList, - 'mediaList' => $MediaList, - 'logCue' => $LogCue, - 'isFilled' => $IsFilled, - 'fillerId' => (int) $FillerID, - 'fillerName' => $FillerName, - 'torrentId' => (int) $TorrentID, - 'timeFilled' => $TimeFilled, - 'tags' => $JsonTags, - 'comments' => $JsonRequestComments, - 'commentPage' => (int) $Page, - 'commentPages' => (int) ceil($Results / TORRENT_COMMENTS_PER_PAGE) + 'requestTax' => $RequestTax, + 'timeAdded' => $TimeAdded, + 'canEdit' => $CanEdit, + 'canVote' => $CanVote, + 'minimumVote' => $MinimumVote, + 'voteCount' => $VoteCount, + 'lastVote' => $LastVote, + 'topContributors' => $JsonTopContributors, + 'totalBounty' => (int) $RequestVotes['TotalBounty'], + 'categoryId' => (int) $CategoryID, + 'categoryName' => $CategoryName, + 'title' => $Title, + 'year' => (int) $Year, + 'image' => $Image, + 'description' => $Text->full_format($Description), + 'musicInfo' => $JsonMusicInfo, + 'catalogueNumber' => $CatalogueNumber, + 'releaseType' => (int) $ReleaseType, + 'releaseName' => $ReleaseName, + 'bitrateList' => $BitrateList, + 'formatList' => $FormatList, + 'mediaList' => $MediaList, + 'logCue' => $LogCue, + 'isFilled' => $IsFilled, + 'fillerId' => (int) $FillerID, + 'fillerName' => $FillerName, + 'torrentId' => (int) $TorrentID, + 'timeFilled' => $TimeFilled, + 'tags' => $JsonTags, + 'comments' => $JsonRequestComments, + 'commentPage' => (int) $Page, + 'commentPages' => (int) ceil($Results / TORRENT_COMMENTS_PER_PAGE) )); ?> diff --git a/sections/ajax/requests.php b/sections/ajax/requests.php index 6105161f..f829ca56 100644 --- a/sections/ajax/requests.php +++ b/sections/ajax/requests.php @@ -28,7 +28,7 @@ if (!empty($_GET['userid'])) { if (is_number($_GET['userid'])) { if (!check_paranoia('requestsvoted_list', $UserInfo['Paranoia'], $Perms['Class'], $_GET['userid'])) { - json_die("failure"); + json_die("failure"); } $Title = "Requests voted for by ".$UserInfo['Username']; $SS->set_filter('voter', array($_GET['userid'])); @@ -290,11 +290,11 @@ $Requests = $SphinxResults['matches']; if ($NumResults == 0) { - json_die("success", array( - 'currentPage' => 1, - 'pages' => 1, - 'results' => array() - )); + json_die("success", array( + 'currentPage' => 1, + 'pages' => 1, + 'results' => array() + )); } else { $JsonResults = array(); $TimeCompare = 1267643718; // Requests v2 was implemented 2010-03-03 20:15:18 @@ -353,10 +353,10 @@ 'timeFilled' => $TimeFilled == 0 ? '' : $TimeFilled ); } - json_die("success", array( - 'currentPage' => intval($Page), - 'pages' => ceil($NumResults / REQUESTS_PER_PAGE), - 'results' => $JsonResults - )); + json_die("success", array( + 'currentPage' => intval($Page), + 'pages' => ceil($NumResults / REQUESTS_PER_PAGE), + 'results' => $JsonResults + )); } ?> diff --git a/sections/ajax/subscriptions.php b/sections/ajax/subscriptions.php index 409fcf72..d02544b0 100644 --- a/sections/ajax/subscriptions.php +++ b/sections/ajax/subscriptions.php @@ -4,7 +4,7 @@ */ if (!empty($LoggedUser['DisableForums'])) { - json_die('failure'); + json_die('failure'); } include(SERVER_ROOT.'/classes/class_text.php'); // Text formatting class @@ -104,6 +104,6 @@ } json_die('success', array( - 'threads' => $JsonPosts + 'threads' => $JsonPosts )); ?> diff --git a/sections/ajax/takevote.php b/sections/ajax/takevote.php index 8bc6ab16..d45dbd89 100644 --- a/sections/ajax/takevote.php +++ b/sections/ajax/takevote.php @@ -23,10 +23,12 @@ echo 'badvote'; die(); } - $Type = ($_REQUEST['vote'] == 'up')?"Up":"Down"; + $Type = ($_REQUEST['vote'] == 'up') ? 'Up' : 'Down'; // Update the two votes tables if needed - $DB->query("INSERT IGNORE INTO users_votes (UserID, GroupID, Type) VALUES ($UserID, $GroupID, '$Type')"); + $DB->query(" + INSERT IGNORE INTO users_votes (UserID, GroupID, Type) + VALUES ($UserID, $GroupID, '$Type')"); if ($DB->affected_rows() == 0) { echo 'noaction'; die(); @@ -34,7 +36,7 @@ // Update the group's cache key $GroupVotes['Total'] += 1; - if ($Type == "Up") { + if ($Type == 'Up') { $GroupVotes['Ups'] += 1; } $Cache->cache_value('votes_'.$GroupID, $GroupVotes); @@ -43,10 +45,10 @@ // so we can cut corners and use the magic of INSERT...ON DUPLICATE KEY UPDATE... // to accomplish both in one query $DB->query("INSERT INTO torrents_votes (GroupID, Total, Ups, Score) - VALUES ($GroupID, 1, ".($Type=='Up'?1:0).", 0) + VALUES ($GroupID, 1, ".($Type == 'Up' ? 1 : 0).", 0) ON DUPLICATE KEY UPDATE Total = Total + 1, - Score = IFNULL(binomial_ci(Ups".($Type=='Up'?'+1':'').",Total),0)". - ($Type=='Up'?', Ups = Ups+1':'')); + Score = IFNULL(binomial_ci(Ups".($Type == 'Up' ? '+1' : '').",Total),0)". + ($Type == 'Up' ? ', Ups = Ups+1' : '')); $UserVotes[$GroupID] = array('GroupID' => $GroupID, 'Type' => $Type); @@ -72,8 +74,8 @@ } } else { $VotePairs[$Vote['GroupID']] = array('GroupID'=>$Vote['GroupID'], - 'Total' => 1, - 'Ups'=>($Type == 'Up')?1:0); + 'Total' => 1, + 'Ups'=>($Type == 'Up') ? 1 : 0); } } } @@ -101,8 +103,8 @@ } } else { $VotePairs[$GroupID] = array('GroupID' => $GroupID, - 'Total' => 1, - 'Ups'=>($Type == 'Up')?1:0); + 'Total' => 1, + 'Ups'=>($Type == 'Up') ? 1 : 0); } $Cache->cache_value('vote_pairs_'.$VGID, $VotePairs); } @@ -117,7 +119,10 @@ } $Type = $UserVotes[$GroupID]['Type']; - $DB->query("DELETE FROM users_votes WHERE UserID=$UserID AND GroupID=$GroupID"); + $DB->query(" + DELETE FROM users_votes + WHERE UserID=$UserID + AND GroupID=$GroupID"); // Update personal cache key unset($UserVotes[$GroupID]); @@ -125,15 +130,17 @@ // Update the group's cache key $GroupVotes['Total'] -= 1; - if ($Type == "Up") { + if ($Type == 'Up') { $GroupVotes['Ups'] -= 1; } $Cache->cache_value('votes_'.$GroupID, $GroupVotes); - $DB->query("UPDATE torrents_votes SET Total = GREATEST(0, Total - 1), - Score = IFNULL(binomial_ci(GREATEST(0,Ups".($Type == 'Up' ? '-1' : '')."),GREATEST(0, Total)),0)". - ($Type == 'Up' ? ', Ups = GREATEST(0, Ups - 1)' : '')." - WHERE GroupID=$GroupID"); + $DB->query(" + UPDATE torrents_votes + SET Total = GREATEST(0, Total - 1), + Score = IFNULL(binomial_ci(GREATEST(0,Ups".($Type == 'Up' ? '-1' : '')."),GREATEST(0, Total)),0)". + ($Type == 'Up' ? ', Ups = GREATEST(0, Ups - 1)' : '')." + WHERE GroupID=$GroupID"); // Update paired cache keys // First update this album's paired votes. If this keys is magically not set, // our life just got a bit easier. We're only tracking paired votes on upvotes. diff --git a/sections/ajax/tcomments.php b/sections/ajax/tcomments.php index f5a9ca0d..d0a6c854 100644 --- a/sections/ajax/tcomments.php +++ b/sections/ajax/tcomments.php @@ -86,7 +86,7 @@ } json_die("success", array( - 'page' => (int) $Page, - 'pages' => ceil($Results / TORRENT_COMMENTS_PER_PAGE), - 'comments' => $JsonComments + 'page' => (int) $Page, + 'pages' => ceil($Results / TORRENT_COMMENTS_PER_PAGE), + 'comments' => $JsonComments )); diff --git a/sections/ajax/torrent.php b/sections/ajax/torrent.php index 28e4ddfc..213654b9 100644 --- a/sections/ajax/torrent.php +++ b/sections/ajax/torrent.php @@ -10,34 +10,34 @@ $TorrentHash = (string)$_GET['hash']; if ($TorrentID && $TorrentHash) { - json_die("failure", "bad parameters"); + json_die("failure", "bad parameters"); } if ($TorrentHash) { - if (!is_valid_torrenthash($TorrentHash)) { - json_die("failure", "bad hash parameter"); - } else { - $TorrentID = (int)torrenthash_to_torrentid($TorrentHash); - if (!$TorrentID) { - json_die("failure", "bad hash parameter"); - } - } + if (!is_valid_torrenthash($TorrentHash)) { + json_die("failure", "bad hash parameter"); + } else { + $TorrentID = (int)torrenthash_to_torrentid($TorrentHash); + if (!$TorrentID) { + json_die("failure", "bad hash parameter"); + } + } } if ($TorrentID <= 0) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } $TorrentCache = get_torrent_info($TorrentID, true, 0, true, true); if (!$TorrentCache) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } list($TorrentDetails, $TorrentList) = $TorrentCache; if (!isset($TorrentList[$TorrentID])) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } $GroupID = $TorrentDetails['ID']; @@ -85,37 +85,37 @@ // Convert file list back to the old format $FileList = explode("\n", $Torrent['FileList']); foreach ($FileList as &$File) { - $File = Torrents::filelist_old_format($File); + $File = Torrents::filelist_old_format($File); } unset($File); $FileList = implode('|||', $FileList); $Userinfo = Users::user_info($Torrent['UserID']); $JsonTorrentList[] = array( - 'id' => (int) $Torrent['ID'], - 'media' => $Torrent['Media'], - 'format' => $Torrent['Format'], - 'encoding' => $Torrent['Encoding'], - 'remastered' => $Torrent['Remastered'] == 1, - 'remasterYear' => (int) $Torrent['RemasterYear'], - 'remasterTitle' => $Torrent['RemasterTitle'], - 'remasterRecordLabel' => $Torrent['RemasterRecordLabel'], - 'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], - 'scene' => $Torrent['Scene'] == 1, - 'hasLog' => $Torrent['HasLog'] == 1, - 'hasCue' => $Torrent['HasCue'] == 1, - 'logScore' => (int) $Torrent['LogScore'], - 'fileCount' => (int) $Torrent['FileCount'], - 'size' => (int) $Torrent['Size'], - 'seeders' => (int) $Torrent['Seeders'], - 'leechers' => (int) $Torrent['Leechers'], - 'snatched' => (int) $Torrent['Snatched'], - 'freeTorrent' => $Torrent['FreeTorrent'] == 1, - 'time' => $Torrent['Time'], - 'description' => $Torrent['Description'], - 'fileList' => $FileList, - 'filePath' => $Torrent['FilePath'], - 'userId' => (int) $Torrent['UserID'], - 'username' => $Userinfo['Username'] + 'id' => (int) $Torrent['ID'], + 'media' => $Torrent['Media'], + 'format' => $Torrent['Format'], + 'encoding' => $Torrent['Encoding'], + 'remastered' => $Torrent['Remastered'] == 1, + 'remasterYear' => (int) $Torrent['RemasterYear'], + 'remasterTitle' => $Torrent['RemasterTitle'], + 'remasterRecordLabel' => $Torrent['RemasterRecordLabel'], + 'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], + 'scene' => $Torrent['Scene'] == 1, + 'hasLog' => $Torrent['HasLog'] == 1, + 'hasCue' => $Torrent['HasCue'] == 1, + 'logScore' => (int) $Torrent['LogScore'], + 'fileCount' => (int) $Torrent['FileCount'], + 'size' => (int) $Torrent['Size'], + 'seeders' => (int) $Torrent['Seeders'], + 'leechers' => (int) $Torrent['Leechers'], + 'snatched' => (int) $Torrent['Snatched'], + 'freeTorrent' => $Torrent['FreeTorrent'] == 1, + 'time' => $Torrent['Time'], + 'description' => $Torrent['Description'], + 'fileList' => $FileList, + 'filePath' => $Torrent['FilePath'], + 'userId' => (int) $Torrent['UserID'], + 'username' => $Userinfo['Username'] ); json_die("success", array('group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList))); diff --git a/sections/ajax/torrentgroup.php b/sections/ajax/torrentgroup.php index e4b0b6bd..a06251ec 100644 --- a/sections/ajax/torrentgroup.php +++ b/sections/ajax/torrentgroup.php @@ -12,28 +12,28 @@ $TorrentHash = (string)$_GET['hash']; if ($GroupID && $TorrentHash) { - json_die("failure", "bad parameters"); + json_die("failure", "bad parameters"); } if ($TorrentHash) { - if (!is_valid_torrenthash($TorrentHash)) { - json_die("failure", "bad hash parameter"); - } else { - $GroupID = (int)torrenthash_to_groupid($TorrentHash); - if (!$GroupID) { - json_die("failure", "bad hash parameter"); - } - } + if (!is_valid_torrenthash($TorrentHash)) { + json_die("failure", "bad hash parameter"); + } else { + $GroupID = (int)torrenthash_to_groupid($TorrentHash); + if (!$GroupID) { + json_die("failure", "bad hash parameter"); + } + } } if ($GroupID <= 0) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } $TorrentCache = get_group_info($GroupID, true, 0, true, true); if (!$TorrentCache) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } list($TorrentDetails, $TorrentList) = $TorrentCache; diff --git a/sections/ajax/torrentgroupalbumart.php b/sections/ajax/torrentgroupalbumart.php index df6fda89..73992496 100644 --- a/sections/ajax/torrentgroupalbumart.php +++ b/sections/ajax/torrentgroupalbumart.php @@ -2,7 +2,9 @@ require(SERVER_ROOT.'/sections/torrents/functions.php'); $GroupID = (int)$_GET['id']; -if ($GroupID == 0) { error('bad id parameter', true); } +if ($GroupID == 0) { + error('bad id parameter', true); +} $TorrentDetails = get_group_info($GroupID, true, 0, false); $TorrentDetails = $TorrentDetails[0]; @@ -12,5 +14,5 @@ } json_die("success", array( - 'wikiImage' => $Image + 'wikiImage' => $Image )); \ No newline at end of file diff --git a/sections/ajax/user.php b/sections/ajax/user.php index 3fdf0c08..06674358 100644 --- a/sections/ajax/user.php +++ b/sections/ajax/user.php @@ -4,7 +4,7 @@ $Text = new TEXT; if (empty($_GET['id']) || !is_numeric($_GET['id'])) { - json_die("failure", "bad id parameter"); + json_die("failure", "bad id parameter"); } $UserID = $_GET['id']; @@ -51,7 +51,7 @@ GROUP BY AuthorID"); if ($DB->record_count() == 0) { // If user doesn't exist - json_die("failure", "no such user"); + json_die("failure", "no such user"); } list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass, $DisableLeech, $JoinDate, $Info, $Avatar, $Country, $Donor, $Warned, $ForumPosts, $InviterID, $DisableInvites, $InviterName, $RatioWatchEnds, $RatioWatchDownload) = $DB->next_record(MYSQLI_NUM, array(9,11)); @@ -249,58 +249,58 @@ function check_paranoia_here($Setting) { //Bugfix for no access time available if ($LastAccess == '0000-00-00 00:00:00') { - $LastAccess = ''; + $LastAccess = ''; } header('Content-Type: text/plain; charset=utf-8'); json_die("success", array( - 'username' => $Username, - 'avatar' => $Avatar, - 'isFriend' => $Friend, - 'profileText' => $Text->full_format($Info), - 'stats' => array( - 'joinedDate' => $JoinDate, - 'lastAccess' => $LastAccess, - 'uploaded' => $Uploaded == null ? null : (int) $Uploaded, - 'downloaded' => $Downloaded == null ? null : (int) $Downloaded, - 'ratio' => $Ratio, - 'requiredRatio' => $RequiredRatio == null ? null : (float) $RequiredRatio - ), - 'ranks' => array( - 'uploaded' => $UploadedRank, - 'downloaded' => $DownloadedRank, - 'uploads' => $UploadsRank, - 'requests' => $RequestRank, - 'bounty' => $BountyRank, - 'posts' => $PostRank, - 'artists' => $ArtistsRank, - 'overall' => $OverallRank == null ? 0 : $OverallRank - ), - 'personal' => array( - 'class' => $ClassLevels[$Class]['Name'], - 'paranoia' => $ParanoiaLevel, - 'paranoiaText' => $ParanoiaLevelText, - 'donor' => $Donor == 1, - 'warned' => ($Warned != '0000-00-00 00:00:00'), - 'enabled' => ($Enabled == '1' || $Enabled == '0' || !$Enabled), - 'passkey' => $torrent_pass - ), - 'community' => array( - 'posts' => (int) $ForumPosts, - 'torrentComments' => (int) $NumComments, - 'collagesStarted' => $NumCollages == null ? null : (int) $NumCollages, - 'collagesContrib' => $NumCollageContribs == null ? null : (int) $NumCollageContribs, - 'requestsFilled' => $RequestsFilled == null ? null : (int) $RequestsFilled, - 'requestsVoted' => $RequestsVoted == null ? null : (int) $RequestsVoted, - 'perfectFlacs' => $PerfectFLACs == null ? null : (int) $PerfectFLACs, - 'uploaded' => $Uploads == null ? null : (int) $Uploads, - 'groups' => $UniqueGroups == null ? null : (int) $UniqueGroups, - 'seeding' => $Seeding == null ? null : (int) $Seeding, - 'leeching' => $Leeching == null ? null : (int) $Leeching, - 'snatched' => $Snatched == null ? null : (int) $Snatched, - 'invited' => $Invited == null ? null : (int) $Invited - ) + 'username' => $Username, + 'avatar' => $Avatar, + 'isFriend' => $Friend, + 'profileText' => $Text->full_format($Info), + 'stats' => array( + 'joinedDate' => $JoinDate, + 'lastAccess' => $LastAccess, + 'uploaded' => $Uploaded == null ? null : (int) $Uploaded, + 'downloaded' => $Downloaded == null ? null : (int) $Downloaded, + 'ratio' => $Ratio, + 'requiredRatio' => $RequiredRatio == null ? null : (float) $RequiredRatio + ), + 'ranks' => array( + 'uploaded' => $UploadedRank, + 'downloaded' => $DownloadedRank, + 'uploads' => $UploadsRank, + 'requests' => $RequestRank, + 'bounty' => $BountyRank, + 'posts' => $PostRank, + 'artists' => $ArtistsRank, + 'overall' => $OverallRank == null ? 0 : $OverallRank + ), + 'personal' => array( + 'class' => $ClassLevels[$Class]['Name'], + 'paranoia' => $ParanoiaLevel, + 'paranoiaText' => $ParanoiaLevelText, + 'donor' => $Donor == 1, + 'warned' => ($Warned != '0000-00-00 00:00:00'), + 'enabled' => ($Enabled == '1' || $Enabled == '0' || !$Enabled), + 'passkey' => $torrent_pass + ), + 'community' => array( + 'posts' => (int) $ForumPosts, + 'torrentComments' => (int) $NumComments, + 'collagesStarted' => $NumCollages == null ? null : (int) $NumCollages, + 'collagesContrib' => $NumCollageContribs == null ? null : (int) $NumCollageContribs, + 'requestsFilled' => $RequestsFilled == null ? null : (int) $RequestsFilled, + 'requestsVoted' => $RequestsVoted == null ? null : (int) $RequestsVoted, + 'perfectFlacs' => $PerfectFLACs == null ? null : (int) $PerfectFLACs, + 'uploaded' => $Uploads == null ? null : (int) $Uploads, + 'groups' => $UniqueGroups == null ? null : (int) $UniqueGroups, + 'seeding' => $Seeding == null ? null : (int) $Seeding, + 'leeching' => $Leeching == null ? null : (int) $Leeching, + 'snatched' => $Snatched == null ? null : (int) $Snatched, + 'invited' => $Invited == null ? null : (int) $Invited + ) )); ?> diff --git a/sections/ajax/usersearch.php b/sections/ajax/usersearch.php index dc1a64d4..609a2926 100644 --- a/sections/ajax/usersearch.php +++ b/sections/ajax/usersearch.php @@ -4,7 +4,7 @@ **********************************************************************/ if (empty($_GET['search'])) { - json_die("failure", "no search terms"); + json_die("failure", "no search terms"); } else { $_GET['username'] = $_GET['search']; } @@ -49,7 +49,7 @@ } json_die("success", array( - 'currentPage' => (int) $Page, - 'pages' => ceil($NumResults / USERS_PER_PAGE), - 'results' => $JsonUsers + 'currentPage' => (int) $Page, + 'pages' => ceil($NumResults / USERS_PER_PAGE), + 'results' => $JsonUsers )); diff --git a/sections/ajax/wiki.php b/sections/ajax/wiki.php index da0ff867..e9068f6a 100644 --- a/sections/ajax/wiki.php +++ b/sections/ajax/wiki.php @@ -10,7 +10,7 @@ } elseif ($_GET['name'] != '') { //Retrieve article ID via alias. $ArticleID = $Alias->to_id($_GET['name']); } else { - json_die("failure"); + json_die("failure"); } if (!$ArticleID) { //No article found @@ -29,13 +29,13 @@ $TextBody = $Text->full_format($Body, false); json_die("success", array( - 'title' => $Title, - 'bbBody' => $Body, - 'body' => $TextBody, - 'aliases' => $Aliases, - 'authorID' => (int) $AuthorID, - 'authorName' => $AuthorName, - 'date' => $Date, - 'revision' => (int) $Revision + 'title' => $Title, + 'bbBody' => $Body, + 'body' => $TextBody, + 'aliases' => $Aliases, + 'authorID' => (int) $AuthorID, + 'authorName' => $AuthorName, + 'date' => $Date, + 'revision' => (int) $Revision )); ?> \ No newline at end of file diff --git a/sections/artist/artist.php b/sections/artist/artist.php index 42da67f6..12fa23b5 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -750,7 +750,7 @@ function compare($X, $Y) { $Tags = Requests::get_tags($RequestID); $ReqTagList = array(); foreach ($Tags as $TagID => $TagName) { - $ReqTagList[] = "'.display_str($TagName).''; + $ReqTagList[] = "'.display_str($TagName).''; } $ReqTagList = implode(', ', $ReqTagList); ?> diff --git a/sections/artist/take_warn.php b/sections/artist/take_warn.php index 654678c4..6ccbe381 100644 --- a/sections/artist/take_warn.php +++ b/sections/artist/take_warn.php @@ -1,5 +1,6 @@ get_value('better_single_groupids')) === false) { - $DB->query("SELECT t.ID AS TorrentID, - t.GroupID AS GroupID + $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' diff --git a/sections/collages/browse.php b/sections/collages/browse.php index 356eb68a..383f8476 100644 --- a/sections/collages/browse.php +++ b/sections/collages/browse.php @@ -131,7 +131,9 @@ $SQL .= " AND c.ID IN(".db_string(implode(',', $CollageIDs)).")"; } } else { - if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) { error(403); } + if (!check_paranoia('collages', $User['Paranoia'], $UserClass, $UserID)) { + error(403); + } $SQL .= " AND UserID='".$_GET['userid']."'"; } $Categories[] = 0; diff --git a/sections/donate/config.php b/sections/donate/config.php index ecf62b0d..f4c58cb6 100644 --- a/sections/donate/config.php +++ b/sections/donate/config.php @@ -25,8 +25,14 @@ function btc_address($UserID, $GenAddress = false) { if (!empty($Addr)) { return $Addr; } elseif ($GenAddress) { - if (empty($NewAddr)) { error(0); } - $DB->query("UPDATE users_info SET BitcoinAddress = '".db_string($NewAddr)."' WHERE UserID = '".$UserID."' AND BitcoinAddress IS NULL"); + if (empty($NewAddr)) { + error(0); + } + $DB->query(" + UPDATE users_info + SET BitcoinAddress = '".db_string($NewAddr)."' + WHERE UserID = '$UserID' + AND BitcoinAddress IS NULL"); return $NewAddr; } else { return false; diff --git a/sections/requests/requests.php b/sections/requests/requests.php index b6d61dca..27199d91 100644 --- a/sections/requests/requests.php +++ b/sections/requests/requests.php @@ -331,7 +331,7 @@ if (count($Queries) > 0) { $Query = implode(' ',$Queries); } else { - $Query=''; + $Query = ''; } $SS->set_index('requests requests_delta'); @@ -646,11 +646,11 @@ =Format::get_size($RequestVotes['TotalBounty'])?>