Browse Source

Journal anonymisé

master
Fred Tempez 9 months ago
parent
commit
79df051d08
  1. 9
      core/class/helper.class.php
  2. 2
      core/core.php
  3. 6
      core/module/config/config.php
  4. 2
      core/module/user/user.php

9
core/class/helper.class.php

@ -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;
}

2
core/core.php

@ -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;

6
core/module/config/config.php

@ -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)',
];

2
core/module/user/user.php

@ -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 ;

Loading…
Cancel
Save