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 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // "Getter" for anonymous remote IP number
41 function GET_ANONYMOUS_REMOTE_ADDR ($remoteAddr) {
45 if ($_CONFIG['removeip_anon_ip'] == "Y") {
46 // Switch way do we like?
47 switch ($_CONFIG['anonymous_ip']) {
48 case "127.0.0.1": // mod_removeip style
49 case "0.0.0.0": // Some people may prefer this...
50 $remoteAddr = $_CONFIG['anonymous_ip'];
53 case "RANDOM": // Pseudo-random IP number
54 $remoteAddr = mt_rand(1,254).".".mt_rand(0,254).".".mt_rand(0,254).".".mt_rand(1,254);
62 // "Getter" for anonymous remote hostname
63 function GET_ANONYMOUS_REMOTE_HOST ($remoteHost) {
67 if ($_CONFIG['removeip_anon_host'] == "Y") {
69 $remoteHost = "localhost.localnet";
75 // "Getter" for anonymous user agent
76 function GET_ANONYMOUS_USER_AGENT ($userAgent) {
80 if ($_CONFIG['removeip_anon_ua'] == "Y") {
81 // Set anon user agent
88 // "Getter" for anonymous referer
89 function GET_ANONYMOUS_REFERER ($referer) {
93 if ($_CONFIG['removeip_anon_ref'] == "Y") {
94 // Set anon user agent
101 // Adds informations about anonymity/privacy to the menu
102 function REMOVEIP_ADD_INFOS () {
105 // "Base-privacy" is by default low (we add more later)
108 // Is some data anonymized?
109 if ($_CONFIG['removeip_anon_ip'] == "Y") $anonymity++;
110 if ($_CONFIG['removeip_anon_host'] == "Y") $anonymity++;
111 if ($_CONFIG['removeip_anon_ua'] == "Y") $anonymity++;
112 if ($_CONFIG['removeip_anon_ref'] == "Y") $anonymity++;
114 // Calculate anonymity level
115 $level = round($anonymity / 4 * 3);
117 // Set constant name suffix depending on that level
118 $suffix = "unsupported_{$level}";
132 case 3: // High level
137 // Construct constant name
138 $constantName = strtoupper(sprintf("REMOVEIP_LEVEL_%s", $suffix));
141 $message = sprintf(REMOVEIP_UNKNOWN_LEVEL, $suffix);
143 // Is that constant there?
144 if (defined($constantName)) {
146 $message = constant($constantName);
149 // Output message in template
150 return LOAD_TEMPLATE("removeip_level", true, $message);