diff --git a/.gitattributes b/.gitattributes index b45a5da..fc0668d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ *.gif filter=lfs diff=lfs merge=lfs -text *.xcf filter=lfs diff=lfs merge=lfs -text *.odg filter=lfs diff=lfs merge=lfs -text +*.xlsx filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 31c8f17..d0ab042 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,5 @@ kanga.world/.htaccess kanga.world/README.md kanga.world/composer.json kanga.world/index.php - +kanga.world/site/config/config.php +kanga.world/content/home/*/ diff --git a/Multiplayer DOS Games.xlsx b/Multiplayer DOS Games.xlsx new file mode 100644 index 0000000..d10000b --- /dev/null +++ b/Multiplayer DOS Games.xlsx @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3d0692dcc41799121e611ce9af6a0a81e19df5278c6e936da7e3f6c731e404e8 +size 95982 diff --git a/SystemDiagram.odg b/SystemDiagram.odg index 639f8c8..1302c90 100644 --- a/SystemDiagram.odg +++ b/SystemDiagram.odg @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13fed84425c8d923344cefc07eefda73216a4166cac5999b54aab2dd6c92fa42 -size 17596 +oid sha256:e8c0758303bf863fe7d1133cedf0cab90205eca905ef78dc4f618625744a6133 +size 18350 diff --git a/SystemDiagram.png b/SystemDiagram.png index b478400..e601a36 100644 --- a/SystemDiagram.png +++ b/SystemDiagram.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:021b74391970639d9ca08ba52497d0bfe702c82da3c33163509647f9d693bdd3 -size 113147 +oid sha256:924ca4c3292cb9399b607c2a22c5100afb5296e7e843076e6681f6aa434300ec +size 118668 diff --git a/kanga.world/content/home/home.txt b/kanga.world/content/home/home.txt index f4dc35b..826ca7b 100644 --- a/kanga.world/content/home/home.txt +++ b/kanga.world/content/home/home.txt @@ -4,7 +4,15 @@ Title: Welcome! Text: -(image: kangaworld.png imgclass:imagecenter width: 400) -(image: onlinegamingnetwork.png imgclass:imagecenter width: 400) -(image: kangaworldlogo.png imgclass:imagecenter width: 400) -(image: comingsoon.png imgclass:imagecenter width: 400) \ No newline at end of file +(columns...) + +[newshere] + +++++ + +(image: kangaworld.png imgclass:imagecenter width: 300) +(image: onlinegamingnetwork.png imgclass:imagecenter width: 300) +(image: kangaworldlogo.png imgclass:imagecenter width: 300) +(image: comingsoon.png imgclass:imagecenter width: 300) + +(...columns) \ No newline at end of file diff --git a/kanga.world/content/login/login.txt b/kanga.world/content/login/login.txt new file mode 100644 index 0000000..c8e9a13 --- /dev/null +++ b/kanga.world/content/login/login.txt @@ -0,0 +1,17 @@ +Title: Login + +---- + +Alert: Invalid email or password + +---- + +Email: Email + +---- + +Password: Password + +---- + +Button: Login \ No newline at end of file diff --git a/kanga.world/content/register/register.txt b/kanga.world/content/register/register.txt new file mode 100644 index 0000000..4cc5d32 --- /dev/null +++ b/kanga.world/content/register/register.txt @@ -0,0 +1,17 @@ +Title: Register + +---- + +Alert: Invalid email or password + +---- + +Email: Email + +---- + +Password: Password + +---- + +Button: Register diff --git a/kanga.world/content/site.txt b/kanga.world/content/site.txt index 8d3a89b..ad8e6be 100644 --- a/kanga.world/content/site.txt +++ b/kanga.world/content/site.txt @@ -1 +1,17 @@ -Title: Kanga World \ No newline at end of file +Title: Kanga World + +---- + +Login: Login + +---- + +Logout: Logout + +---- + +Register: Register + +---- + +User: User Settings diff --git a/kanga.world/content/user/user.txt b/kanga.world/content/user/user.txt new file mode 100644 index 0000000..ab1d601 --- /dev/null +++ b/kanga.world/content/user/user.txt @@ -0,0 +1,34 @@ +Title: User Settings + +---- + +Alert: Invalid email or password + +---- + +Email: New Email + +---- + +Password: New Password + +---- + +Button: Update User + +---- + +Export: Export and download YOUR data: + +---- + +Danger: Danger Zone + +---- + +Delete_Button: Delete Account + +---- + +Delete_Warning: Are you sure? This action cannot be reversed! + diff --git a/kanga.world/site/blueprints/files/default.yml b/kanga.world/site/blueprints/files/default.yml new file mode 100644 index 0000000..2d6347a --- /dev/null +++ b/kanga.world/site/blueprints/files/default.yml @@ -0,0 +1,8 @@ +title: File +icon: file +sections: + content: + type: fields + fields: + description: + type: text diff --git a/kanga.world/site/blueprints/files/image.yml b/kanga.world/site/blueprints/files/image.yml new file mode 100644 index 0000000..bee6eeb --- /dev/null +++ b/kanga.world/site/blueprints/files/image.yml @@ -0,0 +1,4 @@ +title: Image +icon: image +accept: + type: image diff --git a/kanga.world/site/blueprints/pages/home.yml b/kanga.world/site/blueprints/pages/home.yml new file mode 100644 index 0000000..105e4e8 --- /dev/null +++ b/kanga.world/site/blueprints/pages/home.yml @@ -0,0 +1,29 @@ +title: News +icon: document + +columns: + left: + width: 1/2 + fields: + text: + type: textarea + size: large + + right: + width: 1/2 + sections: + drafts: + extends: sections/news + headline: Drafts + status: draft + + unlisted: + extends: sections/news + headline: In Review + status: unlisted + + listed: + extends: sections/news + headline: Published + status: listed + layout: cards diff --git a/kanga.world/site/blueprints/pages/login.yml b/kanga.world/site/blueprints/pages/login.yml new file mode 100644 index 0000000..b13360d --- /dev/null +++ b/kanga.world/site/blueprints/pages/login.yml @@ -0,0 +1,16 @@ +title: Login +icon: 🔐 + +fields: + alert: + label: Alert text + type: text + email: + label: Label for email + type: email + password: + label: Label for password + type: text + button: + label: Button text + type: text \ No newline at end of file diff --git a/kanga.world/site/blueprints/pages/news.yml b/kanga.world/site/blueprints/pages/news.yml new file mode 100644 index 0000000..71058da --- /dev/null +++ b/kanga.world/site/blueprints/pages/news.yml @@ -0,0 +1,44 @@ +title: News Article +icon: document +num: '{{ page.date }}' +options: + changeTemplate: news + +columns: + left: + width: 1/2 + sections: + content: + type: fields + fields: + date: + type: date + display: DD-MMM-YYYY + default: today + required: true + text: + type: textarea + size: large + required: true + + right: + width: 1/2 + sections: + image: + type: files + required: true + layout: cards + ratio: 1/1 + max: 1 + accept: + extension: jpg, png, gif + meta: + type: fields + fields: + author: + type: users + multiple: false + default: '{{ kirby.user }}' + query: kirby.users.filterBy("role", "admin") + tags: + type: tags diff --git a/kanga.world/site/blueprints/pages/register.yml b/kanga.world/site/blueprints/pages/register.yml new file mode 100644 index 0000000..9118f2e --- /dev/null +++ b/kanga.world/site/blueprints/pages/register.yml @@ -0,0 +1,22 @@ +title: Register +icon: 🔐 + +fields: + alert: + label: Alert text + type: text + email: + label: Label for email + type: email + email_info: + label: GDPR info for email + type: text + password: + label: Label for password + type: text + password_info: + label: GDPR info for password + type: text + button: + label: Button text + type: text \ No newline at end of file diff --git a/kanga.world/site/blueprints/sections/news.yml b/kanga.world/site/blueprints/sections/news.yml new file mode 100644 index 0000000..b15f193 --- /dev/null +++ b/kanga.world/site/blueprints/sections/news.yml @@ -0,0 +1,6 @@ +type: pages +headline: News Articles +info: "{{ page.date.toDate('d-M-Y') }}" +template: news +empty: No news yet +sortBy: date desc diff --git a/kanga.world/site/blueprints/users/user.yml b/kanga.world/site/blueprints/users/user.yml index 53834dd..439975b 100644 --- a/kanga.world/site/blueprints/users/user.yml +++ b/kanga.world/site/blueprints/users/user.yml @@ -1 +1,4 @@ title: User +permissions: + access: + panel: false \ No newline at end of file diff --git a/kanga.world/site/config/config.php b/kanga.world/site/config/config.php deleted file mode 100644 index 772d1d9..0000000 --- a/kanga.world/site/config/config.php +++ /dev/null @@ -1,27 +0,0 @@ - true, - 'markdown' => [ - 'extra' => false - ], - - // For: https://github.com/getkirby/kql - 'api' => [ - 'basicAuth' => true, - 'allowInsecure' => true - ], - - 'hooks' => [ - // See: https://getkirby.com/docs/cookbook/extensions/subpage-builder - 'route:after' => function ($route, $path, $method) { - $uid = explode('/', $path); - $uid = end($uid); - $uid = str_replace('+', '/', $uid); - $page = kirby()->page($uid); - if ($page && $page->children()->isEmpty()) { - buildPageTree($page); - } - } - ] -]; diff --git a/kanga.world/site/config/config.php.example b/kanga.world/site/config/config.php.example new file mode 100644 index 0000000..57705e3 --- /dev/null +++ b/kanga.world/site/config/config.php.example @@ -0,0 +1,84 @@ + true, + 'markdown' => [ + 'extra' => false + ], + + // For REST APIs. + 'api' => [ + 'basicAuth' => true, + 'allowInsecure' => true + ], + + 'hooks' => [ + // See: https://getkirby.com/docs/cookbook/extensions/subpage-builder + 'route:after' => function ($route, $path, $method) { + $uid = explode('/', $path); + $uid = end($uid); + $uid = str_replace('+', '/', $uid); + $page = kirby()->page($uid); + if ($page && $page->children()->isEmpty()) { + buildPageTree($page); + } + } + ], + + 'email' => [ + 'transport' => [ + 'type' => 'smtp', + 'host' => 'mail.jaegertech.com', + 'port' => 465, + 'security' => true, + 'auth' => true, + 'username' => '...', + 'password' => '...' + ] + ], + + 'user.email.activation' => true, + 'user.email.activation.sender' => 'noreply@kangaroopunch.com', + 'user.email.activation.subject' => 'Kanga World Account Activation', + + 'routes' => [ + [ + 'pattern' => 'logout', + 'action' => function() { + + if ($user = kirby()->user()) { + $user->logout(); + } + + go('/'); + } + ], + [ + 'pattern' => 'user/activate/(:alphanum)', + 'action' => function($token) { + + if (option('user.email.activation', false) === false) { + go(); + } + + $kirby = kirby(); + $kirby->impersonate('kirby'); + + if ($user = $kirby->users()->findBy('emailActivationToken', $token)) { + if ($user->emailActivationToken()->toString() === Str::toType($token, 'string')) { + $user->update(['emailActivation' => true]); + go('user'); + //go('CUSTOM_SUCCESSFUL_ACTIVATION_PAGE'); + } else { + return false; + //go('CUSTOM_ERROR_ACTIVATION_PAGE'); + //return page('CUSTOM_ERROR_ACTIVATION_PAGE'); + } + } + + $kirby->impersonate(); + } + ] + ] + +]; diff --git a/kanga.world/site/controllers/login.php b/kanga.world/site/controllers/login.php new file mode 100644 index 0000000..171b989 --- /dev/null +++ b/kanga.world/site/controllers/login.php @@ -0,0 +1,69 @@ +user()) { + go('/'); + } + + $error = null; + $alert = null; + + if ($kirby->request()->is('POST') && get('login')) { + + $data = [ + 'email' => esc(get('email')), + 'password' => esc(get('password')) + ]; + + $rules = [ + 'email' => ['required', 'email'], + 'password' => ['required'] + ]; + + $messages = [ + 'email' => 'Please enter a valid email adress', + 'password' => 'Please enter a password' + ]; + + // INVALID DATA + if($invalid = invalid($data, $rules, $messages)) { + + $alert = $invalid; + $error = true; + + // VALID DATA + } else { + + // LOGIN USER + try { + + $kirby->auth()->login($data['email'], $data['password']); + + } catch (Exception $e) { + + if(option('debug')) { + + $alert['error'] = 'Invalid email or password: ' . $e->getMessage(); + } + else { + + $alert['error'] = 'Invalid email or password!'; + } + } + + // SUCCESSFUL + if (empty($alert) === true) { + + $data = []; + go(); + } + } + } + + return [ + 'error' => $error, + 'alert' => $alert, + 'data' => $data ?? false + ]; +}; \ No newline at end of file diff --git a/kanga.world/site/controllers/register.php b/kanga.world/site/controllers/register.php new file mode 100644 index 0000000..6b6a972 --- /dev/null +++ b/kanga.world/site/controllers/register.php @@ -0,0 +1,111 @@ +user()) { + go('/'); + } + + $error = null; + $alert = null; + + // TOKEN FOR ACCOUNT ACTIVATION + $token = Str::random(16); + + if($kirby->request()->is('post') && get('register')) { + + $data = [ + 'email' => esc(get('email')), + 'password' => esc(get('password')) + ]; + + $rules = [ + 'email' => ['required', 'email'], + 'password' => ['required', 'minLength' => 8] + ]; + + $messages = [ + 'email' => 'Please enter a valid email adress', + 'password' => 'Please enter a valid password' + ]; + + // INVALID DATA + if($invalid = invalid($data, $rules, $messages)) { + + $alert = $invalid; + $error = true; + + // VALID DATA + } else { + + $kirby = kirby(); + $kirby->impersonate('kirby'); + + try { + + // CREATE USER + $user = $kirby->users()->create([ + 'email' => $data['email'], + 'role' => 'user', + 'language' => 'en', + 'password' => $data['password'] + ]); + + // CHECK EMAIL ACTIVATION + if (option('user.email.activation', false) === true) { + + $user->update([ + 'emailActivation' => false, + 'emailActivationToken' => $token + ]); + } + + $kirby->impersonate(); + + } catch(Exception $e) { + + if(option('debug')) { + + $alert['error'] = 'The user could not be created: ' . $e->getMessage(); + } + else { + + $alert['error'] = 'The user could not be created!'; + } + } + + // SUCCESSFUL + if (empty($alert) === true && $user) { + + // ACTIVATE ACCOUNT BY EMAIL IF ENABLED + if (option('user.email.activation', false) === true) { + + $link = $kirby->site()->url() . "/user/activate/" . $token; + + $email = $kirby->email([ + 'to' => $data['email'], + 'from' => option('user.email.activation.sender'), + 'subject' => option('user.email.activation.sender', 'Account Activation Link'), + 'template' => 'account-activation', + 'data' => [ + 'link' => $link, + ] + ]); + } + + // LOGIN USER + if($user->login($data['password'])) { + go(); + } + + $data = []; + } + } + }; + + return [ + 'error' => $error, + 'alert' => $alert, + 'data' => $data ?? false + ]; +}; \ No newline at end of file diff --git a/kanga.world/site/controllers/user.php b/kanga.world/site/controllers/user.php new file mode 100644 index 0000000..a4ba2d4 --- /dev/null +++ b/kanga.world/site/controllers/user.php @@ -0,0 +1,146 @@ +user()) { + go('/'); + } + + $error = null; + $alert = null; + + // CHECK ACCOUNT ACTIVATION + if(option('user.email.activation', false) === true && $kirby->user()->emailActivation()->toString() === '' || $kirby->user()->emailActivation() != true) { + + $alert['error'] = 'Please check your emails to activate the account.'; + } + + // UPDATE USER + if($kirby->request()->is('post') && get('update')) { + + $data = [ + 'email' => esc(get('email')), + 'password' => esc(get('password')) + ]; + + $rules = [ + 'email' => ['email'], + 'password' => ['minLength' => 8] + ]; + + $messages = [ + 'email' => 'Please enter a valid email adress', + 'password' => 'Please enter an eight character password' + ]; + + // INVALID DATA + if($invalid = invalid($data, $rules, $messages)) { + + $alert = $invalid; + $error = true; + + // VALID DATA + } else { + + // EMAIL + if (V::email($data['email']) && !get('password')) { + + try { + + $kirby->user()->changeEmail($data['email']); + $success = 'Your email has been changed!'; + + // TOKEN FOR ACCOUNT RE-ACTIVATION + $token = Str::random(16); + + $kirby->user()->update([ + 'emailActivation' => false, + 'emailActivationToken' => $token + ]); + + // ACTIVATE ACCOUNT BY EMAIL IF ENABLED + if (option('user.email.activation', false) === true) { + + $link = $kirby->site()->url() . "/user/activate/" . $token; + + $email = $kirby->email([ + 'to' => $data['email'], + 'from' => option('user.email.activation.sender'), + 'subject' => option('user.email.activation.sender', 'Account Activation Link'), + 'template' => 'account-activation', + 'data' => [ + 'link' => $link, + ] + ]); + } + + } catch(Exception $e) { + + if(option('debug')) { + + $alert['error'] = 'The user email could not be changed: ' . $e->getMessage(); + } + else { + + $alert['error'] = 'The user email could not be changed!'; + } + } + } + + // PASSWORD + if ($data['password']) { + + try { + + $kirby->user()->changePassword($data['password']); + $success = 'Your password has been changed!'; + + } catch(Exception $e) { + + if(option('debug')) { + + $alert['error'] = 'The user password could not be changed: ' . $e->getMessage(); + } + else { + + $alert['error'] = 'The user password could not be changed!'; + } + } + } + + // SUCCESSFUL + if (empty($alert) === true) { + + $error = null; + } + } + } + + // DELETE USER + if($kirby->request()->is('post') && get('delete')) { + + try { + + $kirby->user()->delete(); + go('/'); + + } catch(Exception $e) { + + if(option('debug')) { + + $alert['error'] = 'The user could not be deleted: ' . $e->getMessage(); + } + else { + + $alert['error'] = 'The user could not be deleted!'; + } + } + } + + return [ + 'error' => $error, + 'alert' => $alert, + 'data' => $data ?? false, + 'success' => $success ?? false + ]; +}; \ No newline at end of file diff --git a/kanga.world/site/snippets/header.php b/kanga.world/site/snippets/header.php index a13bb70..4e75e5c 100644 --- a/kanga.world/site/snippets/header.php +++ b/kanga.world/site/snippets/header.php @@ -13,4 +13,5 @@ +
diff --git a/kanga.world/site/snippets/menu.php b/kanga.world/site/snippets/menu.php new file mode 100644 index 0000000..18b9c2f --- /dev/null +++ b/kanga.world/site/snippets/menu.php @@ -0,0 +1,27 @@ + diff --git a/kanga.world/site/snippets/notification.php b/kanga.world/site/snippets/notification.php new file mode 100644 index 0000000..d50a002 --- /dev/null +++ b/kanga.world/site/snippets/notification.php @@ -0,0 +1,4 @@ +
+

alert()->html() : '' ?>

+

+
diff --git a/kanga.world/site/snippets/user.php b/kanga.world/site/snippets/user.php new file mode 100644 index 0000000..d10bd6c --- /dev/null +++ b/kanga.world/site/snippets/user.php @@ -0,0 +1,7 @@ +user()): ?> +is('user'), 'aria-current ') ?> href="">user()->html +logout()->html() ?> + +is('login'), 'aria-current ') ?> href="">login()->htm +is('register'), 'aria-current ') ?> href="">regist + diff --git a/kanga.world/site/templates/emails/account-activation.html.php b/kanga.world/site/templates/emails/account-activation.html.php new file mode 100644 index 0000000..e9bce7d --- /dev/null +++ b/kanga.world/site/templates/emails/account-activation.html.php @@ -0,0 +1,2 @@ +

Welcome

+

Please click the link to activate your Account:

\ No newline at end of file diff --git a/kanga.world/site/templates/emails/account-activation.text.php b/kanga.world/site/templates/emails/account-activation.text.php new file mode 100644 index 0000000..47e8a79 --- /dev/null +++ b/kanga.world/site/templates/emails/account-activation.text.php @@ -0,0 +1,3 @@ +Welcome, + +Please click the link to activate your Account: \ No newline at end of file diff --git a/kanga.world/site/templates/home.php b/kanga.world/site/templates/home.php new file mode 100644 index 0000000..c4dbf2c --- /dev/null +++ b/kanga.world/site/templates/home.php @@ -0,0 +1,30 @@ +[newshere]

'; + $left = strstr($page->text()->kirbytext(), $marker, true); + $right = substr($page->text()->kirbytext(), strlen($left) + strlen($marker)); + + print $left; + + foreach($page->children()->listed()->flip() as $article): +?> + +
+

title()->html() ?>

+ image()) { ?> + + +

Published: date()->toDate('d-M-Y') ?>

+

text()->excerpt(300) ?>

+ Read more... +
+ + diff --git a/kanga.world/site/templates/login.php b/kanga.world/site/templates/login.php new file mode 100644 index 0000000..b61a688 --- /dev/null +++ b/kanga.world/site/templates/login.php @@ -0,0 +1,27 @@ + + + +
+
+ title()->html() ?> + +
+ + + +
+ +
+ + + +
+ +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/kanga.world/site/templates/news.php b/kanga.world/site/templates/news.php new file mode 100644 index 0000000..b3ba626 --- /dev/null +++ b/kanga.world/site/templates/news.php @@ -0,0 +1,9 @@ + + +

title() ?>

+ +

Published: date()->toDate('d-M-Y') ?>

+text()->kirbytext() ?> +Back... + + diff --git a/kanga.world/site/templates/redirect.php b/kanga.world/site/templates/redirect.php new file mode 100644 index 0000000..d55e34c --- /dev/null +++ b/kanga.world/site/templates/redirect.php @@ -0,0 +1,5 @@ + + + + + diff --git a/kanga.world/site/templates/register.php b/kanga.world/site/templates/register.php new file mode 100644 index 0000000..98da742 --- /dev/null +++ b/kanga.world/site/templates/register.php @@ -0,0 +1,27 @@ + + + +
+
+ title()->html() ?> + +
+ + + +
+ +
+ + + +
+ +
+ +
+ +
+
+ + \ No newline at end of file diff --git a/kanga.world/site/templates/user.php b/kanga.world/site/templates/user.php new file mode 100644 index 0000000..7b97900 --- /dev/null +++ b/kanga.world/site/templates/user.php @@ -0,0 +1,29 @@ + + + + + +
+
+ user()->email() ?> + +
+ + + +
+ +
+ + + +
+ +
+ +
+ +
+
+ +