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 @@
...
@@ -31,8 +31,6 @@
require_once
(
"guiconfig.inc"
);
require_once
(
"guiconfig.inc"
);
require_once
(
"captiveportal.inc"
);
require_once
(
"captiveportal.inc"
);
define
(
"FILE_SIZE"
,
450000
);
function
upload_crash_report
(
$files
,
$agent
)
function
upload_crash_report
(
$files
,
$agent
)
{
{
global
$g
;
global
$g
;
...
@@ -81,26 +79,11 @@ $crash_report_header = sprintf(
...
@@ -81,26 +79,11 @@ $crash_report_header = sprintf(
$pkgver
=
explode
(
'-'
,
trim
(
file_get_contents
(
'/usr/local/opnsense/version/opnsense'
)));
$pkgver
=
explode
(
'-'
,
trim
(
file_get_contents
(
'/usr/local/opnsense/version/opnsense'
)));
$user_agent
=
$g
[
'product_name'
]
.
'/'
.
$pkgver
[
0
];
$user_agent
=
$g
[
'product_name'
]
.
'/'
.
$pkgver
[
0
];
$has_crashed
=
get_crash_report
(
true
)
!=
''
;
$crash_reports
=
array
();
?>
if
(
isset
(
$_POST
[
'Submit'
]))
{
if
(
$_POST
[
'Submit'
]
==
'yes'
)
{
<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
(
!
is_dir
(
'/var/crash'
))
{
if
(
!
is_dir
(
'/var/crash'
))
{
mkdir
(
'/var/crash'
,
0750
,
true
);
mkdir
(
'/var/crash'
,
0750
,
true
);
}
}
...
@@ -117,17 +100,18 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
...
@@ -117,17 +100,18 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
@
copy
(
'/var/run/dmesg.boot'
,
'/var/crash/dmesg.boot'
);
@
copy
(
'/var/run/dmesg.boot'
,
'/var/crash/dmesg.boot'
);
exec
(
'/usr/bin/gzip /var/crash/*'
);
exec
(
'/usr/bin/gzip /var/crash/*'
);
$files_to_upload
=
glob
(
'/var/crash/*'
);
$files_to_upload
=
glob
(
'/var/crash/*'
);
echo
gettext
(
'ok'
)
.
'<br/>'
.
gettext
(
'Uploading...'
);
flush
();
$resp
=
upload_crash_report
(
$files_to_upload
,
$user_agent
);
$resp
=
upload_crash_report
(
$files_to_upload
,
$user_agent
);
echo
(
$resp
?
gettext
(
'ok'
)
:
gettext
(
'failed'
))
.
'</p>'
;
array_map
(
'unlink'
,
$files_to_upload
);
array_map
(
'unlink'
,
$files_to_upload
);
}
elseif
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'no'
)
{
}
elseif
(
$_POST
[
'Submit'
]
==
'no'
)
{
array_map
(
'unlink'
,
glob
(
'/var/crash/*'
));
array_map
(
'unlink'
,
glob
(
'/var/crash/*'
));
@
unlink
(
'/tmp/PHP_errors.log'
);
@
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_files
=
glob
(
"/var/crash/*"
);
$crash_reports
[
'System Information'
]
=
trim
(
$crash_report_header
);
$crash_reports
[
'System Information'
]
=
trim
(
$crash_report_header
);
$php_errors
=
@
file_get_contents
(
'/tmp/PHP_errors.log'
);
$php_errors
=
@
file_get_contents
(
'/tmp/PHP_errors.log'
);
...
@@ -139,10 +123,29 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
...
@@ -139,10 +123,29 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
$crash_reports
[
'dmesg.boot'
]
=
trim
(
$dmesg_boot
);
$crash_reports
[
'dmesg.boot'
]
=
trim
(
$dmesg_boot
);
}
}
foreach
(
$crash_files
as
$cf
)
{
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
));
$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
"<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>"
.
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> "
;
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];
...
@@ -154,21 +157,22 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
foreach
(
$crash_reports
as
$report
=>
$content
)
{
foreach
(
$crash_reports
as
$report
=>
$content
)
{
echo
"<p>
{
$report
}
:<br/><pre>
{
$content
}
</pre></p>"
;
echo
"<p>
{
$report
}
:<br/><pre>
{
$content
}
</pre></p>"
;
}
}
}
else
{
}
else
{
if
(
isset
(
$_POST
[
'Submit'
])
&&
$_POST
[
'Submit'
]
==
'yes'
)
{
$message
=
gettext
(
'Luckily we have not detected a programming bug.'
);
echo
'<br/><p><strong>'
;
if
(
isset
(
$_POST
[
'Submit'
]))
{
echo
gettext
(
'Thank you for submitting this crash report.'
);
if
(
$_POST
[
'Submit'
]
==
'yes'
)
{
echo
'</strong></p><br/>'
;
$message
=
gettext
(
'Thank you for submitting this crash report.'
)
;
}
elseif
(
$_POST
[
'Submit'
]
==
'no'
)
{
}
elseif
(
$_POST
[
'Submit'
]
==
'no'
)
{
echo
'<br/><p><strong>'
;
$message
=
gettext
(
'Please consider submitting a crash report if the error persists.'
);
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/>'
;
}
}
}
}
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>
</div>
</form>
</form>
</div>
</div>
...
@@ -177,4 +181,4 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
...
@@ -177,4 +181,4 @@ $user_agent = $g['product_name'] . '/' . $pkgver[0];
</div>
</div>
</section>
</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