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
821f5331
Commit
821f5331
authored
Mar 12, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add revision information on config save
parent
5114af53
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
6 deletions
+39
-6
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+39
-6
No files found.
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
821f5331
...
...
@@ -260,11 +260,37 @@ class Config extends Singleton
}
/**
* update config revision information (ROOT.revision tag)
* @param array|null $revision revision tag (associative array)
* @param \SimpleXMLElement|null pass trough xml node
*/
private
function
updateRevision
(
$revision
,
$node
=
null
)
{
// input must be an array
if
(
is_array
(
$revision
))
{
if
(
$node
==
null
)
{
if
(
isset
(
$this
->
simplexml
->
revision
))
{
$node
=
$this
->
simplexml
->
revision
;
}
else
{
$node
=
$this
->
simplexml
->
addChild
(
"revision"
);
}
}
foreach
(
$revision
as
$revKey
=>
$revItem
)
{
$childNode
=
$node
->
addChild
(
$revKey
);
if
(
is_array
(
$revItem
))
{
$this
->
updateRevision
(
$revItem
,
$childNode
);
}
else
{
$childNode
[
0
]
=
$revItem
;
}
}
}
}
/**
* backup current (running) config
* @param string|null $message log message
*/
private
function
backup
(
$message
)
private
function
backup
()
{
$target_dir
=
dirname
(
$this
->
config_file
)
.
"/backup/"
;
$target_filename
=
"config-"
.
time
()
.
".xml"
;
...
...
@@ -330,17 +356,24 @@ class Config extends Singleton
/**
* save config to filesystem
* @param
string|null $message log message
* @param
array|null $revision revision tag (associative array)
* @param bool $nobackup do not backup current config
* @throws ConfigException
*/
public
function
save
(
$
message
=
null
,
$nobackup
=
false
)
public
function
save
(
$
revision
=
null
,
$nobackup
=
false
)
{
$xml_text
=
$this
->
__toString
();
$this
->
checkvalid
();
if
(
$nobackup
==
false
)
{
$this
->
backup
(
$message
);
$this
->
backup
();
}
// update revision information ROOT.revision tag
$this
->
updateRevision
(
$revision
);
// serialize to text
$xml_text
=
$this
->
__toString
();
// save configuration, try to obtain a lock before doing so.
$target_filename
=
$this
->
config_file
;
if
(
file_exists
(
$target_filename
))
{
...
...
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