‪TYPO3CMS  11.5
TYPO3\CMS\Core\Utility\IpAnonymizationUtility Class Reference

Static Public Member Functions

static string anonymizeIp (string $address, ?int $mask=null)
 

Public Attributes

const MASKV4
 
const MASKV6
 

Detailed Description

Anonymize a given IP

Inspired by https://github.com/geertw/php-ip-anonymizer

Definition at line 25 of file IpAnonymizationUtility.php.

Member Function Documentation

◆ anonymizeIp()

static string TYPO3\CMS\Core\Utility\IpAnonymizationUtility::anonymizeIp ( string  $address,
?int  $mask = null 
)
static

Anonymize given IP

Parameters
string$address‪IP address
int | null$mask‪Allowed values are 0 (masking disabled), 1 (mask host), 2 (mask host and subnet)
Returns
‪string
Exceptions

Definition at line 61 of file IpAnonymizationUtility.php.

References $GLOBALS.

Referenced by TYPO3\CMS\Core\Tests\Unit\Utility\IpAnonymizationUtilityTest\anonymizeIpReturnsCorrectValue(), TYPO3\CMS\Scheduler\Task\IpAnonymizationTask\handleTable(), and TYPO3\CMS\Core\Tests\Unit\Utility\IpAnonymizationUtilityTest\wrongMaskForAnonymizeIpThrowsException().

Member Data Documentation

◆ MASKV4

const TYPO3\CMS\Core\Utility\IpAnonymizationUtility::MASKV4
Initial value:
= [
1 => '255.255.255.0',
2 => '255.255.0.0',
]

Definition at line 35 of file IpAnonymizationUtility.php.

◆ MASKV6

const TYPO3\CMS\Core\Utility\IpAnonymizationUtility::MASKV6
Initial value:
= [
1 => 'ffff:ffff:ffff:ffff:0000:0000:0000:0000',
2 => 'ffff:ffff:ffff:0000:0000:0000:0000:0000',
]

Definition at line 48 of file IpAnonymizationUtility.php.