public static function netMatch($CIDR, $IP)
    {
        /* TODO: IPV6 */
        if (is_array($CIDR)) {
            foreach ($CIDR as &$v) {
                if (self::netMatch($v, $IP)) {
                    return true;
                }
            }

            return false;
        }

        $e = explode('/', $CIDR, 2);

        if (!isset($e[1])) {
            return $e[0] === $IP;
        }

        return (ip2long($IP) & ~((1 << (32 - $e[1])) - 1)) === ip2long($e[0]);
    }
public static function netMatch($CIDR, $IP)
    {
        /* TODO: IPV6 */
        if (is_array($CIDR)) {
            foreach ($CIDR as &$v) {
                if (self::netMatch($v, $IP)) {
                    return true;
                }
            }

            return false;
        }

        $e = explode('/', $CIDR, 2);

        if (!isset($e[1])) {
            return $e[0] === $IP;
        }

        return (ip2long($IP) & ~((1 << (32 - $e[1])) - 1)) === ip2long($e[0]);
    }
public static function netMatch ( $ CIDR , $ IP ) { /* TODO: IPV6 */ if ( is_array ( $ CIDR ) ) { foreach ( $ CIDR as & $ v ) { if ( self :: netMatch ( $ v , $ IP ) ) { return true ; } } return false ; } $ e = explode ( '/' , $ CIDR , 2 ) ; if ( ! isset ( $ e [ 1 ] ) ) { return $ e [ 0 ] === $ IP ; } return ( ip2long ( $ IP ) & ~ ( ( 1 << ( 32 - $ e [ 1 ] ) ) - 1 ) ) === ip2long ( $ e [ 0 ] ) ; }
Checks if the CIDR-mask matches the IP
@param string CIDR-mask
@param string IP
@return boolean Result
Checks if the CIDR - mask matches the IP