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
fb3d5e0b
Commit
fb3d5e0b
authored
Aug 16, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mvc: apply new style rule
parent
50e9ebb6
Changes
30
Show whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
97 additions
and
97 deletions
+97
-97
ControllerBase.php
...ense/mvc/app/controllers/OPNsense/Base/ControllerBase.php
+4
-4
SettingsController.php
...rollers/OPNsense/CaptivePortal/Api/SettingsController.php
+1
-1
InterfaceController.php
...trollers/OPNsense/Diagnostics/Api/InterfaceController.php
+2
-2
NetworkinsightController.php
...ers/OPNsense/Diagnostics/Api/NetworkinsightController.php
+2
-2
SystemhealthController.php
...llers/OPNsense/Diagnostics/Api/SystemhealthController.php
+2
-2
SettingsController.php
...c/app/controllers/OPNsense/IDS/Api/SettingsController.php
+2
-2
SettingsController.php
...rollers/OPNsense/TrafficShaper/Api/SettingsController.php
+3
-3
LDAP.php
src/opnsense/mvc/app/library/OPNsense/Auth/LDAP.php
+4
-4
LocalTOTP.php
src/opnsense/mvc/app/library/OPNsense/Auth/LocalTOTP.php
+1
-1
Radius.php
src/opnsense/mvc/app/library/OPNsense/Auth/Radius.php
+2
-2
Voucher.php
src/opnsense/mvc/app/library/OPNsense/Auth/Voucher.php
+5
-5
Backend.php
src/opnsense/mvc/app/library/OPNsense/Core/Backend.php
+2
-2
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+9
-9
BaseModel.php
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
+11
-11
ArrayField.php
...se/mvc/app/models/OPNsense/Base/FieldTypes/ArrayField.php
+3
-3
AutoNumberField.php
...c/app/models/OPNsense/Base/FieldTypes/AutoNumberField.php
+3
-3
BaseField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
+7
-7
CSVListField.php
.../mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php
+2
-2
CertificateField.php
.../app/models/OPNsense/Base/FieldTypes/CertificateField.php
+1
-1
IntegerField.php
.../mvc/app/models/OPNsense/Base/FieldTypes/IntegerField.php
+3
-3
OptionField.php
...e/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php
+2
-2
PortField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php
+1
-1
TextField.php
...nse/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php
+1
-1
MenuItem.php
src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuItem.php
+7
-7
MenuSystem.php
...opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php
+4
-4
ACL.php
src/opnsense/mvc/app/models/OPNsense/Core/ACL.php
+6
-6
Cron.php
src/opnsense/mvc/app/models/OPNsense/Cron/Cron.php
+1
-1
IDS.php
src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php
+2
-2
run_migrations.php
src/opnsense/mvc/script/run_migrations.php
+2
-2
BaseModelTest.php
...ense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php
+2
-2
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Base/ControllerBase.php
View file @
fb3d5e0b
...
...
@@ -92,7 +92,7 @@ class ControllerBase extends ControllerRoot
}
else
{
$tab
[]
=
$this
->
parseFormNode
(
$node
);
}
$result
[
'tabs'
][]
=
$tab
;
$result
[
'tabs'
][]
=
$tab
;
break
;
case
"subtab"
:
$subtab
=
array
();
...
...
@@ -135,13 +135,13 @@ class ControllerBase extends ControllerRoot
public
function
getForm
(
$formname
)
{
$class_info
=
new
\ReflectionClass
(
$this
);
$filename
=
dirname
(
$class_info
->
getFileName
())
.
"/forms/"
.
$formname
.
".xml"
;
$filename
=
dirname
(
$class_info
->
getFileName
())
.
"/forms/"
.
$formname
.
".xml"
;
if
(
!
file_exists
(
$filename
))
{
throw
new
\Exception
(
'form xml '
.
$filename
.
' missing'
)
;
throw
new
\Exception
(
'form xml '
.
$filename
.
' missing'
);
}
$formXml
=
simplexml_load_file
(
$filename
);
if
(
$formXml
===
false
)
{
throw
new
\Exception
(
'form xml '
.
$filename
.
' not valid'
)
;
throw
new
\Exception
(
'form xml '
.
$filename
.
' not valid'
);
}
return
$this
->
parseFormNode
(
$formXml
);
...
...
src/opnsense/mvc/app/controllers/OPNsense/CaptivePortal/Api/SettingsController.php
View file @
fb3d5e0b
...
...
@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase
}
}
else
{
// generate new node, but don't save to disc
$node
=
$mdlCP
->
zones
->
zone
->
add
()
;
$node
=
$mdlCP
->
zones
->
zone
->
add
();
return
array
(
"zone"
=>
$node
->
getNodes
());
}
return
array
();
...
...
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/InterfaceController.php
View file @
fb3d5e0b
...
...
@@ -44,10 +44,10 @@ class InterfaceController extends ApiControllerBase
{
// collect interface names
$intfmap
=
array
();
$config
=
Config
::
getInstance
()
->
object
()
;
$config
=
Config
::
getInstance
()
->
object
();
if
(
$config
->
interfaces
!=
null
)
{
foreach
(
$config
->
interfaces
->
children
()
as
$key
=>
$node
)
{
$intfmap
[(
string
)
$node
->
if
]
=
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
;
$intfmap
[(
string
)
$node
->
if
]
=
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
;
}
}
return
$intfmap
;
...
...
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/NetworkinsightController.php
View file @
fb3d5e0b
...
...
@@ -155,7 +155,7 @@ class NetworkinsightController extends ApiControllerBase
$data_filter
.=
','
;
}
if
(
isset
(
$filter_values
[
$field_indx
]))
{
$data_filter
.=
$filter_field
.
'='
.
$filter_values
[
$field_indx
]
;
$data_filter
.=
$filter_field
.
'='
.
$filter_values
[
$field_indx
];
}
}
$data_filter
=
"'
{
$data_filter
}
'"
;
...
...
@@ -266,7 +266,7 @@ class NetworkinsightController extends ApiControllerBase
);
if
(
$this
->
request
->
isGet
())
{
$backend
=
new
Backend
();
$configd_cmd
=
"netflow aggregate export
{
$provider
}
{
$from_date
}
{
$to_date
}
{
$resolution
}
"
;
$configd_cmd
=
"netflow aggregate export
{
$provider
}
{
$from_date
}
{
$to_date
}
{
$resolution
}
"
;
$response
=
$backend
->
configdRun
(
$configd_cmd
);
return
$response
;
}
else
{
...
...
src/opnsense/mvc/app/controllers/OPNsense/Diagnostics/Api/SystemhealthController.php
View file @
fb3d5e0b
...
...
@@ -595,10 +595,10 @@ class SystemhealthController extends ApiControllerBase
{
// collect interface names
$intfmap
=
array
();
$config
=
Config
::
getInstance
()
->
object
()
;
$config
=
Config
::
getInstance
()
->
object
();
if
(
$config
->
interfaces
!=
null
)
{
foreach
(
$config
->
interfaces
->
children
()
as
$key
=>
$node
)
{
$intfmap
[(
string
)
$key
]
=
array
(
"descr"
=>
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
)
;
$intfmap
[(
string
)
$key
]
=
array
(
"descr"
=>
!
empty
((
string
)
$node
->
descr
)
?
(
string
)
$node
->
descr
:
$key
);
}
}
return
$intfmap
;
...
...
src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php
View file @
fb3d5e0b
...
...
@@ -243,7 +243,7 @@ class SettingsController extends ApiMutableModelControllerBase
$item
[
'documentation_url'
]
=
$fileinfo
[
'documentation_url'
];
if
(
!
empty
(
$fileinfo
[
'documentation_url'
]))
{
$item
[
'documentation'
]
=
"<a href='"
.
$item
[
'documentation_url'
]
.
"' target='_new'>"
;
$item
[
'documentation'
]
.=
$item
[
'documentation_url'
]
;
$item
[
'documentation'
]
.=
$item
[
'documentation_url'
];
$item
[
'documentation'
]
.=
'</a>'
;
}
else
{
$item
[
'documentation'
]
=
null
;
...
...
@@ -549,7 +549,7 @@ class SettingsController extends ApiMutableModelControllerBase
}
}
else
{
// generate new node, but don't save to disc
$node
=
$mdlIDS
->
userDefinedRules
->
rule
->
add
()
;
$node
=
$mdlIDS
->
userDefinedRules
->
rule
->
add
();
return
array
(
"rule"
=>
$node
->
getNodes
());
}
return
array
();
...
...
src/opnsense/mvc/app/controllers/OPNsense/TrafficShaper/Api/SettingsController.php
View file @
fb3d5e0b
...
...
@@ -91,7 +91,7 @@ class SettingsController extends ApiControllerBase
}
}
else
{
// generate new node, but don't save to disc
$node
=
$mdlShaper
->
pipes
->
pipe
->
add
()
;
$node
=
$mdlShaper
->
pipes
->
pipe
->
add
();
return
array
(
"pipe"
=>
$node
->
getNodes
());
}
return
array
();
...
...
@@ -238,7 +238,7 @@ class SettingsController extends ApiControllerBase
}
}
else
{
// generate new node, but don't save to disc
$node
=
$mdlShaper
->
queues
->
queue
->
add
()
;
$node
=
$mdlShaper
->
queues
->
queue
->
add
();
return
array
(
"queue"
=>
$node
->
getNodes
());
}
return
array
();
...
...
@@ -369,7 +369,7 @@ class SettingsController extends ApiControllerBase
}
}
else
{
// generate new node, but don't save to disc
$node
=
$mdlShaper
->
rules
->
rule
->
add
()
;
$node
=
$mdlShaper
->
rules
->
rule
->
add
();
$node
->
sequence
=
$mdlShaper
->
getMaxRuleSequence
()
+
10
;
return
array
(
"rule"
=>
$node
->
getNodes
());
}
...
...
src/opnsense/mvc/app/library/OPNsense/Auth/LDAP.php
View file @
fb3d5e0b
...
...
@@ -38,7 +38,7 @@ class LDAP implements IAuthConnector
/**
* @var int ldap version to use
*/
private
$ldapVersion
=
3
;
private
$ldapVersion
=
3
;
/**
* @var null base ldap search DN
...
...
@@ -63,12 +63,12 @@ class LDAP implements IAuthConnector
/**
* @var null|string ldap administrative bind dn
*/
private
$ldapBindDN
=
null
;
private
$ldapBindDN
=
null
;
/**
* @var null|string ldap administrative bind passwd
*/
private
$ldapBindPassword
=
null
;
private
$ldapBindPassword
=
null
;
/**
* @var null|string user attribute
...
...
@@ -186,7 +186,7 @@ class LDAP implements IAuthConnector
"ldap_attr_user"
=>
"ldapAttributeUser"
,
"ldap_extended_query"
=>
"ldapExtendedQuery"
,
"local_users"
=>
"userDNmap"
)
;
);
// map properties 1-on-1
foreach
(
$confMap
as
$confSetting
=>
$objectProperty
)
{
...
...
src/opnsense/mvc/app/library/OPNsense/Auth/LocalTOTP.php
View file @
fb3d5e0b
...
...
@@ -218,7 +218,7 @@ class LocalTOTP extends Local
$fields
[
"timeWindow"
][
"type"
]
=
"text"
;
$fields
[
"timeWindow"
][
"default"
]
=
null
;
$fields
[
"timeWindow"
][
"help"
]
=
gettext
(
"The time period in which the token will be valid,"
.
" default is 30 seconds (google authenticator)"
)
;
" default is 30 seconds (google authenticator)"
);
$fields
[
"timeWindow"
][
"validate"
]
=
function
(
$value
)
{
if
(
!
empty
(
$value
)
&&
filter_var
(
$value
,
FILTER_SANITIZE_NUMBER_INT
)
!=
$value
)
{
return
array
(
gettext
(
"Please enter a valid time window in seconds"
));
...
...
src/opnsense/mvc/app/library/OPNsense/Auth/Radius.php
View file @
fb3d5e0b
...
...
@@ -113,7 +113,7 @@ class Radius implements IAuthConnector
'radius_acct_port'
=>
'acctPort'
,
'radius_protocol'
=>
'protocol'
,
'refid'
=>
'nasIdentifier'
)
;
);
// map properties 1-on-1
foreach
(
$confMap
as
$confSetting
=>
$objectProperty
)
{
...
...
@@ -340,7 +340,7 @@ class Radius implements IAuthConnector
*/
public
function
authenticate
(
$username
,
$password
)
{
$this
->
lastAuthProperties
=
array
()
;
// reset auth properties
$this
->
lastAuthProperties
=
array
();
// reset auth properties
$radius
=
radius_auth_open
();
$error
=
null
;
...
...
src/opnsense/mvc/app/library/OPNsense/Auth/Voucher.php
View file @
fb3d5e0b
...
...
@@ -197,7 +197,7 @@ class Voucher implements IAuthConnector
(
$chr_ord
>=
109
&&
$chr_ord
<=
110
)
||
// m..n
(
$chr_ord
>=
112
&&
$chr_ord
<=
122
)
// p..z
)
{
$characterMap
.=
$random_bytes
[
$i
]
;
$characterMap
.=
$random_bytes
[
$i
];
}
}
}
...
...
@@ -212,7 +212,7 @@ class Voucher implements IAuthConnector
for
(
$i
=
0
;
$i
<
strlen
(
$random_bytes
);
$i
++
)
{
$chr_ord
=
ord
(
$random_bytes
[
$i
]);
if
(
$chr_ord
>=
33
&&
$chr_ord
<=
125
&&
!
in_array
(
$random_bytes
[
$i
],
$doNotUseChr
))
{
$characterMap
.=
$random_bytes
[
$i
]
;
$characterMap
.=
$random_bytes
[
$i
];
}
}
}
...
...
@@ -309,7 +309,7 @@ class Voucher implements IAuthConnector
$record
[
'username'
]
=
$row
[
'username'
];
$record
[
'validity'
]
=
$row
[
'validity'
];
# always calculate a starttime, if not registered yet, use now.
$record
[
'starttime'
]
=
empty
(
$row
[
'starttime'
])
?
time
()
:
$row
[
'starttime'
]
;
$record
[
'starttime'
]
=
empty
(
$row
[
'starttime'
])
?
time
()
:
$row
[
'starttime'
];
$record
[
'endtime'
]
=
$record
[
'starttime'
]
+
$row
[
'validity'
];
if
(
empty
(
$row
[
'starttime'
]))
{
...
...
@@ -382,7 +382,7 @@ class Voucher implements IAuthConnector
$this
->
setStartTime
(
$username
,
$row
[
'starttime'
]);
}
if
(
time
()
-
$row
[
'starttime'
]
<
$row
[
'validity'
])
{
$this
->
lastAuthProperties
[
'session_timeout'
]
=
$row
[
'validity'
]
-
(
time
()
-
$row
[
'starttime'
])
;
$this
->
lastAuthProperties
[
'session_timeout'
]
=
$row
[
'validity'
]
-
(
time
()
-
$row
[
'starttime'
]);
return
true
;
}
}
...
...
@@ -400,7 +400,7 @@ class Voucher implements IAuthConnector
$fields
[
"simplePasswords"
]
=
array
();
$fields
[
"simplePasswords"
][
"name"
]
=
gettext
(
"Use simple passwords (less secure)"
);
$fields
[
"simplePasswords"
][
"type"
]
=
"checkbox"
;
$fields
[
"simplePasswords"
][
"help"
]
=
gettext
(
"Use simple (less secure) passwords, which are easier to read"
)
;
$fields
[
"simplePasswords"
][
"help"
]
=
gettext
(
"Use simple (less secure) passwords, which are easier to read"
);
$fields
[
"simplePasswords"
][
"validate"
]
=
function
(
$value
)
{
return
array
();
};
...
...
src/opnsense/mvc/app/library/OPNsense/Core/Backend.php
View file @
fb3d5e0b
...
...
@@ -77,7 +77,7 @@ class Backend
public
function
configdRun
(
$event
,
$detach
=
false
,
$timeout
=
120
,
$connect_timeout
=
10
)
{
$endOfStream
=
chr
(
0
)
.
chr
(
0
)
.
chr
(
0
);
$poll_timeout
=
2
;
// poll timeout interval
$poll_timeout
=
2
;
// poll timeout interval
// wait until socket exist for a maximum of $connect_timeout
$timeout_wait
=
$connect_timeout
;
...
...
@@ -106,7 +106,7 @@ class Backend
}
// read response data
$starttime
=
time
()
;
$starttime
=
time
();
while
(
true
)
{
$resp
=
$resp
.
stream_get_contents
(
$stream
);
...
...
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
fb3d5e0b
...
...
@@ -169,7 +169,7 @@ class Config extends Singleton
// root node
if
(
$node
==
null
)
{
$this
->
simplexml
=
simplexml_load_string
(
'<'
.
$this
->
simplexml
[
0
]
->
getName
()
.
'/>'
);
$node
=
$this
->
simplexml
;
$node
=
$this
->
simplexml
;
// invalidate object on warnings/errors (prevent save from happening)
set_error_handler
(
function
()
{
...
...
@@ -222,7 +222,7 @@ class Config extends Singleton
private
function
checkvalid
()
{
if
(
!
$this
->
statusIsValid
)
{
throw
new
ConfigException
(
'no valid config loaded'
)
;
throw
new
ConfigException
(
'no valid config loaded'
);
}
}
...
...
@@ -267,7 +267,7 @@ class Config extends Singleton
try
{
$this
->
load
();
}
catch
(
\Exception
$e
)
{
$this
->
simplexml
=
null
;
$this
->
simplexml
=
null
;
// there was an issue with loading the config, try to restore the last backup
$backups
=
$this
->
getBackups
();
$logger
=
new
Syslog
(
"config"
,
array
(
'option'
=>
LOG_PID
,
'facility'
=>
LOG_LOCAL4
));
...
...
@@ -299,17 +299,17 @@ class Config extends Singleton
{
// exception handling
if
(
!
file_exists
(
$this
->
config_file
))
{
throw
new
ConfigException
(
'file not found'
)
;
throw
new
ConfigException
(
'file not found'
);
}
$xml
=
file_get_contents
(
$this
->
config_file
);
if
(
trim
(
$xml
)
==
''
)
{
throw
new
ConfigException
(
'empty file'
)
;
throw
new
ConfigException
(
'empty file'
);
}
set_error_handler
(
function
()
{
// reset simplexml pointer on parse error.
$this
->
simplexml
=
null
;
$this
->
simplexml
=
null
;
}
);
...
...
@@ -317,7 +317,7 @@ class Config extends Singleton
if
(
$this
->
simplexml
==
null
)
{
restore_error_handler
();
throw
new
ConfigException
(
"invalid config xml"
)
;
throw
new
ConfigException
(
"invalid config xml"
);
}
restore_error_handler
();
...
...
@@ -470,7 +470,7 @@ class Config extends Singleton
$simplexml
=
$this
->
simplexml
;
try
{
// try to restore config
copy
(
$filename
,
$this
->
config_file
)
;
copy
(
$filename
,
$this
->
config_file
);
$this
->
load
();
return
true
;
}
catch
(
ConfigException
$e
)
{
...
...
@@ -482,7 +482,7 @@ class Config extends Singleton
}
}
else
{
// we don't have a valid config loaded, just copy and load the requested one
copy
(
$filename
,
$this
->
config_file
)
;
copy
(
$filename
,
$this
->
config_file
);
$this
->
load
();
return
true
;
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/BaseModel.php
View file @
fb3d5e0b
...
...
@@ -75,7 +75,7 @@ abstract class BaseModel
*/
protected
function
init
()
{
return
;
return
;
}
/**
...
...
@@ -117,7 +117,7 @@ abstract class BaseModel
$tagName
=
$xmlNode
->
getName
();
// every item results in a Field type object, the first step is to determine which object to create
// based on the input model spec
$fieldObject
=
null
;
$fieldObject
=
null
;
$classname
=
"OPNsense
\\
Base
\\
FieldTypes
\\
"
.
$xmlNode
->
attributes
()[
"type"
];
if
(
class_exists
(
$classname
))
{
// construct field type object
...
...
@@ -160,7 +160,7 @@ abstract class BaseModel
if
(
$config_data
!=
null
&&
isset
(
$config_data
->
$tagName
))
{
$config_section_data
=
$config_data
->
$tagName
;
}
else
{
$config_section_data
=
null
;
$config_section_data
=
null
;
}
if
(
$fieldObject
instanceof
ArrayField
)
{
...
...
@@ -218,16 +218,16 @@ abstract class BaseModel
// determine our caller's filename and try to find the model definition xml
// throw error on failure
$class_info
=
new
\ReflectionClass
(
$this
);
$model_filename
=
substr
(
$class_info
->
getFileName
(),
0
,
strlen
(
$class_info
->
getFileName
())
-
3
)
.
"xml"
;
$model_filename
=
substr
(
$class_info
->
getFileName
(),
0
,
strlen
(
$class_info
->
getFileName
())
-
3
)
.
"xml"
;
if
(
!
file_exists
(
$model_filename
))
{
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' missing'
)
;
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' missing'
);
}
$model_xml
=
simplexml_load_file
(
$model_filename
);
if
(
$model_xml
===
false
)
{
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' not valid'
)
;
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' not valid'
);
}
if
(
$model_xml
->
getName
()
!=
"model"
)
{
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' seems to be of wrong type'
)
;
throw
new
ModelException
(
'model xml '
.
$model_filename
.
' seems to be of wrong type'
);
}
$this
->
internal_mountpoint
=
$model_xml
->
mount
;
...
...
@@ -239,13 +239,13 @@ abstract class BaseModel
// if found, convert the data to a simple structure (or create an empty array)
$tmp_config_data
=
$internalConfigHandle
->
xpath
(
$model_xml
->
mount
);
if
(
$tmp_config_data
->
length
>
0
)
{
$config_array
=
simplexml_import_dom
(
$tmp_config_data
->
item
(
0
))
;
$config_array
=
simplexml_import_dom
(
$tmp_config_data
->
item
(
0
));
}
else
{
$config_array
=
array
();
}
// We've loaded the model template, now let's parse it into this object
$this
->
parseXml
(
$model_xml
->
items
,
$config_array
,
$this
->
internalData
)
;
$this
->
parseXml
(
$model_xml
->
items
,
$config_array
,
$this
->
internalData
);
// root may contain a version, store if found
if
(
empty
(
$config_array
))
{
// new node, reset
...
...
@@ -278,7 +278,7 @@ abstract class BaseModel
*/
public
function
__set
(
$name
,
$value
)
{
$this
->
internalData
->
$name
=
$value
;
$this
->
internalData
->
$name
=
$value
;
}
/**
...
...
@@ -359,7 +359,7 @@ abstract class BaseModel
$fieldnm
=
str_replace
(
$sourceref
,
$targetref
,
$msg
->
getField
());
$result
[
$fieldnm
]
=
$msg
->
getMessage
();
}
else
{
$fieldnm
=
$targetref
.
$msg
->
getField
()
;
$fieldnm
=
$targetref
.
$msg
->
getField
();
$result
[
$fieldnm
]
=
$msg
->
getMessage
();
}
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/ArrayField.php
View file @
fb3d5e0b
...
...
@@ -81,7 +81,7 @@ class ArrayField extends BaseField
// validate child nodes, nesting not supported in this version.
throw
new
\Exception
(
"Unsupported copy, Array doesn't support nesting."
);
}
$new_record
[
$key
]
=
clone
$node
;
$new_record
[
$key
]
=
clone
$node
;
}
$nodeUUID
=
$this
->
generateUUID
();
...
...
@@ -146,11 +146,11 @@ class ArrayField extends BaseField
$sortKey
=
''
;
foreach
(
$fieldNames
as
$fieldName
)
{
if
(
array_key_exists
(
$fieldName
,
$node
->
internalChildnodes
))
{
$sortKey
.=
sprintf
(
"%"
.
$MAX_KEY_LENGTH
.
"s ,"
,
$node
->
$fieldName
)
;
$sortKey
.=
sprintf
(
"%"
.
$MAX_KEY_LENGTH
.
"s ,"
,
$node
->
$fieldName
);
}
}
$sortKey
.=
$nodeKey
;
// prevent overwrite of duplicates
$sortedData
[
$sortKey
]
=
$node
;
$sortedData
[
$sortKey
]
=
$node
;
}
// sort by key on ascending or descending order
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/AutoNumberField.php
View file @
fb3d5e0b
...
...
@@ -52,13 +52,13 @@ class AutoNumberField extends BaseField
* maximum value for this field
* @var integer
*/
private
$maximum_value
;
private
$maximum_value
;
/**
* minimum value for this field
* @var integer
*/
private
$minimum_value
;
private
$minimum_value
;
/**
* constructor, set absolute min and max values
...
...
@@ -69,7 +69,7 @@ class AutoNumberField extends BaseField
{
parent
::
__construct
(
$ref
,
$tagname
);
$this
->
minimum_value
=
0
;
$this
->
maximum_value
=
PHP_INT_MAX
-
1
;
$this
->
maximum_value
=
PHP_INT_MAX
-
1
;
}
/**
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/BaseField.php
View file @
fb3d5e0b
...
...
@@ -90,7 +90,7 @@ abstract class BaseField
/**
* @var bool is this a required attribute?
*/
protected
$internalIsRequired
=
false
;
protected
$internalIsRequired
=
false
;
/**
* @var string validation message string
...
...
@@ -100,7 +100,7 @@ abstract class BaseField
/**
* @var bool node (and subnodes) is virtual
*/
protected
$internalIsVirtual
=
false
;
protected
$internalIsVirtual
=
false
;
/**
* @var array key value store for attributes (will be saved as xml attributes)
...
...
@@ -177,7 +177,7 @@ abstract class BaseField
*/
public
function
__clone
()
{
$this
->
internalIsVirtual
=
false
;
$this
->
internalIsVirtual
=
false
;
$this
->
internalValue
=
""
;
$this
->
internalReference
=
null
;
}
...
...
@@ -240,7 +240,7 @@ abstract class BaseField
$result
=
array
();
foreach
(
$this
->
internalChildnodes
as
$key
=>
$value
)
{
if
(
$value
->
internalIsVirtual
==
false
)
{
$result
[
$key
]
=
$value
;
$result
[
$key
]
=
$value
;
}
}
return
$result
;
...
...
@@ -391,7 +391,7 @@ abstract class BaseField
{
$validators
=
$this
->
getConstraintValidators
();
if
(
$this
->
isEmptyAndRequired
())
{
$validators
[]
=
new
PresenceOf
(
array
(
'message'
=>
$this
->
internalValidationMessage
))
;
$validators
[]
=
new
PresenceOf
(
array
(
'message'
=>
$this
->
internalValidationMessage
));
}
return
$validators
;
}
...
...
@@ -437,7 +437,7 @@ abstract class BaseField
foreach
(
$this
->
__items
as
$node
)
{
foreach
(
$node
->
getFlatNodes
()
as
$childNode
)
{
$result
[
$childNode
->
internalReference
]
=
$childNode
;
$result
[
$childNode
->
internalReference
]
=
$childNode
;
}
}
...
...
@@ -520,7 +520,7 @@ abstract class BaseField
{
if
(
$this
->
internalReference
==
""
||
get_class
(
$this
)
==
"OPNsense
\\
Base
\\
FieldTypes
\\
ArrayField"
)
{
// ignore tags without internal reference (root) and ArrayTypes
$subnode
=
$node
;
$subnode
=
$node
;
}
else
{
if
(
$this
->
internalValue
!=
""
)
{
$newNodeName
=
$this
->
getInternalXMLTagName
();
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CSVListField.php
View file @
fb3d5e0b
...
...
@@ -62,7 +62,7 @@ class CSVListField extends BaseField
/**
* @var string basic regex validation to use for the complete field
*/
protected
$internalMask
=
null
;
protected
$internalMask
=
null
;
/**
* set validation mask
...
...
@@ -70,7 +70,7 @@ class CSVListField extends BaseField
*/
public
function
setMask
(
$value
)
{
$this
->
internalMask
=
$value
;
$this
->
internalMask
=
$value
;
}
/**
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/CertificateField.php
View file @
fb3d5e0b
...
...
@@ -102,7 +102,7 @@ class CertificateField extends BaseField
self
::
$internalOptionList
[
$this
->
certificateType
]
=
array
();
$configObj
=
Config
::
getInstance
()
->
object
();
foreach
(
$configObj
->
{
$this
->
certificateType
}
as
$cert
)
{
self
::
$internalOptionList
[
$this
->
certificateType
][(
string
)
$cert
->
refid
]
=
(
string
)
$cert
->
descr
;
self
::
$internalOptionList
[
$this
->
certificateType
][(
string
)
$cert
->
refid
]
=
(
string
)
$cert
->
descr
;
}
}
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/IntegerField.php
View file @
fb3d5e0b
...
...
@@ -51,13 +51,13 @@ class IntegerField extends BaseField
* maximum value for this field
* @var integer
*/
private
$maximum_value
;
private
$maximum_value
;
/**
* minimum value for this field
* @var integer
*/
private
$minimum_value
;
private
$minimum_value
;
/**
* constructor, set absolute min and max values
...
...
@@ -68,7 +68,7 @@ class IntegerField extends BaseField
{
parent
::
__construct
(
$ref
,
$tagname
);
$this
->
minimum_value
=
PHP_INT_MAX
*-
1
;
$this
->
maximum_value
=
PHP_INT_MAX
;
$this
->
maximum_value
=
PHP_INT_MAX
;
}
/**
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/OptionField.php
View file @
fb3d5e0b
...
...
@@ -79,9 +79,9 @@ class OptionField extends BaseField
foreach
(
$data
as
$key
=>
$value
)
{
if
(
!
is_array
(
$value
))
{
if
(
$key
==
"__empty__"
)
{
$this
->
internalOptionList
[
""
]
=
$value
;
$this
->
internalOptionList
[
""
]
=
$value
;
}
else
{
$this
->
internalOptionList
[
$key
]
=
$value
;
$this
->
internalOptionList
[
$key
]
=
$value
;
}
}
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/PortField.php
View file @
fb3d5e0b
...
...
@@ -130,7 +130,7 @@ class PortField extends BaseField
$validators
=
parent
::
getValidators
();
if
(
$this
->
internalValidationMessage
==
null
)
{
$msg
=
"please specify a valid portnumber (1-65535) or name ("
.
implode
(
","
,
self
::
$wellknownservices
)
.
")"
;
")"
;
}
else
{
$msg
=
$this
->
internalValidationMessage
;
}
...
...
src/opnsense/mvc/app/models/OPNsense/Base/FieldTypes/TextField.php
View file @
fb3d5e0b
...
...
@@ -58,7 +58,7 @@ class TextField extends BaseField
*/
public
function
setMask
(
$value
)
{
$this
->
internalMask
=
$value
;
$this
->
internalMask
=
$value
;
}
/**
...
...
src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuItem.php
View file @
fb3d5e0b
...
...
@@ -88,7 +88,7 @@ class MenuItem
* parent node, used to mark active nodes
* @var null|MenuItem
*/
private
$parent
=
null
;
private
$parent
=
null
;
/**
* is this node or any of the child nodes selected
...
...
@@ -131,7 +131,7 @@ class MenuItem
*/
public
function
getId
()
{
return
$this
->
id
;
return
$this
->
id
;
}
...
...
@@ -186,7 +186,7 @@ class MenuItem
*/
public
function
setCssClass
(
$value
)
{
$this
->
CssClass
=
$value
;
$this
->
CssClass
=
$value
;
}
/**
...
...
@@ -265,7 +265,7 @@ class MenuItem
$isNew
=
false
;
foreach
(
$this
->
children
as
$nodeKey
=>
$node
)
{
if
(
$node
->
getId
()
==
$id
)
{
$newMenuItem
=
$node
;
$newMenuItem
=
$node
;
}
}
if
(
$newMenuItem
==
null
)
{
...
...
@@ -327,7 +327,7 @@ class MenuItem
*/
public
function
select
()
{
$this
->
selected
=
true
;
$this
->
selected
=
true
;
if
(
$this
->
parent
!=
null
)
{
$this
->
parent
->
select
();
}
...
...
@@ -339,7 +339,7 @@ class MenuItem
*/
public
function
toggleSelected
(
$url
)
{
$this
->
selected
=
false
;
$this
->
selected
=
false
;
foreach
(
$this
->
getFilteredChildren
()
as
$nodeId
=>
$node
)
{
$node
->
toggleSelected
(
$url
);
if
(
$node
->
getUrl
()
!=
""
)
{
...
...
@@ -405,7 +405,7 @@ class MenuItem
{
foreach
(
$this
->
getFilteredChildren
()
as
$key
=>
$node
)
{
if
(
strtolower
(
$node
->
getId
())
==
strtolower
(
$id
))
{
return
$node
;
return
$node
;
}
}
return
null
;
...
...
src/opnsense/mvc/app/models/OPNsense/Base/Menu/MenuSystem.php
View file @
fb3d5e0b
...
...
@@ -40,7 +40,7 @@ class MenuSystem
/**
* @var null|MenuItem root node
*/
private
$root
=
null
;
private
$root
=
null
;
/**
* add menu structure to root
...
...
@@ -51,14 +51,14 @@ class MenuSystem
{
// load and validate menu xml
if
(
!
file_exists
(
$filename
))
{
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' missing'
)
;
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' missing'
);
}
$menuXml
=
simplexml_load_file
(
$filename
);
if
(
$menuXml
===
false
)
{
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' not valid'
)
;
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' not valid'
);
}
if
(
$menuXml
->
getName
()
!=
"menu"
)
{
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' seems to be of wrong type'
)
;
throw
new
MenuInitException
(
'Menu xml '
.
$filename
.
' seems to be of wrong type'
);
}
// traverse items
...
...
src/opnsense/mvc/app/models/OPNsense/Core/ACL.php
View file @
fb3d5e0b
...
...
@@ -100,10 +100,10 @@ class ACL
// load ACL xml file and perform some basic validation
$ACLxml
=
simplexml_load_file
(
$acl_cfg_xml
);
if
(
$ACLxml
===
false
)
{
throw
new
\Exception
(
'ACL xml '
.
$acl_cfg_xml
.
' not valid'
)
;
throw
new
\Exception
(
'ACL xml '
.
$acl_cfg_xml
.
' not valid'
);
}
if
(
$ACLxml
->
getName
()
!=
"acl"
)
{
throw
new
\Exception
(
'ACL xml '
.
$acl_cfg_xml
.
' seems to be of wrong type'
)
;
throw
new
\Exception
(
'ACL xml '
.
$acl_cfg_xml
.
' seems to be of wrong type'
);
}
// when acl was correctly loaded, let's parse data into private $this->ACLtags
...
...
@@ -151,11 +151,11 @@ class ACL
$groupmap
=
array
();
// gather user / group data from config.xml
$config
=
Config
::
getInstance
()
->
object
()
;
$config
=
Config
::
getInstance
()
->
object
();
if
(
$config
->
system
!=
null
)
{
foreach
(
$config
->
system
->
children
()
as
$key
=>
$node
)
{
if
(
$key
==
'user'
)
{
$this
->
legacyUsers
[
$node
->
name
->
__toString
()]
=
array
()
;
$this
->
legacyUsers
[
$node
->
name
->
__toString
()]
=
array
();
$this
->
legacyUsers
[
$node
->
name
->
__toString
()][
'uid'
]
=
$node
->
uid
->
__toString
();
$this
->
legacyUsers
[
$node
->
name
->
__toString
()][
'groups'
]
=
array
();
$this
->
legacyUsers
[
$node
->
name
->
__toString
()][
'priv'
]
=
array
();
...
...
@@ -168,7 +168,7 @@ class ACL
}
}
}
elseif
(
$key
==
'group'
)
{
$groupmap
[
$node
->
name
->
__toString
()]
=
$node
;
$groupmap
[
$node
->
name
->
__toString
()]
=
$node
;
}
}
}
...
...
@@ -278,7 +278,7 @@ class ACL
// sort by name ( case insensitive )
uasort
(
$priv_list
,
function
(
$a
,
$b
)
{
return
strcasecmp
(
$a
[
"name"
],
$b
[
"name"
])
;
return
strcasecmp
(
$a
[
"name"
],
$b
[
"name"
]);
});
return
$priv_list
;
...
...
src/opnsense/mvc/app/models/OPNsense/Cron/Cron.php
View file @
fb3d5e0b
...
...
@@ -54,7 +54,7 @@ class Cron extends BaseModel
$cron
->
origin
=
$origin
;
$cron
->
command
=
$command
;
$cron
->
description
=
$description
;
$cron
->
weekdays
=
$weekdays
;
$cron
->
weekdays
=
$weekdays
;
$cron
->
enabled
=
$enabled
;
return
$uuid
;
}
...
...
src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php
View file @
fb3d5e0b
...
...
@@ -161,7 +161,7 @@ class IDS extends BaseModel
}
}
elseif
(
!
$response_plain
)
{
// generate selection for new field
$default_types
=
$this
->
action_list
;
$default_types
=
$this
->
action_list
;
if
(
array_key_exists
(
$default
,
$default_types
))
{
foreach
(
$default_types
as
$key
=>
$value
)
{
if
(
$key
==
$default
)
{
...
...
@@ -199,6 +199,6 @@ class IDS extends BaseModel
$node
=
$this
->
files
->
file
->
Add
();
$node
->
filename
=
$filename
;
return
$node
;
return
$node
;
}
}
src/opnsense/mvc/script/run_migrations.php
View file @
fb3d5e0b
...
...
@@ -39,7 +39,7 @@ $executed_migration = false;
$model_dir
=
dirname
(
$class_info
->
getFileName
())
.
"/../../"
;
foreach
(
new
RecursiveIteratorIterator
(
new
RecursiveDirectoryIterator
(
$model_dir
))
as
$x
)
{
if
(
strtolower
(
substr
(
$x
->
getPathname
(),
-
4
))
==
'.php'
)
{
$classname
=
str_replace
(
'/'
,
'\\'
,
explode
(
'.'
,
str_replace
(
$model_dir
,
''
,
$x
->
getPathname
()))[
0
])
;
$classname
=
str_replace
(
'/'
,
'\\'
,
explode
(
'.'
,
str_replace
(
$model_dir
,
''
,
$x
->
getPathname
()))[
0
]);
try
{
$mdl_class_info
=
new
\ReflectionClass
(
$classname
);
$parent
=
$mdl_class_info
->
getParentClass
();
...
...
@@ -52,7 +52,7 @@ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($model_dir
$version_pre
=
!
empty
(
$version_pre
)
?
$version_pre
:
' <unversioned> '
;
echo
"migrated "
.
$mdl_class_info
->
getName
()
.
" from "
.
$version_pre
.
" to "
.
$version_post
.
"
\n
"
;
" to "
.
$version_post
.
"
\n
"
;
$executed_migration
=
true
;
}
elseif
(
!
empty
(
$version_post
))
{
echo
"keep version "
.
$mdl_class_info
->
getName
()
.
" ("
.
$version_post
.
")
\n
"
;
...
...
src/opnsense/mvc/tests/app/models/OPNsense/Base/BaseModelTest.php
View file @
fb3d5e0b
...
...
@@ -244,7 +244,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase
{
$count
=
2
;
foreach
(
BaseModelTest
::
$model
->
arraytypes
->
item
->
__items
as
$nodeid
=>
$node
)
{
$count
--
;
$count
--
;
if
(
$count
>=
0
)
{
$node
->
number
=
999
;
}
...
...
@@ -259,7 +259,7 @@ class BaseModelTest extends \PHPUnit_Framework_TestCase
{
$count
=
1
;
foreach
(
BaseModelTest
::
$model
->
arraytypes
->
item
->
__items
as
$nodeid
=>
$node
)
{
$count
++
;
$count
++
;
$node
->
number
=
$count
;
}
BaseModelTest
::
$model
->
serializeToConfig
();
...
...
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