CoolCMS API

IpRange
in package

FinalYes

IP address or prefix range (IPv4 and IPv6), as stored in the IP blacklist (`cms_system_blacklists`, type 1).

A value is either a single address (192.168.1.10, 2001:db8::1) or a range with a prefix (192.168.1.0/24, 2001:db8::/32). An IPv4 address never matches an IPv6 range and vice versa; an IPv4-mapped IPv6 address (::ffff:1.2.3.4) is compared as IPv4.

Table of Contents

Methods

contains()  : bool
Tells whether the address lies in the range (a single address in the range = exact match).
isValid()  : bool
Tells whether the value is a valid address or prefix range.
parse()  : array{0: string, 1: int}|null
toBinary()  : string|null
Packed address; an IPv4-mapped IPv6 address is returned as 4 IPv4 bytes.

Methods

contains()

Tells whether the address lies in the range (a single address in the range = exact match).

public static contains(string $range, string $ip) : bool
Parameters
$range : string
$ip : string
Return values
bool

isValid()

Tells whether the value is a valid address or prefix range.

public static isValid(string $value) : bool
Parameters
$value : string
Return values
bool

parse()

private static parse(string $value) : array{0: string, 1: int}|null
Parameters
$value : string
Return values
array{0: string, 1: int}|null —

packed network address and prefix length

toBinary()

Packed address; an IPv4-mapped IPv6 address is returned as 4 IPv4 bytes.

private static toBinary(string $ip) : string|null
Parameters
$ip : string
Return values
string|null
On this page

Search results