diff --git a/core/class/helper.class.php b/core/class/helper.class.php index dd170082..4222b4a0 100644 --- a/core/class/helper.class.php +++ b/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; } diff --git a/core/core.php b/core/core.php index ac4243df..753f0ad0 100755 --- a/core/core.php +++ b/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; diff --git a/core/module/config/config.php b/core/module/config/config.php index 1b7262a7..83b83d63 100644 --- a/core/module/config/config.php +++ b/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)', ]; diff --git a/core/module/user/user.php b/core/module/user/user.php index 73db5078..fc343929 100644 --- a/core/module/user/user.php +++ b/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 ;