PHP Class JBZoo\Utils\IP

Datei anzeigen Open project: jbzoo/utils Class Usage Examples

Public Methods

Method Description
getNetMask ( $ipAddress ) : integer
getRemote ( boolean $trustProxy = false ) : string Returns the IP address of the client.
v4InRange ( string $ipAddress, string $range ) : boolean Check if a given ip is in a network

Method Details

getNetMask() public static method

public static getNetMask ( $ipAddress ) : integer
$ipAddress
return integer

getRemote() public static method

Returns the IP address of the client.
public static getRemote ( boolean $trustProxy = false ) : string
$trustProxy boolean Whether or not to trust the proxy headers HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR. ONLY use if your server is behind a proxy that sets these values
return string

v4InRange() public static method

Check if a given ip is in a network
See also: https://www.pgregg.com/projects/php/ip_in_range/
public static v4InRange ( string $ipAddress, string $range ) : boolean
$ipAddress string IP to check in IPV4 format eg. 127.0.0.1
$range string IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
return boolean