first implementation of error-reporting
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -321,4 +321,79 @@ if ($page == 'overview') {
|
|||||||
|
|
||||||
eval("echo \"" . getTemplate("index/change_theme") . "\";");
|
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", "<br />", $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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -310,6 +310,19 @@ class Database {
|
|||||||
@fwrite($sqllog, date('d.m.Y H:i', time())." --- DEBUG: \n".$error->getTraceAsString()."\n");
|
@fwrite($sqllog, date('d.m.Y H:i', time())." --- DEBUG: \n".$error->getTraceAsString()."\n");
|
||||||
@fclose($sqllog);
|
@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 ($showerror) {
|
||||||
if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
if (!isset($_SERVER['SHELL']) || (isset($_SERVER['SHELL']) && $_SERVER['SHELL'] == '')) {
|
||||||
// if we're not on the shell, output a nicer error-message
|
// if we're not on the shell, output a nicer error-message
|
||||||
@@ -317,6 +330,7 @@ class Database {
|
|||||||
// replace values
|
// replace values
|
||||||
$err_hint = str_replace("<TEXT>", $error->getMessage(), $err_hint);
|
$err_hint = str_replace("<TEXT>", $error->getMessage(), $err_hint);
|
||||||
$err_hint = str_replace("<DEBUG>", $error->getTraceAsString(), $err_hint);
|
$err_hint = str_replace("<DEBUG>", $error->getTraceAsString(), $err_hint);
|
||||||
|
$err_hint = str_replace("<LINK>", $linker->getLink(array('section' => 'index', 'page' => 'send_error_report', 'errorid' => $errid)), $err_hint);
|
||||||
// show
|
// show
|
||||||
die($err_hint);
|
die($err_hint);
|
||||||
}
|
}
|
||||||
|
|||||||
44
templates/Sparkle/admin/index/send_error_report.tpl
vendored
Normal file
44
templates/Sparkle/admin/index/send_error_report.tpl
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
$header
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h2>
|
||||||
|
<img src="templates/{$theme}/assets/img/icons/display_big.png" alt="" />
|
||||||
|
Send error report
|
||||||
|
</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<form method="post" action="{$linker->getLink(array('section' => 'index'))}" enctype="application/x-www-form-urlencoded">
|
||||||
|
<fieldset>
|
||||||
|
<input type="hidden" name="s" value="$s" />
|
||||||
|
<input type="hidden" name="page" value="$page" />
|
||||||
|
<input type="hidden" name="send" value="send" />
|
||||||
|
<table class="bradius">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>Thank you for reporting this error and helping us to make froxlor better.</p>
|
||||||
|
<p>This is the e-mail that will be sent to the froxlor developer team:</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>{$mail_html}</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<input class="bottom" type="submit" value="Send report" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
$footer
|
||||||
44
templates/Sparkle/customer/index/send_error_report.tpl
vendored
Normal file
44
templates/Sparkle/customer/index/send_error_report.tpl
vendored
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
$header
|
||||||
|
<article>
|
||||||
|
<header>
|
||||||
|
<h2>
|
||||||
|
<img src="templates/{$theme}/assets/img/icons/display_big.png" alt="" />
|
||||||
|
Send error report
|
||||||
|
</h2>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<form method="post" action="{$linker->getLink(array('section' => 'index'))}" enctype="application/x-www-form-urlencoded">
|
||||||
|
<fieldset>
|
||||||
|
<input type="hidden" name="s" value="$s" />
|
||||||
|
<input type="hidden" name="page" value="$page" />
|
||||||
|
<input type="hidden" name="send" value="send" />
|
||||||
|
<table class="bradius">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p>Thank you for reporting this error and helping us to make froxlor better.</p>
|
||||||
|
<p>This is the e-mail that will be sent to the froxlor developer team:</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<code>{$mail_html}</code>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<input class="bottom" type="submit" value="Send report" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
$footer
|
||||||
10
templates/Sparkle/misc/dberrornice.tpl
vendored
10
templates/Sparkle/misc/dberrornice.tpl
vendored
@@ -34,8 +34,14 @@
|
|||||||
<p> </p>
|
<p> </p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<aside class="right">
|
<aside>
|
||||||
<a href="#" title="Click here to go back" id="historyback">Go back</a>
|
<div style="float:left;">
|
||||||
|
<a href="#" title="Click here to go back" id="historyback">Go back</a>
|
||||||
|
</div>
|
||||||
|
<div style="float:right;">
|
||||||
|
<a href="<LINK>" title="Click here to report error">Report error</a>
|
||||||
|
</div>
|
||||||
|
<div style="clear:both;"></div>
|
||||||
</aside>
|
</aside>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user