From 45b4ffc68fed9e831da10de3b7d2de0c47496d1a Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Sun, 19 Apr 2015 12:23:44 +0545 Subject: Code style usr-local-www back-end files that do stuff in mostly in the background. --- usr/local/www/crash_reporter.php | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'usr/local/www/crash_reporter.php') diff --git a/usr/local/www/crash_reporter.php b/usr/local/www/crash_reporter.php index 699185c..39d5777 100644 --- a/usr/local/www/crash_reporter.php +++ b/usr/local/www/crash_reporter.php @@ -49,19 +49,19 @@ function upload_crash_report($files) { global $g; $post = array(); $counter = 0; - foreach($files as $file) { + foreach ($files as $file) { $post["file{$counter}"] = "@{$file}"; $counter++; } - $ch = curl_init(); - curl_setopt($ch, CURLOPT_HEADER, 0); - curl_setopt($ch, CURLOPT_VERBOSE, 0); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); - curl_setopt($ch, CURLOPT_URL, $g['crashreporterurl']); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post); - $response = curl_exec($ch); + $ch = curl_init(); + curl_setopt($ch, CURLOPT_HEADER, 0); + curl_setopt($ch, CURLOPT_VERBOSE, 0); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); + curl_setopt($ch, CURLOPT_URL, $g['crashreporterurl']); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, $post); + $response = curl_exec($ch); return $response; } @@ -98,18 +98,20 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors); "; echo gettext("Uploading..."); ob_flush(); flush(); - if(is_array($files_to_upload)) { + if (is_array($files_to_upload)) { $resp = upload_crash_report($files_to_upload); array_map('unlink', glob("/var/crash/*")); // Erase the contents of the PHP error log @@ -120,7 +122,7 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors); } else { echo "Could not find any crash files."; } - } else if(gettext($_POST['Submit']) == "No") { + } else if (gettext($_POST['Submit']) == "No") { array_map('unlink', glob("/var/crash/*")); // Erase the contents of the PHP error log fclose(fopen("/tmp/PHP_errors.log", 'w')); @@ -133,14 +135,14 @@ exec("/usr/bin/grep -vi warning /tmp/PHP_errors.log", $php_errors); $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) { + if (is_array($crash_files)) { + foreach ($crash_files as $cf) { + if (filesize($cf) < FILE_SIZE) { $crash_reports .= "\nFilename: {$cf}\n"; $crash_reports .= file_get_contents($cf); } } - } else { + } else { echo "Could not locate any crash data."; } output_crash_reporter_html($crash_reports); -- cgit v1.1