From ea1aae60c38ae00292418bd91e3e13b7342c9e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Tue, 14 Jan 2020 22:25:43 +0100 Subject: [PATCH] RuleEngine + Frame --- www/fragments/footer.php | 4 - www/fragments/header.php | 19 -- www/frames/default_frame.php | 52 ++++ www/index.php | 259 +++++------------- www/internals/alephnoteStatistics.php | 2 +- www/internals/books.php | 2 +- www/internals/database.php | 2 +- www/internals/euler.php | 2 +- www/internals/highscores.php | 2 +- www/internals/mikeschergitgraph.php | 2 +- www/internals/pageframeoptions.php | 2 +- www/internals/parsedowncustom.php | 109 ++++++++ www/internals/programs.php | 2 +- www/internals/ruleengine.php | 13 +- www/internals/updateslog.php | 2 +- www/internals/urlroute.php | 27 +- www/internals/utils.php | 34 ++- www/internals/website.php | 18 +- .../{errorview.php => error_notfound.php} | 0 www/pages/error_servererror.php | 34 +++ 20 files changed, 327 insertions(+), 260 deletions(-) delete mode 100644 www/fragments/footer.php delete mode 100644 www/fragments/header.php create mode 100644 www/frames/default_frame.php create mode 100644 www/internals/parsedowncustom.php rename www/pages/{errorview.php => error_notfound.php} (100%) create mode 100644 www/pages/error_servererror.php diff --git a/www/fragments/footer.php b/www/fragments/footer.php deleted file mode 100644 index 060bca4..0000000 --- a/www/fragments/footer.php +++ /dev/null @@ -1,4 +0,0 @@ -
-
- made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary* javascript -
\ No newline at end of file diff --git a/www/fragments/header.php b/www/fragments/header.php deleted file mode 100644 index 98c7909..0000000 --- a/www/fragments/header.php +++ /dev/null @@ -1,19 +0,0 @@ -
-
- -
- - - -
\ No newline at end of file diff --git a/www/frames/default_frame.php b/www/frames/default_frame.php new file mode 100644 index 0000000..36045c4 --- /dev/null +++ b/www/frames/default_frame.php @@ -0,0 +1,52 @@ + + + + + + + + <?php echo $FRAME_OPTIONS->title; ?> + + + + + +
+ +
+
+ +
+ +
+ Home + Project Euler + Blog + Programs + Tools + isLoggedInByCookie()): ?>Admin + About +
+ isLoggedInByCookie()): ?> + Github +
+ +
+ + raw; ?> + +
+
+ made with vanilla PHP and MySQL, no frameworks, no bootstrap, no unnecessary* javascript +
+ +
+ + \ No newline at end of file diff --git a/www/index.php b/www/index.php index 52a72bd..82677f3 100644 --- a/www/index.php +++ b/www/index.php @@ -7,212 +7,81 @@ $site->init(); $URL_RULES = [ - [ 'url' => [], 'target' => 'pages/main.php', 'options' => [], ], - [ 'url' => ['index'], 'target' => 'pages/main.php', 'options' => [], ], - [ 'url' => ['index.php'], 'target' => 'pages/main.php', 'options' => [], ], - [ 'url' => ['msmain', 'index'], 'target' => 'pages/main.php', 'options' => [], ], - [ 'url' => ['about'], 'target' => 'pages/about.php', 'options' => [], ], - [ 'url' => ['msmain', 'about'], 'target' => 'pages/about.php', 'options' => [], ], - [ 'url' => ['login'], 'target' => 'pages/login.php', 'options' => [ 'login_target' => '/' ], ], - [ 'url' => ['logout'], 'target' => 'pages/logout.php', 'options' => [ 'logout_target' => '/' ], ], + [ 'url' => [], 'target' => 'main.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['index'], 'target' => 'main.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['index.php'], 'target' => 'main.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['msmain', 'index'], 'target' => 'main.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['about'], 'target' => 'about.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['msmain', 'about'], 'target' => 'about.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['login'], 'target' => 'login.php', 'options' => [ 'http' ], 'parameter' => [ 'login_target' => '/' ], ], + [ 'url' => ['logout'], 'target' => 'logout.php', 'options' => [ 'http' ], 'parameter' => [ 'logout_target' => '/' ], ], - [ 'url' => ['programs'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], - [ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '%GET%' ], ], - [ 'url' => ['programs', 'index'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], - [ 'url' => ['programs', 'cat', '?{categoryfilter}'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '%URL%' ], ], - [ 'url' => ['downloads', 'details.php'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], - [ 'url' => ['downloads', 'downloads.php'], 'target' => 'pages/programs_list.php', 'options' => [ 'categoryfilter' => '' ], ], - [ 'url' => ['programs', 'view', '?{id}'], 'target' => 'pages/programs_view.php', 'options' => [ 'id' => '%URL%' ], ], - [ 'url' => ['programs', 'view'], 'target' => 'pages/programs_view.php', 'options' => [ 'id' => '%GET%' ], ], - [ 'url' => ['downloads', '?{id}'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%URL%' ], ], - [ 'url' => ['programs', 'download', '?{id}'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%URL%' ], ], - [ 'url' => ['programs', 'download'], 'target' => 'pages/programs_download.php', 'options' => [ 'id' => '%GET%' ], ], + [ 'url' => ['programs'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '' ], ], + [ 'url' => ['programs', 'index'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '%GET%' ], ], + [ 'url' => ['programs', 'index'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '' ], ], + [ 'url' => ['programs', 'cat', '?{categoryfilter}'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '%URL%' ], ], + [ 'url' => ['downloads', 'details.php'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '' ], ], + [ 'url' => ['downloads', 'downloads.php'], 'target' => 'programs_list.php', 'options' => [ 'http' ], 'parameter' => [ 'categoryfilter' => '' ], ], + [ 'url' => ['programs', 'view', '?{id}'], 'target' => 'programs_view.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%URL%' ], ], + [ 'url' => ['programs', 'view'], 'target' => 'programs_view.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%GET%' ], ], + [ 'url' => ['downloads', '?{id}'], 'target' => 'programs_download.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%URL%' ], ], + [ 'url' => ['programs', 'download', '?{id}'], 'target' => 'programs_download.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%URL%' ], ], + [ 'url' => ['programs', 'download'], 'target' => 'programs_download.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%GET%' ], ], - [ 'url' => ['books'], 'target' => 'pages/books_list.php', 'options' => [], ], - [ 'url' => ['books', 'list'], 'target' => 'pages/books_list.php', 'options' => [], ], - [ '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' => ['books'], 'target' => 'books_list.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['books', 'list'], 'target' => 'books_list.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['books', 'view', '?{id}'], 'target' => 'books_view.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%GET%' ], ], + [ 'url' => ['books', 'view', '?{id}', '*'], 'target' => 'books_view.php', 'options' => [ 'http' ], 'parameter' => [ 'id' => '%URL%' ], ], - [ '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' => ['update.php'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update.php', '?{Name}'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update', '?{Name}'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['update2'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'update'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'update', '?{Name}'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'progs::updatecheck' ], ], + [ 'url' => ['api', 'test'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'base::test' ], ], + [ 'url' => ['api', 'setselfadress'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'server::setselfaddress' ], ], + [ 'url' => ['api', 'statsping'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'alephnote::statsping' ], ], + [ 'url' => ['api', 'webhook', '?{target}'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'server::gitwebhook' ], ], + [ 'url' => ['api', 'backupupload'], 'target' => 'api.php', 'options' => [ 'http' ], 'parameter' => [ 'cmd' => 'server::backupupload' ], ], + [ 'url' => ['api', '?{cmd}'], 'target' => 'api.php', 'options' => [ ], 'parameter' => [ 'cmd' => '%URL%' ], ], - [ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ], + [ 'url' => ['admin'], 'target' => 'admin.php', 'options' => [ 'password' ], 'parameter' => [ ] ], - [ 'url' => ['blog'], 'target' => 'pages/blog_list.php', 'options' => [], ], - [ 'url' => ['log'], 'target' => 'pages/blog_list.php', 'options' => [], ], - [ 'url' => ['blogpost', 'index'], 'target' => 'pages/blog_list.php', 'options' => [], ], - [ 'url' => ['blog', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['blog', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['blog', '?{id}', '?{name}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['blog', '?{id}', '?{name}', '?{subview}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ], - [ 'url' => ['log', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['log', '?{id}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['log', '?{id}', '?{name}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '' ], ], - [ 'url' => ['log', '?{id}', '?{name}', '?{subview}'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ], - [ 'url' => ['blogpost', 'view'], 'target' => 'pages/blog_view.php', 'options' => [ 'id' => '%GET%', 'subview' => '' ], ], + [ 'url' => ['blog'], 'target' => 'blog_list.php', 'options' => [ ], 'parameter' => [ ], ], + [ 'url' => ['log'], 'target' => 'blog_list.php', 'options' => [ ], 'parameter' => [ ], ], + [ 'url' => ['blogpost', 'index'], 'target' => 'blog_list.php', 'options' => [ ], 'parameter' => [ ], ], + [ 'url' => ['blog', '?{id}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['blog', '?{id}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['blog', '?{id}', '?{name}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['blog', '?{id}', '?{name}', '?{subview}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ], + [ 'url' => ['log', '?{id}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['log', '?{id}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['log', '?{id}', '?{name}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '' ], ], + [ 'url' => ['log', '?{id}', '?{name}', '?{subview}'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%URL%', 'subview' => '%URL%' ], ], + [ 'url' => ['blogpost', 'view'], 'target' => 'blog_view.php', 'options' => [ ], 'parameter' => [ 'id' => '%GET%', 'subview' => '' ], ], - [ 'url' => ['webapps'], 'target' => 'pages/webapps_list.php', 'options' => [], ], + [ 'url' => ['webapps'], 'target' => 'webapps_list.php', 'options' => [ ], 'parameter' => [ ], ], - [ 'url' => ['highscores', 'list.php'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], - [ 'url' => ['highscores', 'list'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], - [ 'url' => ['highscores', 'listentries'], 'target' => 'pages/highscores_listentries.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], - [ 'url' => ['highscores', 'list.php'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ], - [ 'url' => ['highscores', 'list'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ], - [ 'url' => ['highscores', 'listgames'], 'target' => 'pages/highscores_listgames.php', 'options' => [ '_opt' => 'http' ], ], - [ 'url' => ['highscores', 'insert.php'], 'target' => 'pages/highscores_insert.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ], - [ 'url' => ['highscores', 'insert'], 'target' => 'pages/highscores_insert.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ], - [ 'url' => ['highscores', 'update.php'], 'target' => 'pages/highscores_update.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ], - [ 'url' => ['highscores', 'update'], 'target' => 'pages/highscores_update.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ], - [ 'url' => ['highscores', 'list_top50.php'], 'target' => 'pages/highscores_top50.php', 'options' => [ '_opt' => 'http', 'gameid' => '%GET%' ], ], - [ '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' => [], ], + [ 'url' => ['highscores', 'list.php'], 'target' => 'highscores_listentries.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'list'], 'target' => 'highscores_listentries.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'listentries'], 'target' => 'highscores_listentries.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'list.php'], 'target' => 'highscores_listgames.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['highscores', 'list'], 'target' => 'highscores_listgames.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['highscores', 'listgames'], 'target' => 'highscores_listgames.php', 'options' => [ 'http' ], 'parameter' => [ ], ], + [ 'url' => ['highscores', 'insert.php'], 'target' => 'highscores_insert.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ], + [ 'url' => ['highscores', 'insert'], 'target' => 'highscores_insert.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%' ], ], + [ 'url' => ['highscores', 'update.php'], 'target' => 'highscores_update.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'update'], 'target' => 'highscores_update.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%', 'check' => '%GET%', 'name' => '%GET%', 'rand' => '%GET%', 'points' => '%GET%', 'nameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'list_top50.php'], 'target' => 'highscores_top50.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'list_top50'], 'target' => 'highscores_top50.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'getNewID.php'], 'target' => 'highscores_newid.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], + [ 'url' => ['highscores', 'newid'], 'target' => 'highscores_newid.php', 'options' => [ 'http' ], 'parameter' => [ 'gameid' => '%GET%' ], ], ]; $site->serve($URL_RULES); -//############################################################################# - -try { - InitPHP(); - - if (isProd()) - $requri = $_SERVER['REQUEST_URI']; - else - $requri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : 'localhost:80/'; - - $parse = parse_url($requri); - - $path = isset($parse['path']) ? $parse['path'] : ''; - $pathparts = preg_split('@/@', $path, NULL, PREG_SPLIT_NO_EMPTY); - $partcount = count($pathparts); - - global $OPTIONS; - global $HEADER_ACTIVE; - - $HEADER_ACTIVE = 'none'; - - foreach ($URL_RULES as $rule) - { - if ($partcount !== count($rule['url'])) continue; - - $urlparams = []; - $ctrlOpt = key_exists('_opt', $rule['options']) ? explode('|', $rule['options']['_opt']) : []; - $target = $rule['target']; - - $match = true; - for($i = 0; $i < $partcount; $i++) - { - $comp = $rule['url'][$i]; - if (startsWith($comp, '?{') && endsWith($comp, '}')) - { - $ident = substr($comp, 2, strlen($comp)-3); - $urlparams[$ident] = $pathparts[$i]; - } - else if ($comp === '*') - { - // ok - } - else - { - if (strtolower($comp) !== strtolower($pathparts[$i])) { $match = false; break; } - } - } - if (!$match) continue; - - $opt = [ 'controllerOptions' => $ctrlOpt, 'uri' => $requri ]; - foreach($rule['options'] as $optname => $optvalue) - { - $value = $optvalue; - - if ($value === '%GET%') - { - if (!isset($_GET[$optname])) { $match = false; break; } - $value = $_GET[$optname]; - } - else if ($value === '%POST%') - { - if (!isset($_POST[$optname])) { $match = false; break; } - $value = $_POST[$optname]; - } - else if ($value === '%URL%') - { - if (!isset($urlparams[$optname])) { $match = false; break; } - $value = urldecode($urlparams[$optname]); - } - - $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; - - if (in_array('password', $ctrlOpt)) - { - if (!isLoggedInByCookie()) - { - $opt['login_target'] = $path; - $target = 'pages/login.php'; - } - } - - $is_http = (!isset($_SERVER['HTTPS'])) || empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == "off"; - - if (isProd() && $is_http && !in_array('http', $ctrlOpt)) - { - ob_clean(); - $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - header('HTTP/1.1 301 Moved Permanently'); - header('Location: ' . $redirect); - exit(); - } - - $OPTIONS = $opt; - - /** @noinspection PhpIncludeInspection */ - include $target; - return; - - } - - { - // [404] - Page Not Found - $OPTIONS = []; - httpError('404', 'Page not found'); - return; - } - -} catch (Exception $e) { - - if (isProd()) - { - sendExceptionMail($e); - httpError('500 ', 'Internal server error'); - } - else - { - if (isset($e->xdebug_message)) echo ''.$e->xdebug_message.'
'; - else echo nl2br($e); - } - -} //TODO euler insert+show 32bit | 64bit mode //TODO support for different color schemes diff --git a/www/internals/alephnoteStatistics.php b/www/internals/alephnoteStatistics.php index 7fb6749..fcf838c 100644 --- a/www/internals/alephnoteStatistics.php +++ b/www/internals/alephnoteStatistics.php @@ -1,4 +1,4 @@ -{$Element['handler']}($Element['text']); + else + return parent::element($Element); + } + + protected function blockFencedCode($Line) + { + $Block = parent::blockFencedCode($Line); + if ($Block === null) return $Block; + + $Block['custom'] = false; + + if (isset($Block['element']['text']['attributes'])) + { + foreach ($Block['element']['text']['attributes'] as $attr) + { + $spl = explode('__', $attr); + + if ($spl[0] === 'language-befungerunner') + { + $Block['element']['handler'] = 'handleBef93'; + $Block['custom'] = true; + $Block['element']['text']['b93_speed'] = null; + $Block['element']['text']['b93_interactive'] = true; + $Block['element']['text']['b93_editable'] = true; + + foreach ($spl as $param) + { + if (startsWith($param, 'speed-')) $Block['element']['text']['b93_speed'] = intval( substr($param, strlen('speed-'))); + if (startsWith($param, 'interactive-')) $Block['element']['text']['b93_interactive'] = boolval(substr($param, strlen('interactive-'))); + if (startsWith($param, 'editable-')) $Block['element']['text']['b93_editable'] = boolval(substr($param, strlen('editable-'))); + } + + return $Block; + } + else if ($spl[0] === 'language-bfjoustrunner') + { + $Block['element']['handler'] = 'handleBFJoust'; + $Block['custom'] = true; + return $Block; + } + } + } + + return $Block; + } + + protected function blockFencedCodeComplete($Block) + { + if (! $Block['custom']) { return parent::blockFencedCodeComplete($Block); } + + $Block['element']['custom'] = true; + + return $Block; + } + + protected function handleBFJoust(array $Element) + { + global $PARAM_CODE_LEFT; + global $PARAM_CODE_RIGHT; + + $split = preg_split("/\-{16,}/", $Element['text']); + + $PARAM_CODE_LEFT = trim($split[0]); + $PARAM_CODE_RIGHT = trim($split[1]); + + return require (__DIR__ . '/../fragments/widget_bfjoust.php'); + } + + protected function handleBef93(array $Element) + { + global $PARAM_BEFUNGE93RUNNER; + $PARAM_BEFUNGE93RUNNER = + [ + 'code' => $Element['text'], + 'url' => '', + 'interactive' => $Element['b93_interactive'], + 'speed' => $Element['b93_speed'], + 'editable' => $Element['b93_editable'], + ]; + return require (__DIR__ . '/../fragments/widget_befunge93.php'); + } + + protected function blockTable($Line, array $Block = null) + { + // https://stackoverflow.com/a/46346412/1761622 + + $Block = parent::blockTable($Line, $Block); + + if ($Block === null) return $Block; + if (!key_exists('element', $Block)) return $Block; + + $Block['element']['attributes']['class'] = 'stripedtable'; + + return $Block; + } +} \ No newline at end of file diff --git a/www/internals/programs.php b/www/internals/programs.php index e892bed..a8fbe55 100644 --- a/www/internals/programs.php +++ b/www/internals/programs.php @@ -1,4 +1,4 @@ -getCurrentRights() >= $route->minimal_access_rights) return $route; - - if ($app->isLoggedIn()) return URLRoute::getInsufficentRightsRoute($requri); - - if (!$app->isLoggedIn()) return URLRoute::getLoginRoute($route, $requri); + if ($route->needsAdminLogin && !$app->isLoggedIn()) return URLRoute::getLoginRoute($route, $requri); } return URLRoute::getNotFoundRoute($requri); @@ -98,9 +93,9 @@ class RuleEngine if (isset($ctrlOpt['method']) && $_SERVER["REQUEST_METHOD"] !== $ctrlOpt['method']) return null; - $route->minimal_access_rights = (($rule['rights']===null) ? 0 : $rule['rights']); + $route->needsAdminLogin = isset($ctrlOpt['password']); - if ($app->isProd() && $app->config->app_enforce_https && isHTTPRequest() && !in_array('http', $ctrlOpt)) + if ($app->isProd() && isHTTPRequest() && !in_array('http', $ctrlOpt)) { // enforce https $redirect = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; diff --git a/www/internals/updateslog.php b/www/internals/updateslog.php index 184068b..dc40512 100644 --- a/www/internals/updateslog.php +++ b/www/internals/updateslog.php @@ -1,4 +1,4 @@ -targetpath = __DIR__ . '/../pages/' . $target; $this->full_url = $url; $this->parameter = []; - $this->minimal_access_rights = 0; + $this->needsAdminLogin = false; $this->isAPI = false; } /** - * @param VApp $app + * @param Website $app * @return PageFrameOptions */ public function get(Website $app): PageFrameOptions { $pfo = new PageFrameOptions(); - $pfo->title = $app->config->verein_kurzel . " Orga"; // default title + $pfo->title = 'Mikescher.com'; // default title if ($this->isAPI) { $pfo->frame = 'no_frame.php'; @@ -71,18 +71,6 @@ class URLRoute return $FRAME_OPTIONS; } - /** - * @param string $requri - * @return URLRoute - */ - public static function getInsufficentRightsRoute(string $requri): URLRoute - { - $r = new URLRoute('errors/insufficent_rights.php', $requri); - $r->parameter = []; - $r->minimal_access_rights = 0; - return $r; - } - /** * @param URLRoute $route * @param string $requri @@ -92,7 +80,6 @@ class URLRoute { $r = new URLRoute('login.php', $requri); $r->parameter = [ 'redirect' => $route->full_url ]; - $r->minimal_access_rights = 0; return $r; } @@ -104,7 +91,6 @@ class URLRoute { $r = new URLRoute('errors/not_found.php', $requri); $r->parameter = []; - $r->minimal_access_rights = 0; return $r; } @@ -116,7 +102,6 @@ class URLRoute { $r = new URLRoute('errors/server_error.php', $requri); $r->parameter = []; - $r->minimal_access_rights = 0; return $r; } } \ No newline at end of file diff --git a/www/internals/utils.php b/www/internals/utils.php index bf8dbd7..13cf5ae 100644 --- a/www/internals/utils.php +++ b/www/internals/utils.php @@ -1,4 +1,4 @@ -getMessage() . "\n\n"; + $r .= $e->getFile() . "\n\n"; + $r .= $e->getTraceAsString() . "\n\n"; + if (isset($e->xdebug_message)) + { + $xdbg = $e->xdebug_message; + $xdbg = str_replace('
', "\n", $xdbg); + $xdbg = str_replace('
', "\n", $xdbg); + $xdbg = str_replace('
', "\n", $xdbg); + $xdbg = strip_tags($xdbg); + $xdbg = htmlspecialchars($xdbg); + $r .= $xdbg . "\n"; + } + return $r; + } + + return 'object'; } \ No newline at end of file diff --git a/www/internals/website.php b/www/internals/website.php index 5955de6..972bf29 100644 --- a/www/internals/website.php +++ b/www/internals/website.php @@ -1,9 +1,25 @@ - + + + + + Mikescher.com - <?php echo $errormsg; ?> + + + + +
+ + + +
+ +
+
+
+
+ +
+ +
+ + + + \ No newline at end of file