Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
debde29c
Commit
debde29c
authored
Aug 24, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crash reporter: refactor while at it; #241
parent
e7a233b5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
68 deletions
+72
-68
crash_reporter.php
src/www/crash_reporter.php
+72
-68
No files found.
src/www/crash_reporter.php
View file @
debde29c
...
...
@@ -31,8 +31,6 @@
require_once
(
"guiconfig.inc"
);
require_once
(
"captiveportal.inc"
);
define
(
"FILE_SIZE"
,
450000
);
function
upload_crash_report
(
$files
,
$agent
)
{
global
$g
;
...
...
@@ -81,26 +79,11 @@ $crash_report_header = sprintf(
$pkgver
=
explode
(
'-'
,
trim
(
file_get_contents
(
'/usr/local/opnsense/version/opnsense'
)));
$user_agent
=
$g
[
'product_name'
]
.
'/'
.
$pkgver
[
0
];
$has_crashed
=
get_crash_report
(
true
)
!=
''
;
$crash_reports
=
array
();
?>
<body>
<?php
include
(
"fbegin.inc"
);
?>
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
<section
class=
"col-xs-12"
>
<div
class=
"content-box"
>
<form
action=
"crash_reporter.php"
method=
"post"
>
<div
class=
"col-xs-12"
>
<?php
if
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'yes'
)
{
echo
'<br/><p>'
.
gettext
(
'Processing...'
);
flush
();
if
(
isset
(
$_POST
[
'Submit'
]))
{
if
(
$_POST
[
'Submit'
]
==
'yes'
)
{
if
(
!
is_dir
(
'/var/crash'
))
{
mkdir
(
'/var/crash'
,
0750
,
true
);
}
...
...
@@ -117,17 +100,18 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
@
copy
(
'/var/run/dmesg.boot'
,
'/var/crash/dmesg.boot'
);
exec
(
'/usr/bin/gzip /var/crash/*'
);
$files_to_upload
=
glob
(
'/var/crash/*'
);
echo
gettext
(
'ok'
)
.
'<br/>'
.
gettext
(
'Uploading...'
);
flush
();
$resp
=
upload_crash_report
(
$files_to_upload
,
$user_agent
);
echo
(
$resp
?
gettext
(
'ok'
)
:
gettext
(
'failed'
))
.
'</p>'
;
array_map
(
'unlink'
,
$files_to_upload
);
}
elseif
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'no'
)
{
}
elseif
(
$_POST
[
'Submit'
]
==
'no'
)
{
array_map
(
'unlink'
,
glob
(
'/var/crash/*'
));
@
unlink
(
'/tmp/PHP_errors.log'
);
}
elseif
(
$_POST
[
'Submit'
]
==
'new'
)
{
/* force a crash report generation */
$has_crashed
=
true
;
}
}
if
(
get_crash_report
(
true
)
!=
''
||
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'new'
)
)
{
if
(
$has_crashed
)
{
$crash_files
=
glob
(
"/var/crash/*"
);
$crash_reports
[
'System Information'
]
=
trim
(
$crash_report_header
);
$php_errors
=
@
file_get_contents
(
'/tmp/PHP_errors.log'
);
...
...
@@ -139,10 +123,29 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
$crash_reports
[
'dmesg.boot'
]
=
trim
(
$dmesg_boot
);
}
foreach
(
$crash_files
as
$cf
)
{
if
(
!
is_link
(
$cf
)
&&
$cf
!=
'/var/crash/minfree'
&&
$cf
!=
'/var/crash/bounds'
&&
filesize
(
$cf
)
<
FILE_SIZE
)
{
if
(
!
is_link
(
$cf
)
&&
$cf
!=
'/var/crash/minfree'
&&
$cf
!=
'/var/crash/bounds'
&&
filesize
(
$cf
)
<
450000
)
{
$crash_reports
[
$cf
]
=
trim
(
file_get_contents
(
$cf
));
}
}
}
?>
<body>
<?php
include
(
"fbegin.inc"
);
?>
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
<section
class=
"col-xs-12"
>
<div
class=
"content-box"
>
<form
action=
"/crash_reporter.php"
method=
"post"
>
<div
class=
"col-xs-12"
>
<?php
if
(
$has_crashed
)
{
echo
"<br/><p><strong>"
.
gettext
(
"Unfortunately we have detected at least one programming bug."
)
.
"</strong></p>"
;
echo
"<p>"
.
gettext
(
"Would you like to submit this crash report to the developers?"
)
.
"</p>"
;
echo
"<p><button name=
\"
Submit
\"
type=
\"
submit
\"
class=
\"
btn btn-primary
\"
value=
\"
yes
\"
>"
.
gettext
(
'Yes'
)
.
"</button> "
;
...
...
@@ -154,21 +157,22 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
foreach
(
$crash_reports
as
$report
=>
$content
)
{
echo
"<p>
{
$report
}
:<br/><pre>
{
$content
}
</pre></p>"
;
}
}
else
{
if
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'yes'
)
{
echo
'<br/><p><strong>'
;
echo
gettext
(
'Thank you for submitting this crash report.'
);
echo
'</strong></p><br/>'
;
}
else
{
$message
=
gettext
(
'Luckily we have not detected a programming bug.'
);
if
(
isset
(
$_POST
[
'Submit'
]))
{
if
(
$_POST
[
'Submit'
]
==
'yes'
)
{
$message
=
gettext
(
'Thank you for submitting this crash report.'
)
;
}
elseif
(
$_POST
[
'Submit'
]
==
'no'
)
{
echo
'<br/><p><strong>'
;
echo
gettext
(
'Please consider submitting a crash report if the error persists.'
);
echo
'</strong></p><br/>'
;
}
else
{
echo
'<br/><button name="Submit" type="submit" class="btn btn-primary pull-right" value="new">'
.
gettext
(
'Report an issue'
)
.
'</button>'
;
echo
'<p><strong>'
.
gettext
(
'Luckily we have not detected a programming bug.'
)
.
'</strong></p><br/>'
;
$message
=
gettext
(
'Please consider submitting a crash report if the error persists.'
);
}
}
echo
'<br/><button name="Submit" type="submit" class="btn btn-primary pull-right" value="new">'
.
gettext
(
'Report an issue'
)
.
'</button>'
;
echo
'<p><strong>'
.
$message
.
'</strong></p><br/>'
;
}
?>
</div>
</form>
</div>
...
...
@@ -177,4 +181,4 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
</div>
</section>
<?php
include
(
"foot.inc"
);
?>
<?php
include
(
"foot.inc"
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment