Gazelle/sections/forums/delete_poll_option.php

42 lines
1000 B
PHP
Raw Normal View History

<?
authorize();
2013-05-05 08:00:31 +00:00
if (!check_perms('site_moderate_forums')) {
error(404);
}
$ThreadID = $_GET['threadid'];
$PollOption = $_GET['vote'];
2013-05-05 08:00:31 +00:00
if (is_number($ThreadID) && is_number($PollOption)) {
$DB->query("SELECT ForumID FROM forums_topics WHERE ID = $ThreadID");
list($ForumID) = $DB->next_record();
2013-05-05 08:00:31 +00:00
if (!in_array($ForumID, $ForumsRevealVoters)) {
error(403);
}
2013-05-05 08:00:31 +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);
unset($Answers[$PollOption]);
$Answers = serialize($Answers);
2013-05-05 08:00:31 +00:00
$DB->query("
UPDATE forums_polls
SET Answers = '".db_string($Answers)."'
WHERE TopicID = $ThreadID");
$DB->query("
DELETE FROM forums_polls_votes
WHERE Vote = $PollOption
AND TopicID = $ThreadID");
$Cache->delete_value('polls_'.$ThreadID);
2013-05-05 08:00:31 +00:00
header('Location: forums.php?action=viewthread&threadid='.$ThreadID);
2013-02-22 08:00:24 +00:00
} else {
error(404);
}