From dc43ff1eaa74ddbdc8fbdf4b088cbd487631e8c7 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 23 Nov 2011 10:18:29 -0500 Subject: Show the PHP errors reported on the index page in the crash report so users are not confused by an empty report screen. Include them in the report and also clear them after sending. --- usr/local/www/crash_reporter.php | 10 +++++++++- usr/local/www/index.php | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'usr/local') diff --git a/usr/local/www/crash_reporter.php b/usr/local/www/crash_reporter.php index 924532c..a8d1345 100755 --- a/usr/local/www/crash_reporter.php +++ b/usr/local/www/crash_reporter.php @@ -88,6 +88,8 @@ $crash_report_header .= php_uname("r") . "\n"; $crash_report_header .= php_uname("v") . "\n"; $crash_report_header .= "\nCrash report details:\n"; +exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors); + ?> @@ -100,9 +102,9 @@ $crash_report_header .= "\nCrash report details:\n"; if (gettext($_POST['Submit']) == "Yes") { echo gettext("Processing..."); file_put_contents("/var/crash/crashreport_header.txt", $crash_report_header); - exec("/usr/bin/gzip /var/crash/*"); if(file_exists("/tmp/PHP_errors.log")) exec("cp /tmp/PHP_errors.log /var/crash/"); + exec("/usr/bin/gzip /var/crash/*"); $files_to_upload = glob("/var/crash/*"); echo "

"; echo gettext("Uploading..."); @@ -111,6 +113,8 @@ $crash_report_header .= "\nCrash report details:\n"; if(is_array($files_to_upload)) { $resp = upload_crash_report($files_to_upload); exec("rm /var/crash/*"); + // Erase the contents of the PHP error log + fclose(fopen("/tmp/PHP_errors.log", 'w')); echo "

"; print_r($resp); echo "

" . gettext("Continue") . "" . gettext(" and delete crash report files from local disk."); @@ -124,6 +128,10 @@ $crash_report_header .= "\nCrash report details:\n"; } else { $crash_files = glob("/var/crash/*"); $crash_reports = $crash_report_header; + if (count($php_errors) > 0) { + $crash_reports .= "\nPHP Errors:\n"; + $crash_reports .= implode("\n", $php_errors) . "\n\n"; + } if(is_array($crash_files)) { foreach($crash_files as $cf) { if(filesize($cf) < FILE_SIZE) { diff --git a/usr/local/www/index.php b/usr/local/www/index.php index a2d8733..a59a652 100755 --- a/usr/local/www/index.php +++ b/usr/local/www/index.php @@ -60,7 +60,7 @@ if($g['disablecrashreporter'] != true) { // Check to see if we have a crash report $x = 0; if(file_exists("/tmp/PHP_errors.log")) { - $total = `/bin/cat /tmp/PHP_errors.log | /usr/bin/grep -vi warning | wc -l | awk '{ print $1 }'`; + $total = `/usr/bin/grep -vi warning /tmp/PHP_errors.log | /usr/bin/wc -l | /usr/bin/awk '{ print $1 }'`; if($total > 0) $x++; } -- cgit v1.1