get_value('thread_'.$TopicID.'_info')) { $DB->query(" SELECT t.Title, t.ForumID, t.IsLocked, t.IsSticky, COUNT(fp.id) AS Posts, t.LastPostAuthorID, ISNULL(p.TopicID) AS NoPoll 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 = '$TopicID' GROUP BY fp.TopicID"); if ($DB->record_count() == 0) { die(); } $ThreadInfo = $DB->next_record(MYSQLI_ASSOC); if (!$ThreadInfo['IsLocked'] || $ThreadInfo['IsSticky']) { $Cache->cache_value('thread_'.$TopicID.'_info', $ThreadInfo, 0); } } $ForumID = $ThreadInfo['ForumID']; if (!list($Question,$Answers,$Votes,$Featured,$Closed) = $Cache->get_value('polls_'.$TopicID)) { $DB->query(" SELECT Question, Answers, Featured, Closed FROM forums_polls WHERE TopicID='$TopicID'"); 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='$TopicID' AND Vote <> '0' GROUP BY Vote"); $VoteArray = $DB->to_array(false, MYSQLI_NUM); $Votes = array(); foreach ($VoteArray as $VoteSet) { list($Key,$Value) = $VoteSet; $Votes[$Key] = $Value; } for ($i = 1, $il = count($Answers); $i <= $il; ++$i) { if (!isset($Votes[$i])) { $Votes[$i] = 0; } } $Cache->cache_value('polls_'.$TopicID, array($Question,$Answers,$Votes,$Featured,$Closed), 0); } if ($Closed) { error(403,true); } if (!empty($Votes)) { $TotalVotes = array_sum($Votes); $MaxVotes = max($Votes); } else { $TotalVotes = 0; $MaxVotes = 0; } if (!isset($_POST['vote']) || !is_number($_POST['vote'])) { ?> Please select an option.




query('INSERT IGNORE INTO forums_polls_votes (TopicID, UserID, Vote) VALUES ('.$TopicID.','.$LoggedUser['ID'].','.$Vote.')'); if ($DB->affected_rows() == 1 && $Vote != 0) { $Cache->begin_transaction('polls_'.$TopicID); $Cache->update_row(2, array($Vote => '+1')); $Cache->commit_transaction(0); $Votes[$Vote]++; $TotalVotes++; $MaxVotes++; } if ($Vote != 0) { $Answers[$Vote] = '=> '.$Answers[$Vote]; } ?>
Votes: