Class cidr
Located at helper-classes/cidr.php
Methods summary
public static
|
#
cidr2netmask( mixed $cidr )
|
public static
|
#
ipv4_cidr2netmask( mixed $cidr )
|
public static
|
#
ipv6_cidr2netmask( mixed $cidr )
|
public static
|
#
cidr2network( mixed $ip, mixed $cidr )
|
public static
|
#
ipv4_cidr2network( mixed $ip, mixed $cidr )
|
public static
|
#
ipv6_cidr2network( mixed $ip, mixed $cidr )
|
public static
|
#
netmask2cidr( mixed $netmask )
|
public static
|
#
ipv4_netmask2cidr( mixed $netmask )
|
public static
|
#
ipv6_netmask2cidr( mixed $netmask )
|
public static
boolean|int[]
|
#
range2network( integer $start, integer $end )
Parameters
- $start
integer $start
- $end
integer $end
Returns
boolean|int[] FALSE if start/end do not match a network/mask. Otherwise : Array( 'network'
=> '10.0.0.0', 'mask' => 8, 'string' => '10.0.0.0/8')
|
public static
boolean
|
#
cidr_match( string $ip, string $network, integer $cidr )
Parameters
- $ip
string $ip
- $network
string $network
- $cidr
integer $cidr
Returns
boolean
|
public static
integer
|
#
netMatch( string|int[] $sub, string|int[] $ref )
return 0 if not match, 1 if $sub is included in $ref, 2 if $sub is partially
matched by $ref.
return 0 if not match, 1 if $sub is included in $ref, 2 if $sub is partially
matched by $ref.
Parameters
- $sub
string|int[] $sub ie: 192.168.0.2/24, 192.168.0.2,192.168.0.2-192.168.0.4
- $ref
string|int[] $ref
Returns
integer
|
public static
&
|
#
stringToStartEnd( mixed $value )
|
public static
&
|
#
IPv6network2StartEnd( mixed $ip )
|
public static
string
|
#
inet_ptoi( string $ip )
Converts human readable representation to a 128 bit int which can be stored
in MySQL using DECIMAL(39,0).
Converts human readable representation to a 128 bit int which can be stored
in MySQL using DECIMAL(39,0).
Requires PHP to be compiled with IPv6 support. This could be made to work
without IPv6 support but I don't think there would be much use for it if PHP
doesn't support IPv6.
Parameters
- $ip
string $ip IPv4 or IPv6 address to convert
Returns
string 128 bit string that can be used with DECIMNAL(39,0) or false
|
public static
string
|
#
inet_itop( string $decimal )
Converts a 128 bit int to a human readable representation.
Converts a 128 bit int to a human readable representation.
Requires PHP to be compiled with IPv6 support. This could be made to work
without IPv6 support but I don't think there would be much use for it if PHP
doesn't support IPv6.
Parameters
- $decimal
string $decimal 128 bit int
Returns
string IPv4 or IPv6 PROBLEM BY USING IT WITH IPV4 0.X.X.X MAYBE AS NETMASK/WILDCARD AS
IT RETURN IPV6
|