Download the PHP package arraypress/wp-ip-utils without Composer
On this page you can find all versions of the php package arraypress/wp-ip-utils. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arraypress/wp-ip-utils
More information about arraypress/wp-ip-utils
Files in arraypress/wp-ip-utils
Package wp-ip-utils
Short Description A lean WordPress utility for IP address validation, CIDR operations, and GDPR-compliant anonymization
License GPL-2.0-or-later
Homepage https://github.com/arraypress/wp-utils-ip/
Informations about the package wp-ip-utils
WordPress IP Utilities
Get the visitor's real IP, and check it against the rules you care about.
What it does
$_SERVER['REMOTE_ADDR'] is the proxy's address when there is a proxy, and
HTTP_X_FORWARDED_FOR is attacker-controlled unless you know which proxy you
trust. Getting this wrong means either everyone shares one IP, or anyone can
claim any IP they like.
This reads the forwarding headers only when the connecting address is a proxy
you have declared, and falls back to REMOTE_ADDR otherwise. Then it answers
the follow-ups: is this in that CIDR range, does it match that wildcard, and
what does it look like with the last octet dropped for GDPR.
Features
- Read the visitor's IP, honouring forwarding headers only from trusted proxies
- Validate IPv4 and IPv6, and tell private ranges from public ones
- Test membership of a CIDR range, or a list of ranges
- Match wildcard patterns like
192.168.1.*for block lists - Anonymise for GDPR by masking the last octet, or the last 80 bits of IPv6
- Recognise Cloudflare, and read its ray id
- Validate and clean a user-entered list of IPs and patterns
Installation
Quick start
Requirements
- PHP 8.3 or later
- WordPress 7.1 or later
License
GPL-2.0-or-later