diff --git a/src/www/crash_reporter.php b/src/www/crash_reporter.php index 30a242778..f23ecc3ee 100644 --- a/src/www/crash_reporter.php +++ b/src/www/crash_reporter.php @@ -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 '

' . gettext('Luckily we have not detected a programming bug.') . '

'; } else { $crash_files = glob("/var/crash/*"); $crash_reports = $crash_report_header; diff --git a/src/www/guiconfig.inc b/src/www/guiconfig.inc index ab209aed4..350960032 100644 --- a/src/www/guiconfig.inc +++ b/src/www/guiconfig.inc @@ -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 here 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; +} diff --git a/src/www/index.php b/src/www/index.php index b03c4e47a..f5180a088 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -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 here 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;
- - - -