PHP Class Longman\IPTools\Ip

Mostrar archivo Open project: akalongman/php-ip-tools Class Usage Examples

Protected Properties

Property Type Description
$ip
$isv6

Public Methods

Method Description
compare ( string $ip, string $range ) : boolean Checks if an IP is part of an IP range.
ip2long ( string $ip ) : long Gets IP long representation
isLocal ( string $ip ) : boolean Checks if an IP is local
isRemote ( string $ip ) : boolean Checks if an IP is remot
isValid ( string $ip ) : boolean Checks if an IP is valid.
isValidv4 ( string $ip ) : boolean Checks if an IP is valid IPv4 format.
isValidv6 ( string $ip ) : boolean Checks if an IP is valid IPv6 format.
long2ip ( long $dec, $ipv6 = false ) : string Gets IP string representation from IP long
match ( string $ip, $ranges ) : boolean Checks if an IP is part of an IP range.
matchRange ( $ip, $range )

Protected Methods

Method Description
processWithAsterisk ( string $range ) : boolean Checks if an IP is part of an IP range.
processWithMinus ( string $range ) : boolean Checks if an IP is part of an IP range.
processWithSlash ( string $range ) : boolean Checks if an IP is part of an IP range.

Method Details

compare() public static method

Checks if an IP is part of an IP range.
public static compare ( string $ip, string $range ) : boolean
$ip string IPv4/IPv6
$range string IP range specified in one of the following formats: Wildcard format: 1.2.3.* OR 2001:cdba:0000:0000:0000:0000:3257:* CIDR format: 1.2.3/24 OR 1.2.3.4/255.255.255.0 Start-End IP format: 1.2.3.0-1.2.3.255 OR 2001:cdba:0000:0000:0000:0000:3257:0001-2001:cdba:0000:0000:0000:0000:3257:1000
return boolean true if IP is part of range, otherwise false.

ip2long() public static method

Gets IP long representation
public static ip2long ( string $ip ) : long
$ip string IPv4 or IPv6
return long If IP is valid returns IP long representation, otherwise -1.

isLocal() public static method

Checks if an IP is local
public static isLocal ( string $ip ) : boolean
$ip string IP
return boolean true if the IP is local, otherwise false

isRemote() public static method

Checks if an IP is remot
public static isRemote ( string $ip ) : boolean
$ip string IP
return boolean true if the IP is remote, otherwise false

isValid() public static method

Checks if an IP is valid.
public static isValid ( string $ip ) : boolean
$ip string IP
return boolean true if IP is valid, otherwise false.

isValidv4() public static method

Checks if an IP is valid IPv4 format.
public static isValidv4 ( string $ip ) : boolean
$ip string IP
return boolean true if IP is valid IPv4, otherwise false.

isValidv6() public static method

Checks if an IP is valid IPv6 format.
public static isValidv6 ( string $ip ) : boolean
$ip string IP
return boolean true if IP is valid IPv6, otherwise false.

long2ip() public static method

Gets IP string representation from IP long
public static long2ip ( long $dec, $ipv6 = false ) : string
$dec long IPv4 or IPv6 long
return string If IP is valid returns IP string representation, otherwise ''.

match() public static method

Checks if an IP is part of an IP range.
public static match ( string $ip, $ranges ) : boolean
$ip string IPv4/IPv6
return boolean true if IP is part of range, otherwise false.

matchRange() public static method

public static matchRange ( $ip, $range )

processWithAsterisk() protected static method

Checks if an IP is part of an IP range.
protected static processWithAsterisk ( string $range ) : boolean
$range string IP range specified in one of the following formats: Wildcard format: 1.2.3.* OR 2001:cdba:0000:0000:0000:0000:3257:*
return boolean true if IP is part of range, otherwise false.

processWithMinus() protected static method

Checks if an IP is part of an IP range.
protected static processWithMinus ( string $range ) : boolean
$range string IP range specified in one of the following formats: Start-End IP format: 1.2.3.0-1.2.3.255 OR 2001:cdba:0000:0000:0000:0000:3257:0001-2001:cdba:0000:0000:0000:0000:3257:1000
return boolean true if IP is part of range, otherwise false.

processWithSlash() protected static method

Checks if an IP is part of an IP range.
protected static processWithSlash ( string $range ) : boolean
$range string IP range specified in one of the following formats: CIDR format: 1.2.3/24 OR 1.2.3.4/255.255.255.0
return boolean true if IP is part of range, otherwise false.

Property Details

$ip protected_oe static_oe property

protected static $ip

$isv6 protected_oe static_oe property

protected static $isv6