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
bab9a4c1
Commit
bab9a4c1
authored
Mar 13, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove unused functions and switch to SimpleXML as default parser.
parent
6004b1de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
31 deletions
+15
-31
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+15
-31
No files found.
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
bab9a4c1
...
...
@@ -43,12 +43,6 @@ class Config extends Singleton
*/
private
$config_file
=
""
;
/**
* XMLDocument type reference to config
* @var \DOMDocument
*/
private
$configxml
=
null
;
/**
* SimpleXML type reference to config
* @var SimpleXML
...
...
@@ -140,9 +134,7 @@ class Config extends Singleton
// root node
if
(
$node
==
null
)
{
$this
->
configxml
=
new
\DOMDocument
(
'1.0'
);
$this
->
configxml
->
loadXML
(
'<'
.
$this
->
simplexml
[
0
]
->
getName
()
.
'/>'
);
$this
->
simplexml
=
simplexml_import_dom
(
$this
->
configxml
);
$this
->
simplexml
=
simplexml_load_string
(
'<'
.
$this
->
simplexml
[
0
]
->
getName
()
.
'/>'
);
$node
=
$this
->
simplexml
;
}
...
...
@@ -179,7 +171,7 @@ class Config extends Singleton
/**
* Execute a xpath expression on config.xml
* Execute a xpath expression on config.xml
(full DOM implementation)
* @param $query
* @return \DOMNodeList
* @throws ConfigException
...
...
@@ -187,7 +179,12 @@ class Config extends Singleton
public
function
xpath
(
$query
)
{
$this
->
checkvalid
();
$xpath
=
new
\DOMXPath
(
$this
->
configxml
);
$configxml
=
dom_import_simplexml
(
$this
->
simplexml
);
$dom
=
new
\DOMDocument
(
'1.0'
);
$dom_sxe
=
$dom
->
importNode
(
$configxml
,
true
);
$dom
->
appendChild
(
$dom_sxe
);
$xpath
=
new
\DOMXPath
(
$dom
);
return
$xpath
->
query
(
$query
);
}
...
...
@@ -203,18 +200,6 @@ class Config extends Singleton
return
$this
->
simplexml
;
}
/**
* get DOMDocument
* @return XMLDocument
* @throws ConfigException
*/
public
function
getDOM
()
{
$this
->
checkvalid
();
return
$this
->
configxml
;
}
/**
* init new config object, try to load current configuration
...
...
@@ -226,7 +211,7 @@ class Config extends Singleton
try
{
$this
->
load
();
}
catch
(
\Exception
$e
)
{
$this
->
config
xml
=
null
;
$this
->
simple
xml
=
null
;
}
}
...
...
@@ -253,9 +238,7 @@ class Config extends Singleton
}
);
$this
->
configxml
=
new
\DOMDocument
(
'1.0'
);
$this
->
configxml
->
loadXML
(
$xml
);
$this
->
simplexml
=
simplexml_import_dom
(
$this
->
configxml
);
$this
->
simplexml
=
simplexml_load_string
(
$xml
);
restore_error_handler
();
$this
->
statusIsValid
=
true
;
...
...
@@ -268,10 +251,13 @@ class Config extends Singleton
public
function
__toString
()
{
// reformat XML (pretty print)
$dom
=
new
\DOMDocument
;
$configxml
=
dom_import_simplexml
(
$this
->
simplexml
);
$dom
=
new
\DOMDocument
(
'1.0'
);
$dom_sxe
=
$dom
->
importNode
(
$configxml
,
true
);
$dom
->
appendChild
(
$dom_sxe
);
$dom
->
formatOutput
=
true
;
$dom
->
preserveWhiteSpace
=
false
;
$dom
->
loadXML
(
$
this
->
configxml
->
saveXML
());
$dom
->
loadXML
(
$
dom
->
saveXML
());
return
$dom
->
saveXML
();
...
...
@@ -369,7 +355,6 @@ class Config extends Singleton
if
(
$this
->
statusIsValid
)
{
// if current config is valid,
$configxml
=
$this
->
configxml
;
$simplexml
=
$this
->
simplexml
;
try
{
// try to restore config
...
...
@@ -378,7 +363,6 @@ class Config extends Singleton
return
true
;
}
catch
(
ConfigException
$e
)
{
// copy / load failed, restore previous version
$this
->
configxml
=
$configxml
;
$this
->
simplexml
=
$simplexml
;
$this
->
statusIsValid
=
true
;
$this
->
save
(
null
,
true
);
...
...
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