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
8d0e40e2
Commit
8d0e40e2
authored
Jun 20, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) move restore_config_section to diag_backup.php, only used there...
parent
65aa0382
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
40 deletions
+42
-40
pfsense-utils.inc
src/etc/inc/pfsense-utils.inc
+0
-40
diag_backup.php
src/www/diag_backup.php
+42
-0
No files found.
src/etc/inc/pfsense-utils.inc
View file @
8d0e40e2
...
...
@@ -26,46 +26,6 @@
POSSIBILITY OF SUCH DAMAGE.
*/
/*
* restore_config_section($section_name, new_contents): restore a configuration section,
* and write the configuration out
* to disk/cf.
*/
function
restore_config_section
(
$section_name
,
$new_contents
)
{
global
$config
;
$tmpxml
=
'/tmp/tmpxml'
;
$fout
=
fopen
(
$tmpxml
,
'w'
);
fwrite
(
$fout
,
$new_contents
);
fclose
(
$fout
);
$xml
=
parse_xml_config
(
$tmpxml
,
null
);
if
(
isset
(
$xml
[
'pfsense'
]))
{
$xml
=
$xml
[
'pfsense'
];
}
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
;
}
@
unlink
(
$tmpxml
);
if
(
$section_xml
===
-
1
)
{
return
false
;
}
$config
[
$section_name
]
=
&
$section_xml
;
write_config
(
sprintf
(
gettext
(
"Restored %s of config file (maybe from CARP partner)"
),
$section_name
));
disable_security_checks
();
return
true
;
}
/* This xml 2 array function is courtesy of the php.net comment section on xml_parse.
* it is roughly 4 times faster then our existing pfSense parser but due to the large
...
...
src/www/diag_backup.php
View file @
8d0e40e2
...
...
@@ -40,6 +40,48 @@ require_once("rrd.inc");
require_once
(
"system.inc"
);
require_once
(
"pfsense-utils.inc"
);
/**
* restore config section
* @param string $section_name config section name
* @param string $new_contents xml content
* @return bool status
*/
function
restore_config_section
(
$section_name
,
$new_contents
)
{
global
$config
;
$tmpxml
=
'/tmp/tmpxml'
;
$fout
=
fopen
(
$tmpxml
,
'w'
);
fwrite
(
$fout
,
$new_contents
);
fclose
(
$fout
);
$xml
=
parse_xml_config
(
$tmpxml
,
null
);
if
(
isset
(
$xml
[
'pfsense'
]))
{
$xml
=
$xml
[
'pfsense'
];
}
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
;
}
@
unlink
(
$tmpxml
);
if
(
$section_xml
===
-
1
)
{
return
false
;
}
$config
[
$section_name
]
=
&
$section_xml
;
write_config
(
sprintf
(
gettext
(
"Restored %s of config file"
),
$section_name
));
disable_security_checks
();
return
true
;
}
/*
* backup_config_section($section): returns as an xml file string of
* the configuration section
...
...
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