Gazelle/sections/forums/add_poll_option.php

31 lines
829 B
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
authorize();
$ThreadID = $_POST['threadid'];
$NewOption = $_POST['new_option'];
if(!is_number($ThreadID)) {
error(404);
}
if(!check_perms("site_moderate_forums")) {
$DB->query("SELECT ForumID FROM forums_topics WHERE ID = $ThreadID");
list($ForumID) = $DB->next_record();
if(!in_array($ForumID, $ForumsRevealVoters)) {
error(403);
}
}
2011-03-28 14:21:28 +00:00
$DB->query("SELECT Answers FROM forums_polls WHERE TopicID = ".$ThreadID);
if($DB->record_count() < 1) {
error(404);
}
list($Answers) = $DB->next_record(MYSQLI_NUM, false);
$Answers = unserialize($Answers);
$Answers[] = $NewOption;
$Answers = serialize($Answers);
$DB->query("UPDATE forums_polls SET Answers = '".db_string($Answers)."' WHERE TopicID = ".$ThreadID);
$Cache->delete_value('polls_'.$ThreadID);
header("Location: forums.php?action=viewthread&threadid=".$ThreadID);