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) {
43 if (getConfig('removeip_anon_ip') == "Y") {
44 // Switch way do we like?
45 switch (getConfig('anonymous_ip')) {
46 case "127.0.0.1": // mod_removeip style
47 case "0.0.0.0": // Some people may prefer this...
48 $remoteAddr = getConfig('anonymous_ip');
51 case "RANDOM": // Pseudo-random IP number
52 $remoteAddr = mt_rand(1,254).".".mt_rand(0,254).".".mt_rand(0,254).".".mt_rand(1,254);
60 // "Getter" for anonymous remote hostname
61 function GET_ANONYMOUS_REMOTE_HOST ($remoteHost) {
63 if (getConfig('removeip_anon_host') == "Y") {
65 $remoteHost = "localhost.localnet";
71 // "Getter" for anonymous user agent
72 function GET_ANONYMOUS_USER_AGENT ($userAgent) {
74 if (getConfig('removeip_anon_ua') == "Y") {
75 // Set anon user agent
82 // "Getter" for anonymous referer
83 function GET_ANONYMOUS_REFERER ($referer) {
85 if (getConfig('removeip_anon_ref') == "Y") {
86 // Set anon user agent
93 // Adds informations about anonymity/privacy to the menu
94 function REMOVEIP_ADD_INFOS () {
95 // "Base-privacy" is by default low (we add more later)
98 // Is some data anonymized?
99 if (getConfig('removeip_anon_ip') == "Y") $anonymity++;
100 if (getConfig('removeip_anon_host') == "Y") $anonymity++;
101 if (getConfig('removeip_anon_ua') == "Y") $anonymity++;
102 if (getConfig('removeip_anon_ref') == "Y") $anonymity++;
104 // Calculate anonymity level
105 $level = round($anonymity / 4 * 3);
107 // Set constant name suffix depending on that level
108 $suffix = "unsupported_{$level}";
122 case 3: // High level
127 // Construct constant name
128 $constantName = strtoupper(sprintf("REMOVEIP_LEVEL_%s", $suffix));
131 $message = sprintf(REMOVEIP_UNKNOWN_LEVEL, $suffix);
133 // Is that constant there?
134 if (defined($constantName)) {
136 $message = constant($constantName);
139 // Output message in template
140 return LOAD_TEMPLATE("removeip_level", true, $message);
143 // Filter for adding anonymity notice to the output stream
144 function FILTER_ADD_ANONYMITY_NOTICE ($data) {
148 // Extension removeip activated?
149 if ((EXT_IS_ACTIVE("removeip")) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == "Y")) {
150 // Add anoymity/privacy infos
151 $content['content'] .= REMOVEIP_ADD_INFOS()."<br />\n";