2 /************************************************************************
3 * MXChange v0.2.1 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 * For more information visit: http://www.mxchange.org *
23 * This program is free software; you can redistribute it and/or modify *
24 * it under the terms of the GNU General Public License as published by *
25 * the Free Software Foundation; either version 2 of the License, or *
26 * (at your option) any later version. *
28 * This program is distributed in the hope that it will be useful, *
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
31 * GNU General Public License for more details. *
33 * You should have received a copy of the GNU General Public License *
34 * along with this program; if not, write to the Free Software *
35 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
37 ************************************************************************/
39 // Some security stuff...
40 if (!defined('__SECURITY')) {
44 // "Getter" for anonymous remote IP number
45 function getAnonymousRemoteAddress ($remoteAddr) {
47 if (getConfig('removeip_anon_ip') == 'Y') {
48 // Switch way do we like?
49 switch (getConfig('anonymous_ip')) {
50 case 'LOCAL': // localhost
51 $remoteAddr = '127.0.0.1';
54 case 'ZERO': // All four numbers zero
55 $remoteAddr = '0.0.0.0';
58 case 'RANDOM': // Generate random ip
59 $remoteAddr = mt_rand(1, 254) . '.' . mt_rand(0, 254) . '.'.mt_rand(0, 254) . '.' . mt_rand(1, 254);
68 // "Getter" for anonymous remote hostname
69 function getAnonymousRemoteHost ($remoteHost) {
71 if (getConfig('removeip_anon_host') == 'Y') {
73 $remoteHost = 'localhost.localnet';
80 // "Getter" for anonymous user agent
81 function getAnonymousUserAgent ($userAgent) {
83 if (getConfig('removeip_anon_ua') == 'Y') {
84 // Set anon user agent
92 // "Getter" for anonymous referer
93 function getAnonymousReferer ($referer) {
95 if (getConfig('removeip_anon_ref') == 'Y') {
96 // Set anon user agent
104 // Adds informations about anonymity/privacy to the menu
105 function addAnonymityLevel () {
106 // "Base-privacy" is by default low (we add more later)
109 // Is some data anonymized?
110 if (getConfig('removeip_anon_ip') == 'Y') $anonymity++;
111 if (getConfig('removeip_anon_host') == 'Y') $anonymity++;
112 if (getConfig('removeip_anon_ua') == 'Y') $anonymity++;
113 if (getConfig('removeip_anon_ref') == 'Y') $anonymity++;
115 // Calculate anonymity level
116 $level = round($anonymity / 4 * 3);
118 // Set constant name suffix depending on that level
119 $suffix = 'unsupported_' . $level;
133 case 3: // High level
138 // Construct constant name
139 $constantName = sprintf("REMOVEIP_LEVEL_%s", strtoupper($suffix));
142 $message = sprintf(getMessage('REMOVEIP_UNKNOWN_LEVEL'), $suffix);
144 // Is that constant there?
145 if (isMessageIdValid($constantName)) {
147 $message = getMessage($constantName);
150 // Output message in template
151 return loadTemplate('removeip_level', true, $message);
154 // Filter for adding anonymity notice to the output stream
155 function FILTER_ADD_ANONYMITY_NOTICE ($data) {
159 // Extension removeip activated?
160 if ((isExtensionActive('removeip')) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == 'Y')) {
161 // Add anoymity/privacy infos
162 $content['content'] .= addAnonymityLevel() . "<br />\n";