diff --git a/.php-cs-fixer.cache b/.php-cs-fixer.cache new file mode 100644 index 0000000..82f28fb --- /dev/null +++ b/.php-cs-fixer.cache @@ -0,0 +1 @@ +{"php":"8.4.10","version":"3.83.0","indent":" ","lineEnding":"\n","rules":{"binary_operator_spaces":{"default":"at_least_single_space"},"blank_line_after_opening_tag":true,"blank_line_between_import_groups":true,"blank_lines_before_namespace":true,"braces_position":{"allow_single_line_empty_anonymous_classes":true},"class_definition":{"inline_constructor_arguments":false,"space_before_parenthesis":true},"compact_nullable_type_declaration":true,"declare_equal_normalize":true,"lowercase_cast":true,"lowercase_static_reference":true,"new_with_parentheses":true,"no_blank_lines_after_class_opening":true,"no_extra_blank_lines":{"tokens":["use"]},"no_leading_import_slash":true,"no_whitespace_in_blank_line":true,"ordered_class_elements":{"order":["use_trait"]},"ordered_imports":{"imports_order":["class","function","const"],"sort_algorithm":"none"},"return_type_declaration":true,"short_scalar_cast":true,"single_import_per_statement":{"group_to_single_imports":false},"single_space_around_construct":{"constructs_followed_by_a_single_space":["abstract","as","case","catch","class","const_import","do","else","elseif","final","finally","for","foreach","function","function_import","if","insteadof","interface","namespace","new","private","protected","public","static","switch","trait","try","use","use_lambda","while"],"constructs_preceded_by_a_single_space":["as","else","elseif","use_lambda"]},"single_trait_insert_per_statement":true,"ternary_operator_spaces":true,"unary_operator_spaces":{"only_dec_inc":true},"visibility_required":true,"blank_line_after_namespace":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"attribute_placement":"ignore","on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"encoding":true,"full_opening_tag":true},"hashes":{"site\/config\/.null-ls_911210_config.php":"2d78170c9563f5a246bdacb14cf85ec2","site\/config\/.null-ls_465380_config.php":"2d78170c9563f5a246bdacb14cf85ec2","site\/config\/.null-ls_143201_config.php":"5d9b10393e10c10141337fe3b5125e10","site\/config\/.null-ls_163239_config.php":"f1d87565c86bcc321fbfd98122cd6a43","site\/config\/.null-ls_188489_config.php":"8c58ffe66502f2cf9cde2cbd248e8b7e","site\/config\/.null-ls_483057_config.php":"b862e1c88f7b5cc0ed3d66b8ee71e91a","site\/config\/.null-ls_120553_config.php":"b862e1c88f7b5cc0ed3d66b8ee71e91a","site\/config\/.null-ls_846880_config.php":"51784d7f92819ac1bf5100f626799833","site\/config\/.null-ls_762054_config.php":"51784d7f92819ac1bf5100f626799833","site\/controllers\/.null-ls_802479_kontakt.php":"e1d96499642c66ee3f8fcee34ff62c88","site\/controllers\/.null-ls_184446_kontakt.php":"e1d96499642c66ee3f8fcee34ff62c88","site\/config\/.null-ls_985853_config.php":"51784d7f92819ac1bf5100f626799833","site\/config\/.null-ls_862453_config.php":"3baf399164a71b8b9347f7159ed44419","site\/config\/.null-ls_118809_config.php":"3baf399164a71b8b9347f7159ed44419"}} \ No newline at end of file diff --git a/site/config/config.php b/site/config/config.php index 00828c1..527688e 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -2,4 +2,20 @@ return [ 'debug' => true, -]; \ No newline at end of file + 'email' => [ + 'transport' => [ + 'type' => 'smtp', + 'host' => 'smtp.resend.com', + 'port' => 587, + 'security' => true, + 'auth' => true, + 'username' => 'resend', + 'password' => 're_87XcxJAD_43XdRZwdsTC2nYXoXs5UN2NY', + ], + 'presets' => [ + 'contact' => [ + 'from' => 'no-replay@fits-apps.net' + ] + ] + ] +]; diff --git a/site/controllers/kontakt.php b/site/controllers/kontakt.php index 4c6b5e4..e7a0d5d 100644 --- a/site/controllers/kontakt.php +++ b/site/controllers/kontakt.php @@ -1,71 +1,72 @@ request()->is('POST') && get('submit')) { + $alert = null; - // check the honeypot - if (empty(get('website')) === false) { - go($page->url()); - } + if ($kirby->request()->is('POST') && get('submit')) { - $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 = []; - } - } + // check the honeypot + if (empty(get('website')) === false) { + go($page->url()); } - return [ - 'alert' => $alert, - 'data' => $data ?? false, - 'success' => $success ?? false + $data = [ + 'name' => get('name'), + 'email' => get('email'), + 'text' => get('text') ]; - }; \ No newline at end of file + + $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' => 'no-reply@fits-apps.net', + '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 [ + 'alert' => $alert, + 'data' => $data ?? false, + 'success' => $success ?? false + ]; +};