Commit 75f90e5a by Daniel Ruf Committed by Scott

check if the input parameters use the same IP version

parent 47f3adc4
...@@ -179,6 +179,13 @@ ...@@ -179,6 +179,13 @@
Returns whether the ip address $ip is matched by the clause $blockipclause, which can contain a hyphen or asterisk Returns whether the ip address $ip is matched by the clause $blockipclause, which can contain a hyphen or asterisk
*/ */
{ {
// check if the input parameters use the same IP version
if (
((strpos($ip, ".")!==false) && (strpos($blockipclause, ".")==false)) ||
((strpos($ip, ".")==false) && (strpos($blockipclause, ".")!==false))
)
return false;
if (filter_var($ip, FILTER_VALIDATE_IP)) { if (filter_var($ip, FILTER_VALIDATE_IP)) {
if (preg_match('/^(.*)\-(.*)$/', $blockipclause, $matches)) { if (preg_match('/^(.*)\-(.*)$/', $blockipclause, $matches)) {
if ( filter_var($matches[1], FILTER_VALIDATE_IP) && filter_var($matches[2], FILTER_VALIDATE_IP) ) { if ( filter_var($matches[1], FILTER_VALIDATE_IP) && filter_var($matches[2], FILTER_VALIDATE_IP) ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment