diff --git a/classes/donations.class.php b/classes/donations.class.php index 398016e7..7e68453c 100644 --- a/classes/donations.class.php +++ b/classes/donations.class.php @@ -627,7 +627,7 @@ public static function get_leaderboard_position($UserID) { SELECT Position FROM ( SELECT d.UserID, @RowNum := @RowNum + 1 AS Position - FROM users_donor_ranks d + FROM users_donor_ranks AS d ORDER BY TotalRank DESC ) l WHERE UserID = '$UserID'"); diff --git a/classes/forums.class.php b/classes/forums.class.php index aebb5556..7be3cbb9 100644 --- a/classes/forums.class.php +++ b/classes/forums.class.php @@ -47,7 +47,7 @@ public static function get_thread_info($ThreadID, $Return = true, $SelectiveCach p.EditedUserID, p.EditedTime, ed.Username - FROM forums_posts as p + 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'] . "'"); @@ -169,7 +169,7 @@ public static function get_forums() { t.IsSticky AS Sticky 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_topics AS t ON t.ID = f.LastPostTopicID GROUP BY f.ID ORDER BY fc.Sort, fc.Name, f.CategoryID, f.Sort"); $Forums = G::$DB->to_array('ID', MYSQLI_ASSOC, false); @@ -234,15 +234,15 @@ public static function get_last_read($Forums) { CEIL( ( SELECT - COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = l.TopicID - AND forums_posts.ID<=l.PostID + COUNT(p.ID) + FROM forums_posts AS p + WHERE p.TopicID = l.TopicID + AND p.ID <= l.PostID )/$PerPage ) AS Page FROM forums_last_read_topics AS l - WHERE TopicID IN(" . implode(',', $TopicIDs) . ") AND - UserID='" . G::$LoggedUser['ID'] . "'"); + WHERE l.TopicID IN(" . implode(',', $TopicIDs) . ") AND + l.UserID='" . G::$LoggedUser['ID'] . "'"); $LastRead = G::$DB->to_array('TopicID', MYSQLI_ASSOC); G::$DB->set_query_id($QueryID); } else { diff --git a/classes/misc.class.php b/classes/misc.class.php index 2644d06f..cbb626ad 100644 --- a/classes/misc.class.php +++ b/classes/misc.class.php @@ -207,9 +207,9 @@ public static function create_thread($ForumID, $AuthorID, $Title, $PostBody) { array_pop($Forum); } G::$DB->query(" - SELECT f.IsLocked, f.IsSticky, f.NumPosts - FROM forums_topics AS f - WHERE f.ID ='$TopicID'"); + SELECT IsLocked, IsSticky, NumPosts + FROM forums_topics + WHERE ID ='$TopicID'"); list($IsLocked, $IsSticky, $NumPosts) = G::$DB->next_record(); $Part1 = array_slice($Forum, 0, $Stickies, true); //Stickys $Part2 = array( diff --git a/classes/notificationsmanager.class.php b/classes/notificationsmanager.class.php index ddc161d3..74d01a32 100644 --- a/classes/notificationsmanager.class.php +++ b/classes/notificationsmanager.class.php @@ -387,9 +387,9 @@ public function load_collage_subscriptions() { $QueryID = G::$DB->get_query_id(); G::$DB->query(" SELECT COUNT(DISTINCT s.CollageID) - FROM users_collage_subs as s - JOIN collages as c ON s.CollageID = c.ID - JOIN collages_torrents as ct on ct.CollageID = c.ID + FROM users_collage_subs AS s + JOIN collages AS c ON s.CollageID = c.ID + JOIN collages_torrents AS ct ON ct.CollageID = c.ID WHERE s.UserID = " . G::$LoggedUser['ID'] . " AND ct.AddedOn > s.LastVisit AND c.Deleted = '0'"); diff --git a/classes/permissions.class.php b/classes/permissions.class.php index ca9113ea..833b32be 100644 --- a/classes/permissions.class.php +++ b/classes/permissions.class.php @@ -26,8 +26,8 @@ public static function get_permissions($PermissionID) { if (empty($Permission)) { $QueryID = G::$DB->get_query_id(); G::$DB->query(" - SELECT p.Level AS Class, p.Values as Permissions, p.Secondary, p.PermittedForums - FROM permissions AS p + SELECT Level AS Class, `Values` AS Permissions, Secondary, PermittedForums + FROM permissions WHERE ID='$PermissionID'"); $Permission = G::$DB->next_record(MYSQLI_ASSOC, array('Permissions')); G::$DB->set_query_id($QueryID); @@ -53,9 +53,9 @@ public static function get_permissions_for_user($UserID, $CustomPermissions = fa if ($CustomPermissions === false) { $QueryID = G::$DB->get_query_id(); G::$DB->query(' - SELECT um.CustomPermissions - FROM users_main AS um - WHERE um.ID = '.((int)$UserID)); + SELECT CustomPermissions + FROM users_main + WHERE ID = ' . (int)$UserID); list($CustomPermissions) = G::$DB->next_record(MYSQLI_NUM, false); G::$DB->set_query_id($QueryID); } diff --git a/classes/requests.class.php b/classes/requests.class.php index 610b415f..75f43ab3 100644 --- a/classes/requests.class.php +++ b/classes/requests.class.php @@ -205,7 +205,7 @@ public static function get_votes_array($RequestID) { rv.UserID, rv.Bounty, u.Username - FROM requests_votes as rv + FROM requests_votes AS rv LEFT JOIN users_main AS u ON u.ID = rv.UserID WHERE rv.RequestID = $RequestID ORDER BY rv.Bounty DESC"); diff --git a/classes/torrents.class.php b/classes/torrents.class.php index 83266cba..bd50b746 100644 --- a/classes/torrents.class.php +++ b/classes/torrents.class.php @@ -80,9 +80,9 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, $QueryID = G::$DB->get_query_id(); G::$DB->query(" SELECT - g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.TagList, g.ReleaseType, g.VanityHouse, g.WikiImage, g.CategoryID - FROM torrents_group AS g - WHERE g.ID IN ($IDs)"); + ID, Name, Year, RecordLabel, CatalogueNumber, TagList, ReleaseType, VanityHouse, WikiImage, CategoryID + FROM torrents_group + WHERE ID IN ($IDs)"); while ($Group = G::$DB->next_record(MYSQLI_ASSOC, true)) { $NotFound[$Group['ID']] = $Group; @@ -98,7 +98,7 @@ public static function get_groups($GroupIDs, $Return = true, $GetArtists = true, ID, GroupID, Media, Format, Encoding, RemasterYear, Remastered, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Scene, HasLog, HasCue, LogScore, FileCount, FreeTorrent, Size, Leechers, Seeders, Snatched, Time, ID AS HasFile - FROM torrents AS t + FROM torrents WHERE GroupID IN ($IDs) ORDER BY GroupID, Remastered, (RemasterYear != 0) DESC, RemasterYear, RemasterTitle, RemasterRecordLabel, RemasterCatalogueNumber, Media, Format, Encoding, ID"); @@ -399,14 +399,14 @@ public static function delete_group($GroupID) { // Get a count of how many groups or requests use the artist ID G::$DB->query(" SELECT COUNT(ag.ArtistID) - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID WHERE ra.ArtistID IS NOT NULL AND ag.ArtistID = '$ArtistID'"); list($ReqCount) = G::$DB->next_record(); G::$DB->query(" SELECT COUNT(ag.ArtistID) - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID WHERE ta.ArtistID IS NOT NULL AND ag.ArtistID = '$ArtistID'"); diff --git a/classes/wiki.class.php b/classes/wiki.class.php index 64761385..10a193dd 100644 --- a/classes/wiki.class.php +++ b/classes/wiki.class.php @@ -41,8 +41,8 @@ public static function revision_history($Table = '', $PageID = 0, $BaseURL = '') Summary, Time, UserID - FROM $Table AS wiki - WHERE wiki.PageID = $PageID + FROM $Table + WHERE PageID = $PageID ORDER BY RevisionID DESC"); ?> diff --git a/docs/CodingStandards.txt b/docs/CodingStandards.txt index 0b8d6393..8c5d9d5d 100644 --- a/docs/CodingStandards.txt +++ b/docs/CodingStandards.txt @@ -120,6 +120,12 @@ Long SQL queries shall be separated on multiple lines. Short SQL queries may be on a single line. +All SQL keywords shall be uppercase. + +Aliases shall be used to refer to any columns whenever multiple tables are +joined in an SQL query. They shall be using the `tbl_name AS alias_name` +syntax. No table aliases shall be used for single-table queries. + The primary SQL keywords should be at the same indentation level unless part of a JOIN or other complex statement. @@ -128,7 +134,7 @@ Use indents as appropriate to aid readability. The SQL keywords `JOIN`, `RIGHT JOIN`, `LEFT JOIN` must be indented once from the `SELECT` statement. -The SQL keyword `AND` must be indented once from the `WHILE` (and similar) +The SQL keyword `AND` must be indented once from the `WHERE` (and similar) statements. The "not equal to" operator `!=` must be used instead of the alternative diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index e44eaefd..8e185972 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -39,18 +39,18 @@ if (!isset($Forum) || !is_array($Forum)) { $DB->query(" SELECT - t.ID, - t.Title, - t.AuthorID, - t.IsLocked, - t.IsSticky, - t.NumPosts, - t.LastPostID, - t.LastPostTime, - t.LastPostAuthorID - FROM forums_topics AS t - WHERE t.ForumID = '$ForumID' - ORDER BY t.IsSticky DESC, t.LastPostTime DESC + ID, + Title, + AuthorID, + IsLocked, + IsSticky, + NumPosts, + LastPostID, + LastPostTime, + LastPostAuthorID + FROM forums_topics + WHERE ForumID = '$ForumID' + ORDER BY IsSticky DESC, LastPostTime DESC LIMIT $Limit"); // Can be cached until someone makes a new post $Forum = $DB->to_array('ID',MYSQLI_ASSOC, false); if ($Page == 1) { @@ -106,15 +106,15 @@ l.PostID, CEIL( ( - SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = l.TopicID - AND forums_posts.ID <= l.PostID + SELECT COUNT(p.ID) + FROM forums_posts AS p + WHERE p.TopicID = l.TopicID + AND p.ID <= l.PostID ) / $PerPage ) AS Page FROM forums_last_read_topics AS l - WHERE TopicID IN(".implode(', ', array_keys($Forum)).') - AND UserID = \''.$LoggedUser['ID'].'\''); + WHERE l.TopicID IN(".implode(', ', array_keys($Forum)).') + AND l.UserID = \''.$LoggedUser['ID'].'\''); // Turns the result set into a multi-dimensional array, with // forums_last_read_topics.TopicID as the key. diff --git a/sections/ajax/forum/main.php b/sections/ajax/forum/main.php index 09c8e8ae..fcfa1fec 100644 --- a/sections/ajax/forum/main.php +++ b/sections/ajax/forum/main.php @@ -20,13 +20,17 @@ SELECT l.TopicID, l.PostID, - CEIL(( SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = l.TopicID - AND forums_posts.ID <= l.PostID) / $PerPage) AS Page + CEIL( + ( + SELECT COUNT(p.ID) + FROM forums_posts AS p + WHERE p.TopicID = l.TopicID + AND p.ID <= l.PostID + ) / $PerPage + ) AS Page FROM forums_last_read_topics AS l - WHERE TopicID IN(".implode(',', $TopicIDs).") - AND UserID='$LoggedUser[ID]'"); + WHERE l.TopicID IN(".implode(',', $TopicIDs).") + AND l.UserID='$LoggedUser[ID]'"); $LastRead = $DB->to_array('TopicID', MYSQLI_ASSOC); } else { $LastRead = array(); diff --git a/sections/ajax/forum/thread.php b/sections/ajax/forum/thread.php index 2b646c48..382233a3 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -96,7 +96,7 @@ p.Body, p.EditedUserID, p.EditedTime - FROM forums_posts as p + FROM forums_posts AS p WHERE p.TopicID = '$ThreadID' AND p.ID != '".$ThreadInfo['StickyPostID']."' LIMIT $CatalogueLimit"); diff --git a/sections/ajax/inbox/viewconv.php b/sections/ajax/inbox/viewconv.php index b9073801..a3244a45 100644 --- a/sections/ajax/inbox/viewconv.php +++ b/sections/ajax/inbox/viewconv.php @@ -75,7 +75,7 @@ // Get messages $DB->query(" SELECT SentDate, SenderID, Body, ID - FROM pm_messages AS m + FROM pm_messages WHERE ConvID = '$ConvID' ORDER BY ID"); diff --git a/sections/ajax/user.php b/sections/ajax/user.php index 2a2231b7..93072fe0 100644 --- a/sections/ajax/user.php +++ b/sections/ajax/user.php @@ -94,9 +94,9 @@ function check_paranoia_here($Setting) { WHERE r.FillerID = $UserID"); list($RequestsFilled, $TotalBounty) = $DB->next_record(); $DB->query(" - SELECT COUNT(rv.RequestID), SUM(rv.Bounty) - FROM requests_votes AS rv - WHERE rv.UserID = $UserID"); + SELECT COUNT(RequestID), SUM(Bounty) + FROM requests_votes + WHERE UserID = $UserID"); list($RequestsVoted, $TotalSpent) = $DB->next_record(); $DB->query(" @@ -120,9 +120,9 @@ function check_paranoia_here($Setting) { if (check_paranoia_here('artistsadded')) { $DB->query(" - SELECT COUNT(ta.ArtistID) - FROM torrents_artists AS ta - WHERE ta.UserID = $UserID"); + SELECT COUNT(ArtistID) + FROM torrents_artists + WHERE UserID = $UserID"); list($ArtistsAdded) = $DB->next_record(); } else { $ArtistsAdded = 0; @@ -204,10 +204,10 @@ function check_paranoia_here($Setting) { if (check_paranoia_here(array('collagecontribs', 'collagecontribs+'))) { $DB->query(" - SELECT COUNT(DISTINCT CollageID) + SELECT COUNT(DISTINCT ct.CollageID) FROM collages_torrents AS ct - JOIN collages ON CollageID = ID - WHERE Deleted = '0' + JOIN collages AS c ON ct.CollageID = c.ID + WHERE c.Deleted = '0' AND ct.UserID = '$UserID'"); list($NumCollageContribs) = $DB->next_record(); } diff --git a/sections/ajax/userhistory/post_history.php b/sections/ajax/userhistory/post_history.php index b5f1fb6c..3654b95f 100644 --- a/sections/ajax/userhistory/post_history.php +++ b/sections/ajax/userhistory/post_history.php @@ -84,7 +84,7 @@ function error_out($reason = '') { l.PostID AS LastRead, t.IsLocked, t.IsSticky - FROM forums_posts as p + FROM forums_posts AS p LEFT JOIN users_main AS um ON um.ID = p.AuthorID LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID @@ -122,7 +122,7 @@ function error_out($reason = '') { $SQL .= " t.IsLocked, t.IsSticky - FROM forums_posts as p + FROM forums_posts AS p LEFT JOIN users_main AS um ON um.ID = p.AuthorID LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID diff --git a/sections/artist/add_similar.php b/sections/artist/add_similar.php index 05aa250c..566d56c2 100644 --- a/sections/artist/add_similar.php +++ b/sections/artist/add_similar.php @@ -14,9 +14,9 @@ } $DB->query(" - SELECT ag.ArtistID - FROM artists_group AS ag - WHERE ag.Name LIKE '$Artist2Name'"); + SELECT ArtistID + FROM artists_group + WHERE Name LIKE '$Artist2Name'"); list($Artist2ID) = $DB->next_record(); if (!empty($Artist2ID)) { // artist was found in the database @@ -25,7 +25,7 @@ $DB->query(" SELECT s1.SimilarID FROM artists_similar AS s1 - JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID + JOIN artists_similar AS s2 ON s1.SimilarID = s2.SimilarID WHERE s1.ArtistID = '$Artist1ID' AND s2.ArtistID = '$Artist2ID'"); list($SimilarID) = $DB->next_record(); diff --git a/sections/better/files.php b/sections/better/files.php index 5f79b8af..58fee069 100644 --- a/sections/better/files.php +++ b/sections/better/files.php @@ -17,7 +17,7 @@ $Join = ''; $All = true; } else { - $Join = 'JOIN xbt_snatched as x ON x.fid = tfi.TorrentID AND x.uid = '.$LoggedUser['ID']; + $Join = 'JOIN xbt_snatched AS x ON x.fid = tfi.TorrentID AND x.uid = '.$LoggedUser['ID']; $All = false; } diff --git a/sections/better/folders.php b/sections/better/folders.php index 0f50fa70..551da465 100644 --- a/sections/better/folders.php +++ b/sections/better/folders.php @@ -17,7 +17,7 @@ $Join = ''; $All = true; } else { - $Join = "JOIN xbt_snatched as x ON x.fid = tbf.TorrentID AND x.uid = ".$LoggedUser['ID']; + $Join = "JOIN xbt_snatched AS x ON x.fid = tbf.TorrentID AND x.uid = ".$LoggedUser['ID']; $All = false; } diff --git a/sections/better/snatch.php b/sections/better/snatch.php index d8b96bde..ddea9b35 100644 --- a/sections/better/snatch.php +++ b/sections/better/snatch.php @@ -46,16 +46,16 @@ $DB->query(" CREATE TEMPORARY TABLE temp_sections_better_snatch SELECT - t.GroupID, - GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, + GroupID, + GROUP_CONCAT(Encoding SEPARATOR ' ') AS EncodingList, CRC32(CONCAT_WS( ' ', Media, Remasteryear, Remastertitle, Remasterrecordlabel, Remastercataloguenumber) ) AS RemIdent - FROM torrents AS t - WHERE t.GroupID IN(".implode(',', $SnatchedGroupIDs).") - AND t.Format IN ('FLAC', 'MP3') - GROUP BY t.GroupID, RemIdent"); + FROM torrents + WHERE GroupID IN (".implode(',', $SnatchedGroupIDs).") + AND Format IN ('FLAC', 'MP3') + GROUP BY GroupID, RemIdent"); $DB->query(" SELECT GroupID diff --git a/sections/better/tags.php b/sections/better/tags.php index 6de556de..07622c49 100644 --- a/sections/better/tags.php +++ b/sections/better/tags.php @@ -17,7 +17,7 @@ $Join = ''; $All = true; } else { - $Join = "JOIN xbt_snatched as x ON x.fid = tbt.TorrentID AND x.uid = ".$LoggedUser['ID']; + $Join = "JOIN xbt_snatched AS x ON x.fid = tbt.TorrentID AND x.uid = ".$LoggedUser['ID']; $All = false; } diff --git a/sections/better/upload.php b/sections/better/upload.php index b6be6d48..1de3c51e 100644 --- a/sections/better/upload.php +++ b/sections/better/upload.php @@ -34,16 +34,16 @@ $DB->query(" CREATE TEMPORARY TABLE temp_sections_better_upload SELECT - t.GroupID, - GROUP_CONCAT(t.Encoding SEPARATOR ' ') AS EncodingList, + GroupID, + GROUP_CONCAT(Encoding SEPARATOR ' ') AS EncodingList, CRC32(CONCAT_WS( ' ', Media, Remasteryear, Remastertitle, Remasterrecordlabel, Remastercataloguenumber) ) AS RemIdent - FROM torrents AS t - WHERE t.GroupID IN(".implode(',', $UploadedGroupIDs).") - AND t.Format IN ('FLAC', 'MP3') - GROUP BY t.GroupID, RemIdent"); + FROM torrents + WHERE GroupID IN (".implode(',', $UploadedGroupIDs).") + AND Format IN ('FLAC', 'MP3') + GROUP BY GroupID, RemIdent"); $DB->query(" SELECT GroupID diff --git a/sections/forums/ajax_get_edit.php b/sections/forums/ajax_get_edit.php index 4889ff03..c0910ac4 100644 --- a/sections/forums/ajax_get_edit.php +++ b/sections/forums/ajax_get_edit.php @@ -26,10 +26,10 @@ $Edits = $Cache->get_value($Type.'_edits_'.$PostID); if (!is_array($Edits)) { $DB->query(" - SELECT ce.EditUser, ce.EditTime, ce.Body - FROM comments_edits AS ce + SELECT EditUser, EditTime, Body + FROM comments_edits WHERE Page = '$Type' AND PostID = $PostID - ORDER BY ce.EditTime DESC"); + ORDER BY EditTime DESC"); $Edits = $DB->to_array(); $Cache->cache_value($Type.'_edits_'.$PostID, $Edits, 0); } diff --git a/sections/forums/forum.php b/sections/forums/forum.php index 8e22e83b..bd0f281e 100644 --- a/sections/forums/forum.php +++ b/sections/forums/forum.php @@ -37,18 +37,18 @@ if (!isset($Forum) || !is_array($Forum)) { $DB->query(" SELECT - t.ID, - t.Title, - t.AuthorID, - t.IsLocked, - t.IsSticky, - t.NumPosts, - t.LastPostID, - t.LastPostTime, - t.LastPostAuthorID - FROM forums_topics AS t - WHERE t.ForumID = '$ForumID' - ORDER BY t.Ranking = 0, t.Ranking ASC, t.IsSticky DESC, t.LastPostTime DESC + ID, + Title, + AuthorID, + IsLocked, + IsSticky, + NumPosts, + LastPostID, + LastPostTime, + LastPostAuthorID + FROM forums_topics + WHERE ForumID = '$ForumID' + ORDER BY Ranking = 0, Ranking ASC, IsSticky DESC, LastPostTime DESC LIMIT $Limit"); // Can be cached until someone makes a new post $Forum = $DB->to_array('ID', MYSQLI_ASSOC, false); @@ -175,15 +175,15 @@ l.TopicID, l.PostID, CEIL(( - SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = l.TopicID - AND forums_posts.ID <= l.PostID + SELECT COUNT(p.ID) + FROM forums_posts AS p + WHERE p.TopicID = l.TopicID + AND p.ID <= l.PostID ) / $PerPage ) AS Page FROM forums_last_read_topics AS l - WHERE TopicID IN(".implode(', ', array_keys($Forum)).') - AND UserID = \''.$LoggedUser['ID'].'\''); + WHERE l.TopicID IN (".implode(', ', array_keys($Forum)).') + AND l.UserID = \''.$LoggedUser['ID'].'\''); // Turns the result set into a multi-dimensional array, with // forums_last_read_topics.TopicID as the key. diff --git a/sections/forums/get_post.php b/sections/forums/get_post.php index 33efea05..18025edc 100644 --- a/sections/forums/get_post.php +++ b/sections/forums/get_post.php @@ -24,8 +24,8 @@ SELECT p.Body, t.ForumID - FROM forums_posts as p - JOIN forums_topics as t on p.TopicID = t.ID + FROM forums_posts AS p + JOIN forums_topics AS t ON p.TopicID = t.ID WHERE p.ID='$PostID'"); list($Body, $ForumID) = $DB->next_record(MYSQLI_NUM); diff --git a/sections/forums/take_warn.php b/sections/forums/take_warn.php index 4acf9b4f..9e3be20f 100644 --- a/sections/forums/take_warn.php +++ b/sections/forums/take_warn.php @@ -53,15 +53,15 @@ t.ForumID, CEIL( ( - SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = p.TopicID - AND forums_posts.ID <= '$PostID' + SELECT COUNT(p2.ID) + FROM forums_posts AS p2 + WHERE p2.TopicID = p.TopicID + AND p2.ID <= '$PostID' ) / " . POSTS_PER_PAGE . " ) AS Page - FROM forums_posts as p - JOIN forums_topics as t on p.TopicID = t.ID - JOIN forums as f ON t.ForumID = f.ID + FROM forums_posts AS p + JOIN forums_topics AS t ON p.TopicID = t.ID + JOIN forums AS f ON t.ForumID = f.ID WHERE p.ID = '$PostID'"); list($OldBody, $AuthorID, $TopicID, $ForumID, $Page) = $DB->next_record(); diff --git a/sections/forums/takeedit.php b/sections/forums/takeedit.php index aa13b8bc..88622750 100644 --- a/sections/forums/takeedit.php +++ b/sections/forums/takeedit.php @@ -42,15 +42,15 @@ t.ForumID, f.MinClassWrite, CEIL(( - SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = p.TopicID - AND forums_posts.ID <= '$PostID' + SELECT COUNT(p2.ID) + FROM forums_posts AS p2 + WHERE p2.TopicID = p.TopicID + AND p2.ID <= '$PostID' ) / ".POSTS_PER_PAGE." ) AS Page - FROM forums_posts as p - JOIN forums_topics as t on p.TopicID = t.ID - JOIN forums as f ON t.ForumID = f.ID + FROM forums_posts AS p + JOIN forums_topics AS t ON p.TopicID = t.ID + JOIN forums AS f ON t.ForumID = f.ID WHERE p.ID = '$PostID'"); list($OldBody, $AuthorID, $TopicID, $IsLocked, $ForumID, $MinClassWrite, $Page) = $DB->next_record(); diff --git a/sections/forums/thread.php b/sections/forums/thread.php index d48a534c..daa9c4bb 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -102,7 +102,7 @@ p.EditedUserID, p.EditedTime, ed.Username - FROM forums_posts as p + 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']."' diff --git a/sections/forums/warn.php b/sections/forums/warn.php index 738f251d..bc99e8d1 100644 --- a/sections/forums/warn.php +++ b/sections/forums/warn.php @@ -10,8 +10,8 @@ $UserInfo = Users::user_info($UserID); $DB->query(" SELECT p.Body, t.ForumID - FROM forums_posts as p - JOIN forums_topics as t on p.TopicID = t.ID + FROM forums_posts AS p + JOIN forums_topics AS t ON p.TopicID = t.ID WHERE p.ID = '$PostID'"); list($PostBody, $ForumID) = $DB -> next_record(); View::show_header('Warn User'); diff --git a/sections/inbox/conversation.php b/sections/inbox/conversation.php index cc17204d..23e9de9c 100644 --- a/sections/inbox/conversation.php +++ b/sections/inbox/conversation.php @@ -74,7 +74,7 @@ // Get messages $DB->query(" SELECT SentDate, SenderID, Body, ID - FROM pm_messages AS m + FROM pm_messages WHERE ConvID = '$ConvID' ORDER BY ID"); ?> diff --git a/sections/inbox/get_post.php b/sections/inbox/get_post.php index b9295da3..452c082f 100644 --- a/sections/inbox/get_post.php +++ b/sections/inbox/get_post.php @@ -23,7 +23,7 @@ $DB->query(" SELECT m.Body - FROM pm_messages as m + FROM pm_messages AS m JOIN pm_conversations_users AS u ON m.ConvID=u.ConvID WHERE m.ID='$PostID' AND u.UserID=".$LoggedUser['ID']); diff --git a/sections/peerupdate/index.php b/sections/peerupdate/index.php index dbfbb2b4..258f3723 100644 --- a/sections/peerupdate/index.php +++ b/sections/peerupdate/index.php @@ -32,8 +32,8 @@ $DB->query(" INSERT INTO tpc_temp SELECT t2.* - FROM torrents_peerlists t1 - JOIN torrents_peerlists_compare t2 + FROM torrents_peerlists AS t1 + JOIN torrents_peerlists_compare AS t2 USING(TorrentID) WHERE t1.Seeders != t2.Seeders OR t1.Leechers != t2.Leechers diff --git a/sections/questions/questions.php b/sections/questions/questions.php index e253011d..bc55ba48 100644 --- a/sections/questions/questions.php +++ b/sections/questions/questions.php @@ -13,8 +13,8 @@ uq.Date, ( SELECT COUNT(1) - FROM staff_answers - WHERE QuestionID = uq.ID + FROM staff_answers AS sa + WHERE sa.QuestionID = uq.ID ) AS Responses FROM user_questions AS uq WHERE uq.ID NOT IN diff --git a/sections/reports/compose.php b/sections/reports/compose.php index 8129c34f..3042dff2 100644 --- a/sections/reports/compose.php +++ b/sections/reports/compose.php @@ -103,13 +103,13 @@ p.ID, p.Body, p.TopicID, - ( SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = p.TopicID - AND forums_posts.ID<=p.ID + ( SELECT COUNT(p2.ID) + FROM forums_posts AS p2 + WHERE p2.TopicID = p.TopicID + AND p2.ID <= p.ID ) AS PostNum FROM forums_posts AS p - WHERE ID=$ThingID"); + WHERE p.ID = $ThingID"); if (!$DB->has_results()) { $Error = 'No forum post with the reported ID found'; } else { @@ -121,7 +121,7 @@ case 'comment': $DB->query(" SELECT 1 - FROM comments AS c + FROM comments WHERE ID = $ThingID"); if (!$DB->has_results()) { $Error = 'No comment with the reported ID found'; @@ -139,9 +139,9 @@ } $DB->query(" - SELECT r.Reason - FROM reports AS r - WHERE r.ID = $ReportID"); + SELECT Reason + FROM reports + WHERE ID = $ReportID"); list($Reason) = $DB->next_record(); $Body = "You reported $TypeLink for the reason:\n[quote]{$Reason}[/quote]"; diff --git a/sections/reports/reports.php b/sections/reports/reports.php index c22597bc..3bbf30b0 100644 --- a/sections/reports/reports.php +++ b/sections/reports/reports.php @@ -168,24 +168,25 @@ p.ID, p.Body, p.TopicID, - ( SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = p.TopicID - AND forums_posts.ID <= p.ID + ( + SELECT COUNT(p2.ID) + FROM forums_posts AS p2 + WHERE p2.TopicID = p.TopicID + AND p2.ID <= p.ID ) AS PostNum FROM forums_posts AS p - WHERE ID = $ThingID"); + WHERE p.ID = $ThingID"); if (!$DB->has_results()) { echo 'No forum post with the reported ID found'; } else { list($PostID, $Body, $TopicID, $PostNum) = $DB->next_record(); - echo "FORUM POST"; + echo "FORUM POST ID #$PostID"; } break; case 'comment': $DB->query(" SELECT 1 - FROM comments AS c + FROM comments WHERE ID = $ThingID"); if (!$DB->has_results()) { echo 'No comment with the reported ID found'; diff --git a/sections/reports/stats.php b/sections/reports/stats.php index 3b8b8149..69e1c714 100644 --- a/sections/reports/stats.php +++ b/sections/reports/stats.php @@ -154,11 +154,11 @@ query(" SELECT u.Username, - COUNT(LastPostAuthorID) as Trashed - FROM forums_topics as f - LEFT JOIN users_main as u on u.id = LastPostAuthorID - WHERE ForumID = 12 - GROUP BY LastPostAuthorID + COUNT(f.LastPostAuthorID) as Trashed + FROM forums_topics AS f + LEFT JOIN users_main AS u ON u.ID = f.LastPostAuthorID + WHERE f.ForumID = 12 + GROUP BY f.LastPostAuthorID ORDER BY Trashed DESC LIMIT 30"); $Results = $DB->to_array(); diff --git a/sections/reports/takereport.php b/sections/reports/takereport.php index d26e8ebd..01f37892 100644 --- a/sections/reports/takereport.php +++ b/sections/reports/takereport.php @@ -46,13 +46,13 @@ SELECT p.ID, p.TopicID, - ( SELECT COUNT(ID) - FROM forums_posts - WHERE forums_posts.TopicID = p.TopicID - AND forums_posts.ID <= p.ID + ( SELECT COUNT(p2.ID) + FROM forums_posts AS p2 + WHERE p2.TopicID = p.TopicID + AND p2.ID <= p.ID ) AS PostNum FROM forums_posts AS p - WHERE ID = $ID"); + WHERE p.ID = $ID"); list($PostID, $TopicID, $PostNum) = $DB->next_record(); $Link = "forums.php?action=viewthread&threadid=$TopicID&post=$PostNum#post$PostID"; break; diff --git a/sections/reportsv2/views.php b/sections/reportsv2/views.php index 9889cab5..66ee2661 100644 --- a/sections/reportsv2/views.php +++ b/sections/reportsv2/views.php @@ -270,11 +270,11 @@ query(" SELECT - r.Type, - COUNT(r.ID) AS Count - FROM reportsv2 AS r - WHERE r.Status = 'New' - GROUP BY r.Type"); + Type, + COUNT(ID) AS Count + FROM reportsv2 + WHERE Status = 'New' + GROUP BY Type"); $Current = $DB->to_array(); if (!empty($Current)) { ?> diff --git a/sections/requests/take_new_edit.php b/sections/requests/take_new_edit.php index aedd72c3..665e4c6e 100644 --- a/sections/requests/take_new_edit.php +++ b/sections/requests/take_new_edit.php @@ -391,12 +391,12 @@ //1. See if each artist given already exists and if it does, grab the ID. $DB->query(" SELECT - aa.ArtistID, - aa.AliasID, - aa.Name, - aa.Redirect - FROM artists_alias AS aa - WHERE aa.Name = '".db_string($Artist['name'])."'"); + ArtistID, + AliasID, + Name, + Redirect + FROM artists_alias + WHERE Name = '".db_string($Artist['name'])."'"); while (list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) { if (!strcasecmp($Artist['name'], $AliasName)) { @@ -457,14 +457,14 @@ //Get a count of how many groups or requests use the artist ID $DB->query(" SELECT COUNT(ag.ArtistID) - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID WHERE ra.ArtistID IS NOT NULL AND ag.ArtistID = '$ArtistID'"); list($ReqCount) = $DB->next_record(); $DB->query(" SELECT COUNT(ag.ArtistID) - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID WHERE ta.ArtistID IS NOT NULL AND ag.ArtistID = '$ArtistID'"); diff --git a/sections/schedule/index.php b/sections/schedule/index.php index 3bf8c020..8399c568 100644 --- a/sections/schedule/index.php +++ b/sections/schedule/index.php @@ -572,7 +572,7 @@ function next_hour() { INSERT INTO users_torrent_history_snatch (UserID, NumSnatches) SELECT xs.uid, COUNT(DISTINCT xs.fid) FROM xbt_snatched AS xs - JOIN torrents on torrents.ID = xs.fid + JOIN torrents AS t ON t.ID = xs.fid GROUP BY xs.uid"); // Get the fraction of snatched torrents seeded for at least 72 hours this week @@ -864,8 +864,8 @@ function next_hour() { //------------- Demote users --------------------------------------------// sleep(10); $DB->query(' - SELECT um.ID - FROM users_main AS um + SELECT ID + FROM users_main WHERE PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') AND Uploaded / Downloaded < 0.95 OR PermissionID IN('.POWER.', '.ELITE.', '.TORRENT_MASTER.') @@ -889,8 +889,8 @@ function next_hour() { echo "demoted 2\n"; $DB->query(' - SELECT um.ID - FROM users_main AS um + SELECT ID + FROM users_main WHERE PermissionID IN('.MEMBER.', '.POWER.', '.ELITE.', '.TORRENT_MASTER.') AND Uploaded / Downloaded < 0.65'); echo "demoted 3\n"; @@ -1363,7 +1363,7 @@ function next_hour() { $DB->query(" SELECT ID FROM users_main AS um - JOIN users_info AS ui on ui.UserID = um.ID + JOIN users_info AS ui ON ui.UserID = um.ID WHERE um.Enabled = '1' AND ui.DisableInvites = '0' AND ((um.PermissionID = ".POWER." diff --git a/sections/staffpm/ajax_delete_response.php b/sections/staffpm/ajax_delete_response.php index d96a0ac8..de824663 100644 --- a/sections/staffpm/ajax_delete_response.php +++ b/sections/staffpm/ajax_delete_response.php @@ -6,9 +6,9 @@ SELECT i.SupportFor, p.DisplayStaff - FROM users_info as i - JOIN users_main as m ON m.ID = i.UserID - JOIN permissions as p ON p.ID = m.PermissionID + FROM users_info AS i + JOIN users_main AS m ON m.ID = i.UserID + JOIN permissions AS p ON p.ID = m.PermissionID WHERE i.UserID = ".$LoggedUser['ID'] ); list($SupportFor, $DisplayStaff) = $DB->next_record(); diff --git a/sections/staffpm/ajax_edit_response.php b/sections/staffpm/ajax_edit_response.php index 1df04f72..8e19c282 100644 --- a/sections/staffpm/ajax_edit_response.php +++ b/sections/staffpm/ajax_edit_response.php @@ -5,9 +5,9 @@ SELECT i.SupportFor, p.DisplayStaff - FROM users_info as i - JOIN users_main as m ON m.ID = i.UserID - JOIN permissions as p ON p.ID = m.PermissionID + FROM users_info AS i + JOIN users_main AS m ON m.ID = i.UserID + JOIN permissions AS p ON p.ID = m.PermissionID WHERE i.UserID = '.$LoggedUser['ID'] ); list($SupportFor, $DisplayStaff) = $DB->next_record(); diff --git a/sections/staffpm/ajax_get_response.php b/sections/staffpm/ajax_get_response.php index bed77682..e2a6ad7f 100644 --- a/sections/staffpm/ajax_get_response.php +++ b/sections/staffpm/ajax_get_response.php @@ -6,9 +6,9 @@ SELECT i.SupportFor, p.DisplayStaff - FROM users_info as i - JOIN users_main as m ON m.ID = i.UserID - JOIN permissions as p ON p.ID = m.PermissionID + FROM users_info AS i + JOIN users_main AS m ON m.ID = i.UserID + JOIN permissions AS p ON p.ID = m.PermissionID WHERE i.UserID = ".$LoggedUser['ID'] ); list($SupportFor, $DisplayStaff) = $DB->next_record(); diff --git a/sections/staffpm/get_post.php b/sections/staffpm/get_post.php index 175781ee..44060aa5 100644 --- a/sections/staffpm/get_post.php +++ b/sections/staffpm/get_post.php @@ -23,7 +23,7 @@ // the right level $DB->query(" SELECT m.Message, c.Level, c.UserID - FROM staff_pm_messages as m + FROM staff_pm_messages AS m JOIN staff_pm_conversations AS c ON m.ConvID = c.ID WHERE m.ID = '$PostID'"); list($Message, $Level, $UserID) = $DB->next_record(MYSQLI_NUM); diff --git a/sections/staffpm/index.php b/sections/staffpm/index.php index e8d39233..76ce66f5 100644 --- a/sections/staffpm/index.php +++ b/sections/staffpm/index.php @@ -10,9 +10,9 @@ SELECT i.SupportFor, p.DisplayStaff - FROM users_info as i - JOIN users_main as m ON m.ID = i.UserID - JOIN permissions as p ON p.ID = m.PermissionID + FROM users_info AS i + JOIN users_main AS m ON m.ID = i.UserID + JOIN permissions AS p ON p.ID = m.PermissionID WHERE i.UserID = ".$LoggedUser['ID'] ); list($SupportFor, $DisplayStaff) = $DB->next_record(); diff --git a/sections/staffpm/viewconv.php b/sections/staffpm/viewconv.php index cfb4c206..1dcbcbb1 100644 --- a/sections/staffpm/viewconv.php +++ b/sections/staffpm/viewconv.php @@ -187,8 +187,8 @@ SELECT m.ID, m.Username - FROM permissions as p - JOIN users_main as m ON m.PermissionID = p.ID + FROM permissions AS p + JOIN users_main AS m ON m.PermissionID = p.ID WHERE p.DisplayStaff = '1' ORDER BY p.Level DESC, m.Username ASC" ); @@ -206,9 +206,9 @@ SELECT m.ID, m.Username - FROM users_info as i - JOIN users_main as m ON m.ID = i.UserID - JOIN permissions as p ON p.ID = m.PermissionID + FROM users_info AS i + JOIN users_main AS m ON m.ID = i.UserID + JOIN permissions AS p ON p.ID = m.PermissionID WHERE p.DisplayStaff != '1' AND i.SupportFor != '' ORDER BY m.Username ASC diff --git a/sections/tools/data/invite_pool.php b/sections/tools/data/invite_pool.php index dca1e031..9413fe3d 100644 --- a/sections/tools/data/invite_pool.php +++ b/sections/tools/data/invite_pool.php @@ -28,7 +28,7 @@ i.InviteKey, i.Expires, i.Email - FROM invites as i + FROM invites AS i JOIN users_main AS um ON um.ID = i.InviterID "; if ($Search) { $sql .= " diff --git a/sections/tools/data/special_users.php b/sections/tools/data/special_users.php index 99804340..eb2927ae 100644 --- a/sections/tools/data/special_users.php +++ b/sections/tools/data/special_users.php @@ -7,10 +7,10 @@
query(" - SELECT m.ID - FROM users_main AS m - WHERE m.CustomPermissions != '' - AND m.CustomPermissions != 'a:0:{}'"); + SELECT ID + FROM users_main + WHERE CustomPermissions != '' + AND CustomPermissions != 'a:0:{}'"); if ($DB->has_results()) { ?>
diff --git a/sections/tools/managers/bans.php b/sections/tools/managers/bans.php index bd8be1cd..24b1aca8 100644 --- a/sections/tools/managers/bans.php +++ b/sections/tools/managers/bans.php @@ -58,7 +58,7 @@ FromIP, ToIP, Reason - FROM ip_bans AS i "; + FROM ip_bans "; if (!empty($_REQUEST['notes'])) { $sql .= "WHERE Reason LIKE '%".db_string($_REQUEST['notes'])."%' "; diff --git a/sections/tools/managers/dnu_list.php b/sections/tools/managers/dnu_list.php index 6464e4fa..1386391b 100644 --- a/sections/tools/managers/dnu_list.php +++ b/sections/tools/managers/dnu_list.php @@ -12,8 +12,8 @@ d.Comment, d.UserID, d.Time - FROM do_not_upload as d - LEFT JOIN users_main AS um ON um.ID=d.UserID + FROM do_not_upload AS d + LEFT JOIN users_main AS um ON um.ID=d.UserID ORDER BY d.Sequence"); ?>
diff --git a/sections/tools/managers/email_blacklist.php b/sections/tools/managers/email_blacklist.php index 3d1c334c..2a4e68d9 100644 --- a/sections/tools/managers/email_blacklist.php +++ b/sections/tools/managers/email_blacklist.php @@ -9,7 +9,7 @@ $Where = ""; if (!empty($_POST['email'])) { $Email = db_string($_POST['email']); - $Where .= " WHERE eb.Email LIKE '%$Email%'"; + $Where .= " WHERE Email LIKE '%$Email%'"; } if (!empty($_POST['comment'])) { $Comment = db_string($_POST['comment']); @@ -18,19 +18,19 @@ } else { $Where .= " WHERE"; } - $Where .= " eb.Comment LIKE '%$Comment%'"; + $Where .= " Comment LIKE '%$Comment%'"; } $DB->query(" SELECT SQL_CALC_FOUND_ROWS - eb.ID, - eb.UserID, - eb.Time, - eb.Email, - eb.Comment - FROM email_blacklist AS eb + ID, + UserID, + Time, + Email, + Comment + FROM email_blacklist $Where - ORDER BY eb.Time DESC + ORDER BY Time DESC LIMIT $Limit"); $Results = $DB->to_array(false, MYSQLI_ASSOC, false); $DB->query('SELECT FOUND_ROWS()'); diff --git a/sections/tools/managers/email_blacklist_search.php b/sections/tools/managers/email_blacklist_search.php index e648313e..4ea7befb 100644 --- a/sections/tools/managers/email_blacklist_search.php +++ b/sections/tools/managers/email_blacklist_search.php @@ -12,13 +12,13 @@ $DB->query(" SELECT - eb.ID, - eb.UserID, - eb.Time, - eb.Email, - eb.Comment - FROM email_blacklist AS eb - WHERE eb.Email LIKE '%$Search%'"); + ID, + UserID, + Time, + Email, + Comment + FROM email_blacklist + WHERE Email LIKE '%$Search%'"); $EmailResults = $DB->to_array(false, MYSQLI_ASSOC, false); diff --git a/sections/tools/managers/login_watch.php b/sections/tools/managers/login_watch.php index 8833047f..11ab26fa 100644 --- a/sections/tools/managers/login_watch.php +++ b/sections/tools/managers/login_watch.php @@ -14,16 +14,16 @@ $DB->query(' SELECT - l.ID, - l.IP, - l.UserID, - l.LastAttempt, - l.Attempts, - l.BannedUntil, - l.Bans - FROM login_attempts AS l - WHERE l.BannedUntil > "'.sqltime().'" - ORDER BY l.BannedUntil ASC'); + ID, + IP, + UserID, + LastAttempt, + Attempts, + BannedUntil, + Bans + FROM login_attempts + WHERE BannedUntil > "'.sqltime().'" + ORDER BY BannedUntil ASC'); ?>
diff --git a/sections/tools/managers/news.php b/sections/tools/managers/news.php index 1f8c870f..b6accfef 100644 --- a/sections/tools/managers/news.php +++ b/sections/tools/managers/news.php @@ -65,12 +65,12 @@ query(' SELECT - n.ID, - n.Title, - n.Body, - n.Time - FROM news AS n - ORDER BY n.Time DESC');// LIMIT 20 + ID, + Title, + Body, + Time + FROM news + ORDER BY Time DESC');// LIMIT 20 while (list($NewsID, $Title, $Body, $NewsTime) = $DB->next_record()) { ?>
diff --git a/sections/tools/managers/official_tags.php b/sections/tools/managers/official_tags.php index f34b4963..650e26d9 100644 --- a/sections/tools/managers/official_tags.php +++ b/sections/tools/managers/official_tags.php @@ -25,9 +25,9 @@ $TagName = Misc::sanitize_tag($_POST['newtag']); $DB->query(" - SELECT t.ID - FROM tags AS t - WHERE t.Name LIKE '$TagName'"); + SELECT ID + FROM tags + WHERE Name LIKE '$TagName'"); list($TagID) = $DB->next_record(); if ($TagID) { diff --git a/sections/tools/misc/manipulate_tree.php b/sections/tools/misc/manipulate_tree.php index c3c6b72b..2034ba7b 100644 --- a/sections/tools/misc/manipulate_tree.php +++ b/sections/tools/misc/manipulate_tree.php @@ -25,16 +25,16 @@ t1.TreeID, t1.TreeLevel, ( SELECT - t2.TreePosition + t2.TreePosition FROM invite_tree AS t2 - WHERE TreeID=t1.TreeID - AND TreeLevel=t1.TreeLevel - AND t2.TreePosition>t1.TreePosition - ORDER BY TreePosition + WHERE t2.TreeID = t1.TreeID + AND t2.TreeLevel = t1.TreeLevel + AND t2.TreePosition > t1.TreePosition + ORDER BY t2.TreePosition LIMIT 1 ) AS MaxPosition FROM invite_tree AS t1 - WHERE t1.UserID=$UserID"); + WHERE t1.UserID = $UserID"); list ($TreePosition, $TreeID, $TreeLevel, $MaxPosition) = $DB->next_record(); if (!$MaxPosition) { $MaxPosition = 1000000; diff --git a/sections/torrents/add_tag.php b/sections/torrents/add_tag.php index 263dc2e9..948dcb5c 100644 --- a/sections/torrents/add_tag.php +++ b/sections/torrents/add_tag.php @@ -24,9 +24,9 @@ $TagName = Misc::get_alias_tag($TagName); // Check DB for tag matching name $DB->query(" - SELECT t.ID - FROM tags AS t - WHERE t.Name LIKE '$TagName'"); + SELECT ID + FROM tags + WHERE Name LIKE '$TagName'"); list($TagID) = $DB->next_record(); if (!$TagID) { // Tag doesn't exist yet - create tag diff --git a/sections/torrents/delete_alias.php b/sections/torrents/delete_alias.php index ef5d13a7..f7173729 100644 --- a/sections/torrents/delete_alias.php +++ b/sections/torrents/delete_alias.php @@ -33,14 +33,14 @@ // Get a count of how many groups or requests use this artist ID $DB->query(" SELECT ag.ArtistID - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN requests_artists AS ra ON ag.ArtistID = ra.ArtistID WHERE ra.ArtistID IS NOT NULL AND ag.ArtistID = $ArtistID"); $ReqCount = $DB->record_count(); $DB->query(" SELECT ag.ArtistID - FROM artists_group as ag + FROM artists_group AS ag LEFT JOIN torrents_artists AS ta ON ag.ArtistID = ta.ArtistID WHERE ta.ArtistID IS NOT NULL AND ag.ArtistID = $ArtistID"); diff --git a/sections/torrents/downloadlist.php b/sections/torrents/downloadlist.php index f05accb9..2ba50c95 100644 --- a/sections/torrents/downloadlist.php +++ b/sections/torrents/downloadlist.php @@ -15,11 +15,11 @@ $DB->query(" SELECT SQL_CALC_FOUND_ROWS - ud.UserID, - ud.Time - FROM users_downloads AS ud - WHERE ud.TorrentID = '$TorrentID' - ORDER BY ud.Time DESC + UserID, + Time + FROM users_downloads + WHERE TorrentID = '$TorrentID' + ORDER BY Time DESC LIMIT $Limit"); $UserIDs = $DB->collect('UserID'); $Results = $DB->to_array('UserID', MYSQLI_ASSOC); diff --git a/sections/torrents/functions.php b/sections/torrents/functions.php index 95d409ad..b889d1df 100644 --- a/sections/torrents/functions.php +++ b/sections/torrents/functions.php @@ -92,11 +92,11 @@ function get_group_info($GroupID, $Return = true, $RevisionID = 0, $PersonalProp t.ID AS HasFile FROM torrents AS t LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID = t.ID - LEFT JOIN torrents_bad_folders AS tbf on tbf.TorrentID = t.ID - LEFT JOIN torrents_bad_files AS tfi on tfi.TorrentID = t.ID - LEFT JOIN torrents_cassette_approved AS ca on ca.TorrentID = t.ID - LEFT JOIN torrents_lossymaster_approved AS lma on lma.TorrentID = t.ID - LEFT JOIN torrents_lossyweb_approved AS lwa on lwa.TorrentID = t.ID + LEFT JOIN torrents_bad_folders AS tbf ON tbf.TorrentID = t.ID + LEFT JOIN torrents_bad_files AS tfi ON tfi.TorrentID = t.ID + LEFT JOIN torrents_cassette_approved AS ca ON ca.TorrentID = t.ID + LEFT JOIN torrents_lossymaster_approved AS lma ON lma.TorrentID = t.ID + LEFT JOIN torrents_lossyweb_approved AS lwa ON lwa.TorrentID = t.ID LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID = t.ID WHERE t.GroupID = '".db_string($GroupID)."' GROUP BY t.ID @@ -180,9 +180,9 @@ function is_valid_torrenthash($Str) { function torrenthash_to_torrentid($Str) { global $Cache, $DB; $DB->query(" - SELECT t.ID - FROM torrents AS t - WHERE HEX(t.info_hash) = '".db_string($Str)."'"); + SELECT ID + FROM torrents + WHERE HEX(info_hash) = '".db_string($Str)."'"); $TorrentID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($TorrentID) { return $TorrentID; @@ -193,9 +193,9 @@ function torrenthash_to_torrentid($Str) { function torrenthash_to_groupid($Str) { global $Cache, $DB; $DB->query(" - SELECT t.GroupID - FROM torrents AS t - WHERE HEX(t.info_hash) = '".db_string($Str)."'"); + SELECT GroupID + FROM torrents + WHERE HEX(info_hash) = '".db_string($Str)."'"); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($GroupID) { return $GroupID; @@ -206,9 +206,9 @@ function torrenthash_to_groupid($Str) { function torrentid_to_groupid($TorrentID) { global $Cache, $DB; $DB->query(" - SELECT t.GroupID - FROM torrents AS t - WHERE t.ID = '".db_string($TorrentID)."'"); + SELECT GroupID + FROM torrents + WHERE ID = '".db_string($TorrentID)."'"); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($GroupID) { return $GroupID; diff --git a/sections/torrents/redownload.php b/sections/torrents/redownload.php index 7015900d..8deb0a7b 100644 --- a/sections/torrents/redownload.php +++ b/sections/torrents/redownload.php @@ -56,7 +56,7 @@ IF(t.RemasterYear=0,tg.Year,t.RemasterYear) AS Year, tg.Name, t.Size - FROM torrents as t + FROM torrents AS t JOIN torrents_group AS tg ON t.GroupID=tg.ID $SQL GROUP BY TorrentID"); diff --git a/sections/torrents/snatchlist.php b/sections/torrents/snatchlist.php index f108c719..2d1298c1 100644 --- a/sections/torrents/snatchlist.php +++ b/sections/torrents/snatchlist.php @@ -15,11 +15,11 @@ $Result = $DB->query(" SELECT SQL_CALC_FOUND_ROWS - xs.uid, - xs.tstamp - FROM xbt_snatched AS xs - WHERE xs.fid = '$TorrentID' - ORDER BY xs.tstamp DESC + uid, + tstamp + FROM xbt_snatched + WHERE fid = '$TorrentID' + ORDER BY tstamp DESC LIMIT $Limit"); $Results = $DB->to_array('uid', MYSQLI_ASSOC); diff --git a/sections/upload/upload.php b/sections/upload/upload.php index 0aeee258..74a29e3a 100644 --- a/sections/upload/upload.php +++ b/sections/upload/upload.php @@ -52,16 +52,16 @@ } elseif (empty($Properties) && !empty($_GET['requestid']) && is_number($_GET['requestid'])) { $DB->query(' SELECT - r.ID AS RequestID, - r.CategoryID, - r.Title AS Title, - r.Year, - r.RecordLabel, - r.CatalogueNumber, - r.ReleaseType, - r.Image - FROM requests AS r - WHERE r.ID = '.$_GET['requestid']); + ID AS RequestID, + CategoryID, + Title AS Title, + Year, + RecordLabel, + CatalogueNumber, + ReleaseType, + Image + FROM requests + WHERE ID = '.$_GET['requestid']); list($Properties) = $DB->to_array(false, MYSQLI_BOTH); $UploadForm = $Categories[$Properties['CategoryID'] - 1]; @@ -95,17 +95,17 @@ $DB->query(' SELECT - d.Name, - d.Comment, - d.Time - FROM do_not_upload as d - ORDER BY d.Sequence'); + Name, + Comment, + Time + FROM do_not_upload + ORDER BY Sequence'); $DNU = $DB->to_array(); -list($Name, $Comment, $Updated) = reset($DNU); -reset($DNU); +$DB->query('SELECT MAX(Time) FROM do_not_upload'); +list($Updated) = $DB->next_record(); $DB->query(" - SELECT IF(MAX(t.Time) < '$Updated' OR MAX(t.Time) IS NULL, 1, 0) - FROM torrents AS t + SELECT IF(MAX(Time) IS NULL OR MAX(Time) < '$Updated', 1, 0) + FROM torrents WHERE UserID = ".$LoggedUser['ID']); list($NewDNU) = $DB->next_record(); $HideDNU = check_perms('torrents_hide_dnu') && !$NewDNU; diff --git a/sections/upload/upload_handle.php b/sections/upload/upload_handle.php index ec85c82e..39708673 100644 --- a/sections/upload/upload_handle.php +++ b/sections/upload/upload_handle.php @@ -444,16 +444,16 @@ if ($Properties['GroupID']) { $DB->query(" SELECT - tg.id, - tg.WikiImage, - tg.WikiBody, - tg.RevisionID, - tg.Name, - tg.Year, - tg.ReleaseType, - tg.TagList - FROM torrents_group AS tg - WHERE tg.id = ".$Properties['GroupID']); + ID, + WikiImage, + WikiBody, + RevisionID, + Name, + Year, + ReleaseType, + TagList + FROM torrents_group + WHERE id = ".$Properties['GroupID']); if ($DB->has_results()) { // Don't escape tg.Name. It's written directly to the log table list($GroupID, $WikiImage, $WikiBody, $RevisionID, $Properties['Title'], $Properties['Year'], $Properties['ReleaseType'], $Properties['TagList']) = $DB->next_record(MYSQLI_NUM, array(4)); @@ -508,12 +508,12 @@ // The album hasn't been uploaded. Try to get the artist IDs $DB->query(" SELECT - aa.ArtistID, - aa.AliasID, - aa.Name, - aa.Redirect - FROM artists_alias AS aa - WHERE aa.Name = '".db_string($Artist['name'])."'"); + ArtistID, + AliasID, + Name, + Redirect + FROM artists_alias + WHERE Name = '".db_string($Artist['name'])."'"); if ($DB->has_results()) { while (list($ArtistID, $AliasID, $AliasName, $Redirect) = $DB->next_record(MYSQLI_NUM, false)) { if (!strcasecmp($Artist['name'], $AliasName)) { diff --git a/sections/user/advancedsearch.php b/sections/user/advancedsearch.php index 19e48e2f..62a1cfda 100644 --- a/sections/user/advancedsearch.php +++ b/sections/user/advancedsearch.php @@ -1,8 +1,4 @@ ->>>>>>>>>>>>>>>>>>>>>>>>>> User search <<<<<<<<<<<<<<<<<<<<<<<<<<<<* - * Best viewed with a wide screen monitor * - **********************************************************************/ +
- +
@@ -739,9 +739,9 @@ function checked($Checked) { query(" - SELECT COUNT(ta.ArtistID) - FROM torrents_artists AS ta - WHERE ta.UserID = $UserID"); + SELECT COUNT(ArtistID) + FROM torrents_artists + WHERE UserID = $UserID"); list($ArtistsAdded) = $DB->next_record(); ?>
diff --git a/sections/user/index.php b/sections/user/index.php index af0142fb..77a2b2f4 100644 --- a/sections/user/index.php +++ b/sections/user/index.php @@ -42,8 +42,8 @@ case 'edit': include('edit.php'); break; - case 'takeedit': - include('takeedit.php'); + case 'take_edit': + include('take_edit.php'); break; case 'invitetree': include(SERVER_ROOT.'/sections/user/invitetree.php'); @@ -51,11 +51,11 @@ case 'invite': include('invite.php'); break; - case 'takeinvite': - include('takeinvite.php'); + case 'take_invite': + include('take_invite.php'); break; - case 'deleteinvite': - include('deleteinvite.php'); + case 'delete_invite': + include('delete_invite.php'); break; case 'sessions': include('sessions.php'); diff --git a/sections/user/invite.php b/sections/user/invite.php index dbdac26a..e571a45c 100644 --- a/sections/user/invite.php +++ b/sections/user/invite.php @@ -88,7 +88,7 @@ Downloaded, JoinDate, LastAccess - FROM users_main as um + FROM users_main AS um LEFT JOIN users_info AS ui ON ui.UserID = um.ID WHERE ui.Inviter = '$UserID' ORDER BY $OrderBy $CurrentSort"); @@ -144,7 +144,7 @@
- +
@@ -194,7 +194,7 @@ - +
Delete inviteDelete invite
diff --git a/sections/user/notify_handle.php b/sections/user/notify_handle.php index 1d8581de..a3f93bec 100644 --- a/sections/user/notify_handle.php +++ b/sections/user/notify_handle.php @@ -128,10 +128,10 @@ } $DB->query(" - SELECT m.ID, m.Paranoia - FROM users_main AS m - WHERE m.Username IN ('" . implode("', '", $EscapedUsernames) . "') - AND m.ID != $LoggedUser[ID]"); + SELECT ID, Paranoia + FROM users_main + WHERE Username IN ('" . implode("', '", $EscapedUsernames) . "') + AND ID != $LoggedUser[ID]"); while (list($UserID, $Paranoia) = $DB->next_record()) { $Paranoia = unserialize($Paranoia); if (!in_array('notifications', $Paranoia)) { diff --git a/sections/user/permissions.php b/sections/user/permissions.php index e7b9f4c7..eef02707 100644 --- a/sections/user/permissions.php +++ b/sections/user/permissions.php @@ -12,9 +12,9 @@ list($UserID, $Username, $PermissionID) = array_values(Users::user_info($_REQUEST['userid'])); $DB->query(" - SELECT u.CustomPermissions - FROM users_main AS u - WHERE u.ID='$UserID'"); + SELECT CustomPermissions + FROM users_main + WHERE ID='$UserID'"); list($Customs)=$DB->next_record(MYSQLI_NUM, false); diff --git a/sections/user/takeedit.php b/sections/user/take_edit.php similarity index 100% rename from sections/user/takeedit.php rename to sections/user/take_edit.php diff --git a/sections/user/takeinvite.php b/sections/user/take_invite.php similarity index 100% rename from sections/user/takeinvite.php rename to sections/user/take_invite.php diff --git a/sections/user/takemoderate.php b/sections/user/takemoderate.php index ba41b44f..bea2824a 100644 --- a/sections/user/takemoderate.php +++ b/sections/user/takemoderate.php @@ -525,7 +525,7 @@ if ($DisableAvatar != $Cur['DisableAvatar'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableAvatar = '$DisableAvatar'"; - $EditSummary[] = "avatar status changed"; + $EditSummary[] = 'avatar privileges ' . ($DisableAvatar ? 'disabled' : 'enabled'); $HeavyUpdates['DisableAvatar'] = $DisableAvatar; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your avatar privileges have been disabled', "Your avatar privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -551,13 +551,13 @@ Misc::send_pm($UserID, 0, 'Your invite privileges have been disabled', "Your invite privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); } } - $EditSummary[] = 'invites status changed'; + $EditSummary[] = 'invites privileges ' . ($DisableInvites ? 'disabled' : 'enabled'); $HeavyUpdates['DisableInvites'] = $DisableInvites; } if ($DisablePosting != $Cur['DisablePosting'] && check_perms('users_disable_posts')) { $UpdateSet[] = "DisablePosting = '$DisablePosting'"; - $EditSummary[] = 'posting status changed'; + $EditSummary[] = 'posting privileges ' . ($DisablePosting ? 'disabled' : 'enabled'); $HeavyUpdates['DisablePosting'] = $DisablePosting; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your forum posting privileges have been disabled', "Your forum posting privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -566,7 +566,7 @@ if ($DisableForums != $Cur['DisableForums'] && check_perms('users_disable_posts')) { $UpdateSet[] = "DisableForums = '$DisableForums'"; - $EditSummary[] = 'forums status changed'; + $EditSummary[] = 'forums privileges ' . ($DisableForums ? 'disabled' : 'enabled'); $HeavyUpdates['DisableForums'] = $DisableForums; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your forum privileges have been disabled', "Your forum privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -575,7 +575,7 @@ if ($DisableTagging != $Cur['DisableTagging'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableTagging = '$DisableTagging'"; - $EditSummary[] = 'tagging status changed'; + $EditSummary[] = 'tagging privileges ' . ($DisableTagging ? 'disabled' : 'enabled'); $HeavyUpdates['DisableTagging'] = $DisableTagging; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your tagging privileges have been disabled', "Your tagging privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -584,7 +584,7 @@ if ($DisableUpload != $Cur['DisableUpload'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableUpload = '$DisableUpload'"; - $EditSummary[] = 'upload status changed'; + $EditSummary[] = 'upload privileges ' . ($DisableUpload ? 'disabled' : 'enabled'); $HeavyUpdates['DisableUpload'] = $DisableUpload; if ($DisableUpload == 1) { Misc::send_pm($UserID, 0, 'Your upload privileges have been disabled', "Your upload privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -593,7 +593,7 @@ if ($DisableWiki != $Cur['DisableWiki'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableWiki = '$DisableWiki'"; - $EditSummary[] = 'wiki status changed'; + $EditSummary[] = 'wiki privileges ' . ($DisableWiki ? 'disabled' : 'enabled'); $HeavyUpdates['DisableWiki'] = $DisableWiki; $HeavyUpdates['site_edit_wiki'] = 0; if (!empty($UserReason)) { @@ -604,7 +604,7 @@ if ($DisablePM != $Cur['DisablePM'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisablePM = '$DisablePM'"; - $EditSummary[] = 'PM status changed'; + $EditSummary[] = 'PM privileges ' . ($DisablePM ? 'disabled' : 'enabled'); $HeavyUpdates['DisablePM'] = $DisablePM; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your PM privileges have been disabled', "Your PM privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); @@ -613,7 +613,7 @@ if ($DisableIRC != $Cur['DisableIRC'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableIRC = '$DisableIRC'"; - $EditSummary[] = 'IRC status changed'; + $EditSummary[] = 'IRC privileges ' . ($DisableIRC ? 'disabled' : 'enabled'); $HeavyUpdates['DisableIRC'] = $DisableIRC; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your IRC privileges have been disabled', "Your IRC privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in '.BOT_DISABLED_CHAN.'.'); @@ -622,7 +622,7 @@ if ($DisableRequests != $Cur['DisableRequests'] && check_perms('users_disable_any')) { $UpdateSet[] = "DisableRequests = '$DisableRequests'"; - $EditSummary[] = 'request status changed'; + $EditSummary[] = 'request privileges ' . ($DisableRequests ? 'disabled' : 'enabled'); $HeavyUpdates['DisableRequests'] = $DisableRequests; if (!empty($UserReason)) { Misc::send_pm($UserID, 0, 'Your request privileges have been disabled', "Your request privileges have been disabled. The reason given was: $UserReason. If you would like to discuss this, please join ".BOT_DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&name=IRC+-+How+to+join]here[/url].'); diff --git a/sections/user/user.php b/sections/user/user.php index 8772bf0b..fb0832dd 100644 --- a/sections/user/user.php +++ b/sections/user/user.php @@ -308,9 +308,9 @@ function check_paranoia_here($Setting) { if (check_paranoia_here('requestsvoted_count') || check_paranoia_here('requestsvoted_bounty')) { $DB->query(" - SELECT COUNT(rv.RequestID), SUM(rv.Bounty) - FROM requests_votes AS rv - WHERE rv.UserID = $UserID"); + SELECT COUNT(RequestID), SUM(Bounty) + FROM requests_votes + WHERE UserID = $UserID"); list($RequestsVoted, $TotalSpent) = $DB->next_record(); $DB->query(" SELECT COUNT(r.ID), SUM(rv.Bounty) @@ -334,9 +334,9 @@ function check_paranoia_here($Setting) { if (check_paranoia_here('artistsadded')) { $DB->query(" - SELECT COUNT(ta.ArtistID) - FROM torrents_artists AS ta - WHERE ta.UserID = $UserID"); + SELECT COUNT(ArtistID) + FROM torrents_artists + WHERE UserID = $UserID"); list($ArtistsAdded) = $DB->next_record(); } else { $ArtistsAdded = 0; diff --git a/sections/userhistory/email_history.php b/sections/userhistory/email_history.php index ca847cd6..25f6fcdc 100644 --- a/sections/userhistory/email_history.php +++ b/sections/userhistory/email_history.php @@ -118,13 +118,13 @@ $ueQuery = $DB->query(" SELECT ue.UserID, - Username, + um.Username, ue.Time, ue.IP - FROM users_history_emails AS ue, users_main + FROM users_history_emails AS ue, users_main AS um WHERE ue.Email = '".db_string($Values['Email'])."' - AND UserID != $UserID - AND ID = UserID"); + AND ue.UserID != $UserID + AND um.ID = ue.UserID"); while (list($UserID2, $Time, $IP) = $DB->next_record()) { ?> diff --git a/sections/userhistory/post_history.php b/sections/userhistory/post_history.php index 1c8868fc..3e57f62e 100644 --- a/sections/userhistory/post_history.php +++ b/sections/userhistory/post_history.php @@ -76,7 +76,7 @@ l.PostID AS LastRead, t.IsLocked, t.IsSticky - FROM forums_posts as p + FROM forums_posts AS p LEFT JOIN users_main AS um ON um.ID = p.AuthorID LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID @@ -115,7 +115,7 @@ $sql .= " t.IsLocked, t.IsSticky - FROM forums_posts as p + FROM forums_posts AS p LEFT JOIN users_main AS um ON um.ID = p.AuthorID LEFT JOIN users_info AS ui ON ui.UserID = p.AuthorID LEFT JOIN users_main AS ed ON ed.ID = p.EditedUserID diff --git a/sections/wiki/revisions.php b/sections/wiki/revisions.php index 509e5b0e..d2d9ad43 100644 --- a/sections/wiki/revisions.php +++ b/sections/wiki/revisions.php @@ -42,12 +42,12 @@ query(" SELECT - w.Revision, - w.Title, - w.Author, - w.Date - FROM wiki_revisions AS w - WHERE w.ID='$ArticleID' + Revision, + Title, + Author, + Date + FROM wiki_revisions + WHERE ID = '$ArticleID' ORDER BY Revision DESC"); while (list($Revision, $Title, $AuthorID, $Date) = $DB->next_record()) { ?> diff --git a/sections/wiki/search.php b/sections/wiki/search.php index 3a5644b3..108966b5 100644 --- a/sections/wiki/search.php +++ b/sections/wiki/search.php @@ -11,15 +11,15 @@ $OrderVals = array('Title', 'Created', 'Edited'); $WayVals = array('Ascending', 'Descending'); -$TypeTable = array('Title'=>'w.Title', 'Body'=>'w.Body'); -$OrderTable = array('Title'=>'w.Title', 'Created'=>'w.ID', 'Edited'=>'w.Date'); +$TypeTable = array('Title'=>'Title', 'Body'=>'Body'); +$OrderTable = array('Title'=>'Title', 'Created'=>'ID', 'Edited'=>'Date'); $WayTable = array('Ascending'=>'ASC', 'Descending'=>'DESC'); // What are we looking for? Let's make sure it isn't dangerous. $Search = db_string(trim($_GET['search'])); -if (!in_array($Type, array('w.Title', 'w.Body'))) { - $Type = 'w.Title'; +if (!in_array($Type, array('Title', 'Body'))) { + $Type = 'Title'; } // Break search string down into individual words @@ -27,7 +27,7 @@ $Type = $TypeTable[$_GET['type']]; if (!$Type) { - $Type = 'w.Title'; + $Type = 'Title'; } $Order = $OrderTable[$_GET['order']]; @@ -43,12 +43,12 @@ $SQL = " SELECT SQL_CALC_FOUND_ROWS - w.ID, - w.Title, - w.Date, - w.Author - FROM wiki_articles AS w - WHERE w.MinClassRead <= '".$LoggedUser['EffectiveClass']."'"; + ID, + Title, + Date, + Author + FROM wiki_articles + WHERE MinClassRead <= '".$LoggedUser['EffectiveClass']."'"; if ($Search != '') { $SQL .= " AND $Type LIKE '%"; $SQL .= implode("%' AND $Type LIKE '%", $Words); @@ -89,8 +89,8 @@ Search in: - - + + Order by: diff --git a/sections/wiki/wiki_browse.php b/sections/wiki/wiki_browse.php index 1b11b404..41c557d4 100644 --- a/sections/wiki/wiki_browse.php +++ b/sections/wiki/wiki_browse.php @@ -12,14 +12,14 @@ $sql = " SELECT SQL_CALC_FOUND_ROWS - w.ID, - w.Title, - w.Date, - w.Author - FROM wiki_articles AS w - WHERE w.MinClassRead <= '".$LoggedUser['EffectiveClass']."'"; + ID, + Title, + Date, + Author + FROM wiki_articles + WHERE MinClassRead <= '".$LoggedUser['EffectiveClass']."'"; if ($Letter !== '1') { - $sql .= " AND LEFT(w.Title,1) = '".db_string($Letter)."'"; + $sql .= " AND LEFT(Title,1) = '".db_string($Letter)."'"; } else { $Letter = 'All'; }