Compare commits
No commits in common. "v1.2.0" and "0.9.0" have entirely different histories.
1
.gitignore
vendored
@ -1,4 +1,3 @@
|
|||||||
config.php
|
config.php
|
||||||
logs/*
|
logs/*
|
||||||
vendor/
|
vendor/
|
||||||
**/.DS_Store
|
|
||||||
|
@ -10,9 +10,7 @@
|
|||||||
".git",
|
".git",
|
||||||
".eslintrc",
|
".eslintrc",
|
||||||
".nova",
|
".nova",
|
||||||
"*.log",
|
"*.log"
|
||||||
"config.php",
|
|
||||||
"release.php"
|
|
||||||
],
|
],
|
||||||
"remotePath" : "\/var\/www\/html\/Dragonpolls",
|
"remotePath" : "\/var\/www\/html\/Dragonpolls",
|
||||||
"remoteURL" : "https:\/\/phlaym.net\/Dragonpolls\/",
|
"remoteURL" : "https:\/\/phlaym.net\/Dragonpolls\/",
|
||||||
|
@ -5,16 +5,11 @@ require_once __DIR__ .'/bootstrap.php';
|
|||||||
|
|
||||||
if (isset($_GET['code'])) {
|
if (isset($_GET['code'])) {
|
||||||
$success = $api->authenticate($_GET['code']);
|
$success = $api->authenticate($_GET['code']);
|
||||||
$from = empty($_GET['from']) ? null : $_GET['from'];
|
|
||||||
$page = 'index.php';
|
|
||||||
if (!empty($_GET['from'])) {
|
|
||||||
$page = $_GET['from'];
|
|
||||||
}
|
|
||||||
if ($success) {
|
if ($success) {
|
||||||
redirect($page);
|
redirect('index.php');
|
||||||
} else {
|
} else {
|
||||||
quit(get_page_header().'Echo error authenticating');
|
die('Echo error authenticating');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quit(get_page_header().'Echo error authenticating: '. $_GET['error_message']);
|
die('error authenticating: ' . $_GET['error_message']);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hutattedonmyarm/dragonpolls",
|
"name": "hutattedonmyarm/dragonpolls",
|
||||||
"version": "1.2.0-beta",
|
"version": "0.9.0",
|
||||||
"description": "A polling client for pnut.io",
|
"description": "A polling client for pnut.io",
|
||||||
"require": {
|
"require": {
|
||||||
"hutattedonmyarm/apnuti": "@dev"
|
"hutattedonmyarm/apnuti": "@dev"
|
||||||
|
66
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "25a44e30da5350cab5a81a2d96b1750a",
|
"content-hash": "d993b45e1a383647a4d2260a68ee1783",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "hutattedonmyarm/apnuti",
|
"name": "hutattedonmyarm/apnuti",
|
||||||
@ -12,7 +12,7 @@
|
|||||||
"dist": {
|
"dist": {
|
||||||
"type": "path",
|
"type": "path",
|
||||||
"url": "../APnutI",
|
"url": "../APnutI",
|
||||||
"reference": "2f5aa63306ed989499a2f2003d8cfcc36061d341"
|
"reference": "2b45c9fdd0df6a6b6186c1afb1075ae5a0b69bbe"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
@ -43,58 +43,52 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "monolog/monolog",
|
"name": "monolog/monolog",
|
||||||
"version": "2.9.2",
|
"version": "2.2.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/Seldaek/monolog.git",
|
"url": "https://github.com/Seldaek/monolog.git",
|
||||||
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f"
|
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
|
||||||
"reference": "437cb3628f4cf6042cc10ae97fc2b8472e48ca1f",
|
"reference": "1cb1cde8e8dd0f70cc0fe51354a59acad9302084",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.2",
|
"php": ">=7.2",
|
||||||
"psr/log": "^1.0.1 || ^2.0 || ^3.0"
|
"psr/log": "^1.0.1"
|
||||||
},
|
},
|
||||||
"provide": {
|
"provide": {
|
||||||
"psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0"
|
"psr/log-implementation": "1.0.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
|
||||||
"doctrine/couchdb": "~1.0@dev",
|
"doctrine/couchdb": "~1.0@dev",
|
||||||
"elasticsearch/elasticsearch": "^7 || ^8",
|
"elasticsearch/elasticsearch": "^7",
|
||||||
"ext-json": "*",
|
"graylog2/gelf-php": "^1.4.2",
|
||||||
"graylog2/gelf-php": "^1.4.2 || ^2@dev",
|
|
||||||
"guzzlehttp/guzzle": "^7.4",
|
|
||||||
"guzzlehttp/psr7": "^2.2",
|
|
||||||
"mongodb/mongodb": "^1.8",
|
"mongodb/mongodb": "^1.8",
|
||||||
"php-amqplib/php-amqplib": "~2.4 || ^3",
|
"php-amqplib/php-amqplib": "~2.4",
|
||||||
"phpspec/prophecy": "^1.15",
|
"php-console/php-console": "^3.1.3",
|
||||||
"phpstan/phpstan": "^0.12.91",
|
"phpspec/prophecy": "^1.6.1",
|
||||||
"phpunit/phpunit": "^8.5.14",
|
"phpstan/phpstan": "^0.12.59",
|
||||||
"predis/predis": "^1.1 || ^2.0",
|
"phpunit/phpunit": "^8.5",
|
||||||
"rollbar/rollbar": "^1.3 || ^2 || ^3",
|
"predis/predis": "^1.1",
|
||||||
"ruflin/elastica": "^7",
|
"rollbar/rollbar": "^1.3",
|
||||||
"swiftmailer/swiftmailer": "^5.3|^6.0",
|
"ruflin/elastica": ">=0.90 <7.0.1",
|
||||||
"symfony/mailer": "^5.4 || ^6",
|
"swiftmailer/swiftmailer": "^5.3|^6.0"
|
||||||
"symfony/mime": "^5.4 || ^6"
|
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
|
||||||
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
|
||||||
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
|
"elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client",
|
||||||
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
|
||||||
"ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler",
|
|
||||||
"ext-mbstring": "Allow to work properly with unicode symbols",
|
"ext-mbstring": "Allow to work properly with unicode symbols",
|
||||||
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
|
"ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)",
|
||||||
"ext-openssl": "Required to send log messages using SSL",
|
|
||||||
"ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)",
|
|
||||||
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
|
||||||
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
|
"mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)",
|
||||||
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
|
||||||
|
"php-console/php-console": "Allow sending log messages to Google Chrome",
|
||||||
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
"rollbar/rollbar": "Allow sending log messages to Rollbar",
|
||||||
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
"ruflin/elastica": "Allow sending log messages to an Elastic Search server"
|
||||||
},
|
},
|
||||||
@ -129,7 +123,7 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/Seldaek/monolog/issues",
|
"issues": "https://github.com/Seldaek/monolog/issues",
|
||||||
"source": "https://github.com/Seldaek/monolog/tree/2.9.2"
|
"source": "https://github.com/Seldaek/monolog/tree/2.2.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -141,20 +135,20 @@
|
|||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-10-27T15:25:26+00:00"
|
"time": "2020-12-14T13:15:25+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "psr/log",
|
"name": "psr/log",
|
||||||
"version": "1.1.4",
|
"version": "1.1.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/php-fig/log.git",
|
"url": "https://github.com/php-fig/log.git",
|
||||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||||
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
@ -178,7 +172,7 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "PHP-FIG",
|
"name": "PHP-FIG",
|
||||||
"homepage": "https://www.php-fig.org/"
|
"homepage": "http://www.php-fig.org/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Common interface for logging libraries",
|
"description": "Common interface for logging libraries",
|
||||||
@ -189,9 +183,9 @@
|
|||||||
"psr-3"
|
"psr-3"
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
"source": "https://github.com/php-fig/log/tree/1.1.3"
|
||||||
},
|
},
|
||||||
"time": "2021-05-03T11:20:27+00:00"
|
"time": "2020-03-23T09:12:05+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [],
|
"packages-dev": [],
|
||||||
@ -204,5 +198,5 @@
|
|||||||
"prefer-lowest": false,
|
"prefer-lowest": false,
|
||||||
"platform": [],
|
"platform": [],
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "2.6.0"
|
"plugin-api-version": "2.0.0"
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,4 @@ return [
|
|||||||
'app_name' => 'Playground',
|
'app_name' => 'Playground',
|
||||||
'callback_url' => 'http://localhost/auth_callback.php',
|
'callback_url' => 'http://localhost/auth_callback.php',
|
||||||
'permission_scopes' => 'basic' //comma seperated string
|
'permission_scopes' => 'basic' //comma seperated string
|
||||||
'github_username' => '',
|
|
||||||
'github_repo' => '',
|
|
||||||
'github_token' => '',
|
|
||||||
'gitea_url' => '',
|
|
||||||
'gitea_token' => ''
|
|
||||||
];
|
];
|
||||||
|
92
globals.php
@ -20,14 +20,11 @@ function get_page_header(
|
|||||||
$newpoll_class = '';
|
$newpoll_class = '';
|
||||||
if ($api->isAuthenticated(false, true)) {
|
if ($api->isAuthenticated(false, true)) {
|
||||||
$u = $api->getAuthorizedUser();
|
$u = $api->getAuthorizedUser();
|
||||||
$user_avatar_url = $u->getAvatarUrl(30);
|
$greeting = 'Welcome, ' . ($u->name ?? '@'.$u->username);
|
||||||
$user_avatar_url_srcset = get_source_set($u, 30);
|
|
||||||
$avatar = '<img src="' . $user_avatar_url . '" class="avatar" srcset="' . $user_avatar_url_srcset . '"/>';
|
|
||||||
$greeting = $avatar . '<span class="greeting">Welcome, ' . ($u->name ?? '@'.$u->username) . '</span>';
|
|
||||||
$logout_link = '<a href="logout.php" class="logout">Logout</a>';
|
$logout_link = '<a href="logout.php" class="logout">Logout</a>';
|
||||||
} else {
|
} else {
|
||||||
$newpoll_class = 'disabled';
|
$newpoll_class = 'disabled';
|
||||||
$greeting = '<a href="' . $api->getAuthURL('?from=' . $_SERVER['REQUEST_URI']) . '">Login with pnut</a>';
|
$greeting = '<a href="' . $api->getAuthURL() . '">Login with pnut</a>';
|
||||||
}
|
}
|
||||||
$title = '';
|
$title = '';
|
||||||
if ($include_app_name) {
|
if ($include_app_name) {
|
||||||
@ -42,71 +39,29 @@ function get_page_header(
|
|||||||
$script_str .= '<script src="scripts/' . $script . '.js"></script>';
|
$script_str .= '<script src="scripts/' . $script . '.js"></script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$home_link = get_icon_link(
|
return '<html><head><meta charset="utf-8"><title>'.$title.'</title><link rel="stylesheet" href="styles/style.css">'
|
||||||
'index.php',
|
|
||||||
'Home',
|
|
||||||
'home',
|
|
||||||
'homelink'
|
|
||||||
);
|
|
||||||
$new_poll_link = get_icon_link(
|
|
||||||
'new_poll.php',
|
|
||||||
'New Poll',
|
|
||||||
'plus',
|
|
||||||
'newpolllink'
|
|
||||||
);
|
|
||||||
|
|
||||||
$favicons = '<link rel="icon" href="icons/favicon/favicon-32.png" sizes="32x32">'
|
|
||||||
. '<link rel="icon" href="icons/favicon/favicon-96.png" sizes="96x96">'
|
|
||||||
. '<link rel="icon" href="icons/favicon/favicon-128.png" sizes="128x128">'
|
|
||||||
. '<link rel="icon" href="icons/favicon/favicon-192.png" sizes="192x192">'
|
|
||||||
. '<link rel="icon" href="icons/favicon/favicon-228.png" sizes="228x228">'
|
|
||||||
. '<link rel="shortcut icon" sizes="196x196" href=“icons/favicon/favicon-196.png">'
|
|
||||||
. '<link rel="apple-touch-icon" href="icons/favicon/favicon-120.png" sizes="120x120">'
|
|
||||||
. '<link rel="apple-touch-icon" href="path/to/favicon-152.png" sizes="152x152">'
|
|
||||||
. '<link rel="apple-touch-icon" href="path/to/favicon-180.png" sizes="180x180">'
|
|
||||||
. '<link rel="icon" type="image/svg+xml" href="icons/favicon/favicon.svg">';
|
|
||||||
|
|
||||||
return '<html><head><meta charset="utf-8">'
|
|
||||||
. $favicons
|
|
||||||
. '<title>'.$title.'</title><link rel="stylesheet" href="styles/style.css">'
|
|
||||||
. $script_str
|
. $script_str
|
||||||
. '<meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">'
|
|
||||||
. '</head><body><header>'
|
. '</head><body><header>'
|
||||||
. $home_link
|
. '<a href="index.php" class="homelink" title="Home"><div class="linkcontents">'
|
||||||
. $new_poll_link
|
. file_get_contents(__DIR__.'/icons/home.svg')
|
||||||
|
. '<span class="linklabel">Home</span></div></a>'
|
||||||
|
. '<a href="new_poll.php" class="newpolllink '.$newpoll_class.'" title="New Poll"><div class="linkcontents">'
|
||||||
|
. file_get_contents(__DIR__.'/icons/plus.svg')
|
||||||
|
. '<span class="linklabel">New Poll</span></div></a>'
|
||||||
. $greeting
|
. $greeting
|
||||||
. '<div class="spacer"></div>'
|
. '<div class="spacer"></div>'
|
||||||
. $logout_link
|
. $logout_link
|
||||||
. '</header><main>';
|
. '</header><main>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_icon_link(string $href, string $label, string $icon, string $class)
|
|
||||||
{
|
|
||||||
return '<a href="'.$href.'" title="'.$label.'" class="'.$class.'">'
|
|
||||||
. '<div class="linkcontents">'
|
|
||||||
. file_get_contents(__DIR__.'/icons/'.$icon.'.svg')
|
|
||||||
. '<span class="linklabel">'.$label.'</span></div></a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_page_footer()
|
function get_page_footer()
|
||||||
{
|
{
|
||||||
$version = json_decode(file_get_contents(__DIR__ . '/composer.json'), true)['version'];
|
$version = json_decode(file_get_contents(__DIR__ . '/composer.json'), true)['version'];
|
||||||
$repo_link = get_icon_link(
|
|
||||||
'https://phlaym.net/git/phlaym/Dragonpolls',
|
|
||||||
'Source Code',
|
|
||||||
'src',
|
|
||||||
'sourcecode'
|
|
||||||
);
|
|
||||||
$issues_link = get_icon_link(
|
|
||||||
'https://github.com/hutattedonmyarm/Dragonpolls/issues',
|
|
||||||
'Issues',
|
|
||||||
'issues',
|
|
||||||
'issues'
|
|
||||||
);
|
|
||||||
return '</main><footer>'
|
return '</main><footer>'
|
||||||
. '<a href="https://phlaym.net/git/phlaym/Dragonpolls/releases/tag/'.$version.'">Version ' . $version . '</a>'
|
. '<a href="https://phlaym.net/git/phlaym/Pfadlock/releases/tag/'.$version.'">Version ' . $version . '</a>'
|
||||||
. $repo_link
|
. '<a href="https://phlaym.net/git/phlaym/Dragonpolls" title="Source" class="sourcecode"><div class="linkcontents">'
|
||||||
. $issues_link
|
. file_get_contents(__DIR__.'/icons/src.svg')
|
||||||
|
. '<span class="linklabel">Source Code</span></div></a>'
|
||||||
. '</footer></body></html>';
|
. '</footer></body></html>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,24 +80,3 @@ function get_source_set($user, int $base_size, int $max_scale = 3): string
|
|||||||
}
|
}
|
||||||
return implode(', ', $srcset_entries);
|
return implode(', ', $srcset_entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_banner(string $type, string $content, string $custom_symbol = null): string
|
|
||||||
{
|
|
||||||
if (empty($custom_symbol)) {
|
|
||||||
$custom_symbol = $type === 'success' ? 'ઙ' : '×';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '<div class="banner-wrapper">'
|
|
||||||
. ' <div class="'
|
|
||||||
. $type
|
|
||||||
. ' banner"><span>'
|
|
||||||
. $custom_symbol
|
|
||||||
. '</span>'
|
|
||||||
. $content
|
|
||||||
. '</div></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
function quit(string $error, string $error_details = '')
|
|
||||||
{
|
|
||||||
die(make_banner('error', $error) . $error_details . get_page_footer());
|
|
||||||
}
|
|
||||||
|
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.2 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 4.2 KiB |
@ -1,44 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 228 228" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1,0,0,1,-6.63553,4.34231)">
|
|
||||||
<g transform="matrix(0.82911,0,0,1.33061,-6.14838,30.612)">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 167.545,44.826 161.101,44.826L44.035,44.826C37.591,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 37.591,73.927 44.035,73.927L161.101,73.927C167.545,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
<clipPath id="_clip1">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 167.545,44.826 161.101,44.826L44.035,44.826C37.591,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 37.591,73.927 44.035,73.927L161.101,73.927C167.545,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#_clip1)">
|
|
||||||
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
|
|
||||||
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear2);stroke:black;stroke-width:0.72px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1.42367,0,0,1.33061,-25.3881,-29.188)">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 169.73,44.826 165.977,44.826L39.159,44.826C35.406,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 35.406,73.927 39.159,73.927L165.977,73.927C169.73,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
<clipPath id="_clip3">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 169.73,44.826 165.977,44.826L39.159,44.826C35.406,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 35.406,73.927 39.159,73.927L165.977,73.927C169.73,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#_clip3)">
|
|
||||||
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
|
|
||||||
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear4);stroke:black;stroke-width:0.51px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(0.519441,0,0,1.33061,3.8723,90.5329)">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 164.426,44.826 154.14,44.826L50.996,44.826C40.71,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 40.71,73.927 50.996,73.927L154.14,73.927C164.426,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
<clipPath id="_clip5">
|
|
||||||
<path d="M172.777,52.101C172.777,48.086 164.426,44.826 154.14,44.826L50.996,44.826C40.71,44.826 32.359,48.086 32.359,52.101L32.359,66.652C32.359,70.667 40.71,73.927 50.996,73.927L154.14,73.927C164.426,73.927 172.777,70.667 172.777,66.652L172.777,52.101Z"/>
|
|
||||||
</clipPath>
|
|
||||||
<g clip-path="url(#_clip5)">
|
|
||||||
<g transform="matrix(5.01289e-17,1,-1.72969,9.6706e-17,232.073,-27.6888)">
|
|
||||||
<path d="M87.837,39.057C87.837,39.057 91.798,61.175 85.512,69.885C80.891,76.289 72.401,87.684 78.758,99.674C83.99,109.541 89.236,115.312 89.236,115.312C89.236,115.312 89.097,112.405 88.874,108.815C88.687,105.794 88.441,102.29 88.17,99.629C86.254,80.848 85.484,79.752 95.632,70.116C106.135,60.142 87.837,39.057 87.837,39.057Z" style="fill:url(#_Linear6);stroke:black;stroke-width:0.88px;"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
<defs>
|
|
||||||
<linearGradient id="_Linear2" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(-6.87189,46.9884,-50.6429,-6.376,91.6096,53.0397)"><stop offset="0" style="stop-color:rgb(255,0,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,202,0);stop-opacity:1"/></linearGradient>
|
|
||||||
<linearGradient id="_Linear4" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(6.42372,-56.5862,104.722,3.47105,86.0448,105.828)"><stop offset="0" style="stop-color:rgb(255,166,0);stop-opacity:1"/><stop offset="0.44" style="stop-color:rgb(224,116,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(153,0,0);stop-opacity:1"/></linearGradient>
|
|
||||||
<linearGradient id="_Linear6" x1="0" y1="0" x2="1" y2="0" gradientUnits="userSpaceOnUse" gradientTransform="matrix(6.56786,-51.328,79.656,22.3555,85.4444,101.742)"><stop offset="0" style="stop-color:rgb(255,127,0);stop-opacity:1"/><stop offset="0.2" style="stop-color:rgb(255,76,0);stop-opacity:1"/><stop offset="0.41" style="stop-color:rgb(255,24,0);stop-opacity:1"/><stop offset="1" style="stop-color:rgb(255,0,0);stop-opacity:1"/></linearGradient>
|
|
||||||
</defs>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 5.4 KiB |
@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
|
||||||
<svg width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
|
|
||||||
<g transform="matrix(1.35206,0,0,1.35206,-74.2829,-59.7839)">
|
|
||||||
<circle cx="128.901" cy="118.178" r="66.565" style="fill:none;"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(1,0,0,1,0,3.53095)" class="filled">
|
|
||||||
<g transform="matrix(-0.903127,1.10601e-16,-1.10601e-16,-0.903127,192.517,175.685)">
|
|
||||||
<path d="M102.441,58.588C102.441,58.588 91.63,125.231 91.63,153.793C91.63,159.759 96.475,164.603 102.441,164.603C108.408,164.603 113.252,159.759 113.252,153.793C113.252,125.231 102.441,58.588 102.441,58.588Z"/>
|
|
||||||
</g>
|
|
||||||
<g transform="matrix(0.762846,0,0,0.762846,23.9482,35.356)">
|
|
||||||
<circle cx="99.695" cy="160.113" r="11.029"/>
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 1.1 KiB |
62
index.php
@ -2,14 +2,6 @@
|
|||||||
|
|
||||||
require_once __DIR__ .'/bootstrap.php';
|
require_once __DIR__ .'/bootstrap.php';
|
||||||
|
|
||||||
use APnutI\Exceptions\NotFoundException;
|
|
||||||
use APnutI\Exceptions\HttpPnutForbiddenException;
|
|
||||||
use APnutI\Exceptions\NotSupportedPollException;
|
|
||||||
use APnutI\Exceptions\NotAuthorizedException;
|
|
||||||
use APnutI\Exceptions\PollAccessRestrictedException;
|
|
||||||
use APnutI\Entities\Poll;
|
|
||||||
use APnutI\Entities\User;
|
|
||||||
|
|
||||||
// Support the old Dragonpolls links
|
// Support the old Dragonpolls links
|
||||||
if (isset($_GET['poll'])) {
|
if (isset($_GET['poll'])) {
|
||||||
redirect('view_poll.php?id='.$_GET['poll']);
|
redirect('view_poll.php?id='.$_GET['poll']);
|
||||||
@ -17,7 +9,8 @@ if (isset($_GET['poll'])) {
|
|||||||
echo get_page_header();
|
echo get_page_header();
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
Welcome to the new Dragonpolls!<br>
|
Welcome to the new Dragonpolls! In <a href="https://github.com/hutattedonmyarm/Dragonpolls/milestone/3">the future</a>
|
||||||
|
you will find a stream of polls here, right now it's fairly empty!
|
||||||
You can <a href="new_poll.php">create a new poll</a>, look at
|
You can <a href="new_poll.php">create a new poll</a>, look at
|
||||||
<a href="https://github.com/hutattedonmyarm/Dragonpolls/milestones?direction=asc&sort=title&state=open">
|
<a href="https://github.com/hutattedonmyarm/Dragonpolls/milestones?direction=asc&sort=title&state=open">
|
||||||
my roadmap
|
my roadmap
|
||||||
@ -25,13 +18,9 @@ echo get_page_header();
|
|||||||
or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>.
|
or <a href="https://github.com/hutattedonmyarm/Dragonpolls/issues/new/choose">make a feature request</a>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strike>Once all planned features for version 1.0.0 are done, and the 0.9.0 bugs are squashed,
|
Once all planned features for version 1.0.0 are done, and the 0.9.0 bugs are squashed,
|
||||||
I will replace the current version over at
|
I will replace the current version over at
|
||||||
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a></strike>.<br>
|
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>.<br>
|
||||||
Version 1.0.0 is done, and if the next Thememonday goes well,
|
|
||||||
it will be installed over at <a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>.
|
|
||||||
Considering, that 1.1.0 is done as well. I will just go ahead and release 1.1.0!
|
|
||||||
<br/>
|
|
||||||
You may see that this uses a slightly different url format, polls are at <em>view_poll.php?id=XXX</em>
|
You may see that this uses a slightly different url format, polls are at <em>view_poll.php?id=XXX</em>
|
||||||
instead of <em>index.php?poll=YYY</em>. The old links will continue to work of course, however I encourage everyone
|
instead of <em>index.php?poll=YYY</em>. The old links will continue to work of course, however I encourage everyone
|
||||||
to share the new style once this is has replaced the previous incarnation.
|
to share the new style once this is has replaced the previous incarnation.
|
||||||
@ -41,48 +30,5 @@ echo get_page_header();
|
|||||||
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>,
|
<a href="https://wedro.online/dragonpolls">https://wedro.online/dragonpolls</a>,
|
||||||
and update the productive installation with each milestone!
|
and update the productive installation with each milestone!
|
||||||
</p>
|
</p>
|
||||||
<div class="poll-grid">
|
|
||||||
<?php
|
|
||||||
$polls = $api->getPolls();
|
|
||||||
|
|
||||||
foreach ($polls as $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;
|
|
||||||
?>
|
|
||||||
<div class="poll" onclick="location.href='view_poll.php?id=<?= $poll->id ?>'">
|
|
||||||
<div class="header">
|
|
||||||
<div class="user">
|
|
||||||
<div class="usernamewrapper">
|
|
||||||
<img src="<?= $user_avatar_url ?>" class="avatar" srcset="<?= $user_avatar_url_srcset ?>"/>
|
|
||||||
<div class="usernames">
|
|
||||||
<b><?= $user_name.'<br>' ?></b>
|
|
||||||
<span class="username"><?= $username ?></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="spacer"></div>
|
|
||||||
<div class="datewrapper">
|
|
||||||
<span class="created_at">Created</span>
|
|
||||||
<span class="closed_at"><?= $poll->isClosed() ? 'Closed' : 'Closing' ?></span>
|
|
||||||
<time class="created_at" datetime="<?= $created_at->format(\DateTime::ISO8601) ?>">
|
|
||||||
<?= $created_at->format('Y-m-d, H:i:s e') ?>
|
|
||||||
</time>
|
|
||||||
<time class="closed_at" datetime="<?= $closed_at->format(\DateTime::ISO8601) ?>">
|
|
||||||
<?= $closed_at->format('Y-m-d, H:i:s e') ?>
|
|
||||||
</time>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<span class="prompt">
|
|
||||||
<em><?= $poll->prompt ?></em><br>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<a href="view_poll.php?id=<?= $poll->id ?>">View poll</a>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
</div>
|
|
||||||
<?= get_page_footer() ?>
|
<?= get_page_footer() ?>
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
require_once __DIR__ .'/bootstrap.php';
|
|
||||||
|
|
||||||
$api->logout();
|
|
||||||
$url = empty($_SERVER['HTTP_REFERER']) ? 'index.php' : $_SERVER['HTTP_REFERER'];
|
|
||||||
redirect($url);
|
|
17
new_poll.php
@ -13,11 +13,11 @@ use APnutI\Entities\User;
|
|||||||
try {
|
try {
|
||||||
echo get_page_header('New Poll', true, ['new_poll']);
|
echo get_page_header('New Poll', true, ['new_poll']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong :( "'.$e->getMessage().'"');
|
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$api->isAuthenticated(false, true)) {
|
if (!$api->isAuthenticated(false, true)) {
|
||||||
quit('You need to be logged in to create a new poll!');
|
die('You need to be logged in to create a new poll!' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['submit'])) {
|
if (!empty($_POST['submit'])) {
|
||||||
@ -32,9 +32,9 @@ if (!empty($_POST['submit'])) {
|
|||||||
$duration_total_minutes = $duration_days*60*24 + $duration_hours * 60 + $duration_minutes;
|
$duration_total_minutes = $duration_days*60*24 + $duration_hours * 60 + $duration_minutes;
|
||||||
try {
|
try {
|
||||||
$poll = Poll::create($api, $prompt, $options, $max_options, $duration_total_minutes, $is_anonymous, $is_public);
|
$poll = Poll::create($api, $prompt, $options, $max_options, $duration_total_minutes, $is_anonymous, $is_public);
|
||||||
redirect('post_poll.php?poll_token='.$poll->token.'&id='.$poll->id);
|
redirect('post_poll.php?poll_token='.$poll->token.'&id='.$poll->id.'&prompt='.urlencode($prompt));
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong creating the poll: "' . $e->getMessage() . '"');
|
die('Something went wrong creating the poll: "' . $e->getMessage() . '"' . get_page_footer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -63,13 +63,12 @@ if (!empty($_POST['submit'])) {
|
|||||||
<label for="public">Public</label>
|
<label for="public">Public</label>
|
||||||
<input type="checkbox" name="public" id="public" />
|
<input type="checkbox" name="public" id="public" />
|
||||||
<label for="max_options">Max Options</label>
|
<label for="max_options">Max Options</label>
|
||||||
<input type="number" name="max_options" id="max_options" min="1" max="10" value="1" inputmode="numeric" required/>
|
<input type="number" name="max_options" id="max_options" min="1" max="10" value="1" required/>
|
||||||
<label for="duration">Duration</label>
|
<label for="duration">Duration</label>
|
||||||
<div id="duration">
|
<div id="duration">
|
||||||
<input type="number" name="duration_days" value="1" min="0" inputmode="numeric" required/><span>day(s)</span>
|
<input type="number" name="duration_days" value="1" min="0" required/><span>day(s)</span>
|
||||||
<input type="number" name="duration_hours" value="0" min="0" inputmode="numeric" required/><span>hour(s)</span>
|
<input type="number" name="duration_hours" value="0" min="0" required/><span>hour(s)</span>
|
||||||
<input type="number" name="duration_minutes" value="0" min="0" inputmode="numeric" required/><span>minute(s)</span>
|
<input type="number" name="duration_minutes" value="0" min="0" required/><span>minute(s)</span><br>
|
||||||
<br>
|
|
||||||
<span id="openUntil"></span>
|
<span id="openUntil"></span>
|
||||||
</div>
|
</div>
|
||||||
<span class="error"></span>
|
<span class="error"></span>
|
||||||
|
101
post_poll.php
@ -3,99 +3,58 @@
|
|||||||
require_once __DIR__ .'/bootstrap.php';
|
require_once __DIR__ .'/bootstrap.php';
|
||||||
|
|
||||||
use APnutI\Entities\Poll;
|
use APnutI\Entities\Poll;
|
||||||
use APnutI\Entities\Channel;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
echo get_page_header('Post Poll', true, ['post_poll']);
|
echo get_page_header('Post Poll', true, []);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong :( "'.$e->getMessage().'"');
|
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$api->isAuthenticated(false, true)) {
|
if (!$api->isAuthenticated(false, true)) {
|
||||||
quit('You need to be logged in to create a new post!');
|
die('You need to be logged in to create a new post!' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['submit'])) {
|
if (!empty($_POST['submit'])) {
|
||||||
if (empty($_POST['poll_id']) || !is_numeric($_POST['poll_id']) || $_POST['poll_id'] <= 0) {
|
if (empty($_POST['poll_id']) || !is_numeric($_POST['poll_id']) || $_POST['poll_id'] <= 0) {
|
||||||
quit('Invalid poll ID');
|
die('Invalid poll ID'.get_page_footer());
|
||||||
}
|
}
|
||||||
if (empty($_POST['poll_token'])) {
|
if (empty($_POST['poll_token'])) {
|
||||||
quit('Invalid poll token');
|
die('Invalid poll token'.get_page_footer());
|
||||||
}
|
}
|
||||||
if (empty($_POST['post_text'])) {
|
if (empty($_POST['post_text'])) {
|
||||||
quit('Invalid text');
|
die('Invalid text'.get_page_footer());
|
||||||
}
|
}
|
||||||
$channel_id = -1;
|
|
||||||
if (!empty($_POST['channelid']) && is_numeric($_POST['channelid'])) {
|
|
||||||
$channel_id = (int)$_POST['channelid'];
|
|
||||||
}
|
|
||||||
$broadcast = !empty($_POST['broadcast']);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$channel_invite = [];
|
|
||||||
$poll_raw = Poll::makePollNoticeRaw($_POST['poll_id'], $_POST['poll_token']);
|
|
||||||
|
|
||||||
if ($channel_id > 0) {
|
|
||||||
# No broadcast, post to channel and end
|
|
||||||
if (!$broadcast) {
|
|
||||||
$channel = $api->getChannel($channel_id);
|
|
||||||
$channel->postMessage($_POST['post_text'], $poll_raw);
|
|
||||||
redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
# Broadcast, post to global, then to channel
|
|
||||||
$channel_invite = Channel::makeChannelInviteRaw($channel_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'raw' => array_merge($channel_invite, $poll_raw)
|
'raw' => Poll::makePollNoticeRaw($_POST['poll_id'], $_POST['poll_token'])
|
||||||
];
|
];
|
||||||
$post = $api->createPostWithParameters($_POST['post_text'], $params);
|
$api->createPostWithParameters($_POST['post_text'], $params);
|
||||||
if ($broadcast) {
|
|
||||||
$channel = $api->getChannel($channel_id);
|
|
||||||
$broadcast_raw = Channel::makeBroadcastNoticeRaw($post->id);
|
|
||||||
$channel_raw = array_merge($poll_raw, $broadcast_raw);
|
|
||||||
$channel->postMessage($_POST['post_text'], $channel_raw);
|
|
||||||
}
|
|
||||||
redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']);
|
redirect('view_poll.php?poll_created=1&id=' . $_POST['poll_id']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong creating your post: "' . $e->getMessage() . '"');
|
die('Something went wrong creating your post: "' . $e->getMessage() . '"'.get_page_footer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
||||||
quit('Invalid poll ID');
|
die('Invalid poll ID'.get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
$poll_token = empty($_GET['poll_token']) ? null : $_GET['poll_token'];
|
if (empty($_GET['poll_token'])) {
|
||||||
$prompt = empty($_GET['prompt']) ? null : $_GET['prompt'];
|
die('Invalid poll token'.get_page_footer());
|
||||||
$poll_id = (int)$_GET['id'];
|
|
||||||
$poll = null;
|
|
||||||
$is_public = false;
|
|
||||||
try {
|
|
||||||
$poll = $api->getPoll($poll_id, $poll_token);
|
|
||||||
$poll_token = $poll->token;
|
|
||||||
$prompt = $poll->prompt;
|
|
||||||
$is_public = $poll->is_public;
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
// Do nothing, check for token and prompt later
|
|
||||||
}
|
}
|
||||||
|
if (empty($_GET['prompt'])) {
|
||||||
|
die('Invalid prompt'.get_page_footer());
|
||||||
if (empty($poll_token)) {
|
|
||||||
quit('Invalid poll token');
|
|
||||||
}
|
|
||||||
if (empty($prompt)) {
|
|
||||||
quit('Invalid prompt');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$poll_id = (int)$_GET['id'];
|
$poll_id = (int)$_GET['id'];
|
||||||
|
$poll_token = $_GET['poll_token'];
|
||||||
|
$prompt = $_GET['prompt'];
|
||||||
$dir_name = dirname($_SERVER['SCRIPT_NAME']);
|
$dir_name = dirname($_SERVER['SCRIPT_NAME']);
|
||||||
if ($dir_name === '.' || $dir_name === '/') {
|
if ($dir_name === '.' || $dir_name === '/') {
|
||||||
$dir_name = '';
|
$dir_name = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$scheme = empty($_SERVER['REQUEST_SCHEME']) ? 'http' : $_SERVER['REQUEST_SCHEME'];
|
$scheme = empty($_SERVER['REQUEST_SCHEME']) ? 'http' : $_SERVER['REQUEST_SCHEME'];
|
||||||
$url = $scheme
|
$url = $scheme
|
||||||
. '://'
|
. '://'
|
||||||
@ -103,15 +62,6 @@ $url = $scheme
|
|||||||
. $dir_name
|
. $dir_name
|
||||||
. '/view_poll.php?id='
|
. '/view_poll.php?id='
|
||||||
. $poll_id;
|
. $poll_id;
|
||||||
|
|
||||||
$channels = [];
|
|
||||||
$channels_error_banner = '';
|
|
||||||
try {
|
|
||||||
$channels = $api->getSubscribedChannels(false);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
$channels_error_banner = make_banner('error', 'Could not load channels: "'.$e->getMessage().'"');
|
|
||||||
}
|
|
||||||
echo $channels_error_banner;
|
|
||||||
?>
|
?>
|
||||||
Do you want to post about your poll?
|
Do you want to post about your poll?
|
||||||
<form method="POST" class="post-poll">
|
<form method="POST" class="post-poll">
|
||||||
@ -122,27 +72,12 @@ Do you want to post about your poll?
|
|||||||
</textarea><br>
|
</textarea><br>
|
||||||
<input type="hidden" name="poll_id" value="<?= $poll_id ?>">
|
<input type="hidden" name="poll_id" value="<?= $poll_id ?>">
|
||||||
<input type="hidden" name="poll_token" value="<?= $poll_token ?>">
|
<input type="hidden" name="poll_token" value="<?= $poll_token ?>">
|
||||||
<label>Post to channel
|
|
||||||
<select name="channelid">
|
|
||||||
<option value="-1">---</option>
|
|
||||||
<?php
|
|
||||||
foreach ($channels as $channel) { ?>
|
|
||||||
<option value="<?= $channel->id ?>"><?= $channel->name ?></option>
|
|
||||||
<?php } ?>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
<br />
|
|
||||||
<label>Broadcast to global
|
|
||||||
<input type="checkbox" name="broadcast">
|
|
||||||
</label><br />
|
|
||||||
<button type="submit" name="submit" value="submit">Post to pnut</button>
|
<button type="submit" name="submit" value="submit">Post to pnut</button>
|
||||||
</form>
|
</form>
|
||||||
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>
|
<a href="/view_poll.php?id=<?= $poll_id ?>">Take me straight to the poll</a>
|
||||||
<?php if (!$is_public) { ?>
|
|
||||||
<p>
|
<p>
|
||||||
Note, that your poll is set to private. You will either need to share your poll with a post,
|
Note, that if your poll is set to private, you will either need to share your poll with a post,
|
||||||
or give the poll's access token to everyone who should be able to vote in your poll. Your access token is:
|
or give the poll's access token to everyone who should be able to vote in your poll. Your access token is:
|
||||||
<pre><?= $poll_token ?></pre>
|
<pre><?= $poll_token ?></pre>
|
||||||
</p>
|
</p>
|
||||||
<?php } ?>
|
|
||||||
<?= get_page_footer() ?>
|
<?= get_page_footer() ?>
|
35
release.php
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
$config = include(__DIR__.'/config.php');
|
|
||||||
$version = json_decode(file_get_contents(__DIR__.'/composer.json'), true)['version'];
|
|
||||||
|
|
||||||
if (count($argv) < 2) {
|
|
||||||
die('Usage: ' . $argv[0] . ' <release_name>');
|
|
||||||
}
|
|
||||||
$release_name = $argv[1];
|
|
||||||
$release_name_arg = escapeshellarg($release_name);
|
|
||||||
print('Creating tag'.PHP_EOL);
|
|
||||||
$output = shell_exec("git tag -s $version -m $release_name_arg");
|
|
||||||
print($output.PHP_EOL);
|
|
||||||
print(''.PHP_EOL);
|
|
||||||
|
|
||||||
print('Pusing tag'.PHP_EOL);
|
|
||||||
$output = shell_exec('git push --tags');
|
|
||||||
print($output.PHP_EOL);
|
|
||||||
print(''.PHP_EOL);
|
|
||||||
|
|
||||||
print('Creating release on Github'.PHP_EOL);
|
|
||||||
$gh_user = $config['github_username'];
|
|
||||||
$gh_repo = $config['github_repo'];
|
|
||||||
$gh_token = $config['github_token'];
|
|
||||||
$payload = escapeshellarg('{"tag_name":"'.$version.'", "name":"'.$release_name.'"}');
|
|
||||||
$ct_header = '"Content-Type: application/json"';
|
|
||||||
$output = shell_exec("curl -X POST -H $ct_header -u $gh_user:$gh_token https://api.github.com/repos/$gh_user/$gh_repo/releases -d $payload");
|
|
||||||
print($output.PHP_EOL);
|
|
||||||
print(''.PHP_EOL);
|
|
||||||
|
|
||||||
print('Creating release on Gitea'.PHP_EOL);
|
|
||||||
$g_url = $config['gitea_url'];
|
|
||||||
$g_token = $config['gitea_token'];
|
|
||||||
$token_header = '"Authorization: token ' . $g_token . '"';
|
|
||||||
$output = shell_exec("curl -X POST -H $ct_header -H $token_header $g_url -d $payload");
|
|
||||||
print($output.PHP_EOL);
|
|
@ -3,7 +3,7 @@ window.addEventListener('DOMContentLoaded', () => {
|
|||||||
for (const el of document.querySelectorAll('.option input[type=checkbox], .option input[type=radio]')) {
|
for (const el of document.querySelectorAll('.option input[type=checkbox], .option input[type=radio]')) {
|
||||||
el.onclick = updateVotesRemaining;
|
el.onclick = updateVotesRemaining;
|
||||||
}
|
}
|
||||||
const banner = document.querySelector('.banner');
|
const banner = document.querySelector('.success-banner');
|
||||||
if (banner) {
|
if (banner) {
|
||||||
banner.onclick = hideBanner;
|
banner.onclick = hideBanner;
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
window.addEventListener('DOMContentLoaded', () => {
|
|
||||||
const channelSelector = document.querySelector('select[name="channelid"]');
|
|
||||||
document.querySelector('input[name="broadcast"]').disabled = channelSelector.value === '-1';
|
|
||||||
channelSelector.onchange = validateBroadcastStatus;
|
|
||||||
});
|
|
||||||
|
|
||||||
function validateBroadcastStatus() {
|
|
||||||
const postToChannel = parseInt(this.value) > 0;
|
|
||||||
const checkbox = document.querySelector('input[name="broadcast"]');
|
|
||||||
if (!postToChannel) {
|
|
||||||
checkbox.dataset.wasChecked = checkbox.checked;
|
|
||||||
checkbox.checked = false;
|
|
||||||
checkbox.disabled = true;
|
|
||||||
} else {
|
|
||||||
if (checkbox.disabled && checkbox.dataset.wasChecked !== undefined) {
|
|
||||||
checkbox.checked = checkbox.dataset.wasChecked === 'true';
|
|
||||||
}
|
|
||||||
checkbox.disabled = false;
|
|
||||||
}
|
|
||||||
}
|
|
191
styles/style.css
@ -1,56 +1,19 @@
|
|||||||
/* Globals */
|
/* Globals */
|
||||||
:root {
|
|
||||||
--main-bg-color: rgb(223, 223, 223);
|
|
||||||
--secondary-bg-color: rgba(20, 20, 20, 0.7);
|
|
||||||
--ternary-bg-color: rgba(175, 175, 175, 0.7);
|
|
||||||
--main-fg-color: black;
|
|
||||||
--secondary-fg-color: rgb(210, 210, 210);
|
|
||||||
--main-accent-color: rgb(253, 122, 0);
|
|
||||||
--disabled-color: gray;
|
|
||||||
--green: green;
|
|
||||||
--default-shadow: 3px 3px 10px 1px var(--secondary-bg-color);
|
|
||||||
--error-color-translucent: rgba(193, 0, 0, 0.87);
|
|
||||||
--error-color: rgba(255, 0, 0);
|
|
||||||
}
|
|
||||||
@supports (color: color(display-p3 1 1 1)) {
|
|
||||||
:root {
|
|
||||||
--main-accent-color: color(display-p3 0.927 0.506 0.028)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: dark) {
|
|
||||||
:root {
|
:root {
|
||||||
--main-bg-color: rgb(48, 48, 48);
|
--main-bg-color: rgb(48, 48, 48);
|
||||||
--secondary-bg-color: rgba(10, 10, 10, 0.7);
|
--secondary-bg-color: rgba(10, 10, 10, 0.7);
|
||||||
--ternary-bg-color: rgba(10, 10, 10, 0.7);
|
|
||||||
--main-fg-color: white;
|
--main-fg-color: white;
|
||||||
--secondary-fg-color: rgb(210, 210, 210);
|
|
||||||
--main-accent-color: rgb(253, 122, 0);
|
--main-accent-color: rgb(253, 122, 0);
|
||||||
--disabled-color: gray;
|
--disabled-color: gray;
|
||||||
--green: green;
|
--green: green;
|
||||||
--default-shadow: 3px 3px 10px 1px var(--secondary-bg-color);
|
--default-shadow: 3px 3px 10px 1px var(--secondary-bg-color);
|
||||||
--error-color-translucent: rgba(255, 0, 0, 0.3);
|
--error-color: rgba(255, 0, 0, 0.3);
|
||||||
--error-color: rgba(255, 0, 0);
|
|
||||||
}
|
}
|
||||||
@supports (color: color(display-p3 1 1 1)) {
|
@supports (color: color(display-p3 1 1 1)) {
|
||||||
:root {
|
:root {
|
||||||
--main-accent-color: color(display-p3 0.927 0.506 0.028)
|
--main-accent-color: color(display-p3 0.927 0.506 0.028)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@media (prefers-color-scheme: light) {
|
|
||||||
::placeholder {
|
|
||||||
opacity: 1;
|
|
||||||
color: rgb(73, 73, 73);
|
|
||||||
}
|
|
||||||
:-ms-input-placeholder {
|
|
||||||
color: rgb(73, 73, 73);
|
|
||||||
}
|
|
||||||
::-ms-input-placeholder {
|
|
||||||
color: rgb(73, 73, 73);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
a:visited, a {
|
a:visited, a {
|
||||||
color: var(--main-accent-color);
|
color: var(--main-accent-color);
|
||||||
@ -63,10 +26,6 @@ a svg {
|
|||||||
stroke-width: 0.5em;
|
stroke-width: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
a svg .filled {
|
|
||||||
fill: var(--main-accent-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: var(--main-bg-color);
|
background: var(--main-bg-color);
|
||||||
color: var(--main-fg-color);
|
color: var(--main-fg-color);
|
||||||
@ -120,7 +79,6 @@ header {
|
|||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
background: var(--secondary-bg-color);
|
background: var(--secondary-bg-color);
|
||||||
box-shadow: var(--default-shadow);
|
box-shadow: var(--default-shadow);
|
||||||
color: var(--secondary-fg-color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.spacer {
|
.spacer {
|
||||||
@ -144,23 +102,6 @@ header .newpolllink svg {
|
|||||||
stroke-width: 1em;
|
stroke-width: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
header .avatar {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
margin-right: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 450px) {
|
|
||||||
.linklabel {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@media (max-width: 380px) {
|
|
||||||
.greeting {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Polls */
|
/* Polls */
|
||||||
.poll {
|
.poll {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -181,11 +122,6 @@ header .avatar {
|
|||||||
box-shadow: var(--default-shadow);
|
box-shadow: var(--default-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.poll .user .usernamewrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.datewrapper {
|
.datewrapper {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-column-gap: 8px;
|
grid-column-gap: 8px;
|
||||||
@ -213,28 +149,9 @@ datewrapper time {
|
|||||||
}
|
}
|
||||||
.poll .header .user .avatar {
|
.poll .header .user .avatar {
|
||||||
width: 50px;
|
width: 50px;
|
||||||
height: 50px;
|
|
||||||
}
|
}
|
||||||
.option-responses .avatar {
|
.option-responses .avatar {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 450px) {
|
|
||||||
.poll-grid .poll .user {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
.datewrapper {
|
|
||||||
margin-left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 380px) {
|
|
||||||
.poll .user {
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: start;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success banner */
|
/* Success banner */
|
||||||
@ -244,20 +161,14 @@ datewrapper time {
|
|||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner {
|
.success-banner {
|
||||||
|
background-color: var(--green);
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
box-shadow: var(--default-shadow);
|
box-shadow: var(--default-shadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner.success {
|
|
||||||
background-color: var(--green);
|
|
||||||
}
|
|
||||||
.banner.error {
|
|
||||||
background-color: var(--error-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.banner-wrapper.hiding {
|
.banner-wrapper.hiding {
|
||||||
transform: translateX(-200%);
|
transform: translateX(-200%);
|
||||||
}
|
}
|
||||||
@ -268,9 +179,8 @@ datewrapper time {
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.banner span {
|
.success-banner span {
|
||||||
font-size: x-large;
|
font-size: x-large;
|
||||||
margin-right: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Poll creation */
|
/* Poll creation */
|
||||||
@ -288,13 +198,13 @@ datewrapper time {
|
|||||||
}
|
}
|
||||||
.create-poll input[type=number] {
|
.create-poll input[type=number] {
|
||||||
max-width: 3em;
|
max-width: 3em;
|
||||||
background-color: var(--ternary-bg-color);
|
background-color: var(--secondary-bg-color);
|
||||||
color: var(--main-accent-color);
|
color: var(--main-accent-color);
|
||||||
}
|
}
|
||||||
.create-poll input[type=text] {
|
.create-poll input[type=text] {
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: var(--ternary-bg-color);
|
background-color: var(--secondary-bg-color);
|
||||||
color: var(--main-accent-color);
|
color: var(--main-accent-color);
|
||||||
}
|
}
|
||||||
.create-poll input[type=text]:focus {
|
.create-poll input[type=text]:focus {
|
||||||
@ -330,7 +240,7 @@ datewrapper time {
|
|||||||
.create-poll .error {
|
.create-poll .error {
|
||||||
grid-column: 1/3;
|
grid-column: 1/3;
|
||||||
grid-row: 7;
|
grid-row: 7;
|
||||||
background-color: var(--error-color-translucent);
|
background-color: var(--error-color);
|
||||||
}
|
}
|
||||||
.create-poll .error:not(:empty) {
|
.create-poll .error:not(:empty) {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
@ -340,42 +250,6 @@ datewrapper time {
|
|||||||
color: var(--main-text-color);
|
color: var(--main-text-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 800px) {
|
|
||||||
#prompt {
|
|
||||||
grid-row: 2;
|
|
||||||
}
|
|
||||||
label[for=prompt] {
|
|
||||||
grid-row: 2;
|
|
||||||
}
|
|
||||||
.create-poll label[for=options] {
|
|
||||||
grid-row: 3;
|
|
||||||
}
|
|
||||||
.create-poll #options {
|
|
||||||
grid-row: 3;
|
|
||||||
}
|
|
||||||
.create-poll label[for=anonymous] {
|
|
||||||
grid-row: 4
|
|
||||||
}
|
|
||||||
.create-poll label[for=public] {
|
|
||||||
grid-row: 5
|
|
||||||
}
|
|
||||||
.create-poll label[for=max_options] {
|
|
||||||
grid-row: 6
|
|
||||||
}
|
|
||||||
.create-poll label[for=duration] {
|
|
||||||
grid-row: 7
|
|
||||||
}
|
|
||||||
#duration {
|
|
||||||
grid-row: 7;
|
|
||||||
}
|
|
||||||
.create-poll button[type=submit] {
|
|
||||||
grid-row: 8;
|
|
||||||
}
|
|
||||||
.create-poll .error {
|
|
||||||
grid-row: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Footer */
|
/* Footer */
|
||||||
footer {
|
footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -389,54 +263,3 @@ footer {
|
|||||||
footer .sourcecode svg {
|
footer .sourcecode svg {
|
||||||
stroke-width: 1.5em;
|
stroke-width: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Deal with the pill on iOS */
|
|
||||||
@supports (padding: env(safe-area-inset-left)) {
|
|
||||||
@media (max-width: 1000px) {
|
|
||||||
header {
|
|
||||||
padding-left: max(env(safe-area-inset-left, 20px), 8px);
|
|
||||||
padding-right: env(safe-area-inset-right, 20px);
|
|
||||||
padding-top: calc(env(safe-area-inset-top, 20px) + 8px);
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
padding-left: calc(env(safe-area-inset-left, 20px) + 8px);
|
|
||||||
padding-right: env(safe-area-inset-right, 20px);
|
|
||||||
padding-bottom: max(env(safe-area-inset-bottom, 20px), 8px);
|
|
||||||
}
|
|
||||||
main {
|
|
||||||
padding-left: max(env(safe-area-inset-left, 20px), 8px);
|
|
||||||
padding-right: max(env(safe-area-inset-right, 20px), 8px);
|
|
||||||
}
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Poll grid */
|
|
||||||
.poll-grid {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.poll-grid .poll {
|
|
||||||
display: initial;
|
|
||||||
padding: 8px;
|
|
||||||
border: 2px solid var(--main-accent-color);
|
|
||||||
margin: 8px;
|
|
||||||
transition: all 0.2s;
|
|
||||||
cursor: pointer;
|
|
||||||
width: 500px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.poll-grid .poll:hover {
|
|
||||||
box-shadow: 4px 6px 3px 0 var(--secondary-bg-color);
|
|
||||||
transform: translate(-2px, -2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Other */
|
|
||||||
|
|
||||||
form.polltoken-input {
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
@ -10,16 +10,14 @@ use APnutI\Exceptions\PollAccessRestrictedException;
|
|||||||
use APnutI\Entities\Poll;
|
use APnutI\Entities\Poll;
|
||||||
use APnutI\Entities\User;
|
use APnutI\Entities\User;
|
||||||
|
|
||||||
$die = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
echo get_page_header('Poll', true, ['poll']);
|
echo get_page_header('Poll', true, ['poll']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong :( "' . $e->getMessage());
|
die('Something went wrong :( "' . $e->getMessage() . '"' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
if (empty($_GET['id']) || !is_numeric($_GET['id']) || $_GET['id'] <= 0) {
|
||||||
quit('Invalid poll ID');
|
die('Invalid poll ID'.get_page_footer());
|
||||||
}
|
}
|
||||||
$poll_id = (int)$_GET['id'];
|
$poll_id = (int)$_GET['id'];
|
||||||
$poll = null;
|
$poll = null;
|
||||||
@ -28,25 +26,24 @@ try {
|
|||||||
$poll_token = array_key_exists('polltoken', $_GET) ? $_GET['polltoken'] : null;
|
$poll_token = array_key_exists('polltoken', $_GET) ? $_GET['polltoken'] : null;
|
||||||
$poll = $api->getPoll($poll_id, $poll_token);
|
$poll = $api->getPoll($poll_id, $poll_token);
|
||||||
} catch (NotFoundException $nfe) {
|
} catch (NotFoundException $nfe) {
|
||||||
die('Poll not found');
|
die('Poll not found'.get_page_footer());
|
||||||
} catch (NotSupportedPollException $nspe) {
|
} catch (NotSupportedPollException $nspe) {
|
||||||
quit('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage());
|
die('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage() . get_page_footer());
|
||||||
} catch (PollAccessRestrictedException $are) {
|
} catch (PollAccessRestrictedException $are) {
|
||||||
$message_header = array_key_exists('polltoken', $_GET)
|
$message = array_key_exists('polltoken', $_GET)
|
||||||
? 'Sorry, your poll token is invalid! Please enter a valid token: '
|
? 'Sorry, your poll token is invalid! Please enter a valid token: '
|
||||||
: 'Sorry, this poll is private!';
|
: ('Sorry, this poll is private! If you have found this poll on a post, '
|
||||||
$message_text = array_key_exists('polltoken', $_GET)
|
|
||||||
? 'Please enter a valid token: '
|
|
||||||
: ('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: ');
|
. 'please enter a link to the post, the post ID or the access token for the poll: ');
|
||||||
$form = '<form class="polltoken-input"><input type="text" name="polltoken">'
|
die(
|
||||||
. '<input type="hidden" name="id" value="'.$poll_id.'"><button type="submit">Access poll</button></form>';
|
$message
|
||||||
quit($message_header, $message_text . $form);
|
. '<form><input type="text" name="polltoken">'
|
||||||
|
. '<input type="hidden" name="id" value="'.$poll_id.'"><button type="submit">Access poll</button></form>'
|
||||||
|
. get_page_footer()
|
||||||
|
);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
quit('Something went wrong :( "' . $e->getMessage(). '"');
|
die('Something went wrong :( "'.$e->getMessage().'"' . get_page_footer());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$user_avatar_url = $poll->user->getAvatarUrl(50);
|
$user_avatar_url = $poll->user->getAvatarUrl(50);
|
||||||
$user_avatar_url_srcset = get_source_set($poll->user, 50);
|
$user_avatar_url_srcset = get_source_set($poll->user, 50);
|
||||||
|
|
||||||
@ -63,15 +60,16 @@ try {
|
|||||||
$votes_remaining_hidden = $poll->canVote() ? '' : ' hidden';
|
$votes_remaining_hidden = $poll->canVote() ? '' : ' hidden';
|
||||||
$data_can_vote = $poll->canVote() ? 'true' : 'false';
|
$data_can_vote = $poll->canVote() ? 'true' : 'false';
|
||||||
$disabled_button = ($poll->canVote() && count($user_votes) > 0) ? '' : 'disabled';
|
$disabled_button = ($poll->canVote() && count($user_votes) > 0) ? '' : 'disabled';
|
||||||
} catch (\Exception $e) {
|
|
||||||
quit('Something went wrong :( "' . $e->getMessage(). '"');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (array_key_exists('success', $_GET) && $_GET['success'] == 1) { ?>
|
if (array_key_exists('success', $_GET) && $_GET['success'] == 1) { ?>
|
||||||
<?= make_banner('success', 'Your vote has been saved, thank you!') ?>
|
<div class="banner-wrapper">
|
||||||
|
<div class="success-banner"><span>✓</span> Your vote has been saved, thank you!</div>
|
||||||
|
</div>
|
||||||
<?php }
|
<?php }
|
||||||
if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
|
if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
|
||||||
<?= make_banner('success', 'Your poll and post have been created, thank you!') ?>
|
<div class="banner-wrapper">
|
||||||
|
<div class="success-banner"><span>✓</span> Your poll and post have been created, thank you!</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="poll">
|
<div class="poll">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
@ -114,24 +112,24 @@ if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
|
|||||||
$input_type = $poll->max_options === 1 ? 'radio' : 'checkbox';
|
$input_type = $poll->max_options === 1 ? 'radio' : 'checkbox';
|
||||||
$input_name = $poll->max_options === 1 ? 'options' : 'options[]';
|
$input_name = $poll->max_options === 1 ? 'options' : 'options[]';
|
||||||
foreach ($poll->options as $option) {
|
foreach ($poll->options as $option) {
|
||||||
$checked = $option->is_your_response ? 'checked' : '';
|
$checked = $option->is_your_response ? 'checked' : ''; ?>
|
||||||
$num_respondents_text = $option->respondents > 0 ? ' (' . $option->respondents . ')' : '';
|
|
||||||
?>
|
|
||||||
<div class="option" style="grid-row: <?= $row ?>;">
|
<div class="option" style="grid-row: <?= $row ?>;">
|
||||||
<input
|
<input
|
||||||
type="<?= $input_type ?>" <?= $checked.' '.$disabled ?>
|
type="<?= $input_type ?>" <?= $checked.' '.$disabled ?>
|
||||||
value="<?= $option->position ?>"
|
value="<?= $option->position ?>"
|
||||||
name="<?= $input_name ?>"/>
|
name="<?= $input_name ?>"/>
|
||||||
<span class="option-text"><?= $option->text . $num_respondents_text?></span>
|
<span class="option-text"><?= $option->text . ' (' . $option->respondents . ')'?></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="option-responses" style="grid-row: <?= $row++ ?>;grid-column: 2;">
|
<div class="option-responses" style="grid-row: <?= $row++ ?>;grid-column: 2;">
|
||||||
<?php foreach ($option->respondent_ids as $res_id) {
|
<?php foreach ($option->respondent_ids as $res_id) {
|
||||||
$u = $api->getUser($res_id, $user_args); ?>
|
$u = $api->getUser($res_id, $user_args); ?>
|
||||||
<a href="https://pnut.io/@<?= $u->username ?>"><img
|
<a href="https://pnut.io/@<?= $u->username ?>">
|
||||||
|
<img
|
||||||
src="<?= $u->getAvatarUrl(20) ?>"
|
src="<?= $u->getAvatarUrl(20) ?>"
|
||||||
srcset="<?= get_source_set($u, 20) ?>"
|
srcset="<?= get_source_set($u, 20) ?>"
|
||||||
class="avatar"
|
class="avatar"
|
||||||
title="@<?= $u->username ?>"></a>
|
title="@<?= $u->username ?>">
|
||||||
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -140,7 +138,7 @@ if (array_key_exists('poll_created', $_GET) && $_GET['poll_created'] == 1) { ?>
|
|||||||
name="submit_vote"
|
name="submit_vote"
|
||||||
value="submit" <?= $disabled_button?>
|
value="submit" <?= $disabled_button?>
|
||||||
data-can-vote="<?= $data_can_vote ?>">
|
data-can-vote="<?= $data_can_vote ?>">
|
||||||
<?= count($user_votes) > 0 ? 'Update' : '' ?> Vote
|
Vote
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,12 +12,11 @@ if (is_array($_POST['options'])) {
|
|||||||
try {
|
try {
|
||||||
$res = $api->voteInPoll((int)$_POST['pollid'], $voted_options, $_POST['polltoken']);
|
$res = $api->voteInPoll((int)$_POST['pollid'], $voted_options, $_POST['polltoken']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$header = get_page_header('Voting error');
|
get_page_header('Voting error');
|
||||||
$str = $header
|
$str = 'Sorry, something went wrong while voting! "'
|
||||||
. 'Sorry, something went wrong while voting! "'
|
|
||||||
. $e->getMessage()
|
. $e->getMessage()
|
||||||
. '"<br>Please yell at <a href="https://pnut.io/@hutattedonmyarm">@hutattedonmyarm</a><br>'
|
. '"<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>';
|
. '<a href="view_poll.php?id='.$_POST['pollid'].'"s>Go back to the poll</a>';
|
||||||
quit($str);
|
die($str);
|
||||||
}
|
}
|
||||||
redirect('view_poll.php?id='.$_POST['pollid'].'&success=1');
|
redirect('view_poll.php?id='.$_POST['pollid'].'&success=1');
|
||||||
|