vBulletin v6.0.4

vB_Utility_Ip
in package
Uses vB_Utility_Trait_NoSerialize

Table of Contents

Methods

__serialize()  : array<string|int, mixed>
__sleep()  : array<string|int, mixed>
__unserialize()  : void
__wakeup()  : void
ipSubstring()  : mixed
Truncate an ipv4 address based on the number of octets requested
iptype()  : int
Get the type of an ip address
isInList()  : bool
Check to see if the IP is in a list of IP addresses
isIpV4()  : bool
Checks if the string is a valid ip v4 address
isIpV6()  : bool
Checks if the string is a valid ip v6 address
isPublic()  : bool
Checks if this is a valid public IP address
isValid()  : mixed
normalize()  : mixed
Normalizes an ip address string

Methods

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__sleep()

public __sleep() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(mixed $serialized) : void
Parameters
$serialized : mixed

ipSubstring()

Truncate an ipv4 address based on the number of octets requested

public ipSubstring( $ip,  $octets) : mixed

This will return the requested number of octets for an ipV4 address. An ipV6 address will be returned unchanged. The IP address is not validated and behavior for invalid IP addresses is not defined.

Parameters
$ip :

the ip address string

$octets :

-- the number of octets to return. The number should be between 1 and 4 inclusive, but is not validated.

iptype()

Get the type of an ip address

public iptype(string $ip) : int
Parameters
$ip : string
Return values
int

-- Returns 4 if a valid v4 address, 6 if a valid v6 address, 0 if not a valid address

isInList()

Check to see if the IP is in a list of IP addresses

public isInList(string $ip, array<string|int, mixed> $list) : bool
Parameters
$ip : string
$list : array<string|int, mixed>

-- array of ip address to check. In addition to proper ip addresses, it allows wildcard addresses that end in "". These will match any ip address for which they are a prefix (so 127.0. will match 127.0.0.1 as will 127.0*). Note that no formatting normalization will take place on these strings so "2607:f8b0:0000:*" will not match "2607:f8b0::4007:0:0:2004"

Return values
bool

-- true if the $ip matches anything in the list, false otherwise.

isIpV4()

Checks if the string is a valid ip v4 address

public isIpV4(string $ip) : bool
Parameters
$ip : string
Return values
bool

isIpV6()

Checks if the string is a valid ip v6 address

public isIpV6(string $ip) : bool
Parameters
$ip : string
Return values
bool

isPublic()

Checks if this is a valid public IP address

public isPublic(string $ip) : bool
Parameters
$ip : string
Return values
bool

-- Returns true if the IP address is valid (v4 or v6) and not in a private or restricted range

isValid()

public isValid(mixed $ip) : mixed
Parameters
$ip : mixed

normalize()

Normalizes an ip address string

public normalize(string $ip) : mixed

This is particularly important for ipv6 strings which have a number of shortcuts that will invalidate string matches. This will also trim whitespace from the string.

Parameters
$ip : string

        
On this page

Search results