From 8fdb7071788ea1b6f6e86224064524889fc2fe71 Mon Sep 17 00:00:00 2001 From: Tobias Feigel Date: Sun, 13 Jul 2025 17:10:26 +0200 Subject: [PATCH 1/2] chore: remove `mzur/kirby-uniform` dependency and update `composer.lock` Removed the `mzur/kirby-uniform` plugin from `composer.json` and its related dependencies from `composer.lock` to clean up unused form handling functionalities. --- composer.json | 3 +- composer.lock | 179 +------------------------------------------------- 2 files changed, 2 insertions(+), 180 deletions(-) diff --git a/composer.json b/composer.json index 07db368..fa37377 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,7 @@ }, "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "getkirby/cms": "^5.0", - "mzur/kirby-uniform": "^5.6" + "getkirby/cms": "^5.0" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index e76fe3a..20135ef 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9c8fcd821a223ac622d59eac3a763ea2", + "content-hash": "43770e3691ceb6a19553beb3dbca1057", "packages": [ { "name": "christian-riesen/base32", @@ -597,183 +597,6 @@ }, "time": "2016-12-13T01:01:17+00:00" }, - { - "name": "mzur/kirby-flash", - "version": "v2.2.0", - "source": { - "type": "git", - "url": "https://github.com/mzur/kirby-flash.git", - "reference": "298df11e3adc8d872db8cd48ef3736c3cbdb6c6e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mzur/kirby-flash/zipball/298df11e3adc8d872db8cd48ef3736c3cbdb6c6e", - "reference": "298df11e3adc8d872db8cd48ef3736c3cbdb6c6e", - "shasum": "" - }, - "require": { - "getkirby/composer-installer": "^1.2" - }, - "require-dev": { - "getkirby/cms": "^3.0", - "mzur/kirby-defuse-session": "^1.0", - "phpunit/phpunit": "^9.0" - }, - "type": "kirby-plugin", - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Jevets\\Kirby\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Steve Jamesson", - "email": "steve@evendev.com" - }, - { - "name": "Martin Zurowietz", - "email": "martin@the-inspired-ones.de" - } - ], - "description": "Stores data in the session for the next request. Data is removed after the next page load.", - "keywords": [ - "flash", - "kirby", - "session" - ], - "support": { - "issues": "https://github.com/mzur/kirby-flash/issues", - "source": "https://github.com/mzur/kirby-flash/tree/v2.2.0" - }, - "time": "2023-01-05T18:59:28+00:00" - }, - { - "name": "mzur/kirby-form", - "version": "v3.3.0", - "source": { - "type": "git", - "url": "https://github.com/mzur/kirby-form.git", - "reference": "8dc211b321375dbf77c43e1287e9fe0be2762ec0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mzur/kirby-form/zipball/8dc211b321375dbf77c43e1287e9fe0be2762ec0", - "reference": "8dc211b321375dbf77c43e1287e9fe0be2762ec0", - "shasum": "" - }, - "require": { - "getkirby/composer-installer": "^1.2", - "mzur/kirby-flash": "^2.0" - }, - "require-dev": { - "getkirby/cms": "^3.0", - "mzur/kirby-defuse-session": "^1.0", - "phpunit/phpunit": "^9.0" - }, - "type": "kirby-plugin", - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Jevets\\Kirby\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Steve Jamesson", - "email": "steve@evendev.com" - }, - { - "name": "Martin Zurowietz", - "email": "martin@the-inspired-ones.de" - } - ], - "description": "A form helper for Kirby-based websites, using the Post/Redirect/Get pattern.", - "keywords": [ - "form", - "kirby" - ], - "support": { - "issues": "https://github.com/mzur/kirby-form/issues", - "source": "https://github.com/mzur/kirby-form/tree/v3.3.0" - }, - "time": "2023-02-19T09:51:38+00:00" - }, - { - "name": "mzur/kirby-uniform", - "version": "v5.6.1", - "source": { - "type": "git", - "url": "https://github.com/mzur/kirby-uniform.git", - "reference": "b16b507e36b710c21044eba8cc3ae36c512be554" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/mzur/kirby-uniform/zipball/b16b507e36b710c21044eba8cc3ae36c512be554", - "reference": "b16b507e36b710c21044eba8cc3ae36c512be554", - "shasum": "" - }, - "require": { - "getkirby/composer-installer": "^1.2", - "mzur/kirby-form": "^3.0" - }, - "require-dev": { - "getkirby/cms": "^3.5 || ^4.0", - "phpunit/phpunit": "^9.0" - }, - "type": "kirby-plugin", - "autoload": { - "files": [ - "src/helpers.php" - ], - "psr-4": { - "Uniform\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Martin Zurowietz", - "email": "martin@the-inspired-ones.de" - } - ], - "description": "A versatile Kirby plugin to handle web form actions.", - "keywords": [ - "form", - "kirby" - ], - "support": { - "docs": "http://kirby-uniform.readthedocs.io", - "issues": "https://github.com/mzur/kirby-uniform/issues", - "source": "https://github.com/mzur/kirby-uniform" - }, - "funding": [ - { - "url": "https://www.paypal.me/drmzur", - "type": "custom" - }, - { - "url": "https://github.com/mzur", - "type": "github" - } - ], - "time": "2024-03-07T10:29:12+00:00" - }, { "name": "phpmailer/phpmailer", "version": "v6.10.0", From 78789132a4577fb1e366bc869d01ff70ca52079c Mon Sep 17 00:00:00 2001 From: Tobias Feigel Date: Sun, 13 Jul 2025 17:40:58 +0200 Subject: [PATCH 2/2] feat: replace `mzur/kirby-uniform` with custom Kontaktformular implementation Replaced the `mzur/kirby-uniform` dependency with a custom form handling solution. Updated `kontakt.php`, its backend controller, and corresponding email template for streamlined submission handling. Adjusted styles in `input.css` and integrated a honeypot field for spam prevention. --- site/controllers/kontakt.php | 92 +++++++++++++++++------- site/snippets/blocks/kontaktformular.php | 0 site/templates/emails/email.php | 5 ++ site/templates/kontakt.php | 72 ++++++++++--------- src/css/input.css | 2 +- 5 files changed, 111 insertions(+), 60 deletions(-) delete mode 100644 site/snippets/blocks/kontaktformular.php create mode 100644 site/templates/emails/email.php diff --git a/site/controllers/kontakt.php b/site/controllers/kontakt.php index 8c9731c..69f4779 100644 --- a/site/controllers/kontakt.php +++ b/site/controllers/kontakt.php @@ -1,33 +1,71 @@ [ - 'rules' => ['required', 'email'], - 'message' => 'Bitte geben Sie eine gültige E-Mail Adresse ein.', - ], - 'name' => [ - 'rules' => ['required'], - 'message' => 'Bitte geben Sie Ihren Namen ein.', - ], - 'message' => [ - 'rules' => ['required'], - 'message' => 'Bitte geben Sie eine Nachricht ein.', - ], - ]); + if ($kirby->request()->is('POST') && get('submit')) { - if ($kirby->request()->is('POST')) { - $form->emailAction([ - 'to' => [ - 'info@feigel.it' - ], - 'from' => 'webmaster@schachfreunde-badsteben.de', - 'subject' => 'Kontaktanfrage über die Homepage der Schachfreunde Bad Steben', - ])->done(); + // check the honeypot + if (empty(get('website')) === false) { + go($page->url()); + } + + $data = [ + 'name' => get('name'), + 'email' => get('email'), + 'text' => get('text') + ]; + + $rules = [ + 'name' => ['required', 'minLength' => 3], + 'email' => ['required', 'email'], + 'text' => ['required', 'minLength' => 3, 'maxLength' => 3000], + ]; + + $messages = [ + 'name' => 'Bitte geben Sie einen Namen ein.', + 'email' => 'Bitte geben Sie eine gültige E-Mail-Adresse ein.', + 'text' => 'Bitte geben Sie einen Text ein, der zwischen 3 und 3000 Zeichen lang ist.' + ]; + + // some of the data is invalid + if ($invalid = invalid($data, $rules, $messages)) { + $alert = $invalid; + + // the data is fine, let's send the email + } else { + try { + $kirby->email([ + 'template' => 'email', + 'from' => 'webmaster@schachfreunde-badsteben.de', + 'replyTo' => $data['email'], + 'to' => 'info@feigel.it', + 'subject' => esc($data['name']) . ' hat eine Nachricht über das Kontaktformular gesendet', + 'data' => [ + 'text' => esc($data['text']), + 'sender' => esc($data['name']) + ] + ]); + + } catch (Exception $error) { + if (option('debug')): + $alert['error'] = 'Beim Versenden ist ein Fehler aufgetreten: ' . $error->getMessage() . ''; + else: + $alert['error'] = 'Beim Versenden ist ein Fehler aufgetreten!'; + endif; + } + + // no exception occurred, let's send a success message + if (empty($alert) === true) { + $success = 'Ihre Nachricht wurde gesendet! Wir werden uns bald bei Ihnen melden.'; + $data = []; + } + } } - return compact('form'); - }; + return [ + 'alert' => $alert, + 'data' => $data ?? false, + 'success' => $success ?? false + ]; + }; \ No newline at end of file diff --git a/site/snippets/blocks/kontaktformular.php b/site/snippets/blocks/kontaktformular.php deleted file mode 100644 index e69de29..0000000 diff --git a/site/templates/emails/email.php b/site/templates/emails/email.php new file mode 100644 index 0000000..9ab16f0 --- /dev/null +++ b/site/templates/emails/email.php @@ -0,0 +1,5 @@ +Hallo Schachfreunde Bad Steben, + + + + \ No newline at end of file diff --git a/site/templates/kontakt.php b/site/templates/kontakt.php index effa858..6ff5796 100644 --- a/site/templates/kontakt.php +++ b/site/templates/kontakt.php @@ -58,45 +58,53 @@ - -
-
-
-
- -
- +
+ +
+ + +
+
+
+
+ +
+ + ' . esc($alert['name']) . '' : '' ?> +
+ +
+ +
+ + ' . esc($alert['email']) . '' : '' ?> +
+
+
+ +
+ + ' . esc($alert['text']) . '' : '' ?> +
+
+
+
+
-
- -
- -
-
-
- -
- -
-
-
- + + +
+

-
- - - success()): ?> - Thank you for your message. We will get back to you soon! -
- $form]) ?> -
- + +
+ - +
diff --git a/src/css/input.css b/src/css/input.css index 8281ff3..e2e1314 100644 --- a/src/css/input.css +++ b/src/css/input.css @@ -70,7 +70,7 @@ @apply text-sf_blau-500 font-bold hover:text-sf_gelb-600; } - .uniform__potty { + .honeypot { position: absolute; left: -9999px; }