From d0aea4e4e749fbd220f9f6fda4fea4cb4d246996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 28 Dec 2019 22:42:25 +0100 Subject: [PATCH] Refactor [su_ajax|admin_cmd|api_webhook] methods into single /api/ interface --- www/{ajax => commands}/.htaccess | 0 .../alephnote_show.php} | 0 www/commands/alephnote_statsping.php | 42 +++++++++ .../api_test.php => commands/base_test.php} | 0 .../extendedgitgraph_redraw.php} | 2 +- .../extendedgitgraph_refresh.php} | 2 +- .../extendedgitgraph_status.php} | 4 +- www/commands/progs_updatecheck.php | 21 +++++ .../server_backupupload.php} | 17 ++-- www/commands/server_gitwebhook.php | 29 ++++++ www/commands/server_setselfaddress.php | 9 ++ www/commands/site_createBookThumbnails.php | 32 +++++++ www/commands/site_createProgramThumbnails.php | 29 ++++++ .../updates_show.php} | 0 www/data/css/styles.css | 4 +- www/data/css/styles.min.css | 4 +- www/data/css/styles_about.scss | 2 +- www/data/css/styles_admin.scss | 2 +- www/data/javascript/admin.js | 10 +-- www/extern/{egh => egg}/EGGDatabase.php | 0 www/extern/{egh => egg}/ExtendedGitGraph2.php | 0 www/extern/{egh => egg}/Logger.php | 0 www/extern/{egh => egg}/Models.php | 0 www/extern/{egh => egg}/OutputGenerator.php | 0 www/extern/{egh => egg}/RemoteSource.php | 0 www/extern/{egh => egg}/Utils.php | 0 www/extern/{egh => egg}/db_init.sql | 0 www/extern/{egh => egg}/db_queryyear.sql | 0 www/index.php | 41 ++++----- www/internals/mikeschergitgraph.php | 2 +- www/pages/about.php | 2 +- www/pages/admin.php | 14 +-- www/pages/admin_cmd.php | 64 ------------- www/pages/api.php | 89 +++++++++++++++++++ www/pages/api_setselfadress.php | 9 -- www/pages/api_stats.php | 37 -------- www/pages/api_updatecheck.php | 18 ---- www/pages/api_webhook.php | 28 ------ www/pages/su_ajax.php | 27 ------ 39 files changed, 306 insertions(+), 234 deletions(-) rename www/{ajax => commands}/.htaccess (100%) rename www/{ajax/an_activeusers.php => commands/alephnote_show.php} (100%) create mode 100644 www/commands/alephnote_statsping.php rename www/{pages/api_test.php => commands/base_test.php} (100%) rename www/{ajax/egh_redraw.php => commands/extendedgitgraph_redraw.php} (76%) rename www/{ajax/egh_refresh.php => commands/extendedgitgraph_refresh.php} (77%) rename www/{ajax/egh_status.php => commands/extendedgitgraph_status.php} (100%) create mode 100644 www/commands/progs_updatecheck.php rename www/{pages/api_backupupload.php => commands/server_backupupload.php} (65%) create mode 100644 www/commands/server_gitwebhook.php create mode 100644 www/commands/server_setselfaddress.php create mode 100644 www/commands/site_createBookThumbnails.php create mode 100644 www/commands/site_createProgramThumbnails.php rename www/{ajax/ul_entries.php => commands/updates_show.php} (100%) rename www/extern/{egh => egg}/EGGDatabase.php (100%) rename www/extern/{egh => egg}/ExtendedGitGraph2.php (100%) rename www/extern/{egh => egg}/Logger.php (100%) rename www/extern/{egh => egg}/Models.php (100%) rename www/extern/{egh => egg}/OutputGenerator.php (100%) rename www/extern/{egh => egg}/RemoteSource.php (100%) rename www/extern/{egh => egg}/Utils.php (100%) rename www/extern/{egh => egg}/db_init.sql (100%) rename www/extern/{egh => egg}/db_queryyear.sql (100%) delete mode 100644 www/pages/admin_cmd.php create mode 100644 www/pages/api.php delete mode 100644 www/pages/api_setselfadress.php delete mode 100644 www/pages/api_stats.php delete mode 100644 www/pages/api_updatecheck.php delete mode 100644 www/pages/api_webhook.php delete mode 100644 www/pages/su_ajax.php diff --git a/www/ajax/.htaccess b/www/commands/.htaccess similarity index 100% rename from www/ajax/.htaccess rename to www/commands/.htaccess diff --git a/www/ajax/an_activeusers.php b/www/commands/alephnote_show.php similarity index 100% rename from www/ajax/an_activeusers.php rename to www/commands/alephnote_show.php diff --git a/www/commands/alephnote_statsping.php b/www/commands/alephnote_statsping.php new file mode 100644 index 0000000..2f566ff --- /dev/null +++ b/www/commands/alephnote_statsping.php @@ -0,0 +1,42 @@ +".$data['version']."
".$data['url']); diff --git a/www/pages/api_backupupload.php b/www/commands/server_backupupload.php similarity index 65% rename from www/pages/api_backupupload.php rename to www/commands/server_backupupload.php index a6d2673..1f22411 100644 --- a/www/pages/api_backupupload.php +++ b/www/commands/server_backupupload.php @@ -1,19 +1,22 @@ '; +echo ''; +echo ''; +echo ''; +echo 'Mikescher.com - AdminExec'; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; + +foreach (Books::listAll() as $book) +{ + echo 'Create preview for ' . $book['title'] . '
' . "\n"; + Books::createPreview($book); +} +echo 'Finished.' . '
' . "\n"; + +echo ''; +echo ''; +echo ''; + + +die('Wrong command.'); \ No newline at end of file diff --git a/www/commands/site_createProgramThumbnails.php b/www/commands/site_createProgramThumbnails.php new file mode 100644 index 0000000..8b5cd6a --- /dev/null +++ b/www/commands/site_createProgramThumbnails.php @@ -0,0 +1,29 @@ +'; +echo ''; +echo ''; +echo ''; +echo 'Mikescher.com - AdminExec'; +echo ''; +echo ''; +echo ''; +echo ''; +echo ''; + +foreach (Programs::listAll() as $prog) +{ + echo 'Create preview for ' . $prog['name'] . '
' . "\n"; + Programs::createPreview($prog); +} +echo 'Finished.' . '
' . "\n"; + +echo ''; +echo ''; +echo ''; diff --git a/www/ajax/ul_entries.php b/www/commands/updates_show.php similarity index 100% rename from www/ajax/ul_entries.php rename to www/commands/updates_show.php diff --git a/www/data/css/styles.css b/www/data/css/styles.css index b722316..81dbbb9 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -677,7 +677,7 @@ html, body { margin-bottom: 20px; } -.about_egh_container { +.about_egg_container { display: flex; flex-direction: column; align-items: center; @@ -812,7 +812,7 @@ html, body { margin-bottom: 20px; } -.egh_ajaxOutput { +.egg_ajaxOutput { display: flex; box-sizing: border-box; width: 100%; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index d30e097..3fe2531 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -134,7 +134,7 @@ html,body{margin:0;padding:0;height:100%} @media(max-width:850px){.index_pnl_base{width:330px}} .aboutcontent{display:block;width:100%} .aboutcontent .boxedcontent{margin-bottom:20px} -.about_egh_container{display:flex;flex-direction:column;align-items:center} +.about_egg_container{display:flex;flex-direction:column;align-items:center} .git_list{display:inline-block;width:715px;height:115px;overflow:visible} @media(max-width:991px){ .git_list{width:100%;height:auto} @@ -159,7 +159,7 @@ html,body{margin:0;padding:0;height:100%} .egg_col_x5_4{fill:#003958} .admincontent{display:block;width:100%} .admincontent .boxedcontent{margin-bottom:20px} -.egh_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px} +.egg_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px} .keyvaluelist{display:flex;flex-direction:column} .keyvaluelist div{display:flex;flex-direction:row} .keyvaluelist div span{align-self:center} diff --git a/www/data/css/styles_about.scss b/www/data/css/styles_about.scss index c2eabcc..6c6acbc 100644 --- a/www/data/css/styles_about.scss +++ b/www/data/css/styles_about.scss @@ -9,7 +9,7 @@ margin-bottom: 20px; } -.about_egh_container { +.about_egg_container { display: flex; flex-direction: column; align-items: center; diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index 2cc00ef..d581245 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -9,7 +9,7 @@ margin-bottom: 20px; } -.egh_ajaxOutput { +.egg_ajaxOutput { display: flex; box-sizing: border-box; diff --git a/www/data/javascript/admin.js b/www/data/javascript/admin.js index 270dc90..cf0e325 100644 --- a/www/data/javascript/admin.js +++ b/www/data/javascript/admin.js @@ -1,7 +1,7 @@ function queryStatus(appendix, secret) { jQuery.ajax({ - url: '/admin/egh/status?secret='+secret, + url: '/api/extendedgitgraph::status?secret='+secret, success: function(result) { let ajaxOutput = $('#egh_ajaxOutput'); @@ -14,11 +14,11 @@ function queryStatus(appendix, secret) function startAjaxRefresh(secret) { - $('#egh_ajaxOutput').val("Started."); + $('#egg_ajaxOutput').val("Started."); val = setInterval(function(){ queryStatus('', secret); }, 500); jQuery.ajax({ - url: '/admin/egh/refresh?secret='+secret, + url: '/api/extendedgitgraph::refresh?secret='+secret, success: function(result) { clearInterval(val); @@ -35,11 +35,11 @@ function startAjaxRefresh(secret) function startAjaxRedraw(secret) { - $('#egh_ajaxOutput').val("Started."); + $('#egg_ajaxOutput').val("Started."); val = setInterval(function(){ queryStatus('', secret); }, 500); jQuery.ajax({ - url: '/admin/egh/redraw?secret='+secret, + url: '/api/extendedgitgraph::redraw?secret='+secret, success: function(result) { clearInterval(val); diff --git a/www/extern/egh/EGGDatabase.php b/www/extern/egg/EGGDatabase.php similarity index 100% rename from www/extern/egh/EGGDatabase.php rename to www/extern/egg/EGGDatabase.php diff --git a/www/extern/egh/ExtendedGitGraph2.php b/www/extern/egg/ExtendedGitGraph2.php similarity index 100% rename from www/extern/egh/ExtendedGitGraph2.php rename to www/extern/egg/ExtendedGitGraph2.php diff --git a/www/extern/egh/Logger.php b/www/extern/egg/Logger.php similarity index 100% rename from www/extern/egh/Logger.php rename to www/extern/egg/Logger.php diff --git a/www/extern/egh/Models.php b/www/extern/egg/Models.php similarity index 100% rename from www/extern/egh/Models.php rename to www/extern/egg/Models.php diff --git a/www/extern/egh/OutputGenerator.php b/www/extern/egg/OutputGenerator.php similarity index 100% rename from www/extern/egh/OutputGenerator.php rename to www/extern/egg/OutputGenerator.php diff --git a/www/extern/egh/RemoteSource.php b/www/extern/egg/RemoteSource.php similarity index 100% rename from www/extern/egh/RemoteSource.php rename to www/extern/egg/RemoteSource.php diff --git a/www/extern/egh/Utils.php b/www/extern/egg/Utils.php similarity index 100% rename from www/extern/egh/Utils.php rename to www/extern/egg/Utils.php diff --git a/www/extern/egh/db_init.sql b/www/extern/egg/db_init.sql similarity index 100% rename from www/extern/egh/db_init.sql rename to www/extern/egg/db_init.sql diff --git a/www/extern/egh/db_queryyear.sql b/www/extern/egg/db_queryyear.sql similarity index 100% rename from www/extern/egh/db_queryyear.sql rename to www/extern/egg/db_queryyear.sql diff --git a/www/index.php b/www/index.php index 1a10158..e9c705a 100644 --- a/www/index.php +++ b/www/index.php @@ -30,26 +30,21 @@ $URL_RULES = [ 'url' => ['books', 'view', '?{id}'], 'target' => 'pages/books_view.php', 'options' => [ 'id' => '%GET%' ], ], [ 'url' => ['books', 'view', '?{id}', '*'], 'target' => 'pages/books_view.php', 'options' => [ 'id' => '%URL%' ], ], - [ 'url' => ['update.php'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ], - [ 'url' => ['update.php', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ], - [ 'url' => ['update'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ], - [ 'url' => ['update', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ], - [ 'url' => ['update2'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ], - [ 'url' => ['api', 'update'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%' ], ], - [ 'url' => ['api', 'update', '?{Name}'], 'target' => 'pages/api_updatecheck.php', 'options' => [ '_opt' => 'http', 'Name' => '%URL%' ], ], - [ 'url' => ['api', 'test'], 'target' => 'pages/api_test.php', 'options' => [ '_opt' => 'http', ], ], - [ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api_setselfadress.php', 'options' => [ '_opt' => 'http', ], ], - [ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ '_opt' => 'http', 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ], - [ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'pages/api_webhook.php', 'options' => [ '_opt' => 'http', 'target' => '%URL%', 'secret' => '%GET%', ],], - [ 'url' => ['api', 'backupupload'], 'target' => 'pages/api_backupupload.php', 'options' => [ '_opt' => 'http', 'folder' => '%GET%', 'filename' => '%GET%', 'secret' => '%GET%', ],], + [ 'url' => ['update.php'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update.php', '?{Name}'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update', '?{Name}'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update2'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'update'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'update', '?{Name}'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'test'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'base::test' ], ], + [ 'url' => ['api', 'setselfadress'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'server::setselfaddress' ], ], + [ 'url' => ['api', 'statsping'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'alephnote::statsping' ], ], + [ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'server::gitwebhook' ], ], + [ 'url' => ['api', 'backupupload'], 'target' => 'pages/api.php', 'options' => [ '_opt' => 'http', 'cmd' => 'server::backupupload' ], ], + [ 'url' => ['api', '?{cmd}'], 'target' => 'pages/api.php', 'options' => [ 'cmd' => '%URL%' ], ], [ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ], - [ 'url' => ['admin', 'updateslog', '${name}'], 'target' => 'pages/admin_ul-list.php', 'options' => [ '_opt' => 'password', 'name' => '%URL%'],], - [ 'url' => ['admin', 'cmd', '?{cmd}'], 'target' => 'pages/admin_cmd.php', 'options' => [ '_opt' => 'password', 'cmd' => '%URL%'], ], - [ 'url' => ['admin', 'egh', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => 'egh', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], - - [ 'url' => ['su_ajax', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], - [ 'url' => ['su_ajax'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%GET%', 'secret' => '%GET%' ], ], [ 'url' => ['blog'], 'target' => 'pages/blog_list.php', 'options' => [], ], [ 'url' => ['log'], 'target' => 'pages/blog_list.php', 'options' => [], ], @@ -80,7 +75,7 @@ $URL_RULES = [ 'url' => ['highscores', 'list_top50'], 'target' => 'pages/highscores_top50.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], [ 'url' => ['highscores', 'getNewID.php'], 'target' => 'pages/highscores_newid.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], [ 'url' => ['highscores', 'newid'], 'target' => 'pages/highscores_newid.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], - + [ 'url' => ['404'], 'target' => 'pages/error_404.php', 'options' => [], ], ]; @@ -156,6 +151,10 @@ try { $opt[strtolower($optname)] = $value; } + + $opt['_urlparams'] = []; + foreach ($urlparams as $name => $value) $opt['_urlparams'][strtolower($name)] = urldecode($value); + if (!$match) continue; if (in_array('disabled', $ctrlOpt)) continue; @@ -181,7 +180,9 @@ try { } $OPTIONS = $opt; - include $target; + + /** @noinspection PhpIncludeInspection */ + include $target; return; } diff --git a/www/internals/mikeschergitgraph.php b/www/internals/mikeschergitgraph.php index 0b4d02d..a664882 100644 --- a/www/internals/mikeschergitgraph.php +++ b/www/internals/mikeschergitgraph.php @@ -1,7 +1,7 @@
My git timeline
-
+
diff --git a/www/pages/admin.php b/www/pages/admin.php index a2bca8b..a44477b 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -19,7 +19,7 @@ $consistency_blog = Blog::checkConsistency(); $consistency_prog = Programs::checkConsistency(); $consistency_euler = Euler::checkConsistency(); $consistency_books = Books::checkConsistency(); -$consistency_egh = MikescherGitGraph::checkConsistency(); +$consistency_egg = MikescherGitGraph::checkConsistency(); $consistency_progimg = Programs::checkThumbnails(); $consistency_bookimg = Books::checkThumbnails(); $consistency_aoc = AdventOfCode::checkConsistency(); @@ -75,7 +75,7 @@ function dumpConsistency($c) {
Program thumbnails:
-
ExtendedGitGraph:
+
ExtendedGitGraph:
Book thumbnails:
Blog data:
Euler data:
@@ -84,8 +84,8 @@ function dumpConsistency($c) {
Books data:

- Update Program Thumbnails - Update Book Thumbnails + Update Program Thumbnails + Update Book Thumbnails
@@ -115,7 +115,7 @@ function dumpConsistency($c) {
- + Update Redraw @@ -136,7 +136,7 @@ function dumpConsistency($c) {

- Show + Show
@@ -162,7 +162,7 @@ function dumpConsistency($c) {
-
+

diff --git a/www/pages/admin_cmd.php b/www/pages/admin_cmd.php deleted file mode 100644 index 951fcce..0000000 --- a/www/pages/admin_cmd.php +++ /dev/null @@ -1,64 +0,0 @@ -'; - echo ''; - echo ''; - echo ''; - echo 'Mikescher.com - AdminExec'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - foreach (Programs::listAll() as $prog) - { - echo 'Create preview for ' . $prog['name'] . '
' . "\n"; - Programs::createPreview($prog); - } - echo 'Finished.' . '
' . "\n"; - - echo ''; - echo ''; - echo ''; - exit; -} - -if ($cmd === 'createBookThumbnails') -{ - echo ''; - echo ''; - echo ''; - echo ''; - echo 'Mikescher.com - AdminExec'; - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - foreach (Books::listAll() as $book) - { - echo 'Create preview for ' . $book['title'] . '
' . "\n"; - Books::createPreview($book); - } - echo 'Finished.' . '
' . "\n"; - - echo ''; - echo ''; - echo ''; - exit; -} - - -die('Wrong command.'); \ No newline at end of file diff --git a/www/pages/api.php b/www/pages/api.php new file mode 100644 index 0000000..836b768 --- /dev/null +++ b/www/pages/api.php @@ -0,0 +1,89 @@ + [ 'src' => __DIR__.'/../commands/base_test.php', 'auth' => 'none' ], + + 'progs::updatecheck' => [ 'src' => __DIR__.'/../commands/progs_updatecheck.php', 'auth' => 'none' ], + + 'site::createProgramThumbnails' => [ 'src' => __DIR__.'/../commands/site_createProgramThumbnails.php', 'auth' => 'admin' ], + 'site::createBookThumbnails' => [ 'src' => __DIR__.'/../commands/site_createBookThumbnails.php', 'auth' => 'admin' ], + + 'server::setselfaddress' => [ 'src' => __DIR__.'/../commands/server_setselfaddress.php', 'auth' => 'none' ], + 'server::gitwebhook' => [ 'src' => __DIR__.'/../commands/server_gitwebhook.php', 'auth' => 'webhook_secret' ], + 'server::backupupload' => [ 'src' => __DIR__.'/../commands/server_backupupload.php', 'auth' => 'upload_secret' ], + + 'extendedgitgraph::status' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_status.php', 'auth' => 'ajax_secret' ], + 'extendedgitgraph::redraw' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_redraw.php', 'auth' => 'ajax_secret' ], + 'extendedgitgraph::refresh' => [ 'src' => __DIR__.'/../commands/extendedgitgraph_refresh.php', 'auth' => 'ajax_secret' ], + + 'alephnote::statsping' => [ 'src' => __DIR__.'/../commands/alephnote_statsping.php', 'auth' => 'none' ], + 'alephnote::show' => [ 'src' => __DIR__.'/../commands/alephnote_show.php', 'auth' => 'ajax_secret' ], + + 'updates::show' => [ 'src' => __DIR__.'/../commands/updates_show.php', 'auth' => 'ajax_secret' ], +]; + +$cmd = strtolower($OPTIONS['cmd']); + +if (!array_key_exists($cmd, $API_COMMANDS)) +{ + print(" \n"); + print(" \n"); + print(" ... \n"); + print(" ;::::; \n"); + print(" ;::::; :; \n"); + print(" ;:::::' :; \n"); + print(" ;:::::; ;. \n"); + print(" ,:::::' ; OOO\\ \n"); + print(" ::::::; ; OOOOO\\ \n"); + print(" ;:::::; ; OOOOOOOO \n"); + print(" ,;::::::; ;' / OOOOOOO \n"); + print(" ;:::::::::`. ,,,;. / / DOOOOOO \n"); + print(" .';:::::::::::::::::;, / / DOOOO \n"); + print(" ,::::::;::::::;;;;::::;, / / DOOO \n"); + print(" ;`::::::`'::::::;;;::::: ,#/ / DOOO \n"); + print(" :`:::::::`;::::::;;::: ;::# / DOOO \n"); + print(" ::`:::::::`;:::::::: ;::::# / DOO \n"); + print(" `:`:::::::`;:::::: ;::::::#/ DOO \n"); + print(" :::`:::::::`;; ;:::::::::## OO \n"); + print(" ::::`:::::::`;::::::::;:::# OO \n"); + print(" `:::::`::::::::::::;'`:;::# O \n"); + print(" `:::::`::::::::;' / / `:# \n"); + print(" ::::::`:::::;' / / `# \n"); + print(" \n"); + print(" \n"); + die('Wrong command.'); +} + +$config = $API_COMMANDS[$cmd]; + + +$secret = isset($_GET['secret']) ? $_GET['secret'] : ''; + +if ($config['auth'] === 'webhook_secret' && $secret !== $CONFIG['webhook_secret']) die('Unauthorized.'); +if ($config['auth'] === 'ajax_secret' && $secret !== $CONFIG['ajax_secret']) die('Unauthorized.'); +if ($config['auth'] === 'upload_secret' && $secret !== $CONFIG['upload_secret']) die('Unauthorized.'); +if ($config['auth'] === 'admin' && !isLoggedInByCookie()) die('Unauthorized.'); + + +global $API_OPTIONS; + +$API_OPTIONS = []; +foreach ($_GET as $k => $v) $API_OPTIONS[strtolower($k)] = $v; +foreach ($OPTIONS['_urlparams'] as $k => $v) $API_OPTIONS[strtolower($k)] = $v; + + +try +{ + /** @noinspection PhpIncludeInspection */ + include $config['src']; +} +catch (exception $e) +{ + print("API Command failed with exception"); + print($e); +} diff --git a/www/pages/api_setselfadress.php b/www/pages/api_setselfadress.php deleted file mode 100644 index aa96d14..0000000 --- a/www/pages/api_setselfadress.php +++ /dev/null @@ -1,9 +0,0 @@ -".$data['version']."
".$data['url']); \ No newline at end of file diff --git a/www/pages/api_webhook.php b/www/pages/api_webhook.php deleted file mode 100644 index db44fe5..0000000 --- a/www/pages/api_webhook.php +++ /dev/null @@ -1,28 +0,0 @@ -getMessage(); -} - -die('Wrong command.');