Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dirk Dankhoff
ISPConfig 3
Commits
2df8c0b8
Commit
2df8c0b8
authored
Aug 23, 2015
by
Florian Schaal
Browse files
better regex for ipv4
parent
88187101
Changes
6
Show whitespace changes
Inline
Side-by-side
interface/lib/classes/functions.inc.php
View file @
2df8c0b8
...
...
@@ -186,7 +186,8 @@ class functions {
global
$app
;
if
(
$type
==
'IPv4'
){
$regex
=
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
;
// $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/";
$regex
=
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
;
}
else
{
// IPv6
$regex
=
"/^(\:\:([a-f0-9]
{
1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3
}
)?$/i"
;
...
...
interface/lib/classes/tform_base.inc.php
View file @
2df8c0b8
...
...
@@ -1058,11 +1058,10 @@ class tform_base {
}
break
;
case
'ISIPV4'
:
$vip
=
1
;
if
(
preg_match
(
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
,
$field_value
)){
// if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
if
(
preg_match
(
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
,
$field_value
)){
$groups
=
explode
(
"."
,
$field_value
);
foreach
(
$groups
as
$group
){
if
(
$group
<
0
or
$group
>
255
)
...
...
@@ -1078,6 +1077,7 @@ class tform_base {
}
}
break
;
case
'ISIP'
:
if
(
$validator
[
'allowempty'
]
!=
'y'
)
$validator
[
'allowempty'
]
=
'n'
;
if
(
$validator
[
'allowempty'
]
==
'y'
&&
$field_value
==
''
)
{
...
...
@@ -1107,7 +1107,8 @@ class tform_base {
if
(
preg_match
(
"/^(\:\:([a-f0-9]
{
1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3
}
)?$/i"
,
$field_value
)){
$ip_ok
=
1
;
}
if
(
preg_match
(
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
,
$field_value
)){
// if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
if
(
preg_match
(
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
,
$field_value
)){
$ip_ok
=
1
;
}
if
(
$ip_ok
==
0
)
{
...
...
interface/lib/classes/validate_database.inc.php
View file @
2df8c0b8
...
...
@@ -44,7 +44,8 @@ class validate_database {
$cur_value
=
trim
(
$cur_value
);
$valid
=
true
;
if
(
preg_match
(
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
,
$cur_value
))
{
// if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $cur_value)) {
if
(
preg_match
(
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
,
$cur_value
))
{
$groups
=
explode
(
"."
,
$cur_value
);
foreach
(
$groups
as
$group
){
if
(
$group
<
0
or
$group
>
255
)
...
...
interface/lib/classes/validate_dns.inc.php
View file @
2df8c0b8
...
...
@@ -315,7 +315,8 @@ class validate_dns {
if
(
preg_match
(
"/^(\:\:([a-f0-9]
{
1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3
}
)?$/i"
,
$field_value
)){
$ip_ok
=
1
;
}
if
(
preg_match
(
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
,
$field_value
)){
// if(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $field_value)){
if
(
preg_match
(
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
,
$field_value
)){
$ip_ok
=
1
;
}
if
(
$ip_ok
==
0
)
{
...
...
server/lib/classes/functions.inc.php
View file @
2df8c0b8
...
...
@@ -230,7 +230,8 @@ class functions {
global
$app
;
if
(
$type
==
'IPv4'
){
$regex
=
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
;
// $regex = "/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/";
$regex
=
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
;
}
else
{
// IPv6
$regex
=
"/^(\:\:([a-f0-9]
{
1,4}\:){0,6}?[a-f0-9]{0,4}|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){0,6}?\:\:|[a-f0-9]{1,4}(\:[a-f0-9]{1,4}){1,6}?\:\:([a-f0-9]{1,4}\:){1,6}?[a-f0-9]{1,4})(\/\d{1,3
}
)?$/i"
;
...
...
server/plugins-available/mysql_clientdb_plugin.inc.php
View file @
2df8c0b8
...
...
@@ -101,7 +101,8 @@ class mysql_clientdb_plugin {
$valid
=
true
;
if
(
$db_host
==
'%'
||
$db_host
==
'localhost'
)
{
$valid
=
true
;
}
elseif
(
preg_match
(
"/^[0-9]
{
1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3
}
$/"
,
$db_host
))
{
// } elseif(preg_match("/^[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}(\.)[0-9]{1,3}$/", $db_host)) {
}
elseif
(
preg_match
(
"/^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)
\\
.)
{
3
}
(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/"
,
$db_host
))
{
$groups
=
explode
(
'.'
,
$db_host
);
foreach
(
$groups
as
$group
){
if
(
$group
<
0
or
$group
>
255
)
...
...
Write
Preview
Supports
Markdown
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