summaryrefslogtreecommitdiffstats
path: root/usr/local/www/crash_reporter.php
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
committerPhil Davis <phil.davis@inf.org>2015-04-19 12:23:44 +0545
commit45b4ffc68fed9e831da10de3b7d2de0c47496d1a (patch)
treeb197e9e651ea5df4f28d33bda408ae8002c38034 /usr/local/www/crash_reporter.php
parentabaa7feb680dc6f6f9bc79577075c45b3786a061 (diff)
downloadpfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.zip
pfsense-45b4ffc68fed9e831da10de3b7d2de0c47496d1a.tar.gz
Code style usr-local-www back-end
files that do stuff in mostly in the background.
Diffstat (limited to 'usr/local/www/crash_reporter.php')
-rw-r--r--usr/local/www/crash_reporter.php38
1 files changed, 20 insertions, 18 deletions
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);
<?php
if (gettext($_POST['Submit']) == "Yes") {
echo gettext("Processing...");
- if (!is_dir("/var/crash"))
+ if (!is_dir("/var/crash")) {
mkdir("/var/crash", 0750, true);
+ }
@file_put_contents("/var/crash/crashreport_header.txt", $crash_report_header);
- if(file_exists("/tmp/PHP_errors.log"))
+ if (file_exists("/tmp/PHP_errors.log")) {
copy("/tmp/PHP_errors.log", "/var/crash/PHP_errors.log");
+ }
exec("/usr/bin/gzip /var/crash/*");
$files_to_upload = glob("/var/crash/*");
echo "<br/>";
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);
OpenPOWER on IntegriCloud