mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
crash reporter: improve the output and behaviour
* Refactor crash report link into a function so it could be called from any page if desired. * Do not show a crash report when there is none.
This commit is contained in:
parent
023fa9c1f1
commit
9ecce53e8c
@ -126,6 +126,8 @@ $php_errors = @file_get_contents('/tmp/PHP_errors.log');
|
||||
fclose(fopen("/tmp/PHP_errors.log", 'w'));
|
||||
header("Location: /");
|
||||
exit;
|
||||
} elseif (get_crash_report(true) == '') {
|
||||
echo '<p><strong>' . gettext('Luckily we have not detected a programming bug.') . '</strong></p>';
|
||||
} else {
|
||||
$crash_files = glob("/var/crash/*");
|
||||
$crash_reports = $crash_report_header;
|
||||
|
||||
@ -1102,3 +1102,33 @@ if (!$timezone) {
|
||||
}
|
||||
|
||||
date_default_timezone_set($timezone);
|
||||
|
||||
function get_crash_report($pedantic = false)
|
||||
{
|
||||
global $g;
|
||||
|
||||
$savemsg = "{$g['product_name']} has detected a crash report or programming bug. Click <a href='crash_reporter.php'>here</a> for more information.";
|
||||
$skip_files = array('.', '..', 'minfree', '');
|
||||
$count = 0;
|
||||
|
||||
if (file_exists('/tmp/PHP_errors.log')) {
|
||||
/* only notify about crash report when there's an error */
|
||||
$total = `/usr/bin/grep -v 'PHP Warning:' /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
|
||||
if ($total > 0 || $pedantic) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
$crashes = glob('/var/crash/*');
|
||||
foreach ($crashes as $crash) {
|
||||
if (!in_array(basename($crash), $skip_files)) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$count) {
|
||||
$savemsg = '';
|
||||
}
|
||||
|
||||
return $savemsg;
|
||||
}
|
||||
|
||||
@ -50,34 +50,6 @@ if ($_REQUEST['act'] == 'alias_info_popup' && !preg_match("/\D/",$_REQUEST['alia
|
||||
exit;
|
||||
}
|
||||
|
||||
/* CRASH REPORT BEGIN */
|
||||
|
||||
$x = 0;
|
||||
|
||||
if (file_exists('/tmp/PHP_errors.log')) {
|
||||
/* don't notify about crash report when there's only errors */
|
||||
$total = `/usr/bin/grep -v 'PHP Warning:' /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`;
|
||||
if($total > 0) {
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
|
||||
$crash = glob('/var/crash/*');
|
||||
if (is_array($crash)) {
|
||||
$skip_files = array('.', '..', 'minfree', '');
|
||||
foreach($crash as $c) {
|
||||
if (!in_array(basename($c), $skip_files)) {
|
||||
$x++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($x > 0) {
|
||||
$savemsg = "{$g['product_name']} has detected a crash report or programming bug. Click <a href='crash_reporter.php'>here</a> for more information.";
|
||||
}
|
||||
|
||||
/* CRASH REPORT END */
|
||||
|
||||
##build list of widgets
|
||||
$directory = "/usr/local/www/widgets/widgets/";
|
||||
$dirhandle = opendir($directory);
|
||||
@ -443,15 +415,11 @@ echo $jscriptstr;
|
||||
<div class="row">
|
||||
|
||||
<?php
|
||||
if ($savemsg)
|
||||
print_info_box($savemsg);
|
||||
$crash_report = get_crash_report();
|
||||
if ($crash_report != '') {
|
||||
print_info_box($crash_report);
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$totalwidgets = count($widgetfiles);
|
||||
$halftotal = $totalwidgets / 2 - 2;
|
||||
$widgetcounter = 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user