diff --git a/classes/artists.class.php b/classes/artists.class.php index 503b8a73..69f16c00 100644 --- a/classes/artists.class.php +++ b/classes/artists.class.php @@ -180,7 +180,7 @@ public static function display_artists($Artists, $MakeLink = true, $IncludeHyphe case 2: $link = Artists::display_artist($DJs[0], $MakeLink, $Escape).$ampersand.Artists::display_artist($DJs[1], $MakeLink, $Escape); break; - default : + default: $link = 'Various DJs'; } return $link.($IncludeHyphen?' - ':''); diff --git a/classes/forums.class.php b/classes/forums.class.php index 54b74a5a..c044d397 100644 --- a/classes/forums.class.php +++ b/classes/forums.class.php @@ -31,8 +31,9 @@ public static function get_thread_info($ThreadID, $Return = true, $SelectiveCach LEFT JOIN forums_polls AS p ON p.TopicID=t.ID WHERE t.ID = '$ThreadID' GROUP BY fp.TopicID"); - if (G::$DB->record_count() == 0) { - error(404); + if (!G::$DB->has_results()) { + G::$DB->set_query_id($QueryID); + return null; } $ThreadInfo = G::$DB->next_record(MYSQLI_ASSOC, false); if ($ThreadInfo['StickyPostID']) { @@ -108,7 +109,7 @@ public static function get_forum_info($ForumID) { LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID WHERE forums.ID='$ForumID' GROUP BY ForumID"); - if (G::$DB->record_count() == 0) { + if (!G::$DB->has_results()) { return false; } // Makes an array, with $Forum['Name'], etc. diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index 55aa6334..90ceec62 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,8 @@ CHANGELOG +2013-10-01 by alderaan +In the staff toolbox, reorganized tools into more useful categories + 2013-09-30 by alderaan Refactored backend code for staff toolbox diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 6a2ca6e4..d3d89d58 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -80,7 +80,7 @@ $ForumName = display_str($Forums[$ForumID]['Name']); $JsonSpecificRules = array(); foreach ($Forums[$ForumID]['SpecificRules'] as $ThreadIDs) { - $Thread = get_thread_info($ThreadIDs); + $Thread = Forums::get_thread_info($ThreadIDs); $JsonSpecificRules[] = array( 'threadId' => (int) $ThreadIDs, 'thread' => display_str($Thread['Title']) diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index 01bd6eff..baeba883 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -6,62 +6,11 @@ print json_encode(array('status' => 'failure')); die(); } else { - include(SERVER_ROOT.'/sections/forums/functions.php'); // Replace the old hard-coded forum categories - unset($ForumCats); - $ForumCats = $Cache->get_value('forums_categories'); - if ($ForumCats === false) { - $DB->query(" - SELECT ID, Name - FROM forums_categories"); - $ForumCats = array(); - while (list($ID, $Name) = $DB->next_record()) { - $ForumCats[$ID] = $Name; - } - $Cache->cache_value('forums_categories', $ForumCats, 0); //Inf cache. - } + $ForumCats = Forums::get_forum_categories(); //This variable contains all our lovely forum data - if (!$Forums = $Cache->get_value('forums_list')) { - $DB->query(" - SELECT - f.ID, - f.CategoryID, - f.Name, - f.Description, - f.MinClassRead, - f.MinClassWrite, - f.MinClassCreate, - f.NumTopics, - f.NumPosts, - f.LastPostID, - f.LastPostAuthorID, - f.LastPostTopicID, - f.LastPostTime, - COUNT(sr.ThreadID) AS SpecificRules, - t.Title, - t.IsLocked, - t.IsSticky - FROM forums AS f - JOIN forums_categories AS fc ON fc.ID = f.CategoryID - LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID - LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID - GROUP BY f.ID - ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort"); - $Forums = $DB->to_array('ID', MYSQLI_ASSOC, false); - foreach ($Forums as $ForumID => $Forum) { - if (count($Forum['SpecificRules'])) { - $DB->query(" - SELECT ThreadID - FROM forums_specific_rules - WHERE ForumID = $ForumID"); - $ThreadIDs = $DB->collect('ThreadID'); - $Forums[$ForumID]['SpecificRules'] = $ThreadIDs; - } - } - unset($ForumID, $Forum); - $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. - } + $Forums = Forums::get_forums(); if (empty($_GET['type']) || $_GET['type'] == 'main') { include(SERVER_ROOT.'/sections/ajax/forum/main.php'); @@ -79,33 +28,3 @@ } } } - -// Function to get basic information on a forum -// Uses class CACHE -function get_forum_info($ForumID) { - global $DB, $Cache; - $Forum = $Cache->get_value("ForumInfo_$ForumID"); - if (!$Forum) { - $DB->query(" - SELECT - Name, - MinClassRead, - MinClassWrite, - MinClassCreate, - COUNT(forums_topics.ID) AS Topics - FROM forums - LEFT JOIN forums_topics ON forums_topics.ForumID = forums.ID - WHERE forums.ID = '$ForumID' - GROUP BY ForumID"); - if (!$DB->has_results()) { - return false; - } - // Makes an array, with $Forum['Name'], etc. - $Forum = $DB->next_record(MYSQLI_ASSOC); - - $Cache->cache_value("ForumInfo_$ForumID", $Forum, 86400); // Cache for a day - } - return $Forum; -} - -?> diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index fc194c14..de804a71 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -51,14 +51,14 @@ //---------- Get some data to start processing // Thread information, constant across all pages -$ThreadInfo = get_thread_info($ThreadID, true, true, true); -if ($ThreadInfo == NULL) { +$ThreadInfo = Forums::get_thread_info($ThreadID, true, true); +if ($ThreadInfo === null) { json_die('failure', 'no such thread exists'); } $ForumID = $ThreadInfo['ForumID']; // Make sure they're allowed to look at the page -if (!check_forumperm($ForumID)) { +if (!Forums::check_forumperm($ForumID)) { print json_encode(array('status' => 'failure')); die(); } diff --git a/sections/ajax/raw_bbcode.php b/sections/ajax/raw_bbcode.php index abc50f79..686aa11c 100644 --- a/sections/ajax/raw_bbcode.php +++ b/sections/ajax/raw_bbcode.php @@ -1,7 +1,5 @@ next_record(); -$Forums = get_forums(); -if (!check_forumperm($ForumID)) { +if (!Forums::check_forumperm($ForumID)) { json_die("error", "assholes"); } diff --git a/sections/ajax/top10/index.php b/sections/ajax/top10/index.php index 8b061fc5..b3d238ef 100644 --- a/sections/ajax/top10/index.php +++ b/sections/ajax/top10/index.php @@ -12,16 +12,16 @@ include(SERVER_ROOT.'/sections/ajax/top10/torrents.php'); } else { switch ($_GET['type']) { - case 'users' : + case 'users': include(SERVER_ROOT.'/sections/ajax/top10/users.php'); break; - case 'tags' : + case 'tags': include(SERVER_ROOT.'/sections/ajax/top10/tags.php'); break; - case 'history' : + case 'history': include(SERVER_ROOT.'/sections/ajax/top10/history.php'); break; - default : + default: print json_encode(array('status' => 'failure')); break; } diff --git a/sections/blog/index.php b/sections/blog/index.php index 4d68de56..0a3bbb70 100644 --- a/sections/blog/index.php +++ b/sections/blog/index.php @@ -9,7 +9,7 @@ if (check_perms('admin_manage_blog')) { if (!empty($_REQUEST['action'])) { switch ($_REQUEST['action']) { - case 'deadthread' : + case 'deadthread': if (is_number($_GET['id'])) { $DB->query(" UPDATE blog diff --git a/sections/forums/ajax_get_edit.php b/sections/forums/ajax_get_edit.php index 10a39e6d..4889ff03 100644 --- a/sections/forums/ajax_get_edit.php +++ b/sections/forums/ajax_get_edit.php @@ -40,7 +40,7 @@ } else { //Not an edit, have to get from the original switch ($Type) { - case 'forums' : + case 'forums': //Get from normal forum stuffs $DB->query(" SELECT Body @@ -48,10 +48,10 @@ WHERE ID = $PostID"); list($Body) = $DB->next_record(); break; - case 'collages' : - case 'requests' : - case 'artist' : - case 'torrents' : + case 'collages': + case 'requests': + case 'artist': + case 'torrents': $DB->query(" SELECT Body FROM comments diff --git a/sections/forums/forum.php b/sections/forums/forum.php index 6043761f..4d4ff554 100644 --- a/sections/forums/forum.php +++ b/sections/forums/forum.php @@ -136,6 +136,9 @@ Forum Specific Rules
diff --git a/sections/forums/functions.php b/sections/forums/functions.php deleted file mode 100644 index 3b8e0bbe..00000000 --- a/sections/forums/functions.php +++ /dev/null @@ -1,141 +0,0 @@ -get_value('thread_'.$ThreadID.'_info')) || !isset($ThreadInfo['OP'])) { - $DB->query(" - SELECT - t.Title, - t.ForumID, - t.IsLocked, - t.IsSticky, - COUNT(fp.id) AS Posts, - t.LastPostAuthorID, - ISNULL(p.TopicID) AS NoPoll, - t.StickyPostID, - t.AuthorID as OP, - t.Ranking - FROM forums_topics AS t - JOIN forums_posts AS fp ON fp.TopicID = t.ID - LEFT JOIN forums_polls AS p ON p.TopicID=t.ID - WHERE t.ID = '$ThreadID' - GROUP BY fp.TopicID"); - if (!$DB->has_results()) { - if (!$ApiCall) { - error(404); - } else { - return NULL; - } - } - $ThreadInfo = $DB->next_record(MYSQLI_ASSOC, false); - if ($ThreadInfo['StickyPostID']) { - $ThreadInfo['Posts']--; - $DB->query(" - SELECT - p.ID, - p.AuthorID, - p.AddedTime, - p.Body, - p.EditedUserID, - p.EditedTime, - ed.Username - FROM forums_posts as p - LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID - WHERE p.TopicID = '$ThreadID' - AND p.ID = '".$ThreadInfo['StickyPostID']."'"); - list($ThreadInfo['StickyPost']) = $DB->to_array(false, MYSQLI_ASSOC); - } - if (!$SelectiveCache || !$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { - $Cache->cache_value('thread_'.$ThreadID.'_info', $ThreadInfo, 0); - } - } - if ($Return) { - return $ThreadInfo; - } -} - -function check_forumperm($ForumID, $Perm = 'Read') { - global $LoggedUser, $Forums; - if ($LoggedUser['CustomForums'][$ForumID] == 1) { - return true; - } - if ($Forums[$ForumID]['MinClass'.$Perm] > $LoggedUser['Class'] && (!isset($LoggedUser['CustomForums'][$ForumID]) || $LoggedUser['CustomForums'][$ForumID] == 0)) { - return false; - } - if (isset($LoggedUser['CustomForums'][$ForumID]) && $LoggedUser['CustomForums'][$ForumID] == 0) { - return false; - } - return true; -} - -// Function to get basic information on a forum -// Uses class CACHE -function get_forum_info($ForumID) { - global $DB, $Cache; - $Forum = $Cache->get_value('ForumInfo_'.$ForumID); - if (!$Forum) { - $DB->query(" - SELECT - Name, - MinClassRead, - MinClassWrite, - MinClassCreate, - COUNT(forums_topics.ID) AS Topics - FROM forums - LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID - WHERE forums.ID='$ForumID' - GROUP BY ForumID"); - if (!$DB->has_results()) { - return false; - } - // Makes an array, with $Forum['Name'], etc. - $Forum = $DB->next_record(MYSQLI_ASSOC); - - $Cache->cache_value('ForumInfo_'.$ForumID, $Forum, 86400); // Cache for a day - } - return $Forum; -} - -function get_forums() { - global $DB, $Cache; - if (!$Forums = $Cache->get_value('forums_list')) { - $DB->query(' - SELECT - f.ID, - f.CategoryID, - f.Name, - f.Description, - f.MinClassRead, - f.MinClassWrite, - f.MinClassCreate, - f.NumTopics, - f.NumPosts, - f.LastPostID, - f.LastPostAuthorID, - f.LastPostTopicID, - f.LastPostTime, - COUNT(sr.ThreadID) AS SpecificRules, - t.Title, - t.IsLocked, - t.IsSticky - FROM forums AS f - JOIN forums_categories AS fc ON fc.ID = f.CategoryID - LEFT JOIN forums_topics as t ON t.ID = f.LastPostTopicID - LEFT JOIN forums_specific_rules AS sr ON sr.ForumID = f.ID - GROUP BY f.ID - ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort'); - $Forums = $DB->to_array('ID', MYSQLI_ASSOC, false); - foreach ($Forums as $ForumID => $Forum) { - if (count($Forum['SpecificRules'])) { - $DB->query(" - SELECT ThreadID - FROM forums_specific_rules - WHERE ForumID = $ForumID"); - $ThreadIDs = $DB->collect('ThreadID'); - $Forums[$ForumID]['SpecificRules'] = $ThreadIDs; - } - } - unset($ForumID, $Forum); - $Cache->cache_value('forums_list', $Forums, 0); //Inf cache. - } - return $Forums; -} diff --git a/sections/forums/take_reply.php b/sections/forums/take_reply.php index 6ee7e063..d36eead2 100644 --- a/sections/forums/take_reply.php +++ b/sections/forums/take_reply.php @@ -48,6 +48,9 @@ $TopicID = $_POST['thread']; $ThreadInfo = Forums::get_thread_info($TopicID); +if ($ThreadInfo === null) { + error(404); +} $ForumID = $ThreadInfo['ForumID']; $SQLTime = sqltime(); diff --git a/sections/forums/take_warn.php b/sections/forums/take_warn.php index 5f00d4b1..246f79a2 100644 --- a/sections/forums/take_warn.php +++ b/sections/forums/take_warn.php @@ -88,6 +88,9 @@ $Cache->commit_transaction(3600 * 24 * 5); } $ThreadInfo = Forums::get_thread_info($TopicID); +if ($ThreadInfo === null) { + error(404); +} if ($ThreadInfo['StickyPostID'] == $PostID) { $ThreadInfo['StickyPost']['Body'] = $Body; $ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID']; diff --git a/sections/forums/takeedit.php b/sections/forums/takeedit.php index bf349889..58137192 100644 --- a/sections/forums/takeedit.php +++ b/sections/forums/takeedit.php @@ -104,6 +104,9 @@ $Cache->commit_transaction(3600 * 24 * 5); } $ThreadInfo = Forums::get_thread_info($TopicID); +if ($ThreadInfo === null) { + error(404); +} if ($ThreadInfo['StickyPostID'] == $PostID) { $ThreadInfo['StickyPost']['Body'] = $Body; $ThreadInfo['StickyPost']['EditedUserID'] = $LoggedUser['ID']; diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 2fce84cf..4f21f157 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -49,6 +49,9 @@ // Thread information, constant across all pages $ThreadInfo = Forums::get_thread_info($ThreadID, true, true); +if ($ThreadInfo === null) { + error(404); +} $ForumID = $ThreadInfo['ForumID']; $IsDonorForum = $ForumID == DONOR_FORUM ? true : false; diff --git a/sections/friends/index.php b/sections/friends/index.php index 67cd38e5..2dd51736 100644 --- a/sections/friends/index.php +++ b/sections/friends/index.php @@ -24,7 +24,7 @@ case 'Contact': header('Location: inbox.php?action=compose&to='.$_POST['friendid']); break; - default : + default: error(404); } } else { diff --git a/sections/login/index.php b/sections/login/index.php index 7482294d..72fef109 100644 --- a/sections/login/index.php +++ b/sections/login/index.php @@ -303,8 +303,6 @@ function log_attempt($UserID) { $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; } - - $DB->query(" INSERT INTO users_sessions (UserID, SessionID, KeepLogged, Browser, OperatingSystem, IP, LastUpdate, FullUA) diff --git a/sections/reports/reports.php b/sections/reports/reports.php index 10a81d26..58335ea8 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -26,10 +26,10 @@ } else { $View = $_GET['view']; switch ($_GET['view']) { - case 'old' : + case 'old': $Where = "Status = 'Resolved'"; break; - default : + default: error(404); break; } diff --git a/sections/requests/takevote.php b/sections/requests/takevote.php index a9cda9e2..48a4eb85 100644 --- a/sections/requests/takevote.php +++ b/sections/requests/takevote.php @@ -80,6 +80,7 @@ $UserIDs[] = $UserID; } NotificationsManager::notify_users($UserIDs, NotificationsManager::REQUESTALERTS, Format::get_size($Amount) . " of bounty has been added to a request you've voted on!", "requests.php?action=view&id=" . $RequestID); + } elseif ($LoggedUser['BytesUploaded'] < $Amount) { echo 'bankrupt'; } diff --git a/sections/rules/ratio.php b/sections/rules/ratio.php index d1d04125..a04f05aa 100644 --- a/sections/rules/ratio.php +++ b/sections/rules/ratio.php @@ -101,27 +101,27 @@ bracket. The maximum and minimum required ratios are also referred to as the 0% seeded and 100% seeded required ratios, respectively.
  • 2: Determine the actual required ratio. Your actual required ratio will be a number that falls between the maximum and minimum required ratio values determined in the - previous step. To determine your actual required ratio, the system first uses the maximum required ratio (0% seeded) and multiplies it by the value [1 − (seeding / snatched)]. Formatted + previous step. To determine your actual required ratio, the system first uses the maximum required ratio (0% seeded) and multiplies it by the value [1 − (seeding / snatched)]. Formatted differently, the calculation performed by the system looks like this: +
    +
    +
    + +
    +
    +
    +
  • - -
    -
    - -
    -
    -
    -
    - @@ -147,7 +147,7 @@
  • In this example, Rippy has downloaded 25 GB. Rippy falls into the 20–30 GB amount downloaded bracket in the table above. Rippy's maximum required ratio (0% seeded) is 0.30, and his minimum required ratio (100% seeded) is 0.05.
  • In this example, Rippy has snatched 90 torrents, and is currently seeding 45 torrents.
  • -
  • To calculate Rippy's actual required ratio, we take his maximum required ratio (0% seeded), which is 0.30, and multiply it by [1 − (seeding / snatched)] (which is 0.50). Written out: +
  • To calculate Rippy's actual required ratio, we take his maximum required ratio (0% seeded), which is 0.30, and multiply it by [1 − (seeding / snatched)] (which is 0.50). Written out: 0.3 * [1 − (45 / 90)] = 0.15
  • The resulting required ratio is 0.15, which falls between the maximum required ratio of 0.30 and the minimum required ratio of 0.05 for his amount downloaded bracket.
  • diff --git a/sections/staffpm/assign.php b/sections/staffpm/assign.php index 5ec451a5..e28043cf 100644 --- a/sections/staffpm/assign.php +++ b/sections/staffpm/assign.php @@ -17,13 +17,13 @@ if (!empty($_GET['to'])) { $Level = 0; switch ($_GET['to']) { - case 'forum' : + case 'forum': $Level = 650; break; - case 'staff' : + case 'staff': $Level = 700; break; - default : + default: error(404); break; } diff --git a/sections/staffpm/user_inbox.php b/sections/staffpm/user_inbox.php index ce28290b..92067fad 100644 --- a/sections/staffpm/user_inbox.php +++ b/sections/staffpm/user_inbox.php @@ -1,7 +1,5 @@ +
    +

    +

    @@ -23,7 +26,7 @@ - + to_pair(0, 1, false); ?> -
    +
    -

    Unprocessed Bitcoin donations

    +

    -
    Do not process these donations manually! The bitcoin parser will get them sooner or later (poke a developer if something seems broken).
    +
    Do not process these donations manually! The Bitcoin parser will get them sooner or later (poke a developer if something seems broken).
    UsernameReceiving Bitcoin addressReceiving Bitcoin Address Amount
    - + - - - - + + + + -
    -
    -
    -
    - - -
    -
    Bitcoin addressBitcoin Address UserUnprocessed amount ()Total amountDonor rankSpecial rankUnprocessed Amount (Total: )Total AmountDonor RankSpecial Rank
    - - - - - - - - - - - -
    Enable: - /> - - - /> - - -
    Controls: - - - - - - -
    - -
    - -
    -

    - - - - - - - - - - - - - - - - - - - - - - - - -
    Status
    Total Storage:Used Storage: (%)Free Storage: (%)
    Cached Scripts:Removed Scripts:Cached Keys:N/A
    -

    - - - - - - - -'; -} -$Row = 'a'; // For the pretty colours -foreach ($CachedScripts as $Script) { - list($FilePath, $Modified, $Size, $Reloads, $Uses, $Hits) = array_values($Script); - $Row = $Row === 'a' ? 'b' : 'a'; -?> - - - - - - - -
    File PathAgeSizeHits
    No scripts cached.
    -
    - diff --git a/sections/tools/data/upscale_pool.php b/sections/tools/data/upscale_pool.php index 1eb56f06..262c923c 100644 --- a/sections/tools/data/upscale_pool.php +++ b/sections/tools/data/upscale_pool.php @@ -36,11 +36,15 @@ AND BanReason = '2'"); list($TotalDisabled) = $DB->next_record(); $DB->set_query_id($RS); - +?> +
    +

    Upscale Pool

    +
    +has_results()) { ?> -
    -

    There are currently users queued by the system and already disabled.

    +
    +

    There are currently enabled users on Ratio Watch and already disabled.