Commit 689520c1 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '284-update-auf-laravel-5-3' into 'development'

Mailsystem auf das von Laravel 5.3 umgestellt

Außerdem habe ich eine Überprüfung in das Spendenformular eingebaut. Diese prüft, ob die angegebene Kontonummer/Iban korrekt ist

Closes #284

See merge request !469
parents 490d68ac 0dd6fab5
......@@ -2,6 +2,9 @@
namespace App\Http\Controllers;
use App\Mail\Kontakt;
use App\Mail\Spende;
use App\Mail\Sprachdatei;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use LaravelLocalization;
......@@ -34,23 +37,12 @@ class MailController extends Controller
} else {
# Wir versenden die Mail des Benutzers an uns:
$message = $request->input('message');
$subject = "[Ticket " . date("Y") . date("d") . date("m") . date("H") . date("i") . date("s") . "] MetaGer - Kontaktanfrage";
if (Mail::send(['text' => 'kontakt.mail'], ['messageText' => $message], function ($message) use ($replyTo, $subject) {
$message->to("office@suma-ev.de", $name = null);
$message->from($replyTo, $name = null);
$message->replyTo($replyTo, $name = null);
$message->subject($subject);
})) {
# Mail erfolgreich gesendet
$messageType = "success";
$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.';
} else {
# Fehler beim senden der Email
$messageType = "error";
$returnMessage = 'Beim Senden Ihrer Email ist ein Fehler aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
}
$messageType = "success";
Mail::to("office@suma-ev.de")
->send(new Kontakt($replyTo, $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";
}
return view('kontakt.kontakt')
......@@ -67,54 +59,55 @@ class MailController extends Controller
$messageType = ""; # [success|error]
#Sicherheitsüberprüfung (Wir wurden in letzter Zeit ziemlich mit Mails zugespammt
$hash = md5(date('Y') . date('m') . date('d'));
if ($request->input('dt') !== $hash) {
return redirect(url('spende'));
}
# Folgende Felder werden vom Spendenformular als Input übergeben:
# Name
# Telefon
# email
# Kontonummer ( IBAN )
# Bankleitzahl ( BIC )
# Nachricht
if (!$request->has('Kontonummer') || !$request->has('Bankleitzahl') || !$request->has('Nachricht')) {
$messageToUser = "Sie haben eins der folgenden Felder nicht ausgefüllt: IBAN, BIC, Nachricht. Bitte korrigieren Sie Ihre Eingabe und versuchen es erneut.\n";
# Wir überprüfen also, ob das Feld für die Kontonummer tatsächlich eine Kontonummer, oder eine IBAN enthält:
$iban = $request->input('Kontonummer', '');
$iban = preg_replace("/\s/s", "", $iban);
# Eine Kontonummer besteht nur aus Zahlen
# Eine IBAN besteht aus einem Ländercode (2 Buchstaben), einer 2 stelligen Prüfsumme (2 Ziffern) gefolgt von
# einer Kombination aus Buchstaben und Zahlen
if (!preg_match("/^\d+$/s", $iban) && !preg_match("/^[a-zA-Z]{2}\d{2}[a-zA-Z0-9]+$/s", $iban)) {
$messageToUser = "Die eingegebene IBAN/Kontonummer scheint nicht Korrekt zu sein. Nachricht wurde nicht gesendet";
$messageType = "error";
} else {
$message = "\r\nName: " . $request->input('Name', 'Keine Angabe');
$message .= "\r\nTelefon: " . $request->input('Telefon', 'Keine Angabe');
$message .= "\r\nKontonummer: " . $request->input('Kontonummer');
$message .= "\r\nBankleitzahl: " . $request->input('Bankleitzahl');
$message .= "\r\nNachricht: " . $request->input('Nachricht');
$replyTo = $request->input('email', 'anonymous-user@metager.de');
if (!filter_var($replyTo, FILTER_VALIDATE_EMAIL)) {
$messageToUser .= "Die eingegebene Email-Addresse ($replyTo) scheint nicht korrekt zu sein.";
}
try {
if (Mail::send(['text' => 'kontakt.mail'], ['messageText' => $message], function ($message) use ($replyTo) {
$message->to("office@suma-ev.de", $name = null);
$message->from($replyTo, $name = null);
$message->replyTo($replyTo, $name = null);
$message->subject("MetaGer - Spende");
})) {
# Folgende Felder werden vom Spendenformular als Input übergeben:
# Name
# Telefon
# email
# Kontonummer ( IBAN )
# Bankleitzahl ( BIC )
# Nachricht
if (!$request->has('Kontonummer') || !$request->has('Bankleitzahl') || !$request->has('Nachricht')) {
$messageToUser = "Sie haben eins der folgenden Felder nicht ausgefüllt: IBAN, BIC, Nachricht. Bitte korrigieren Sie Ihre Eingabe und versuchen es erneut.\n";
$messageType = "error";
} else {
$message = "\r\nName: " . $request->input('Name', 'Keine Angabe');
$message .= "\r\nTelefon: " . $request->input('Telefon', 'Keine Angabe');
$message .= "\r\nKontonummer: " . $request->input('Kontonummer');
$message .= "\r\nBankleitzahl: " . $request->input('Bankleitzahl');
$message .= "\r\nNachricht: " . $request->input('Nachricht');
$replyTo = $request->input('email', 'anonymous-user@metager.de');
if (!filter_var($replyTo, FILTER_VALIDATE_EMAIL)) {
$messageToUser .= "Die eingegebene Email-Addresse ($replyTo) scheint nicht korrekt zu sein.";
}
try {
Mail::to("office@suma-ev.de")
->send(new Spende($replyTo, $message));
$messageType = "success";
$messageToUser = "Herzlichen Dank!! Wir haben Ihre Spendenbenachrichtigung erhalten.";
} else {
} catch (\Swift_TransportException $e) {
$messageType = "error";
$messageToUser = 'Beim Senden Ihrer Spendenbenachrichtigung ist ein Fehler auf unserer Seite aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
}
} catch (\Swift_TransportException $e) {
$messageType = "error";
$messageToUser = 'Beim Senden Ihrer Spendenbenachrichtigung ist ein Fehler auf unserer Seite aufgetreten. Bitte schicken Sie eine Email an: office@suma-ev.de, damit wir uns darum kümmern können.';
}
}
if ($messageType === "error") {
return view('spende.danke')
$request->flash();
return view('spende.spende')
->with('title', 'Kontakt')
->with('css', 'donation.css')
->with($messageType, $messageToUser);
......@@ -188,12 +181,8 @@ class MailController extends Controller
$ex["new"] += $new;
if ($new > 0) {
Mail::send(['text' => 'kontakt.mail'], ['messageText' => $message], function ($message) use ($output, $filename) {
$message->subject('MetaGer - Sprachdatei');
$message->from('noreply@metager.de');
$message->to('office@suma-ev.de');
$message->attachData($output, basename($filename));
});
Mail::to("dev@suma-ev.de")
->send(new Sprachdatei($message, $output, basename($filename)));
}
$ex = base64_encode(serialize($ex));
return redirect(url('languages/edit', ['from' => $from, 'to' => $to, 'exclude' => $ex]));
......
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Kontakt extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($from, $message)
{
$this->subject = "[Ticket " . date("Y") . date("d") . date("m") . date("H") . date("i") . date("s") . "] MetaGer - Kontaktanfrage";
$this->reply = $from;
$this->message = $message;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from($this->reply)
->subject($this->subject)
->text('kontakt.mail')
->with('messageText', $this->message);
}
}
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Spende extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($from, $message)
{
$this->subject = "MetaGer - Spende";
$this->reply = $from;
$this->message = $message;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from($this->reply)
->subject($this->subject)
->text('kontakt.mail')
->with('messageText', $this->message);
}
}
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class Sprachdatei extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($message, $fileContent, $filename)
{
$this->subject = "MetaGer - Sprachdatei";
$this->reply = "noreply@metager.de";
$this->message = $message;
$this->fileContent = $fileContent;
$this->filename = $filename;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from($this->reply)
->cc('carsten@suma-ev.de')
->subject($this->subject)
->text('kontakt.mail')
->with('messageText', $this->message)
->attachData($this->fileContent, $this->filename);
}
}
......@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "de1198adb5eb9dbe1f9dfc41a29eb06e",
"content-hash": "5370835516a2e14e2719a22c97efb77e",
"hash": "8e241daaa385d66306759f61396adaee",
"content-hash": "57a41f9bae38c1e2f2bc82e9f115eff5",
"packages": [
{
"name": "classpreloader/classpreloader",
......@@ -212,6 +212,177 @@
],
"time": "2015-12-24 15:02:55"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.2.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "3f808fba627f2c5b69e2501217bf31af349c1427"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427",
"reference": "3f808fba627f2c5b69e2501217bf31af349c1427",
"shasum": ""
},
"require": {
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.3.1",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.0",
"psr/log": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.2-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"time": "2016-07-15 17:22:37"
},
{
"name": "guzzlehttp/promises",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "c10d860e2a9595f8883527fa0021c7da9e65f579"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579",
"reference": "c10d860e2a9595f8883527fa0021c7da9e65f579",
"shasum": ""
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"time": "2016-05-18 16:56:05"
},
{
"name": "guzzlehttp/psr7",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "PSR-7 message implementation",
"keywords": [
"http",
"message",
"stream",
"uri"
],
"time": "2016-06-24 23:00:38"
},
{
"name": "jakub-onderka/php-console-color",
"version": "0.1",
......@@ -416,16 +587,16 @@
},
{
"name": "laravel/framework",
"version": "v5.3.16",
"version": "v5.3.17",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "9932861dee0fef30138f9839102fb00ddd6ddce1"
"reference": "67fb3e638eb4d862279f50642101910163d14e61"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/9932861dee0fef30138f9839102fb00ddd6ddce1",
"reference": "9932861dee0fef30138f9839102fb00ddd6ddce1",
"url": "https://api.github.com/repos/laravel/framework/zipball/67fb3e638eb4d862279f50642101910163d14e61",
"reference": "67fb3e638eb4d862279f50642101910163d14e61",
"shasum": ""
},
"require": {
......@@ -540,7 +711,7 @@
"framework",
"laravel"
],
"time": "2016-10-04 16:05:47"
"time": "2016-10-06 18:06:32"
},
{
"name": "league/flysystem",
......@@ -1085,6 +1256,56 @@
],
"time": "2016-06-16 16:22:20"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"time": "2016-08-06 14:39:51"
},
{
"name": "psr/log",
"version": "1.0.1",
......@@ -2877,16 +3098,16 @@
},
{
"name": "phpunit/phpunit",
"version": "5.5.7",
"version": "5.6.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba"
"reference": "a7f2db56518e50ab92f28f739810dfad2f223b6b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/3f67cee782c9abfaee5e32fd2f57cdd54bc257ba",
"reference": "3f67cee782c9abfaee5e32fd2f57cdd54bc257ba",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a7f2db56518e50ab92f28f739810dfad2f223b6b",
"reference": "a7f2db56518e50ab92f28f739810dfad2f223b6b",
"shasum": ""
},
"require": {
......@@ -2920,7 +3141,6 @@
"ext-pdo": "*"
},
"suggest": {
"ext-tidy": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "~1.1"
},
......@@ -2930,7 +3150,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.5.x-dev"
"dev-master": "5.6.x-dev"
}
},
"autoload": {
......@@ -2956,7 +3176,7 @@
"testing",
"xunit"
],
"time": "2016-10-03 13:04:15"
"time": "2016-10-06 15:20:39"
},
{
"name": "phpunit/phpunit-mock-objects",
......
......@@ -42,10 +42,10 @@
</div>
<div class="col-lg-6 col-md-12 col-sm-12 others noprint" id="right">
<h2>{{ trans('spenden.about.1') }}</h2>
<p>{{ trans('spenden.about.2') }}</p>
<p>{{ trans('spenden.about.3') }}</p>
<p>{{ trans('spenden.about.4') }}</p>
<p>{{ trans('spenden.about.5') }}</p>
<p>{!! trans('spenden.about.2') !!}</p>
<p>{!! trans('spenden.about.3') !!}</p>
<p>{!! trans('spenden.about.4') !!}</p>
<p>{!! trans('spenden.about.5') !!}</p>
</div>
<div class="clearfix"></div>
</div>
......
......@@ -45,27 +45,27 @@
<input type="hidden" name="dt" value="{{ md5(date('Y') . date('m') . date('d')) }}" />
<div class="form-group donation-form-group">
<label for="Name">{!! trans('spenden.lastschrift.3') !!}</label>
<input type="text" class="form-control" id="Name" required="" name="Name" placeholder="{!! trans('spenden.lastschrift.3.placeholder') !!}">
<input type="text" class="form-control" id="Name" required="" name="Name" placeholder="{!! trans('spenden.lastschrift.3.placeholder') !!}" value="{{ old('Name') }}" />
</div>
<div class="form-group donation-form-group">
<label for="email">{!! trans('spenden.lastschrift.4') !!}</label>
<input type="email" class="form-control" id="email" name="email" placeholder="Email">
<input type="email" class="form-control" id="email" name="email" placeholder="Email" value="{{ old('email') }}" />