summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/general.php28
-rw-r--r--pages/account/13.php7
2 files changed, 33 insertions, 2 deletions
diff --git a/includes/general.php b/includes/general.php
index 854aab4..43c0ce7 100644
--- a/includes/general.php
+++ b/includes/general.php
@@ -802,5 +802,33 @@
return $res;
}
+ /**
+ * Returns the given ip address truncated to /16 (ipv4) or to /48 (ipv6)
+ *
+ *
+ */
+ function anonymizeIP($ip){
+ $bits = @inet_pton($ip);
+ if($bits === false)
+ return false;
+
+ if(strlen($bits) == 4) {
+ $bits[2] = "\0";
+ $bits[3] = "\0";
+ $newIP = @inet_ntop($bits);
+ if($newIP !== false)
+ $newIP .= "/16";
+ return $newIP;
+ } else if(strlen($bits) == 16) {
+ for($i=6;$i<16;$i++){
+ $bits[$i]="\0";
+ }
+ $newIP = @inet_ntop($bits);
+ if($newIP !== false)
+ $newIP .= "/48";
+ return $newIP;
+ }
+ return false;
+ }
?>
diff --git a/pages/account/13.php b/pages/account/13.php
index d468b3d..5bbbfcb 100644
--- a/pages/account/13.php
+++ b/pages/account/13.php
@@ -27,10 +27,13 @@
if($showdetails){
$body = sprintf(_("Hi %s,"),$user['fname'])."\n\n";
+ $ip = anonymizeIp($_SERVER['REMOTE_ADDR']);
+ if($ip === false)
+ $ip = "Error";
$body .= sprintf(_("You receive this automatic mail since you yourself or someone ".
"else looked up your secret questions and answers for a forgotten ".
"password.\n\n".
- "IP-Address: %s\nTime: %s\n\n".
+ "Network: %s\nTime: %s\n\n".
"If it was you who looked up or changed that data, or clicked ".
"through the menu in your account, everything is in best order ".
"and you can ignore this mail.\n\n".
@@ -38,7 +41,7 @@
"there is a danger that an unauthorised person accessed your ".
"account, and you should promptly change your password and your ".
"secret questions and answers."),
- $_SERVER['REMOTE_ADDR'],
+ $ip,
date("Y-m-d H:i:s T"))."\n\n";
$body .= _("Best regards")."\n"._("CAcert Support");