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() : mixed
since |
1.6.0 |
---|
Response
mixed
checkIPv6CIDR
Checks if an IPv6 address $ip is part of the IPv6 CIDR block $cidrnet
checkIPv6CIDR(string ip, string cidrnet) : bool
since |
1.6.0 |
---|
Arguments
- 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
Response
bool
detectAndCleanIP
Gets the visitor's IP address.
detectAndCleanIP() : string
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() : string
since |
1.6.0 |
---|
Response
string
getIp
Get the current visitor's IP address
getIp() : string
since |
1.6.0 |
---|
Response
string
inetToBits
Converts inet_pton output to bits string
inetToBits(string inet) : string
since |
1.6.0 |
---|
Arguments
- inet
string
The 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(string ip, array|string ipTable = '') : bool
since |
1.6.0 |
---|
Arguments
- 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
Response
bool
isIPv6
Is it an IPv6 IP address?
isIPv6(string ip) : bool
since |
1.6.0 |
---|
Arguments
- ip
string
An 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(bool newState) : void
since |
1.6.0 |
---|
Arguments
- newState
bool
True to allow the override
setIp
Set the IP address of the current visitor
setIp(string ip) : void
since |
1.6.0 |
---|
Arguments
- ip
string
The visitor's IP address
workaroundIPIssues
Works around the REMOTE_ADDR not containing the user's IP
workaroundIPIssues() : void
since |
1.6.0 |
---|
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