From 6f0fd2da1a35f193cb77eb4d64af6ebf91575596 Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 11:09:58 +0200 Subject: [PATCH 1/6] feat: add send mail to developer --- src/Classes/IndexController.php | 10 ++++++ src/Classes/SendMail.php | 52 ++++++++++++++++++++++++++++ src/Templates/ReportProblem.tmpl.php | 33 ++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 src/Classes/SendMail.php create mode 100644 src/Templates/ReportProblem.tmpl.php diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index 248b88e7..79cb21ba 100644 --- a/src/Classes/IndexController.php +++ b/src/Classes/IndexController.php @@ -89,6 +89,10 @@ public function invoke() $this->invokeSelfUpdate(); break; + case 'reportProblem': + $this->invokeReportProblem(); + break; + default: $this->invokeIndex(); break; @@ -459,6 +463,12 @@ public function invokeUnloadLocalModule() Redirect::redirect('/'); } + public function invokeReportProblem() + { + $this->checkAccessRight(); + 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..ff9d1b48 --- /dev/null +++ b/src/Classes/SendMail.php @@ -0,0 +1,52 @@ + + * + * 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( + array( + "text" => "Warnung: Felder können nicht leer gelassen werden.", + "type" => "error" + ) + ); + return; + } + $to = 'd.bjelajac@hoqmee.net'; + $subject = 'Report problem'; + $shopVersion = ShopInfo::getModifiedVersion(); + $message .= "
Modified version: " . $shopVersion . '
'; + $message .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . '
'; + $message .= 'PHP version: ' . phpversion() . '
'; + $headers[] = 'MIME-Version: 1.0'; + $headers[] = 'Content-type: text/html; charset=iso-8859-1'; + $headers[] = 'From: '.$from.' <'.$fromEmail.'>'; + if (mail($to, $subject, $message, implode("\r\n", $headers))) { + Notification::pushFlashMessage( + array( + "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/ReportProblem.tmpl.php b/src/Templates/ReportProblem.tmpl.php new file mode 100644 index 00000000..35a10c6e --- /dev/null +++ b/src/Templates/ReportProblem.tmpl.php @@ -0,0 +1,33 @@ + + + + + + + + + + + + +
+ +
+
+
+
+ + + + +
+
+
+
+
+ + + From 42d1e7bb85e0b89925f04ca530d53d9a030b9ecb Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 11:14:40 +0200 Subject: [PATCH 2/6] feat: add send mail to developer --- src/Classes/IndexController.php | 10 ++++++ src/Classes/SendMail.php | 52 ++++++++++++++++++++++++++++ src/Templates/ReportProblem.tmpl.php | 33 ++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 src/Classes/SendMail.php create mode 100644 src/Templates/ReportProblem.tmpl.php diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index 248b88e7..79cb21ba 100644 --- a/src/Classes/IndexController.php +++ b/src/Classes/IndexController.php @@ -89,6 +89,10 @@ public function invoke() $this->invokeSelfUpdate(); break; + case 'reportProblem': + $this->invokeReportProblem(); + break; + default: $this->invokeIndex(); break; @@ -459,6 +463,12 @@ public function invokeUnloadLocalModule() Redirect::redirect('/'); } + public function invokeReportProblem() + { + $this->checkAccessRight(); + 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..e00dfabb --- /dev/null +++ b/src/Classes/SendMail.php @@ -0,0 +1,52 @@ + + * + * 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( + array( + "text" => "Warnung: Felder können nicht leer gelassen werden.", + "type" => "error" + ) + ); + return; + } + $to = 'info@module-loader.de'; + $subject = 'Report problem'; + $shopVersion = ShopInfo::getModifiedVersion(); + $message .= "
Modified version: " . $shopVersion . '
'; + $message .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . '
'; + $message .= 'PHP version: ' . phpversion() . '
'; + $headers[] = 'MIME-Version: 1.0'; + $headers[] = 'Content-type: text/html; charset=iso-8859-1'; + $headers[] = 'From: '.$from.' <'.$fromEmail.'>'; + if (mail($to, $subject, $message, implode("\r\n", $headers))) { + Notification::pushFlashMessage( + array( + "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/ReportProblem.tmpl.php b/src/Templates/ReportProblem.tmpl.php new file mode 100644 index 00000000..35a10c6e --- /dev/null +++ b/src/Templates/ReportProblem.tmpl.php @@ -0,0 +1,33 @@ + + + + + + + + + + + + +
+ +
+
+
+
+ + + + +
+
+
+
+
+ + + From bcf48c7e4da5b6ad93ea155757fc68e824831da7 Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 11:16:47 +0200 Subject: [PATCH 3/6] small_change --- src/Classes/SendMail.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Classes/SendMail.php b/src/Classes/SendMail.php index f31bc703..3b1f7fde 100644 --- a/src/Classes/SendMail.php +++ b/src/Classes/SendMail.php @@ -31,11 +31,7 @@ public function sendFeedback() ); return; } -<<<<<<< HEAD - $to = 'info@module-loader.de'; -======= - $to = 'd.bjelajac@hoqmee.net'; ->>>>>>> 6f0fd2da1a35f193cb77eb4d64af6ebf91575596 + $to = 'info@module-loader.de'; $subject = 'Report problem'; $shopVersion = ShopInfo::getModifiedVersion(); $message .= "
Modified version: " . $shopVersion . '
'; From 1a02c9d1090ffff3b3177fbdf88ddd7bfdc1e459 Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 11:20:38 +0200 Subject: [PATCH 4/6] small fix --- src/Templates/Navi.tmpl.php | 1 + 1 file changed, 1 insertion(+) 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 @@ From e12ea0a6943bed1a2821bd2a65b9b2cdec1f2cca Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 13:39:24 +0200 Subject: [PATCH 5/6] fix: corrected german umlauts, fix: changed array to short version fix: added space before / after dot operator --- src/Classes/SendMail.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Classes/SendMail.php b/src/Classes/SendMail.php index 3b1f7fde..2bad946d 100644 --- a/src/Classes/SendMail.php +++ b/src/Classes/SendMail.php @@ -24,10 +24,10 @@ public function sendFeedback() $message = ArrayHelper::getIfSet($_POST, 'message', ''); if ($fromEmail == '' || $from == '' || $message == '') { Notification::pushFlashMessage( - array( - "text" => "Warnung: Felder können nicht leer gelassen werden.", + [ + "text" => "Warnung: Felder können nicht leer gelassen werden.", "type" => "error" - ) + ] ); return; } @@ -39,13 +39,13 @@ public function sendFeedback() $message .= 'PHP version: ' . phpversion() . '
'; $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html; charset=iso-8859-1'; - $headers[] = 'From: '.$from.' <'.$fromEmail.'>'; + $headers[] = 'From: ' . $from . ' <' . $fromEmail . '>'; if (mail($to, $subject, $message, implode("\r\n", $headers))) { Notification::pushFlashMessage( - array( - "text" => "Erfolg: Die Nachricht wurde erfolgreich gesendet, wir werden so schnell wie möglich antworten.", + [ + "text" => "Erfolg: Die Nachricht wurde erfolgreich gesendet, wir werden so schnell wie möglich antworten.", "type" => "info" - ) + ] ); } } From 0ab220da963ae7151b5dabf769a63a083422569d Mon Sep 17 00:00:00 2001 From: php-schubser Date: Tue, 11 Aug 2020 16:16:49 +0200 Subject: [PATCH 6/6] fix: send domain in mail fix: move logical code from template to controller fix: changed charset for mail --- src/Classes/IndexController.php | 4 ++++ src/Classes/SendMail.php | 25 +++++++++++++++---------- src/Templates/ReportProblem.tmpl.php | 8 +------- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/Classes/IndexController.php b/src/Classes/IndexController.php index 79cb21ba..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 { @@ -466,6 +467,9 @@ public function invokeUnloadLocalModule() public function invokeReportProblem() { $this->checkAccessRight(); + if (isset($_POST['send_mail'])) { + SendMail::sendFeedback(); + } include App::getTemplatesRoot() . '/ReportProblem.tmpl.php'; } diff --git a/src/Classes/SendMail.php b/src/Classes/SendMail.php index 2bad946d..ff8da664 100644 --- a/src/Classes/SendMail.php +++ b/src/Classes/SendMail.php @@ -25,8 +25,8 @@ public function sendFeedback() if ($fromEmail == '' || $from == '' || $message == '') { Notification::pushFlashMessage( [ - "text" => "Warnung: Felder können nicht leer gelassen werden.", - "type" => "error" + 'text' => 'Warnung: Felder können nicht leer gelassen werden.', + 'type' => 'error' ] ); return; @@ -34,17 +34,22 @@ public function sendFeedback() $to = 'info@module-loader.de'; $subject = 'Report problem'; $shopVersion = ShopInfo::getModifiedVersion(); - $message .= "
Modified version: " . $shopVersion . '
'; - $message .= 'Browser: ' . $_SERVER['HTTP_USER_AGENT'] . '
'; - $message .= 'PHP version: ' . phpversion() . '
'; - $headers[] = 'MIME-Version: 1.0'; - $headers[] = 'Content-type: text/html; charset=iso-8859-1'; - $headers[] = 'From: ' . $from . ' <' . $fromEmail . '>'; + $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" + 'text' => 'Erfolg: Die Nachricht wurde erfolgreich gesendet, wir werden so schnell wie möglich antworten.', + 'type' => 'info' ] ); } diff --git a/src/Templates/ReportProblem.tmpl.php b/src/Templates/ReportProblem.tmpl.php index 35a10c6e..81a8e0bb 100644 --- a/src/Templates/ReportProblem.tmpl.php +++ b/src/Templates/ReportProblem.tmpl.php @@ -1,11 +1,5 @@ - - - @@ -18,7 +12,7 @@
-
+