From b9521ad7edab556770441f19579f0c533a3f55ae Mon Sep 17 00:00:00 2001 From: aymm Date: Thu, 11 Mar 2021 16:51:25 +0000 Subject: [PATCH] initial commit --- .gitignore | 3 + .nova/Configuration.json | 4 + auth_callback.php | 28 ++++++ bootstrap.php | 16 ++++ composer.json | 11 +++ composer.lock | 202 +++++++++++++++++++++++++++++++++++++++ config.php.default | 10 ++ index.php | 10 ++ phpcs.xml | 28 ++++++ view_poll.php | 30 ++++++ 10 files changed, 342 insertions(+) create mode 100644 .gitignore create mode 100644 .nova/Configuration.json create mode 100644 auth_callback.php create mode 100644 bootstrap.php create mode 100644 composer.json create mode 100644 composer.lock create mode 100644 config.php.default create mode 100644 index.php create mode 100644 phpcs.xml create mode 100644 view_poll.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e52c867 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +config.php +logs/* +vendor/ \ No newline at end of file diff --git a/.nova/Configuration.json b/.nova/Configuration.json new file mode 100644 index 0000000..0ad224e --- /dev/null +++ b/.nova/Configuration.json @@ -0,0 +1,4 @@ +{ + "com.thorlaksson.phpcs.runOnChange" : "onSave", + "com.thorlaksson.phpcs.standard" : "\/Volumes\/Alyx\/Users\/max\/Dev\/Pnut\/Dragonpolls\/phpcs.xml" +} diff --git a/auth_callback.php b/auth_callback.php new file mode 100644 index 0000000..24d083c --- /dev/null +++ b/auth_callback.php @@ -0,0 +1,28 @@ +authenticate($_GET['code']); + if ($success) { + die('Welcome! Back to home'); + } else { + die('Echo error authenticating'); + } +} else { + die('error authenticating: ' . $_GET['error_message']); +} diff --git a/bootstrap.php b/bootstrap.php new file mode 100644 index 0000000..087bf3c --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,16 @@ +=7.2", + "psr/log": "^1.0.1" + }, + "provide": { + "psr/log-implementation": "1.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7", + "graylog2/gelf-php": "^1.4.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4", + "php-console/php-console": "^3.1.3", + "phpspec/prophecy": "^1.6.1", + "phpstan/phpstan": "^0.12.59", + "phpunit/phpunit": "^8.5", + "predis/predis": "^1.1", + "rollbar/rollbar": "^1.3", + "ruflin/elastica": ">=0.90 <7.0.1", + "swiftmailer/swiftmailer": "^5.3|^6.0" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "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-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "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-console/php-console": "Allow sending log messages to Google Chrome", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "time": "2020-12-14T13:15:25+00:00" + }, + { + "name": "psr/log", + "version": "1.1.3", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc", + "reference": "0f73288fd15629204f9d42b7055f72dacbe811fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, + "time": "2020-03-23T09:12:05+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": { + "hutattedonmyarm/apnuti": 20 + }, + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/config.php.default b/config.php.default new file mode 100644 index 0000000..61eeaf1 --- /dev/null +++ b/config.php.default @@ -0,0 +1,10 @@ + '', + 'client_secret' => '', + 'log_file' => '../../logs/Dragonpolls.log', // Relative to index.php + 'app_name' => 'Playground', + 'callback_url' => 'http://localhost/auth_callback.php', + 'permission_scopes' => 'basic' //comma seperated string +]; diff --git a/index.php b/index.php new file mode 100644 index 0000000..e4e6e3e --- /dev/null +++ b/index.php @@ -0,0 +1,10 @@ +isAuthenticated(); +if (!$is_authenticated) { + echo 'Login with pnut'; +} else { + echo 'Welcome'; +} diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..4bb20d7 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/view_poll.php b/view_poll.php new file mode 100644 index 0000000..2a3d43a --- /dev/null +++ b/view_poll.php @@ -0,0 +1,30 @@ +getPoll($poll_id); +} catch (NotFoundException $nfe) { + die('Poll not found'); +} catch (HttpPnutForbiddenException $fe) { + die('Poll token required!'); +} catch (NotSupportedPollException $nspe) { + die('Sorry, this poll has a not yet supported type: ' . $nspe->getMessage()); +} + +#echo json_encode($poll); +#$user_avatar_url = $api->getAvatarUrl($poll->user->id, 50); +$user_avatar_url = $poll->user->getAvatarUrl(50); +$prompt = '@' . $poll->user->username . ' asks: ' . $poll->prompt; +echo ''; +echo $prompt;