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
c8e68c6b
Commit
c8e68c6b
authored
Jul 04, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: slightly improve backup flexibility; sort of refs #471
parent
811cf082
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
diag_backup.php
src/www/diag_backup.php
+27
-14
No files found.
src/www/diag_backup.php
View file @
c8e68c6b
...
@@ -51,17 +51,26 @@ function restore_config_section($section_name, $new_contents)
...
@@ -51,17 +51,26 @@ function restore_config_section($section_name, $new_contents)
fclose
(
$fout
);
fclose
(
$fout
);
$xml
=
parse_xml_config
(
$tmpxml
,
null
);
$xml
=
parse_xml_config
(
$tmpxml
,
null
);
if
(
isset
(
$xml
[
'pfsense'
]))
{
if
(
$xml
===
-
1
)
{
$xml
=
$xml
[
'pfsense'
];
return
false
;
}
elseif
(
isset
(
$xml
[
'm0n0wall'
]))
{
}
$xml
=
$xml
[
'm0n0wall'
];
}
elseif
(
isset
(
$xml
[
'opnsense'
]))
{
$xml
=
$xml
[
'opnsense'
];
}
if
(
isset
(
$xml
[
$section_name
]))
{
$section_xml
=
$xml
[
$section_name
];
}
else
{
$section_xml
=
-
1
;
$section_xml
=
-
1
;
/*
* So, we're looking for a non-root tag written as a
* root tag, or a proper config where we cherry-pick
* a specific matching section... ok...
*/
foreach
(
$xml
as
$xml_strip_root
)
{
if
(
isset
(
$xml_strip_root
[
$section
]))
{
$section_xml
=
$xml_strip_root
[
$section
];
break
;
}
}
if
(
$section_xml
=
-
1
&&
isset
(
$xml
[
$section_name
]))
{
$section_xml
=
$xml
[
$section_name
];
}
}
@
unlink
(
$tmpxml
);
@
unlink
(
$tmpxml
);
...
@@ -81,18 +90,22 @@ function restore_config_section($section_name, $new_contents)
...
@@ -81,18 +90,22 @@ function restore_config_section($section_name, $new_contents)
* backup_config_section($section): returns as an xml file string of
* backup_config_section($section): returns as an xml file string of
* the configuration section
* the configuration section
*/
*/
function
backup_config_section
(
$section_name
)
{
function
backup_config_section
(
$section_name
)
{
global
$config
;
global
$config
;
$new_section
=
&
$config
[
$section_name
];
$new_section
=
&
$config
[
$section_name
];
/* generate configuration XML */
$xmlconfig
=
dump_xml_config
(
$new_section
,
$section_name
);
$xmlconfig
=
dump_xml_config
(
$new_section
,
$section_name
);
$xmlconfig
=
str_replace
(
"<?xml version=
\"
1.0
\"
?>"
,
""
,
$xmlconfig
);
$xmlconfig
=
str_replace
(
"<?xml version=
\"
1.0
\"
?>"
,
""
,
$xmlconfig
);
/* KEEP THIS: unbreaks syntax highlighting <?php */
return
$xmlconfig
;
return
$xmlconfig
;
}
}
/* KEEP THIS: unbreaks syntax highlighting <?php */
function
rrd_data_xml
()
{
function
rrd_data_xml
()
{
$rrddbpath
=
'/var/db/rrd'
;
$rrddbpath
=
'/var/db/rrd'
;
$result
=
"
\t
<rrddata>
\n
"
;
$result
=
"
\t
<rrddata>
\n
"
;
...
...
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