1 |
45d72d82
|
Scott Ullrich
|
<?php
|
2 |
|
|
/* $Id$ */
|
3 |
|
|
/*
|
4 |
|
|
crash_reporter.php
|
5 |
|
|
part of pfSense
|
6 |
|
|
Copyright (C) 2011 Scott Ullrich
|
7 |
|
|
All rights reserved.
|
8 |
|
|
|
9 |
|
|
Redistribution and use in source and binary forms, with or without
|
10 |
|
|
modification, are permitted provided that the following conditions are met:
|
11 |
|
|
|
12 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
13 |
|
|
this list of conditions and the following disclaimer.
|
14 |
|
|
|
15 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
16 |
|
|
notice, this list of conditions and the following disclaimer in the
|
17 |
|
|
documentation and/or other materials provided with the distribution.
|
18 |
|
|
|
19 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
20 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
22 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
23 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
24 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
25 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
26 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
27 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
28 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
29 |
|
|
*/
|
30 |
|
|
/*
|
31 |
|
|
pfSense_MODULE: header
|
32 |
|
|
*/
|
33 |
|
|
|
34 |
|
|
##|+PRIV
|
35 |
528d5abf
|
Scott Ullrich
|
##|*IDENT=page-diagnostics-crash-reporter
|
36 |
|
|
##|*NAME=Crash reporter
|
37 |
|
|
##|*DESCR=Uploads crash reports to pfSense and or deletes crash reports.
|
38 |
|
|
##|*MATCH=crash_reporter.php*
|
39 |
45d72d82
|
Scott Ullrich
|
##|-PRIV
|
40 |
|
|
|
41 |
|
|
require("guiconfig.inc");
|
42 |
|
|
require("functions.inc");
|
43 |
|
|
require("captiveportal.inc");
|
44 |
|
|
|
45 |
|
|
function upload_crash_report($files) {
|
46 |
|
|
$ch = curl_init();
|
47 |
|
|
curl_setopt($ch, CURLOPT_HEADER, 0);
|
48 |
|
|
curl_setopt($ch, CURLOPT_VERBOSE, 0);
|
49 |
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
50 |
|
|
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
|
51 |
|
|
curl_setopt($ch, CURLOPT_URL, "crashreporter.pfsense.org/submit.php");
|
52 |
|
|
curl_setopt($ch, CURLOPT_POST, true);
|
53 |
|
|
// same as <input type="file" name="file_box">
|
54 |
|
|
$post = array();
|
55 |
|
|
$counter = 0;
|
56 |
|
|
foreach($files as $file) {
|
57 |
|
|
$tmp = array();
|
58 |
|
|
$tmp["file{$counter}"] = "@{$file}";
|
59 |
|
|
$post[] = $tmp;
|
60 |
|
|
$counter++;
|
61 |
|
|
}
|
62 |
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
|
63 |
|
|
$response = curl_exec($ch);
|
64 |
528d5abf
|
Scott Ullrich
|
return $response;
|
65 |
45d72d82
|
Scott Ullrich
|
}
|
66 |
|
|
|
67 |
|
|
function output_crash_reporter_html($crash_reports) {
|
68 |
528d5abf
|
Scott Ullrich
|
echo "<strong>" . gettext("Unfortunately we have detected a kernel crash (panic).") . "</strong></p>";
|
69 |
|
|
echo "<strong>" . gettext("Would you like to submit the crash debug logs to the pfSense developers for inspection?") . "</strong></p>";
|
70 |
49c8f964
|
Scott Ullrich
|
echo "<p>";
|
71 |
|
|
echo gettext("Contents of crash reports") . ":<br/>";
|
72 |
886caa75
|
Scott Ullrich
|
echo "<textarea name='crashreports'>{$crash_reports}</textarea>";
|
73 |
528d5abf
|
Scott Ullrich
|
echo "<p/>";
|
74 |
|
|
echo "<input name=\"Submit\" type=\"submit\" class=\"formbtn\" value=\"" . gettext("Yes") . ">";
|
75 |
|
|
echo "<input name=\"Submit\" type=\"submit\" class=\"formbtn\" value=\"" . gettext("No") . ">";
|
76 |
|
|
echo "</p>";
|
77 |
|
|
echo "</form>";
|
78 |
45d72d82
|
Scott Ullrich
|
}
|
79 |
|
|
|
80 |
421f72a7
|
Scott Ullrich
|
$pgtitle = array(gettext("Diagnostics"),gettext("Crash reporter"));
|
81 |
45d72d82
|
Scott Ullrich
|
include('head.inc');
|
82 |
|
|
|
83 |
|
|
?>
|
84 |
|
|
|
85 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
86 |
|
|
|
87 |
|
|
<?php include("fbegin.inc"); ?>
|
88 |
|
|
|
89 |
421f72a7
|
Scott Ullrich
|
<form action="crash_reporter.php" method="post">
|
90 |
45d72d82
|
Scott Ullrich
|
<p>
|
91 |
|
|
|
92 |
|
|
<?php
|
93 |
49c8f964
|
Scott Ullrich
|
if (gettext($_POST['Submit']) == "Yes") {
|
94 |
45d72d82
|
Scott Ullrich
|
echo gettext("Processing...");
|
95 |
|
|
exec("/usr/bin/gzip /var/crash/*");
|
96 |
|
|
$files_to_upload = glob("/var/crash/*");
|
97 |
|
|
echo "<p/>";
|
98 |
|
|
echo gettext("Uploading...");
|
99 |
|
|
echo "<p/>";
|
100 |
|
|
if(is_array($files_to_upload)) {
|
101 |
|
|
upload_crash_report($files_to_upload);
|
102 |
|
|
exec("rm /var/crash/*");
|
103 |
|
|
echo gettext("Crash files have been submitted for inspection.");
|
104 |
|
|
echo "<p/><a href='/'>" . gettext("Continue") . "</a>";
|
105 |
|
|
} else {
|
106 |
|
|
echo "Could not find any crash files.";
|
107 |
|
|
}
|
108 |
49c8f964
|
Scott Ullrich
|
} else if(gettext($_POST['Submit']) == "No") {
|
109 |
45d72d82
|
Scott Ullrich
|
exec("rm /var/crash/*");
|
110 |
|
|
Header("Location: /");
|
111 |
|
|
exit;
|
112 |
|
|
} else {
|
113 |
|
|
$crash_files = glob("/var/crash/*");
|
114 |
|
|
if(is_array($crash_files))
|
115 |
|
|
foreach($crash_files as $cf)
|
116 |
|
|
$crash_reports .= file_get_contents($cf);
|
117 |
|
|
else
|
118 |
|
|
echo "Could not locate any crash data.";
|
119 |
|
|
output_crash_reporter_html($crash_reports);
|
120 |
|
|
}
|
121 |
|
|
?>
|
122 |
|
|
|
123 |
|
|
<?php include("fend.inc"); ?>
|
124 |
|
|
|
125 |
|
|
</body>
|
126 |
|
|
</html>
|