IpHelper
IpHelper is a utility class for processing IP addresses
| since |
1.6.0 |
|---|---|
| package |
Joomla Framework |
Methods
__construct
Private constructor to prevent instantiation of this class
__construct() :
| since |
1.6.0 |
|---|
Response
mixed
checkIPv6CIDR
Checks if an IPv6 address $ip is part of the IPv6 CIDR block $cidrnet
checkIPv6CIDR( ip, cidrnet) :
| since |
1.6.0 |
|---|
Arguments
- ip
stringThe IPv6 address to check, e.g. 21DA:00D3:0000:2F3B:02AC:00FF:FE28:9C5A- cidrnet
stringThe IPv6 CIDR block, e.g. 21DA:00D3:0000:2F3B::/64
Response
bool
detectAndCleanIP
Gets the visitor's IP address.
detectAndCleanIP() :
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
- https://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.
| since |
1.6.0 |
|---|
Response
string
detectIP
Gets the visitor's IP address
detectIP() :
| since |
1.6.0 |
|---|
Response
string
getIp
Get the current visitor's IP address
getIp() :
| since |
1.6.0 |
|---|
Response
string
inetToBits
Converts inet_pton output to bits string
inetToBits( inet) :
| since |
1.6.0 |
|---|
Arguments
- inet
stringThe in_addr representation of an IPv4 or IPv6 address
Response
string
IPinList
Checks if an IP is contained in a list of IPs or IP expressions
IPinList( ip, array|string ipTable = '') :
| since |
1.6.0 |
|---|
Arguments
- ip
stringThe IPv4/IPv6 address to check- ipTable
array<string|int, mixed>|stringAn IP expression (or a comma-separated or array list of IP expressions) to check against
Response
bool
isIPv6
Is it an IPv6 IP address?
isIPv6( ip) :
| since |
1.6.0 |
|---|
Arguments
- ip
stringAn IPv4 or IPv6 address
Response
bool
setAllowIpOverrides
Should I allow the remote client's IP to be overridden by an X-Forwarded-For or Client-Ip HTTP header?
setAllowIpOverrides( newState) :
| since |
1.6.0 |
|---|
Arguments
- newState
boolTrue to allow the override
Response
void
setIp
Set the IP address of the current visitor
setIp( ip) :
| since |
1.6.0 |
|---|
Arguments
- ip
stringThe visitor's IP address
Response
void
workaroundIPIssues
Works around the REMOTE_ADDR not containing the user's IP
workaroundIPIssues() :
| since |
1.6.0 |
|---|
Response
void
Properties
ip
The IP address of the current visitor
| since |
1.6.0 |
|---|
Type(s)
string
allowIpOverrides
Should I allow IP overrides through X-Forwarded-For or Client-Ip HTTP headers?
| since |
1.6.0 |
|---|---|
| note |
The default value is false in version 2.0+ |
Type(s)
bool