dragonpolls/vote_poll.php

24 lines
755 B
PHP
Raw Normal View History

2021-03-28 19:19:04 +00:00
<?php
require_once __DIR__ . '/bootstrap.php';
$voted_options = [];
if (is_array($_POST['options'])) {
foreach ($_POST['options'] as $option) {
$voted_options[] = (int)$option;
}
} else {
$voted_options[] = (int)$_POST['options'];
2021-03-28 19:19:04 +00:00
}
try {
$res = $api->voteInPoll((int)$_POST['pollid'], $voted_options, $_POST['polltoken']);
} catch (\Exception $e) {
2021-04-17 14:04:34 +00:00
$header = get_page_header('Voting error');
$str = $header
. 'Sorry, something went wrong while voting! "'
. $e->getMessage()
. '"<br>Please yell at <a href="https://pnut.io/@hutattedonmyarm">@hutattedonmyarm</a><br>'
. '<a href="view_poll.php?id='.$_POST['pollid'].'"s>Go back to the poll</a>';
2021-04-17 14:04:34 +00:00
quit($str);
2021-03-28 19:19:04 +00:00
}
redirect('view_poll.php?id='.$_POST['pollid'].'&success=1');