Anonymizes an IP address.
Description
Taken from https://github.com/geertw/php-ip-anonymizer/blob/master/src/IpAnonymizer.php.
See also
Parameters
- $address
-
(string) (Required) IPv4 or IPv6 address.
Return
(string) Anonymized IP address.
Source
File: src/db-objects/submissions/submission-manager.php
protected function anonymize_ip_address( $address ) { $packed_address = inet_pton( $address ); if ( strlen( $packed_address ) === 4 ) { return inet_ntop( $packed_address & inet_pton( '255.255.255.0' ) ); } if ( strlen( $packed_address ) === 16 ) { return inet_ntop( $packed_address & inet_pton( 'ffff:ffff:ffff:ffff:0000:0000:0000:0000' ) ); } return ''; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |