diff --git a/app/Http/Controllers/MailController.php b/app/Http/Controllers/MailController.php index 5835dfe7bfa4cf8d9beac69a86462ce3f0849339..35a2855e7ba79348e1f86140780e3af39a100455 100644 --- a/app/Http/Controllers/MailController.php +++ b/app/Http/Controllers/MailController.php @@ -9,6 +9,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use LaravelLocalization; use Mail; +use Validator; class MailController extends Controller { @@ -24,6 +25,23 @@ class MailController extends Controller # Nachricht, die wir an den Nutzer weiterleiten: $messageType = ""; # [success|error] $returnMessage = ''; + + # Wir benötigen 3 Felder von dem Benutzer wenn diese nicht übermittelt wurden, oder nicht korrekt sind geben wir einen Error zurück + $validator = Validator::make( + [ + 'email' => $request->input('email') + ], + [ + 'email' => 'required|email' + ] + ); + + if($validator->fails()){ + return view('kontakt.kontakt')->with('formerrors', $validator)->with('title', trans('titles.kontakt'))->with('navbarFocus', 'kontakt'); + } + + $name = $request->input('name', ''); + $replyTo = $request->input('email', 'noreply@metager.de'); if ($replyTo === "") { $replyTo = "noreply@metager.de"; @@ -31,15 +49,15 @@ class MailController extends Controller $replyTo = $request->input('email'); } - if (!$request->has('message')) { + if (!$request->has('message') || !$request->has('subject')) { $messageType = "error"; $returnMessage = "Tut uns leid, aber leider haben wir mit Ihrer Kontaktanfrage keine Daten erhalten. Die Email wurde nicht versand"; } else { # Wir versenden die Mail des Benutzers an uns: $message = $request->input('message'); - - Mail::to("office@suma-ev.de") - ->send(new Kontakt($replyTo, $message)); + $subject = $request->input('subject'); + Mail::to("support@suma-ev.de") + ->send(new Kontakt($name, $replyTo, $subject, $message)); $returnMessage = 'Ihre Email wurde uns erfolgreich zugestellt. Vielen Dank dafür! Wir werden diese schnellstmöglich bearbeiten und uns dann ggf. wieder bei Ihnen melden.'; $messageType = "success"; diff --git a/app/Mail/Kontakt.php b/app/Mail/Kontakt.php index 91934a1a5c5544442e776d9dcebfe48947d6cf03..dc707cfa5bf95eba6616ae24e9791d76cb1e7fed 100644 --- a/app/Mail/Kontakt.php +++ b/app/Mail/Kontakt.php @@ -15,10 +15,11 @@ class Kontakt extends Mailable * * @return void */ - public function __construct($from, $message) + public function __construct($name, $from, $subject, $message) { - $this->subject = "[Ticket " . date("Y") . date("d") . date("m") . date("H") . date("i") . date("s") . "] MetaGer - Kontaktanfrage"; + $this->name = $name; $this->reply = $from; + $this->subject = $subject; $this->message = $message; } @@ -29,7 +30,7 @@ class Kontakt extends Mailable */ public function build() { - return $this->from($this->reply) + return $this->from($this->reply, $this->name) ->subject($this->subject) ->text('kontakt.mail') ->with('messageText', $this->message); diff --git a/public/js/kontakt.js b/public/js/kontakt.js deleted file mode 100644 index 30205ed76209115cfa1ff3a9e4ceafba42cb4c9c..0000000000000000000000000000000000000000 --- a/public/js/kontakt.js +++ /dev/null @@ -1,70 +0,0 @@ -$(document).ready(function () { - switch (getLanguage()) { - case 'de': - $('.encrypt-btn').html('Verschlüsseln und senden'); - break; - case 'en': - $('.encrypt-btn').html('encrypt and send'); - break; - case 'es': - // $(".encrypt-btn").html(""); TODO - break; - } - $('.contact').submit(function () { - return encrypt(this); - }); -}); -// based on https://github.com/encrypt-to/secure.contactform.php -/* The MIT License (MIT) -Copyright (c) 2013 Jan Wiegelmann - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.*/ -function encrypt () { - if (window.crypto && window.crypto.getRandomValues) { - var message = document.getElementById('message'); - if (message.value.indexOf('-----BEGIN PGP MESSAGE-----') !== -1 && message.value.indexOf('-----END PGP MESSAGE-----') !== -1) { - // encryption done - } else { - var pub_key = openpgp.key.readArmored(document.getElementById('pubkey').innerHTML).keys[0]; - var plaintext = message.value; - var ciphertext = openpgp.encryptMessage([pub_key], plaintext); - message.value = ciphertext; - return true; - } - } else { - switch (getLanguage()) { - case 'de': - alert('Fehler: Ihr Browser wird nicht unterstützt. Bitte installieren Sie einen aktuellen Browser wie z.B. Mozilla Firefox.'); - break; - case 'en': - alert('Error: Your browser is not supported. Please install an up to date browser like Mozilla Firefox.'); - break; - case 'es': - // alert(""); TODO - break; - } - return false; - } -} - -function getLanguage () { - var metaData = document.getElementsByTagName('meta'); - for (var m in metaData) { - if (metaData[m]['httpEquiv'] == 'language') { - return metaData[m]['content']; - } - } -} diff --git a/resources/lang/de/kontakt.php b/resources/lang/de/kontakt.php index f57a29906a09377dd39a9c67055bde5d3df9bd79..3b38be08a150886008a42c6572311005f5bbed13 100644 --- a/resources/lang/de/kontakt.php +++ b/resources/lang/de/kontakt.php @@ -2,19 +2,14 @@ return [ 'headline.1' => 'Kontakt', - 'headline.2' => 'Forum', - 'headline.3' => 'Bitte stellen Sie technische Fragen zuerst in unserem Forum', - 'headline.4' => 'So können auch andere von einer Antwort profitieren.', - 'form.1' => 'Sicheres Kontakformular', - 'form.2' => 'Über dieses Formular können Sie uns verschlüsselt kontaktieren. -Alternativ können Sie uns natürlich auch per email erreichen.', - 'form.3' => 'Beachten Sie: Aufgrund der Vielzahl der Anfragen sind wir personell nicht immer in der Lage, alles zeitnah zu beantworten.', - 'form.4' => 'Wenn Sie keine email-Adresse angeben, können wir Ihnen nicht antworten.', - 'form.5' => 'Ihre e-mail-Adresse (optional)', + 'form.2' => 'Über dieses Formular können Sie uns kontaktieren. +Alternativ können Sie uns natürlich auch per email erreichen.', +'form.name' => "Name (Vorname Nachname)", + 'form.5' => 'Ihre e-mail-Adresse', 'form.6' => 'Ihre Nachricht', - 'form.7' => 'Ihre Nachricht wird vor dem Absenden mit OpenPGP.js verschlüsselt. Dafür wird Javascript benötigt. Falls Sie Javascript deaktiviert haben, wird Ihre Eingabe unverschlüsselt gesendet.', - 'form.8' => 'Verschlüsseln und senden', + 'form.7' => 'Betreff', + 'form.8' => 'Senden', 'mail.1' => 'Per Email', 'mail.2' => 'Sie können uns auch direkt eine email an die folgende Adresse schicken: office@suma-ev.de', diff --git a/resources/lang/en/kontakt.php b/resources/lang/en/kontakt.php index 1d70cd7777cab5a055543d093f4be502a8f9a2eb..1c982276dc80ac89fc4690598ec631d7752cf93e 100644 --- a/resources/lang/en/kontakt.php +++ b/resources/lang/en/kontakt.php @@ -2,19 +2,13 @@ return [ 'headline.1' => 'Contact', - 'headline.2' => 'Forum', - 'headline.3' => 'If you have a technical question, ask the community at our board first, please.', - 'headline.4' => 'So others could benefit from an answer.', 'form.1' => 'Secure Contact Form', - 'form.2' => 'Via this form you can contact us by encrypted e-mail.', + 'form.2' => 'Via this form you can contact us by e-mail.', - 'form.3' => 'Please note that due to a lot of requests we are personnel-wise not able to answer everything promptly.', - 'form.4' => 'If you do not enter an email-adress, we can not answer you.', 'form.5' => 'Your e-mail-adress (optional)', 'form.6' => 'Your message', - 'form.7' => 'Before dispatch, your messgae is encrypted with OpenPGP.js. We use Javascript for this. If you have Javascript disabled, your message will be send unencrypted.', - 'form.8' => 'Encrypt and send', + 'form.8' => 'Send', 'mail.1' => 'By Email', 'mail.2' => 'You can also email us directly at: office@suma-ev.de', diff --git a/resources/lang/es/kontakt.php b/resources/lang/es/kontakt.php index 0a2c646dae6c74f4abbbe94db6b730cd314773e7..8f2fb2f813a72abb54c6d1e9a05fda90f4344960 100644 --- a/resources/lang/es/kontakt.php +++ b/resources/lang/es/kontakt.php @@ -9,7 +9,6 @@ return [ "form.1" => "Formulario de contacto seguro", "form.2" => "Con este formulario nos puede contactar encryptado. Por supuesto como vía alterna nos puede mandar un email.", "form.3" => "Por la cantidad de consultas que recibimos no estamos siempre contestando a tiempo.", - "form.4" => "Si no nos da su correo electrónico, no podemos contestarle.", "form.5" => "Su dirección de correo electrónico (opcional)", "form.6" => "Su mensaje", 'form.7' => 'Su mensaje será encryptada antes de mandarla OpenPGP.js para esto necesitamos Javascript. Sino tiene activado Javascript su mensaje será enviada sin encryptación.', diff --git a/resources/views/kontakt/kontakt.blade.php b/resources/views/kontakt/kontakt.blade.php index 584ef75fc0b14587be2a201a49b4ddd00344663c..b15ae49dff9719caa934cc5457f612318d6d612d 100644 --- a/resources/views/kontakt/kontakt.blade.php +++ b/resources/views/kontakt/kontakt.blade.php @@ -4,25 +4,33 @@ @section('content')
{!! trans('kontakt.headline.3') !!} - {!! trans('kontakt.headline.4') !!}
{!! trans('kontakt.form.2') !!}
-{!! trans('kontakt.form.3') !!}
-{!! trans('kontakt.form.4') !!}
+ @if(isset($formerrors)) + @foreach($formerrors->errors()->all() as $errormessage) +{!! trans('kontakt.letter.2') !!}
{!! trans('kontakt.letter.3') !!} - @endsection