PHP Класс FOF30\Utils\Ip

Makes sure that we get the real IP of the user
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$allowIpOverrides boolean Should I allow IP overrides through X-Forwarded-For or Client-Ip HTTP headers?
$ip string The IP address of the current visitor

Открытые методы

Метод Описание
IPinList ( string $ip, array | string $ipTable = '' ) : null | boolean Checks if an IP is contained in a list of IPs or IP expressions
getIp ( ) : string Get the current visitor's IP address
setAllowIpOverrides ( boolean $newState ) : void Should I allow the remote client's IP to be overridden by an X-Forwarded-For or Client-Ip HTTP header?
setIp ( string $ip ) : void Set the IP address of the current visitor
workaroundIPIssues ( ) Works around the REMOTE_ADDR not containing the user's IP

Защищенные методы

Метод Описание
checkIPv6CIDR ( string $ip, string $cidrnet ) : boolean Checks if an IPv6 address $ip is part of the IPv6 CIDR block $cidrnet
detectAndCleanIP ( ) : string Gets the visitor's IP address. Automatically handles reverse proxies reporting the IPs of intermediate devices, like load balancers. Examples: https://www.akeebabackup.com/support/admin-tools/13743-double-ip-adresses-in-security-exception-log-warnings.html http://stackoverflow.com/questions/2422395/why-is-request-envremote-addr-returning-two-ips The solution used is assuming that the last IP address is the external one.
detectIP ( ) : string Gets the visitor's IP address
inet_to_bits ( string $inet ) : string Converts inet_pton output to bits string
isIPv6 ( string $ip ) : boolean Is it an IPv6 IP address?

Описание методов

IPinList() публичный статический Метод

Checks if an IP is contained in a list of IPs or IP expressions
public static IPinList ( string $ip, array | string $ipTable = '' ) : null | boolean
$ip string The IPv4/IPv6 address to check
$ipTable array | string An IP expression (or a comma-separated or array list of IP expressions) to check against
Результат null | boolean True if it's in the list

checkIPv6CIDR() защищенный статический Метод

Checks if an IPv6 address $ip is part of the IPv6 CIDR block $cidrnet
protected static checkIPv6CIDR ( string $ip, string $cidrnet ) : boolean
$ip string The IPv6 address to check, e.g. 21DA:00D3:0000:2F3B:02AC:00FF:FE28:9C5A
$cidrnet string The IPv6 CIDR block, e.g. 21DA:00D3:0000:2F3B::/64
Результат boolean

detectAndCleanIP() защищенный статический Метод

Gets the visitor's IP address. Automatically handles reverse proxies reporting the IPs of intermediate devices, like load balancers. Examples: https://www.akeebabackup.com/support/admin-tools/13743-double-ip-adresses-in-security-exception-log-warnings.html http://stackoverflow.com/questions/2422395/why-is-request-envremote-addr-returning-two-ips The solution used is assuming that the last IP address is the external one.
protected static detectAndCleanIP ( ) : string
Результат string

detectIP() защищенный статический Метод

Gets the visitor's IP address
protected static detectIP ( ) : string
Результат string

getIp() публичный статический Метод

Get the current visitor's IP address
public static getIp ( ) : string
Результат string

inet_to_bits() защищенный статический Метод

Converts inet_pton output to bits string
protected static inet_to_bits ( string $inet ) : string
$inet string The in_addr representation of an IPv4 or IPv6 address
Результат string

isIPv6() защищенный статический Метод

Is it an IPv6 IP address?
protected static isIPv6 ( string $ip ) : boolean
$ip string An IPv4 or IPv6 address
Результат boolean True if it's IPv6

setAllowIpOverrides() публичный статический Метод

Should I allow the remote client's IP to be overridden by an X-Forwarded-For or Client-Ip HTTP header?
public static setAllowIpOverrides ( boolean $newState ) : void
$newState boolean True to allow the override
Результат void

setIp() публичный статический Метод

Set the IP address of the current visitor
public static setIp ( string $ip ) : void
$ip string
Результат void

workaroundIPIssues() публичный статический Метод

Works around the REMOTE_ADDR not containing the user's IP
public static workaroundIPIssues ( )

Описание свойств

$allowIpOverrides защищенное статическое свойство

Should I allow IP overrides through X-Forwarded-For or Client-Ip HTTP headers?
protected static bool $allowIpOverrides
Результат boolean

$ip защищенное статическое свойство

The IP address of the current visitor
protected static string $ip
Результат string