From 443a6b48e7fdc6128af3f9ff5c517e39c6b4495b Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Mon, 18 Sep 2017 21:19:49 +0200 Subject: [PATCH] Fix exception reporting. - Repariert: Fehlerberichte konnten nicht gesendet werden. --- Tests/Tests.csproj | 6 +- Tests/packages.config | 6 +- www/postreport.php | 81 +++++++++---------- .../ExceptionHandler/ExceptionViewModel.cs | 2 +- .../SubmissionCompletedAction.cs | 4 +- .../SubmissionFailureView.xaml | 14 ++-- .../SubmissionProcessAction.cs | 2 +- .../SubmissionSuccessView.xaml | 11 +-- zaaReloaded2/packages.config | 2 +- zaaReloaded2/zaaReloaded2.csproj | 3 +- 10 files changed, 67 insertions(+), 64 deletions(-) diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 5ac530b..8f090f7 100755 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -49,11 +49,11 @@ True - ..\packages\NLog.4.4.3\lib\net40\NLog.dll + ..\packages\NLog.4.4.12\lib\net40\NLog.dll True - - ..\packages\NUnit.3.6.1\lib\net40\nunit.framework.dll + + ..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll True diff --git a/Tests/packages.config b/Tests/packages.config index 6ce6096..3ba2bfb 100755 --- a/Tests/packages.config +++ b/Tests/packages.config @@ -2,7 +2,7 @@ - - - + + + \ No newline at end of file diff --git a/www/postreport.php b/www/postreport.php index 4ec082c..75595fb 100644 --- a/www/postreport.php +++ b/www/postreport.php @@ -1,53 +1,52 @@ isSMTP(); -$mail->SMTPAuth = true; -$mail->Host = 'nephrowiki.de'; -$mail->Username = 'zaareloaded@nephrowiki.de'; -$mail->Password = 'ooZ1eiJa'; -// $mail->SMTPSecure = 'tls'; -$mail->Port = 25; +function sendMail() { + $to = 'dk@doktorkraus.de'; + $headers = "From: \"zaaReloaded\" "; + $reportId = $_POST['report_id']; + $info = print_r( $_POST, true ); // this will be a string, not an array! + $body = <<From = 'zaareloaded@nephrowiki.de'; -$mail->FromName = 'zaaReloaded'; -$mail->addAddress('dk@doktorkraus.de'); -$mail->Subject = "[zaaReloaded] Exception $reportId"; +----- -if ( $_POST['ccUser'] ) { - $validMail = filter_var( $_POST['usersMail'], FILTER_VALIDATE_EMAIL ); - $validUser = filter_var( $_POST['usersName'], FILTER_SANITIZE_STRING ); - if ( $validUser ) { - $validUser = "\"$validUser\" "; // space character deliberately placed - }; - if ( $validMail ) { - $mail->addCC($validMail, $validUser); - }; -}; +Benutzerkommentar: -$info = print_r( $_POST, true ); - -$mail->Body = <<send()) -{ - // Must return the report ID to indicate success - echo($reportId); + if ( $_POST['ccUser'] ) { + $validMail = filter_var( $_POST['usersMail'], FILTER_VALIDATE_EMAIL ); + $validUser = filter_var( $_POST['usersName'], FILTER_SANITIZE_STRING ); + if ( $validUser ) { + $validUser = "\"$validUser\" "; // space character deliberately placed + }; + if ( $validMail ) { + $headers .= "\r\nCc: $validUser<$validMail>"; + }; + }; + mail($to, "Exception report [$reportId]", $body, $headers); } -else -{ - echo($mail->ErrorInfo); + +// ============================================================= +// Begin main script +// ============================================================= + +if (!isset($_POST['report_id'])) { + http_response_code(400); + exit; } + +sendMail(); +// Return the report ID and the issue URL to signal all is well. +$reportId = $_POST['report_id']; +$load = "{\"ReportId\": \"$reportId\", \"IssueUrl\": \"https://www.doktorkraus.de/zaareloaded\"}"; +error_log( __FILE__ . ": Load = $load" ); +header('Content-Type: application/json'); +echo $load; diff --git a/zaaReloaded2/ExceptionHandler/ExceptionViewModel.cs b/zaaReloaded2/ExceptionHandler/ExceptionViewModel.cs index c58c365..c3a8668 100755 --- a/zaaReloaded2/ExceptionHandler/ExceptionViewModel.cs +++ b/zaaReloaded2/ExceptionHandler/ExceptionViewModel.cs @@ -83,7 +83,7 @@ namespace zaaReloaded2.ExceptionHandler protected override string DevPath() { - return @"x:\Code\zaaReloaded2\zaaReloaded2\"; + return @"x:\\Code\\zaaReloaded2\\zaaReloaded2\\"; } protected override Bovender.UserSettings.UserSettingsBase UserSettings diff --git a/zaaReloaded2/ExceptionHandler/SubmissionCompletedAction.cs b/zaaReloaded2/ExceptionHandler/SubmissionCompletedAction.cs index 57ab932..e6696bc 100755 --- a/zaaReloaded2/ExceptionHandler/SubmissionCompletedAction.cs +++ b/zaaReloaded2/ExceptionHandler/SubmissionCompletedAction.cs @@ -34,12 +34,12 @@ namespace zaaReloaded2.ExceptionHandler { protected override Window CreateSuccessWindow() { - return Content.InjectInto(); + return new SubmissionSuccessView(); } protected override Window CreateFailureWindow() { - return Content.InjectInto(); + return new SubmissionFailureView(); } protected override Window CreateCancelledWindow() diff --git a/zaaReloaded2/ExceptionHandler/SubmissionFailureView.xaml b/zaaReloaded2/ExceptionHandler/SubmissionFailureView.xaml index 14679f4..95eb934 100755 --- a/zaaReloaded2/ExceptionHandler/SubmissionFailureView.xaml +++ b/zaaReloaded2/ExceptionHandler/SubmissionFailureView.xaml @@ -21,14 +21,14 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:l="clr-namespace:zaaReloaded2" - SizeToContent="WidthAndHeight" + SizeToContent="Height" Width="540" Title="Fehlerbericht versenden" > - - + × @@ -36,11 +36,13 @@ - - + +