diff --git a/artist.php b/artist.php index 0e1a3153..3af9f084 100644 --- a/artist.php +++ b/artist.php @@ -1,4 +1,3 @@ warnings(); // see comment in MYSQL::query + $Queries = $this->get_queries(); + $DBWarningCount = 0; + foreach ($Queries as $Query) { + if (!empty($Query[2])) { + $DBWarningCount += count($Query[2]); + } + } + if ($DBWarningCount) { + $Reason[] = $DBWarningCount . ' DB warning(s)'; + } + if (isset($_REQUEST['profile'])) { global $LoggedUser; $Reason[] = 'Requested by '.$LoggedUser['Username']; @@ -477,6 +489,7 @@ public function cache_table($CacheKeys = false) { + Clear this cache key @@ -542,11 +555,13 @@ public function query_table($Queries=false) { ', $Warnings); ?> + warnings manually + * for the last query! + */ + if ($this->QueryID) { + $this->warnings(); + } $QueryStartTime = microtime(true); $this->connect(); // In the event of a MySQL deadlock, we sleep allowing MySQL time to unlock, then attempt again for a maximum of 5 tries @@ -218,7 +231,7 @@ function query($Query, $AutoHandle = 1) { sleep($i * rand(2, 5)); // Wait longer as attempts increase } $QueryEndTime = microtime(true); - $this->Queries[] = array(display_str($Query), ($QueryEndTime - $QueryStartTime) * 1000); + $this->Queries[] = array(display_str($Query), ($QueryEndTime - $QueryStartTime) * 1000, null); $this->Time += ($QueryEndTime-$QueryStartTime) * 1000; if (!$this->QueryID) { @@ -232,8 +245,8 @@ function query($Query, $AutoHandle = 1) { } } - $QueryType = substr($Query,0, 6); /* + $QueryType = substr($Query,0, 6); if ($QueryType == 'DELETE' || $QueryType == 'UPDATE') { if ($this->affected_rows() > 50) { $Debug->analysis($this->affected_rows().' rows altered:', $Query, 3600 * 24); @@ -364,5 +377,24 @@ function beginning() { mysqli_data_seek($this->QueryID, 0); $this->Row = 0; } + + /** + * This function determines whether the last query caused warning messages + * and stores them in $this->Queries. + */ + function warnings() { + $Warnings = array(); + if (mysqli_warning_count($this->LinkID)) { + $e = mysqli_get_warnings($this->LinkID); + do { + if ($e->errno == 1592) { + // 1592: Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT. + continue; + } + $Warnings[] = 'Code ' . $e->errno . ': ' . display_str($e->message); + } while ($e->next()); + } + $this->Queries[count($this->Queries) - 1][2] = $Warnings; + } } ?> diff --git a/classes/text.class.php b/classes/text.class.php index c05367eb..1b3550b7 100644 --- a/classes/text.class.php +++ b/classes/text.class.php @@ -658,7 +658,7 @@ private function to_html ($Array) { $Str .= ''.$Block['Val'].''; break; case 'tex': - $Str .= ''.$Block['Val'].''; + $Str .= ''.$Block['Val'].''; break; case 'plain': $Str .= $Block['Val']; diff --git a/design/privateheader.php b/design/privateheader.php index 595eede5..a17c392c 100644 --- a/design/privateheader.php +++ b/design/privateheader.php @@ -694,4 +694,4 @@ class="stat" -
\ No newline at end of file +
diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index ee5344fe..dff4b40e 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,8 @@ CHANGELOG +2013-07-01 by alderaan +Serve Google Charts API images over HTTPS + 2013-07-01 by Ajax Moved autocomplete logic to jquery plugin, introduced artist autocompletes on rest of site diff --git a/sections/ajax/forum/forum.php b/sections/ajax/forum/forum.php index 32eaf29e..b93b5fe1 100644 --- a/sections/ajax/forum/forum.php +++ b/sections/ajax/forum/forum.php @@ -34,7 +34,7 @@ // Caching anything beyond the first page of any given forum is just wasting ram // users are more likely to search then to browse to page 2 if ($Page == 1) { - list($Forum,,,$Stickies) = $Cache->get_value('forums_'.$ForumID); + list($Forum,,,$Stickies) = $Cache->get_value("forums_$ForumID"); } if (!isset($Forum) || !is_array($Forum)) { $DB->query(" @@ -57,10 +57,10 @@ $DB->query(" SELECT COUNT(ID) FROM forums_topics - WHERE ForumID='$ForumID' - AND IsSticky='1'"); + WHERE ForumID = '$ForumID' + AND IsSticky = '1'"); list($Stickies) = $DB->next_record(); - $Cache->cache_value('forums_'.$ForumID, array($Forum, '', 0, $Stickies), 0); + $Cache->cache_value("forums_$ForumID", array($Forum, '', 0, $Stickies), 0); } } diff --git a/sections/ajax/forum/index.php b/sections/ajax/forum/index.php index 5bb791ec..245cdd30 100644 --- a/sections/ajax/forum/index.php +++ b/sections/ajax/forum/index.php @@ -5,14 +5,15 @@ if (!empty($LoggedUser['DisableForums'])) { print json_encode(array('status' => 'failure')); die(); -} -else { +} 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"); + $DB->query(" + SELECT ID, Name + FROM forums_categories"); $ForumCats = array(); while (list($ID, $Name) = $DB->next_record()) { $ForumCats[$ID] = $Name; @@ -83,7 +84,7 @@ // Uses class CACHE function get_forum_info($ForumID) { global $DB, $Cache; - $Forum = $Cache->get_value('ForumInfo_'.$ForumID); + $Forum = $Cache->get_value("ForumInfo_$ForumID"); if (!$Forum) { $DB->query(" SELECT @@ -93,8 +94,8 @@ function get_forum_info($ForumID) { MinClassCreate, COUNT(forums_topics.ID) AS Topics FROM forums - LEFT JOIN forums_topics ON forums_topics.ForumID=forums.ID - WHERE forums.ID='$ForumID' + LEFT JOIN forums_topics ON forums_topics.ForumID = forums.ID + WHERE forums.ID = '$ForumID' GROUP BY ForumID"); if ($DB->record_count() == 0) { return false; @@ -102,7 +103,7 @@ function get_forum_info($ForumID) { // Makes an array, with $Forum['Name'], etc. $Forum = $DB->next_record(MYSQLI_ASSOC); - $Cache->cache_value('ForumInfo_'.$ForumID, $Forum, 86400); // Cache for a day + $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 f0ec9994..0f28a260 100644 --- a/sections/ajax/forum/thread.php +++ b/sections/ajax/forum/thread.php @@ -150,17 +150,17 @@ $JsonPoll = array(); if ($ThreadInfo['NoPoll'] == 0) { - if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value('polls_'.$ThreadID)) { + if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value("polls_$ThreadID")) { $DB->query(" SELECT Question, Answers, Featured, Closed FROM forums_polls - WHERE TopicID='$ThreadID'"); + WHERE TopicID = '$ThreadID'"); list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1)); $Answers = unserialize($Answers); $DB->query(" SELECT Vote, COUNT(UserID) FROM forums_polls_votes - WHERE TopicID='$ThreadID' + WHERE TopicID = '$ThreadID' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); @@ -175,7 +175,7 @@ $Votes[$i] = 0; } } - $Cache->cache_value('polls_'.$ThreadID, array($Question, $Answers, $Votes, $Featured, $Closed), 0); + $Cache->cache_value("polls_$ThreadID", array($Question, $Answers, $Votes, $Featured, $Closed), 0); } if (!empty($Votes)) { @@ -191,8 +191,8 @@ $DB->query(" SELECT Vote FROM forums_polls_votes - WHERE UserID='".$LoggedUser['ID']."' - AND TopicID='$ThreadID'"); + WHERE UserID = '".$LoggedUser['ID']."' + AND TopicID = '$ThreadID'"); list($UserResponse) = $DB->next_record(); if (!empty($UserResponse) && $UserResponse != 0) { $Answers[$UserResponse] = '» '.$Answers[$UserResponse]; diff --git a/sections/artist/artist.php b/sections/artist/artist.php index f61de29a..40fbc543 100644 --- a/sections/artist/artist.php +++ b/sections/artist/artist.php @@ -939,7 +939,7 @@ function require(file, callback) { // --- Comments --- // gets the amount of comments for this group -$Results = $Cache->get_value('artist_comments_'.$ArtistID); +$Results = $Cache->get_value("artist_comments_$ArtistID"); if ($Results === false) { $DB->query(" SELECT @@ -947,7 +947,7 @@ function require(file, callback) { FROM artist_comments as c WHERE c.ArtistID = '$ArtistID'"); list($Results) = $DB->next_record(); - $Cache->cache_value('artist_comments_'.$ArtistID, $Results, 0); + $Cache->cache_value("artist_comments_$ArtistID", $Results, 0); } if (isset($_GET['postid']) && is_number($_GET['postid']) && $Results > TORRENT_COMMENTS_PER_PAGE) { diff --git a/sections/artist/autocomplete.php b/sections/artist/autocomplete.php index b64a88c6..ed1700da 100644 --- a/sections/artist/autocomplete.php +++ b/sections/artist/autocomplete.php @@ -37,7 +37,7 @@ foreach ($AutoSuggest as $Suggestion) { list($ID, $Name) = $Suggestion; if (stripos($Name, $FullName) === 0) { - $Response['suggestions'][] = array('value' => display_str($Name), 'data' => $ID); + $Response['suggestions'][] = array('value' => $Name, 'data' => $ID); if (++$Matched > 9) { break; } diff --git a/sections/forums/mod_thread.php b/sections/forums/mod_thread.php index 142ec3f2..d796085a 100644 --- a/sections/forums/mod_thread.php +++ b/sections/forums/mod_thread.php @@ -31,9 +31,9 @@ $Sticky = (isset($_POST['sticky'])) ? 1 : 0; $Locked = (isset($_POST['locked'])) ? 1 : 0; $Ranking = (int) $_POST['ranking']; -if(!$Sticky && $Ranking > 0) { +if (!$Sticky && $Ranking > 0) { $Ranking = 0; -} elseif(0 > $Ranking) { +} elseif (0 > $Ranking) { error("Ranking cannot be a negative value"); } $Title = db_string($_POST['title']); @@ -44,7 +44,9 @@ if ($Locked == 1) { - $DB->query("DELETE FROM forums_last_read_topics WHERE TopicID='$TopicID'"); + $DB->query(" + DELETE FROM forums_last_read_topics + WHERE TopicID = '$TopicID'"); } $DB->query(" @@ -53,9 +55,9 @@ f.MinClassWrite, COUNT(p.ID) AS Posts FROM forums_topics AS t - LEFT JOIN forums_posts AS p ON p.TopicID=t.ID - LEFT JOIN forums AS f ON f.ID=.t.ForumID - WHERE t.ID='$TopicID' + LEFT JOIN forums_posts AS p ON p.TopicID = t.ID + LEFT JOIN forums AS f ON f.ID = t.ForumID + WHERE t.ID = '$TopicID' GROUP BY p.TopicID"); list($OldForumID, $MinClassWrite, $Posts) = $DB->next_record(); @@ -64,14 +66,18 @@ } // If we're moving -$Cache->delete_value('forums_'.$ForumID); -$Cache->delete_value('forums_'.$OldForumID); +$Cache->delete_value("forums_$ForumID"); +$Cache->delete_value("forums_$OldForumID"); // If we're deleting a thread if (isset($_POST['delete'])) { if (check_perms('site_admin_forums')) { - $DB->query("DELETE FROM forums_posts WHERE TopicID='$TopicID'"); - $DB->query("DELETE FROM forums_topics WHERE ID='$TopicID'"); + $DB->query(" + DELETE FROM forums_posts + WHERE TopicID = '$TopicID'"); + $DB->query(" + DELETE FROM forums_topics + WHERE ID = '$TopicID'"); $DB->query(" SELECT @@ -81,16 +87,18 @@ p.AuthorID, um.Username, p.AddedTime, - ( SELECT COUNT(pp.ID) + ( + SELECT COUNT(pp.ID) FROM forums_posts AS pp - JOIN forums_topics AS tt ON pp.TopicID=tt.ID - WHERE tt.ForumID='$ForumID'), + JOIN forums_topics AS tt ON pp.TopicID = tt.ID + WHERE tt.ForumID = '$ForumID' + ), t.IsLocked, t.IsSticky FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID - LEFT JOIN users_main AS um ON um.ID=p.AuthorID - WHERE t.ForumID='$ForumID' + JOIN forums_posts AS p ON p.ID = t.LastPostID + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + WHERE t.ForumID = '$ForumID' GROUP BY t.ID ORDER BY t.LastPostID DESC LIMIT 1"); @@ -99,16 +107,15 @@ $DB->query(" UPDATE forums SET - NumTopics=NumTopics-1, - NumPosts=NumPosts-'$Posts', - LastPostTopicID='$NewLastTopic', - LastPostID='$NewLastPostID', - LastPostAuthorID='$NewLastAuthorID', - LastPostTime='$NewLastAddedTime' + NumTopics = NumTopics - 1, + NumPosts = NumPosts - '$Posts', + LastPostTopicID = '$NewLastTopic', + LastPostID = '$NewLastPostID', + LastPostAuthorID = '$NewLastAuthorID', + LastPostTime = '$NewLastAddedTime' WHERE ID='$ForumID'"); - $Cache->delete_value('thread_'.$TopicID); - + $Cache->delete_value("thread_$TopicID"); $Cache->begin_transaction('forums_list'); $UpdateArray = array( @@ -125,7 +132,7 @@ $Cache->update_row($ForumID, $UpdateArray); $Cache->commit_transaction(0); - $Cache->delete_value('thread_'.$TopicID.'_info'); + $Cache->delete_value("thread_{$TopicID}_info"); header('Location: forums.php?action=viewforum&forumid='.$ForumID); } else { @@ -134,7 +141,7 @@ } else { // If we're just editing it - $Cache->begin_transaction('thread_'.$TopicID.'_info'); + $Cache->begin_transaction("thread_{$TopicID}_info"); $UpdateArray = array( 'IsSticky' => $Sticky, 'Ranking' => $Ranking, @@ -152,15 +159,18 @@ Ranking = '$Ranking', IsLocked = '$Locked', Title = '$Title', - ForumID ='$ForumID' - WHERE ID='$TopicID'"); + ForumID = '$ForumID' + WHERE ID = '$TopicID'"); if ($ForumID != $OldForumID) { // If we're moving a thread, change the forum stats - $DB->query("SELECT MinClassRead, MinClassWrite, Name FROM forums WHERE ID='$ForumID'"); + $DB->query(" + SELECT MinClassRead, MinClassWrite, Name + FROM forums + WHERE ID = '$ForumID'"); list($MinClassRead, $MinClassWrite, $ForumName) = $DB->next_record(MYSQLI_NUM, false); - $Cache->begin_transaction('thread_'.$TopicID.'_info'); + $Cache->begin_transaction("thread_{$TopicID}_info"); $UpdateArray = array( 'ForumName' => $ForumName, 'MinClassRead' => $MinClassRead, @@ -171,7 +181,6 @@ $Cache->begin_transaction('forums_list'); - // Forum we're moving from $DB->query(" SELECT @@ -181,17 +190,19 @@ p.AuthorID, um.Username, p.AddedTime, - ( SELECT COUNT(pp.ID) + ( + SELECT COUNT(pp.ID) FROM forums_posts AS pp - JOIN forums_topics AS tt ON pp.TopicID=tt.ID - WHERE tt.ForumID='$OldForumID'), + JOIN forums_topics AS tt ON pp.TopicID = tt.ID + WHERE tt.ForumID = '$OldForumID' + ), t.IsLocked, t.IsSticky, t.Ranking FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID - LEFT JOIN users_main AS um ON um.ID=p.AuthorID - WHERE t.ForumID='$OldForumID' + JOIN forums_posts AS p ON p.ID = t.LastPostID + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + WHERE t.ForumID = '$OldForumID' ORDER BY t.LastPostID DESC LIMIT 1"); list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts, $NewLocked, $NewSticky, $NewRanking) = $DB->next_record(MYSQLI_NUM, false); @@ -199,13 +210,13 @@ $DB->query(" UPDATE forums SET - NumTopics=NumTopics-1, - NumPosts=NumPosts-'$Posts', - LastPostTopicID='$NewLastTopic', - LastPostID='$NewLastPostID', - LastPostAuthorID='$NewLastAuthorID', - LastPostTime='$NewLastAddedTime' - WHERE ID='$OldForumID'"); + NumTopics = NumTopics - 1, + NumPosts = NumPosts - '$Posts', + LastPostTopicID = '$NewLastTopic', + LastPostID = '$NewLastPostID', + LastPostAuthorID = '$NewLastAuthorID', + LastPostTime = '$NewLastAddedTime' + WHERE ID = '$OldForumID'"); $UpdateArray = array( @@ -234,14 +245,15 @@ p.AuthorID, um.Username, p.AddedTime, - ( SELECT COUNT(pp.ID) + ( + SELECT COUNT(pp.ID) FROM forums_posts AS pp - JOIN forums_topics AS tt ON pp.TopicID=tt.ID - WHERE tt.ForumID='$ForumID') + JOIN forums_topics AS tt ON pp.TopicID = tt.ID + WHERE tt.ForumID = '$ForumID') FROM forums_topics AS t - JOIN forums_posts AS p ON p.ID=t.LastPostID - LEFT JOIN users_main AS um ON um.ID=p.AuthorID - WHERE t.ForumID='$ForumID' + JOIN forums_posts AS p ON p.ID = t.LastPostID + LEFT JOIN users_main AS um ON um.ID = p.AuthorID + WHERE t.ForumID = '$ForumID' ORDER BY t.LastPostID DESC LIMIT 1"); list($NewLastTopic, $NewLastPostID, $NewLastTitle, $NewLastAuthorID, $NewLastAuthorName, $NewLastAddedTime, $NumPosts) = $DB->next_record(MYSQLI_NUM, false); @@ -249,13 +261,13 @@ $DB->query(" UPDATE forums SET - NumTopics=NumTopics+1, - NumPosts=NumPosts+'$Posts', - LastPostTopicID='$NewLastTopic', - LastPostID='$NewLastPostID', - LastPostAuthorID='$NewLastAuthorID', - LastPostTime='$NewLastAddedTime' - WHERE ID='$ForumID'"); + NumTopics = NumTopics + 1, + NumPosts = NumPosts + '$Posts', + LastPostTopicID = '$NewLastTopic', + LastPostID = '$NewLastPostID', + LastPostAuthorID = '$NewLastAuthorID', + LastPostTime = '$NewLastAddedTime' + WHERE ID = '$ForumID'"); $UpdateArray = array( @@ -272,7 +284,10 @@ $Cache->commit_transaction(0); } else { // Editing - $DB->query("SELECT LastPostTopicID FROM forums WHERE ID='$ForumID'"); + $DB->query(" + SELECT LastPostTopicID + FROM forums + WHERE ID = '$ForumID'"); list($LastTopicID) = $DB->next_record(); if ($LastTopicID == $TopicID) { $UpdateArray = array( @@ -289,12 +304,15 @@ if ($Locked) { $CatalogueID = floor($NumPosts / THREAD_CATALOGUE); for ($i = 0; $i <= $CatalogueID; $i++) { - $Cache->expire_value('thread_'.$TopicID.'_catalogue_'.$i, 3600 * 24 * 7); // 7 days + $Cache->expire_value("thread_{$TopicID}_catalogue_$i", 3600 * 24 * 7); // 7 days } - $Cache->expire_value('thread_'.$TopicID.'_info', 3600 * 24 * 7); // 7 days + $Cache->expire_value("thread_{$TopicID}_info", 3600 * 24 * 7); // 7 days - $DB->query('UPDATE forums_polls SET Closed=\'0\' WHERE TopicID=\''.$TopicID.'\''); - $Cache->delete_value('polls_'.$TopicID); + $DB->query(" + UPDATE forums_polls + SET Closed = '0' + WHERE TopicID = '$TopicID'"); + $Cache->delete_value("polls_$TopicID"); } header('Location: forums.php?action=viewthread&threadid='.$TopicID.'&page='.$Page); } diff --git a/sections/forums/thread.php b/sections/forums/thread.php index 5079cf33..219b7b5f 100644 --- a/sections/forums/thread.php +++ b/sections/forums/thread.php @@ -20,7 +20,10 @@ if (isset($_GET['topicid']) && is_number($_GET['topicid'])) { $ThreadID = $_GET['topicid']; } elseif (isset($_GET['postid']) && is_number($_GET['postid'])) { - $DB->query("SELECT TopicID FROM forums_posts WHERE ID = $_GET[postid]"); + $DB->query(" + SELECT TopicID + FROM forums_posts + WHERE ID = $_GET[postid]"); list($ThreadID) = $DB->next_record(); if ($ThreadID) { header("Location: forums.php?action=viewthread&threadid=$ThreadID&postid=$_GET[postid]#post$_GET[postid]"); @@ -80,10 +83,10 @@ if (($Page - 1) * $PerPage > $ThreadInfo['Posts']) { $Page = ceil($ThreadInfo['Posts'] / $PerPage); } -list($CatalogueID,$CatalogueLimit) = Format::catalogue_limit($Page,$PerPage,THREAD_CATALOGUE); +list($CatalogueID,$CatalogueLimit) = Format::catalogue_limit($Page, $PerPage, THREAD_CATALOGUE); // Cache catalogue from which the page is selected, allows block caches and future ability to specify posts per page -if (!$Catalogue = $Cache->get_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID)) { +if (!$Catalogue = $Cache->get_value("thread_{$ThreadID}_catalogue_$CatalogueID")) { $DB->query(" SELECT p.ID, @@ -98,12 +101,12 @@ WHERE p.TopicID = '$ThreadID' AND p.ID != '".$ThreadInfo['StickyPostID']."' LIMIT $CatalogueLimit"); - $Catalogue = $DB->to_array(false,MYSQLI_ASSOC); + $Catalogue = $DB->to_array(false, MYSQLI_ASSOC); if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { - $Cache->cache_value('thread_'.$ThreadID.'_catalogue_'.$CatalogueID, $Catalogue, 0); + $Cache->cache_value("thread_{$ThreadID}_catalogue_$CatalogueID", $Catalogue, 0); } } -$Thread = Format::catalogue_select($Catalogue,$Page,$PerPage,THREAD_CATALOGUE); +$Thread = Format::catalogue_select($Catalogue, $Page, $PerPage, THREAD_CATALOGUE); if ($_GET['updatelastread'] != '0') { $LastPost = end($Thread); $LastPost = $LastPost['ID']; @@ -119,23 +122,26 @@ $DB->query(" SELECT PostID FROM forums_last_read_topics - WHERE UserID='$LoggedUser[ID]' - AND TopicID='$ThreadID'"); + WHERE UserID = '$LoggedUser[ID]' + AND TopicID = '$ThreadID'"); list($LastRead) = $DB->next_record(); if ($LastRead < $LastPost) { $DB->query(" INSERT INTO forums_last_read_topics (UserID, TopicID, PostID) VALUES ('$LoggedUser[ID]', '$ThreadID', '".db_string($LastPost)."') - ON DUPLICATE KEY UPDATE PostID='$LastPost'"); + ON DUPLICATE KEY UPDATE PostID = '$LastPost'"); } } } //Handle subscriptions if (($UserSubscriptions = $Cache->get_value('subscriptions_user_'.$LoggedUser['ID'])) === false) { - $DB->query("SELECT TopicID FROM users_subscriptions WHERE UserID = '$LoggedUser[ID]'"); + $DB->query(" + SELECT TopicID + FROM users_subscriptions + WHERE UserID = '$LoggedUser[ID]'"); $UserSubscriptions = $DB->collect(0); - $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'],$UserSubscriptions,0); + $Cache->cache_value('subscriptions_user_'.$LoggedUser['ID'], $UserSubscriptions,0); } if (empty($UserSubscriptions)) { @@ -210,17 +216,17 @@
get_value('polls_'.$ThreadID)) { + if (!list($Question, $Answers, $Votes, $Featured, $Closed) = $Cache->get_value("polls_$ThreadID")) { $DB->query(" SELECT Question, Answers, Featured, Closed FROM forums_polls - WHERE TopicID='$ThreadID'"); + WHERE TopicID = '$ThreadID'"); list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1)); $Answers = unserialize($Answers); $DB->query(" SELECT Vote, COUNT(UserID) FROM forums_polls_votes - WHERE TopicID='$ThreadID' + WHERE TopicID = '$ThreadID' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); @@ -235,7 +241,7 @@ $Votes[$i] = 0; } } - $Cache->cache_value('polls_'.$ThreadID, array($Question, $Answers, $Votes, $Featured, $Closed), 0); + $Cache->cache_value("polls_$ThreadID", array($Question, $Answers, $Votes, $Featured, $Closed), 0); } if (!empty($Votes)) { @@ -251,8 +257,8 @@ $DB->query(" SELECT Vote FROM forums_polls_votes - WHERE UserID='".$LoggedUser['ID']."' - AND TopicID='$ThreadID'"); + WHERE UserID = '".$LoggedUser['ID']."' + AND TopicID = '$ThreadID'"); list($UserResponse) = $DB->next_record(); if (!empty($UserResponse) && $UserResponse != 0) { $Answers[$UserResponse] = '» '.$Answers[$UserResponse]; @@ -280,7 +286,7 @@ $Percent = 0; } ?> -
  • (%)
  • +
  • (%)
  • @@ -316,7 +322,7 @@ GROUP_CONCAT(um.Username SEPARATOR ', ') FROM users_main AS um LEFT JOIN forums_polls_votes AS fpv ON um.ID = fpv.UserID - WHERE TopicID = ".$ThreadID." + WHERE TopicID = $ThreadID GROUP BY fpv.Vote"); $StaffVotesTmp = $DB->to_array(); @@ -553,7 +559,7 @@ tabindex="2" /> -
  • > + >