2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 10/01/2008 *
4 * =================== Last change: 10/01/2008 *
6 * -------------------------------------------------------------------- *
7 * File : removeip_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Special functions for removeip extension *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Spezielle Funktion fuer removeip-Erweiterung *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
45 // "Getter" for anonymous remote IP number
46 function getAnonymousRemoteAddress ($remoteAddr) {
48 if (getConfig('removeip_anon_ip') == 'Y') {
49 // Switch way do we like?
50 switch (getConfig('anonymous_ip')) {
51 case 'LOCAL': // localhost
52 $remoteAddr = '127.0.0.1';
55 case 'ZERO': // All four numbers zero
56 $remoteAddr = '0.0.0.0';
59 case 'RANDOM': // Generate random ip
60 $remoteAddr = mt_rand(1, 254) . '.' . mt_rand(0, 254) . '.'.mt_rand(0, 254) . '.' . mt_rand(1, 254);
69 // "Getter" for anonymous remote hostname
70 function getAnonymousRemoteHost ($remoteHost) {
72 if (getConfig('removeip_anon_host') == 'Y') {
74 $remoteHost = 'localhost.localnet';
81 // "Getter" for anonymous user agent
82 function getAnonymousUserAgent ($userAgent) {
84 if (getConfig('removeip_anon_ua') == 'Y') {
85 // Set anon user agent
93 // "Getter" for anonymous referer
94 function getAnonymousReferer ($referer) {
96 if (getConfig('removeip_anon_ref') == 'Y') {
97 // Set anon user agent
105 // Adds informations about anonymity/privacy to the menu
106 function addAnonymityLevel () {
107 // "Base-privacy" is by default low (we add more later)
110 // Is some data anonymized?
111 if (getConfig('removeip_anon_ip') == 'Y') $anonymity++;
112 if (getConfig('removeip_anon_host') == 'Y') $anonymity++;
113 if (getConfig('removeip_anon_ua') == 'Y') $anonymity++;
114 if (getConfig('removeip_anon_ref') == 'Y') $anonymity++;
116 // Calculate anonymity level
117 $level = round($anonymity / 4 * 3);
119 // Set constant name suffix depending on that level
120 $suffix = 'unsupported_' . $level;
134 case '3': // High level
139 // Construct constant name
140 $constantName = sprintf("REMOVEIP_LEVEL_%s", strtoupper($suffix));
143 $message = getMaskedMessage('REMOVEIP_UNKNOWN_LEVEL', $suffix);
145 // Is that constant there?
146 if (isMessageIdValid($constantName)) {
148 $message = getMessage($constantName);
151 // Output message in template
152 return loadTemplate('removeip_level', true, $message);
155 // Filter for adding anonymity notice to the output stream
156 function FILTER_ADD_ANONYMITY_NOTICE ($data) {
160 // Extension removeip activated?
161 if ((isExtensionActive('removeip')) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == 'Y')) {
162 // Add anoymity/privacy infos
163 $content['content'] .= addAnonymityLevel() . "<br />\n";