PHP Class Piwik\IP

As of Piwik 1.3, IP addresses are stored in the DB has VARBINARY(16), and passed around in network address format which has the advantage of being in big-endian byte order. This allows for binary-safe string comparison of addresses (of the same length), even on Intel x86. As a matter of naming convention, we use $ip for the network address format and $ipString for the presentation format (i.e., human-readable form). We're not using the network address format (in_addr) for socket functions, so we don't have to worry about incompatibility with Windows UNICODE and inetPtonW().
Datei anzeigen Open project: piwik/piwik Class Usage Examples

Public Methods

Method Description
getFirstIpFromList ( string $csv, array $excludedIps = null ) : string Returns the last IP address in a comma separated list, subject to an optional exclusion list.
getIpFromHeader ( ) : string Returns the most accurate IP address available for the current user, in IPv4 format. This could be the proxy client's IP address.
getNonProxyIpFromHeader ( string $default, array $proxyHeaders ) : string Returns a non-proxy IP address from header.

Method Details

getFirstIpFromList() public static method

Returns the last IP address in a comma separated list, subject to an optional exclusion list.
public static getFirstIpFromList ( string $csv, array $excludedIps = null ) : string
$csv string Comma separated list of elements.
$excludedIps array Optional list of excluded IP addresses (or IP address ranges).
return string Last (non-excluded) IP address in the list or an empty string if all given IPs are excluded.

getIpFromHeader() public static method

Returns the most accurate IP address available for the current user, in IPv4 format. This could be the proxy client's IP address.
public static getIpFromHeader ( ) : string
return string IP address in presentation format.

getNonProxyIpFromHeader() public static method

Returns a non-proxy IP address from header.
public static getNonProxyIpFromHeader ( string $default, array $proxyHeaders ) : string
$default string Default value to return if there no matching proxy header.
$proxyHeaders array List of proxy headers.
return string