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, [1]); if ($Featured == '') { $Featured = null; } $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 = []; 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; } } } if (isset($_POST['feature'])) { if (!$Featured) { $Featured = sqltime(); $Cache->cache_value('polls_featured',$TopicID,0); $DB->prepared_query(" UPDATE forums_polls SET Featured = ? WHERE TopicID = ? ", $Featured, $TopicID ); } } if (isset($_POST['close'])) { $Closed = !$Closed; $DB->query(' UPDATE forums_polls SET Closed=\''.$Closed.'\' WHERE TopicID=\''.$TopicID.'\''); } $Cache->cache_value('polls_'.$TopicID, [$Question,$Answers,$Votes,$Featured,$Closed], 0); $Location = (empty($_SERVER['HTTP_REFERER'])) ? "forums.php?action=viewthread&threadid={$TopicID}" : $_SERVER['HTTP_REFERER']; header("Location: {$Location}");