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 @@ 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 @@ - + - + No - + diff --git a/sections/requests/take_warn.php b/sections/requests/take_warn.php index e7361597..ceef6f3e 100644 --- a/sections/requests/take_warn.php +++ b/sections/requests/take_warn.php @@ -21,45 +21,55 @@ 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 post.[/url]\n\n" . $PrivateMessage; $WarnTime = time_plus($Time); - $AdminComment = date("Y-m-d") . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $Reason\n\n"; + $AdminComment = date('Y-m-d') . ' - Warned until ' . $WarnTime . ' by ' . $LoggedUser['Username'] . " for $URL \nReason: $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) - . "') - ON DUPLICATE KEY UPDATE Comment = CONCAT('" . db_string($AdminComment) . "', Comment)"); +$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); -$DB->query("SELECT - rc.Body, - rc.AuthorID, - rc.RequestID, - rc.AddedTime - FROM requests_comments AS rc - WHERE rc.ID='".db_string($_POST['post'])."'"); +$DB->query(" + SELECT + rc.Body, + rc.AuthorID, + rc.RequestID, + rc.AddedTime + FROM requests_comments AS rc + WHERE rc.ID='".db_string($_POST['post'])."'"); list($OldBody, $AuthorID,$RequestID,$AddedTime)=$DB->next_record(); -$DB->query("SELECT ceil(COUNT(ID) / ".POSTS_PER_PAGE.") AS Page FROM requests_comments WHERE RequestID = $GroupID AND ID <= $PostID"); +$DB->query(" + SELECT ceil(COUNT(ID) / ".POSTS_PER_PAGE.") AS Page + FROM requests_comments + WHERE RequestID = $GroupID AND ID <= $PostID"); list($Page) = $DB->next_record(); -if ($LoggedUser['ID']!=$AuthorID && !check_perms('site_moderate_forums')) { error(404); } -if ($DB->record_count()==0) { error(404); } +if ($LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) { + error(404); +} +if ($DB->record_count() == 0) { + error(404); +} // Perform the update -$DB->query("UPDATE requests_comments SET - Body = '" . db_string($Body) . "', - EditedUserID = '".$LoggedUser['ID']."', - EditedTime = '".sqltime()."' - WHERE ID='".$PostID."'"); +$DB->query(" + UPDATE requests_comments + SET + Body = '" . db_string($Body) . "', + EditedUserID = '".$LoggedUser['ID']."', + EditedTime = '".sqltime()."' + WHERE ID='".$PostID."'"); // Update the cache -$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE*$Page-TORRENT_COMMENTS_PER_PAGE)/THREAD_CATALOGUE); +$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $Page - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE); $Cache->begin_transaction('request_comments_'.$RequestID.'_catalogue_'.$CatalogueID); $Cache->update_row($Key, array( @@ -73,8 +83,9 @@ )); $Cache->commit_transaction(0); -$DB->query("INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) - VALUES ('requests', ".$PostID.", ".db_string($LoggedUser['ID']).", '".sqltime()."', '".db_string($OldBody)."')"); +$DB->query(" + INSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body) + VALUES ('requests', $PostID, " . db_string($LoggedUser['ID']) . ", '" . sqltime() . "', '" . db_string($OldBody) . "')"); header("Location: requests.php?id=$GroupID&postid=$PostID#post$PostID"); diff --git a/sections/requests/takefill.php b/sections/requests/takefill.php index 419e0869..d000c71d 100644 --- a/sections/requests/takefill.php +++ b/sections/requests/takefill.php @@ -17,7 +17,7 @@ $Err = 'You forgot to supply a link to the filling torrent'; } else { $Link = $_POST['link']; - if (preg_match("/".TORRENT_REGEX."/i", $Link, $Matches) < 1) { + if (preg_match('/'.TORRENT_REGEX.'/i', $Link, $Matches) < 1) { $Err = "Your link didn't seem to be a valid torrent link"; } else { $TorrentID = $Matches[0]; @@ -113,7 +113,7 @@ }*/ //WEB has no ripping log. Ditto Vinyl - Actually ditto everything but CD - //$WEBOverride = ((strpos($MediaList, 'WEB') !== false) && $Media == "WEB"); + //$WEBOverride = ((strpos($MediaList, 'WEB') !== false) && $Media == "WEB"); //$VinylOverride = ((strpos($MediaList, 'Vinyl') !== false) && $Media == "Vinyl"); //if ($Format == 'FLAC' && $LogCue && !$WEBOverride && !$VinylOverride) { if ($Format == 'FLAC' && $LogCue && $Media == 'CD') { @@ -189,9 +189,10 @@ Misc::write_log("Request $RequestID (".$FullName.") was filled by user $FillerID (".$FillerUsername.") with the torrent $TorrentID for a ".Format::get_size($RequestVotes['TotalBounty']).' bounty.'); // Give bounty -$DB->query("UPDATE users_main - SET Uploaded = (Uploaded + ".$RequestVotes['TotalBounty'].") - WHERE ID = $FillerID"); +$DB->query(" + UPDATE users_main + SET Uploaded = (Uploaded + ".$RequestVotes['TotalBounty'].") + WHERE ID = $FillerID"); diff --git a/sections/tools/misc/analysis.php b/sections/tools/misc/analysis.php index f72531e7..0011f862 100644 --- a/sections/tools/misc/analysis.php +++ b/sections/tools/misc/analysis.php @@ -1,7 +1,11 @@ get_value('analysis_'.$_GET['case'])) { error(404); } +if (!isset($_GET['case']) || !$Analysis = $Cache->get_value('analysis_'.$_GET['case'])) { + error(404); +} View::show_header('Case Analysis'); ?> diff --git a/sections/tools/misc/quick_ban.php b/sections/tools/misc/quick_ban.php index 9f0453ae..40b98c5d 100644 --- a/sections/tools/misc/quick_ban.php +++ b/sections/tools/misc/quick_ban.php @@ -1,22 +1,24 @@ query('DELETE FROM ip_bans WHERE ID='.$_GET['id']); - $Bans = $Cache->delete_value('ip_bans_'.$IPA); - } elseif ($_GET['perform'] == 'create') { - $Notes = db_string($_GET['notes']); - $IP = Tools::ip_to_unsigned($_GET['ip']); //Sanitized by Validation regex - $DB->query("INSERT INTO ip_bans - (FromIP, ToIP, Reason) VALUES - ('$IP','$IP', '$Notes')"); - $Cache->delete_value('ip_bans_'.$IPA); +if (!check_perms('admin_manage_ipbans')) { + error(403); +} +if (isset($_GET['perform'])) { + $IPA = substr($_GET['ip'], 0, strcspn($_GET['ip'], '.')); + if ($_GET['perform'] == 'delete') { + if (!is_number($_GET['id']) || $_GET['id'] == '') { + error(0); } + $DB->query('DELETE FROM ip_bans WHERE ID='.$_GET['id']); + $Bans = $Cache->delete_value('ip_bans_'.$IPA); + } elseif ($_GET['perform'] == 'create') { + $Notes = db_string($_GET['notes']); + $IP = Tools::ip_to_unsigned($_GET['ip']); //Sanitized by Validation regex + $DB->query(" + INSERT INTO ip_bans (FromIP, ToIP, Reason) + VALUES ('$IP','$IP', '$Notes')"); + $Cache->delete_value('ip_bans_'.$IPA); + } } diff --git a/sections/tools/misc/update_geoip.php b/sections/tools/misc/update_geoip.php index 70b89922..a4ea3632 100644 --- a/sections/tools/misc/update_geoip.php +++ b/sections/tools/misc/update_geoip.php @@ -2,7 +2,9 @@ ini_set('memory_limit', '5G'); set_time_limit(0); -//if (!check_perms('site_debug')) { error(403); } +//if (!check_perms('site_debug')) { +// error(403); +//} View::show_header(); @@ -12,32 +14,32 @@ shell_exec('rm GeoLiteCity-latest.zip'); if (($Locations = file("GeoLiteCity_".date('Ym')."07/GeoLiteCity-Location.csv", FILE_IGNORE_NEW_LINES)) === false) { - error("Download or extraction of maxmind database failed"); + error('Download or extraction of maxmind database failed'); } array_shift($Locations); array_shift($Locations); -echo "There are ".count($Locations)." locations"; -echo "
"; +echo 'There are '.count($Locations).' locations'; +echo '
'; $CountryIDs = array(); foreach ($Locations as $Location) { - $Parts = explode(",", $Location); + $Parts = explode(',', $Location); //CountryIDs[1] = "AP"; $CountryIDs[trim($Parts[0], '"')] = trim($Parts[1], '"'); } -echo "There are ".count($CountryIDs)." CountryIDs"; -echo "
"; +echo 'There are '.count($CountryIDs).' CountryIDs'; +echo '
'; if (($Blocks = file("GeoLiteCity_".date('Ym')."07/GeoLiteCity-Blocks.csv", FILE_IGNORE_NEW_LINES)) === false) { - echo "Error"; + echo 'Error'; } array_shift($Blocks); array_shift($Blocks); -echo "There are ".count($Blocks)." blocks"; -echo "
"; +echo 'There are '.count($Blocks).' blocks'; +echo '
'; //Because 4,000,000 rows is a lot for any server to handle, we split it into manageable groups of 10,000 $SplitOn = 10000; @@ -49,15 +51,19 @@ $StartIP = trim($StartIP, '"'); $EndIP = trim($EndIP, '"'); $CountryID = trim($CountryID, '"'); - $Values[] = "('".$StartIP."', '".$EndIP."', '".$CountryIDs[$CountryID]."')"; + $Values[] = "('$StartIP', '$EndIP', '".$CountryIDs[$CountryID]."')"; if ($Index % $SplitOn == 0) { - $DB->query("INSERT INTO geoip_country (StartIP, EndIP, Code) VALUES ".implode(", ", $Values)); + $DB->query(' + INSERT INTO geoip_country (StartIP, EndIP, Code) + VALUES '.implode(', ', $Values)); $Values = array(); } } if (count($Values) > 0) { - $DB->query("INSERT INTO geoip_country (StartIP, EndIP, Code) VALUES ".implode(", ", $Values)); + $DB->query(" + INSERT INTO geoip_country (StartIP, EndIP, Code) + VALUES ".implode(', ', $Values)); } @@ -73,7 +79,7 @@ } enforce_login(); -ini_set('memory_limit',1024*1024*1024); +ini_set('memory_limit', 1024 * 1024 * 1024); ini_set('max_execution_time', 3600); header('Content-type: text/plain'); diff --git a/sections/torrents/grouplog.php b/sections/torrents/grouplog.php index 96649dcc..ca51d3f5 100644 --- a/sections/torrents/grouplog.php +++ b/sections/torrents/grouplog.php @@ -1,6 +1,8 @@ query("SELECT TorrentID, UserID, Info, Time FROM group_log WHERE GroupID = ".$GroupID." ORDER BY Time DESC"); $LogEntries = $DB->to_array(false, MYSQL_NUM); - foreach ($LogEntries AS $LogEntry) - { + foreach ($LogEntries AS $LogEntry) { list($TorrentID, $UserID, $Info, $Time) = $LogEntry; ?> @@ -39,7 +40,7 @@ list($Media, $Format, $Encoding) = $DB->next_record(); if ($DB->record_count() == 0) { ?> (Deleted) + } elseif ($Media == '') { ?> (//) diff --git a/sections/torrents/vote_ranks.php b/sections/torrents/vote_ranks.php index 46daa106..8a6cca9e 100644 --- a/sections/torrents/vote_ranks.php +++ b/sections/torrents/vote_ranks.php @@ -1,13 +1,13 @@ 'overall', - 'decade'=>check_perms('site_advanced_top10') ? 'for the '.$GroupDecade.'s' : 'for the '.$GroupDecade.'s', - 'year'=>check_perms('site_advanced_top10') ? 'for '.$GroupYear.'' : "for $GroupYear"); + 'decade'=>check_perms('site_advanced_top10') ? 'for the '.$GroupDecade.'s' : 'for the '.$GroupDecade.'s', + 'year'=>check_perms('site_advanced_top10') ? 'for '.$GroupYear.'' : "for $GroupYear"); foreach ($names as $key => $text) { if ($Rank = $Rankings[$key]) { @@ -19,7 +19,7 @@ $Class = 'vr_top_50'; } - $LIs .= '
  • No. '.$Rank.' '.$text.'
  • '; + $LIs .= "
  • No. $Rank $text
  • "; } } diff --git a/sections/user/edit.php b/sections/user/edit.php index 1d5d2920..fdb9479b 100644 --- a/sections/user/edit.php +++ b/sections/user/edit.php @@ -355,9 +355,9 @@ function checked($Checked) { Preset - - - + Show everything + Show stats only + @@ -477,7 +477,7 @@ function checked($Checked) { Reset passkey -