diff --git a/admin_index.php b/admin_index.php index 39925f54..5b2aef6a 100644 --- a/admin_index.php +++ b/admin_index.php @@ -321,4 +321,79 @@ if ($page == 'overview') { eval("echo \"" . getTemplate("index/change_theme") . "\";"); } + +} elseif ($page == 'send_error_report') { + + // only show this if we really have an exception to report + if (isset($_GET['errorid']) + && $_GET['errorid'] != '' + ) { + + $errid = $_GET['errorid']; + // read error file + $err_dir = makeCorrectDir(FROXLOR_INSTALL_DIR."/logs/"); + $err_file = makeCorrectFile($err_dir."/".$errid."_sql-error.log"); + + if (file_exists($err_file)) { + + $error_content = file_get_contents($err_file); + $error = explode("|", $error_content); + + $_error = array( + 'code' => str_replace("\n", "", substr($error[1], 5)), + 'message' => str_replace("\n", "", substr($error[2], 4)), + 'file' => str_replace("\n", "", substr($error[3], 5 + strlen(FROXLOR_INSTALL_DIR))), + 'line' => str_replace("\n", "", substr($error[4], 5)), + 'trace' => str_replace(FROXLOR_INSTALL_DIR, "", substr($error[5], 6)) + ); + + // build mail-content + $mail_body = "Dear froxlor-team,\n\n"; + $mail_body .= "the following error has been reported by a user:\n\n"; + $mail_body .= "-------------------------------------------------------------\n"; + $mail_body .= $_error['code'].' '.$_error['message']."\n"; + $mail_body .= $_error['file'].':'.$_error['line']."\n\n"; + $mail_body .= "Trace:\n".$_error['trace']."\n\n"; + $mail_body .= "-------------------------------------------------------------\n"; + $mail_body .= "End of report"; + $mail_html = str_replace("\n", "
", $mail_body); + + // send actual report to dev-team + if (isset($_POST['send']) + && $_POST['send'] == 'send' + ) { + // send mail and say thanks + $_mailerror = false; + try { + $mail->Subject = '[Froxlor] Error report by user'; + $mail->AltBody = $mail_body; + $mail->MsgHTML($mail_html); + $mail->AddAddress('team@froxlor.org', 'Froxlor Developer Team'); + $mail->Send(); + } catch(phpmailerException $e) { + $mailerr_msg = $e->errorMessage(); + $_mailerror = true; + } catch (Exception $e) { + $mailerr_msg = $e->getMessage(); + $_mailerror = true; + } + + if ($_mailerror) { + // error when reporting an error...LOLFUQ + } + + // finally remove error from fs + @unlink($err_file); + redirectTo($filename, array('s' => $s)); + } + // show a nice summary of the error-report + // before actually sending anything + eval("echo \"" . getTemplate("index/send_error_report") . "\";"); + + } else { + redirectTo($filename, array('s' => $s)); + } + } else { + redirectTo($filename, array('s' => $s)); + } } diff --git a/lib/classes/database/class.Database.php b/lib/classes/database/class.Database.php index 7dcfdff8..ac18af8e 100644 --- a/lib/classes/database/class.Database.php +++ b/lib/classes/database/class.Database.php @@ -310,6 +310,19 @@ class Database { @fwrite($sqllog, date('d.m.Y H:i', time())." --- DEBUG: \n".$error->getTraceAsString()."\n"); @fclose($sqllog); + /** + * log error for reporting + */ + $errid = substr(md5(microtime()), 5, 5); + $err_file = makeCorrectFile($sl_dir."/".$errid."_sql-error.log"); + $errlog = @fopen($err_file, 'w'); + @fwrite($errlog, "|CODE ".$error->getCode()."\n"); + @fwrite($errlog, "|MSG ".$error->getMessage()."\n"); + @fwrite($errlog, "|FILE ".$error->getFile()."\n"); + @fwrite($errlog, "|LINE ".$error->getLine()."\n"); + @fwrite($errlog, "|TRACE\n".$error->getTraceAsString()."\n"); + @fclose($errlog); + if ($showerror) { if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) { // if we're not on the shell, output a nicer error-message @@ -317,6 +330,7 @@ class Database { // replace values $err_hint = str_replace("", $error->getMessage(), $err_hint); $err_hint = str_replace("", $error->getTraceAsString(), $err_hint); + $err_hint = str_replace("", $linker->getLink(array('section' => 'index', 'page' => 'send_error_report', 'errorid' => $errid)), $err_hint); // show die($err_hint); } diff --git a/templates/Sparkle/admin/index/send_error_report.tpl b/templates/Sparkle/admin/index/send_error_report.tpl new file mode 100644 index 00000000..6a5e2cf3 --- /dev/null +++ b/templates/Sparkle/admin/index/send_error_report.tpl @@ -0,0 +1,44 @@ +$header +
+
+

+   + Send error report +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+

Thank you for reporting this error and helping us to make froxlor better.

+

This is the e-mail that will be sent to the froxlor developer team:

+
+ {$mail_html} +
+ +
+
+
+
+
+$footer diff --git a/templates/Sparkle/customer/index/send_error_report.tpl b/templates/Sparkle/customer/index/send_error_report.tpl new file mode 100644 index 00000000..6a5e2cf3 --- /dev/null +++ b/templates/Sparkle/customer/index/send_error_report.tpl @@ -0,0 +1,44 @@ +$header +
+
+

+   + Send error report +

+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
+

Thank you for reporting this error and helping us to make froxlor better.

+

This is the e-mail that will be sent to the froxlor developer team:

+
+ {$mail_html} +
+ +
+
+
+
+
+$footer diff --git a/templates/Sparkle/misc/dberrornice.tpl b/templates/Sparkle/misc/dberrornice.tpl index 4abaf8a4..7bf3ec68 100644 --- a/templates/Sparkle/misc/dberrornice.tpl +++ b/templates/Sparkle/misc/dberrornice.tpl @@ -34,8 +34,14 @@

 

-