Submission_Manager::anonymize_ip_address( string $address )

Anonymizes an IP address.

Description

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

Changelog
Version Description
1.0.0 Introduced.