src/IPSet.php
public function match( $ip ) {
		$raw = AtEase::quietCall( 'inet_pton', $ip );
		if ( $raw === false ) {
			return false;
		}

		$rawOrd = array_map( 'ord', str_split( $raw ) );
		if ( count( $rawOrd ) == 4 ) {
			$node =& $this->root4;
		} else {
			$node =& $this->root6;
		}

		$curBit = 0;
		while ( $node !== true && $node !== false ) {
			if ( isset( $node['comp'] ) ) {
				// compressed node, matches 1 whole byte on a byte boundary
				if ( $rawOrd[$curBit >> 3] != $node['comp'] ) {
					return false;
				}
				$curBit += 8;
				$node =& $node['next'];
			} else {
				// uncompressed node, walk in the correct direction for the current bit-value
				$maskShift = 7 - ( $curBit & 7 );
				$node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift];
				++$curBit;
			}
		}

		return $node;
	}
public function match( $ip ) {
		$raw = AtEase::quietCall( 'inet_pton', $ip );
		if ( $raw === false ) {
			return false;
		}

		$rawOrd = array_map( 'ord', str_split( $raw ) );
		if ( count( $rawOrd ) == 4 ) {
			$node =& $this->root4;
		} else {
			$node =& $this->root6;
		}

		$curBit = 0;
		while ( $node !== true && $node !== false ) {
			if ( isset( $node['comp'] ) ) {
				// compressed node, matches 1 whole byte on a byte boundary
				if ( $rawOrd[$curBit >> 3] != $node['comp'] ) {
					return false;
				}
				$curBit += 8;
				$node =& $node['next'];
			} else {
				// uncompressed node, walk in the correct direction for the current bit-value
				$maskShift = 7 - ( $curBit & 7 );
				$node =& $node[( $rawOrd[$curBit >> 3] & ( 1 << $maskShift ) ) >> $maskShift];
				++$curBit;
			}
		}

		return $node;
	}
public function match ( $ ip ) { $ raw = AtEase :: quietCall ( 'inet_pton' , $ ip ) ; if ( $ raw === false ) { return false ; } $ rawOrd = array_map ( 'ord' , str_split ( $ raw ) ) ; if ( count ( $ rawOrd ) == 4 ) { $ node = & $ this -> root4 ; } else { $ node = & $ this -> root6 ; } $ curBit = 0 ; while ( $ node !== true && $ node !== false ) { if ( isset ( $ node [ 'comp' ] ) ) { // compressed node, matches 1 whole byte on a byte boundary if ( $ rawOrd [ $ curBit >> 3 ] != $ node [ 'comp' ] ) { return false ; } $ curBit += 8 ; $ node = & $ node [ 'next' ] ; } else { // uncompressed node, walk in the correct direction for the current bit-value $ maskShift = 7 - ( $ curBit & 7 ) ; $ node = & $ node [ ( $ rawOrd [ $ curBit >> 3 ] & ( 1 << $ maskShift ) ) >> $ maskShift ] ; ++ $ curBit ; } } return $ node ; }
Match an IP address against the set

If $ip is unparseable, inet_pton may issue an E_WARNING to that effect

@param string $ip string IPv[46] address
@return bool True is match success, false is match failure
Match an IP address against the set