Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
outils
question2answer
Commits
c5d5ef64
Commit
c5d5ef64
authored
Feb 07, 2016
by
Daniel Ruf
Committed by
Scott
Feb 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support IPv6 in qa_block_ip_match
parent
0c163460
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
11 deletions
+18
-11
limits.php
qa-include/app/limits.php
+18
-11
No files found.
qa-include/app/limits.php
View file @
c5d5ef64
...
...
@@ -179,19 +179,27 @@
Returns whether the ip address $ip is matched by the clause $blockipclause, which can contain a hyphen or asterisk
*/
{
if
(
long2ip
(
ip2long
(
$ip
))
==
$ip
)
{
if
(
filter_var
(
$ip
,
FILTER_VALIDATE_IP
)
)
{
if
(
preg_match
(
'/^(.*)\-(.*)$/'
,
$blockipclause
,
$matches
))
{
if
(
(
long2ip
(
ip2long
(
$matches
[
1
]))
==
$matches
[
1
])
&&
(
long2ip
(
ip2long
(
$matches
[
2
]))
==
$matches
[
2
])
)
{
$iplong
=
sprintf
(
'%u'
,
ip2long
(
$ip
));
$end1long
=
sprintf
(
'%u'
,
ip2long
(
$matches
[
1
]));
$end2long
=
sprintf
(
'%u'
,
ip2long
(
$matches
[
2
]));
if
(
filter_var
(
$matches
[
1
],
FILTER_VALIDATE_IP
)
&&
filter_var
(
$matches
[
2
],
FILTER_VALIDATE_IP
)
)
{
if
(
filter_var
(
$ip
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV6
)){
$ip
=
ipv6_expand
(
$ip
);
$matches
[
1
]
=
ipv6_expand
(
$matches
[
1
],
true
);
$matches
[
2
]
=
ipv6_expand
(
$matches
[
2
],
true
);
}
$iplong
=
ipv6_numeric
(
$ip
);
$end1long
=
ipv6_numeric
(
$matches
[
1
]);
$end2long
=
ipv6_numeric
(
$matches
[
2
]);
return
((
$iplong
>=
$end1long
)
&&
(
$iplong
<=
$end2long
))
||
((
$iplong
>=
$end2long
)
&&
(
$iplong
<=
$end1long
));
}
}
elseif
(
strlen
(
$blockipclause
))
return
preg_match
(
'/^'
.
str_replace
(
'\\*'
,
'[0-9]+'
,
preg_quote
(
$blockipclause
,
'/'
))
.
'$/'
,
$ip
)
>
0
;
}
elseif
(
strlen
(
$blockipclause
)){
if
(
filter_var
(
$ip
,
FILTER_VALIDATE_IP
,
FILTER_FLAG_IPV6
)){
$ip
=
ipv6_expand
(
$ip
,
true
);
$blockipclause
=
ipv6_expand
(
$blockipclause
,
true
);
}
return
preg_match
(
'/^'
.
str_replace
(
'\\*'
,
'[0-9a-fA-F]+'
,
preg_quote
(
$blockipclause
,
'/'
))
.
'$/'
,
$ip
)
>
0
;
// preg_quote misses hyphens but that is OK here
}
}
return
false
;
...
...
@@ -226,4 +234,4 @@
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
*/
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