Journal anonymisé

This commit is contained in:
Fred Tempez 2021-10-11 17:53:41 +02:00
parent c90ca726c9
commit 79df051d08
4 changed files with 12 additions and 7 deletions

View File

@ -37,8 +37,13 @@ class helper {
else{
$ip=$_SERVER['REMOTE_ADDR'];
}
switch ($anon):
$ip='192.168.12.56';
// Anonymiser l'adresse IP v4
$d = array_slice(explode('.', $ip), 0, $anon);
$d = implode ('.', $d);
$j = array_fill(0, 4 - $anon, 'x');
$k = implode ('.', $j);
$ip = count($j) == 0 ? $d : $d . '.' . $k;
return $ip;
}

View File

@ -2260,7 +2260,7 @@ class core extends common {
$dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true)
? strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';'
: utf8_encode(strftime('%d/%m/%y',time())) . ';' . utf8_encode(strftime('%R',time())) . ';' ;
$dataLog .= helper::getIp() . ';';
$dataLog .= helper::getIp($this->getData(['config','connect','anonymousIp'])) . ';';
$dataLog .= $this->getUser('id') ? $this->getUser('id') . ';' : 'anonyme' . ';';
$dataLog .= $this->getUrl();
$dataLog .= PHP_EOL;

View File

@ -180,10 +180,10 @@ class config extends common {
];
// Anonymisation des IP du journal
public static $anonIP = [
0 => 'Non tronquées',
1 => 'Niveau 1 (192.168.12.x)',
4 => 'Non tronquées',
3 => 'Niveau 1 (192.168.12.x)',
2 => 'Niveau 2 (192.168.x.x)',
3 => 'Niveau 3 (192.x.x.x)',
1 => 'Niveau 3 (192.x.x.x)',
];

View File

@ -490,7 +490,7 @@ class user extends common {
$dataLog = mb_detect_encoding(strftime('%d/%m/%y',time()), 'UTF-8', true)
? strftime('%d/%m/%y',time()) . ';' . strftime('%R',time()) . ';'
: utf8_encode(strftime('%d/%m/%y',time())) . ';' . utf8_encode(strftime('%R',time())) . ';' ;
$dataLog .= helper::getIp() . ';';
$dataLog .= helper::getIp($this->getData(['config','connect','anonymousIp'])) . ';';
$dataLog .= $this->getInput('userLoginId', helper::FILTER_ID) . ';' ;
$dataLog .= $this->getUrl() .';' ;
$dataLog .= $logStatus ;