diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index 248b88e7..a83502b6 100644 --- a/src/Classes/IndexController.php +++ b/src/Classes/IndexController.php @@ -21,6 +21,7 @@ use RobinTheHood\ModifiedModuleLoaderClient\ModuleFilter; use RobinTheHood\ModifiedModuleLoaderClient\ModuleSorter; use RobinTheHood\ModifiedModuleLoaderClient\Category; +use RobinTheHood\ModifiedModuleLoaderClient\SendMail; class IndexController { @@ -89,6 +90,10 @@ public function invoke() $this->invokeSelfUpdate(); break; + case 'reportProblem': + $this->invokeReportProblem(); + break; + default: $this->invokeIndex(); break; @@ -459,6 +464,15 @@ public function invokeUnloadLocalModule() Redirect::redirect('/'); } + public function invokeReportProblem() + { + $this->checkAccessRight(); + if (isset($_POST['send_mail'])) { + SendMail::sendFeedback(); + } + include App::getTemplatesRoot() . '/ReportProblem.tmpl.php'; + } + public function checkAccessRight() { if (session_status() != PHP_SESSION_ACTIVE) { diff --git a/src/Classes/SendMail.php b/src/Classes/SendMail.php new file mode 100644 index 00000000..ff8da664 --- /dev/null +++ b/src/Classes/SendMail.php @@ -0,0 +1,57 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace RobinTheHood\ModifiedModuleLoaderClient; + +use RobinTheHood\ModifiedModuleLoaderClient\ShopInfo; +use RobinTheHood\ModifiedModuleLoaderClient\Notification; +use RobinTheHood\ModifiedModuleLoaderClient\Helpers\ArrayHelper; + +class SendMail +{ + public function sendFeedback() + { + $fromEmail = ArrayHelper::getIfSet($_POST, 'email', ''); + $from = ArrayHelper::getIfSet($_POST, 'name', ''); + $message = ArrayHelper::getIfSet($_POST, 'message', ''); + if ($fromEmail == '' || $from == '' || $message == '') { + Notification::pushFlashMessage( + [ + 'text' => 'Warnung: Felder können nicht leer gelassen werden.', + 'type' => 'error' + ] + ); + return; + } + $to = 'info@module-loader.de'; + $subject = 'Report problem'; + $shopVersion = ShopInfo::getModifiedVersion(); + $message .= + '
Message sent from: ' . $_SERVER['HTTP_HOST'] . + '
Modified version: ' . $shopVersion . + '
Browser: ' . $_SERVER['HTTP_USER_AGENT'] . + '
PHP version: ' . phpversion(); + $headers = [ + 'MIME-Version: 1.0', + 'Content-type: text/html; charset=utf-8', + 'From: ' . $from . ' <' . $fromEmail . '>' + ]; + + if (mail($to, $subject, $message, implode("\r\n", $headers))) { + Notification::pushFlashMessage( + [ + 'text' => 'Erfolg: Die Nachricht wurde erfolgreich gesendet, wir werden so schnell wie möglich antworten.', + 'type' => 'info' + ] + ); + } + } +} \ No newline at end of file diff --git a/src/Templates/Navi.tmpl.php b/src/Templates/Navi.tmpl.php index e1686ab7..072343da 100644 --- a/src/Templates/Navi.tmpl.php +++ b/src/Templates/Navi.tmpl.php @@ -14,6 +14,7 @@ diff --git a/src/Templates/ReportProblem.tmpl.php b/src/Templates/ReportProblem.tmpl.php new file mode 100644 index 00000000..81a8e0bb --- /dev/null +++ b/src/Templates/ReportProblem.tmpl.php @@ -0,0 +1,27 @@ + + + + + + + + + +
+ +
+
+
+
+ + + + +
+
+
+
+
+ + +