Conditions | 1 |
Paths | 1 |
Total Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function match($value) |
||
22 | { |
||
23 | // Adapted from https://gist.github.com/tott/7684443 |
||
24 | |||
25 | list($range, $netmask) = explode('/', $this->_definition, 2); |
||
26 | $rangeDecimal = ip2long($range); |
||
27 | $ipDecimal = ip2long($value); |
||
28 | $wildcardDecimal = pow(2, (32 - $netmask)) - 1; |
||
29 | $netmaskDecimal = ~ $wildcardDecimal; |
||
30 | return (($ipDecimal & $netmaskDecimal) == ($rangeDecimal & $netmaskDecimal)); |
||
31 | } |
||
32 | } |
||
33 |