getMessage() . '"' . get_page_footer()); } if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) { die('Invalid poll ID'.get_page_footer()); } $poll_id = (int)$_GET['id']; $poll = null; try { $poll_token = array_key_exists('polltoken', $_GET) ? $_GET['polltoken'] : null; $poll = $api->getPoll($poll_id, $poll_token); } catch (NotFoundException $nfe) { die('Poll not found'.get_page_footer()); } catch (NotSupportedPollException $nspe) { die('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage() . get_page_footer()); } catch (PollAccessRestrictedException $are) { $message = array_key_exists('polltoken', $_GET) ? 'Sorry, your poll token is invalid! Please enter a valid token: ' : ('Sorry, this poll is private! If you have found this poll on a post, ' . 'please enter a link to the post, the post ID or the access token for the poll: '); die( $message . '
' . get_page_footer() ); } catch (\Exception $e) { die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer()); } jslog($poll); $user_avatar_url = $poll->user->getAvatarUrl(50); $user_avatar_url_srcset = get_source_set($poll->user, 50); $username = '@' . $poll->user->username; $disabled = $poll->canVote() ? '' : 'disabled'; $user_name = $poll->user->name ?? ''; $created_at = $poll->created_at; $closed_at = $poll->closed_at; $user_votes = $poll->getMyVotes(); $votes_remaining = $poll->max_options - count($user_votes); $votes_remaining_plural = $votes_remaining === 1 ? '' : 's'; $votes_remaining_text = "$votes_remaining Vote$votes_remaining_plural remaining"; $votes_remaining_hidden = $poll->canVote() ? '' : ' hidden'; $data_can_vote = $poll->canVote() ? 'true' : 'false'; $disabled_button = ($poll->canVote() && count($user_votes) > 0) ? '' : 'disabled'; if (array_key_exists('success', $_GET) && $_GET['success'] == 1) { ?>