From 3f4962990d057fe21cb3daa7f4687a7e77e51938 Mon Sep 17 00:00:00 2001 From: SJ Date: Thu, 25 Jul 2013 13:27:56 +0200 Subject: [PATCH] anonimize shown ip address in demo mode --- webui/config.php | 1 + webui/model/audit/audit.php | 2 +- webui/system/misc.php | 12 ++++++++++++ webui/view/theme/default/templates/stat/online.tpl | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/webui/config.php b/webui/config.php index 227d602c..e5e3fa93 100644 --- a/webui/config.php +++ b/webui/config.php @@ -29,6 +29,7 @@ $config['SITE_NAME'] = 'piler.yourdomain.com'; $config['SITE_URL'] = 'http://piler.yourdomain.com/'; $config['ENABLE_SAAS'] = 0; +$config['DEMO_MODE'] = 0; $config['TIMEZONE'] = 'Europe/Budapest'; diff --git a/webui/model/audit/audit.php b/webui/model/audit/audit.php index bc8477fe..0d0d3622 100644 --- a/webui/model/audit/audit.php +++ b/webui/model/audit/audit.php @@ -92,7 +92,7 @@ class ModelAuditAudit extends Model { 'action' => $a['action'], 'email' => $a['email'], 'date' => date(AUDIT_DATE_FORMAT, $a['ts']), - 'ipaddr' => $a['ipaddr'], + 'ipaddr' => DEMO_MODE == 1 ? anonimize_ip_addr($a['ipaddr']) : $a['ipaddr'], 'description' => $a['description'], 'shortdescription' => make_short_string($a['description'], MAX_CGI_FROM_SUBJ_LEN) ); diff --git a/webui/system/misc.php b/webui/system/misc.php index f5b29045..e73e8cd9 100644 --- a/webui/system/misc.php +++ b/webui/system/misc.php @@ -492,6 +492,18 @@ function safe_feof($fp, &$start = NULL) { } +function anonimize_ip_addr($ip = '') { + $ip = explode(".", $ip); + if(count($ip) == 4) { + $ip[0] = $ip[1] = 'x'; + + $ip = implode(".", $ip); + } + + return $ip; +} + + function get_ldap_attribute_names($ldap_type = '') { $ldap_mail_attr = LDAP_MAIL_ATTR; diff --git a/webui/view/theme/default/templates/stat/online.tpl b/webui/view/theme/default/templates/stat/online.tpl index f934f16e..553645f0 100644 --- a/webui/view/theme/default/templates/stat/online.tpl +++ b/webui/view/theme/default/templates/stat/online.tpl @@ -16,7 +16,7 @@ - +