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 - 2008 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')) {
41 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
45 // "Getter" for anonymous remote IP number
46 function GET_ANONYMOUS_REMOTE_ADDR ($remoteAddr) {
48 if (getConfig('removeip_anon_ip') == "Y") {
49 // Switch way do we like?
50 switch (getConfig('anonymous_ip')) {
51 case "127.0.0.1": // mod_removeip style
52 case "0.0.0.0": // Some people may prefer this...
53 $remoteAddr = getConfig('anonymous_ip');
56 case "RANDOM": // Pseudo-random IP number
57 $remoteAddr = mt_rand(1,254).".".mt_rand(0,254).".".mt_rand(0,254).".".mt_rand(1,254);
65 // "Getter" for anonymous remote hostname
66 function GET_ANONYMOUS_REMOTE_HOST ($remoteHost) {
68 if (getConfig('removeip_anon_host') == "Y") {
70 $remoteHost = "localhost.localnet";
76 // "Getter" for anonymous user agent
77 function GET_ANONYMOUS_USER_AGENT ($userAgent) {
79 if (getConfig('removeip_anon_ua') == "Y") {
80 // Set anon user agent
87 // "Getter" for anonymous referer
88 function GET_ANONYMOUS_REFERER ($referer) {
90 if (getConfig('removeip_anon_ref') == "Y") {
91 // Set anon user agent
98 // Adds informations about anonymity/privacy to the menu
99 function REMOVEIP_ADD_INFOS () {
100 // "Base-privacy" is by default low (we add more later)
103 // Is some data anonymized?
104 if (getConfig('removeip_anon_ip') == "Y") $anonymity++;
105 if (getConfig('removeip_anon_host') == "Y") $anonymity++;
106 if (getConfig('removeip_anon_ua') == "Y") $anonymity++;
107 if (getConfig('removeip_anon_ref') == "Y") $anonymity++;
109 // Calculate anonymity level
110 $level = round($anonymity / 4 * 3);
112 // Set constant name suffix depending on that level
113 $suffix = "unsupported_{$level}";
127 case 3: // High level
132 // Construct constant name
133 $constantName = strtoupper(sprintf("REMOVEIP_LEVEL_%s", $suffix));
136 $message = sprintf(REMOVEIP_UNKNOWN_LEVEL, $suffix);
138 // Is that constant there?
139 if (defined($constantName)) {
141 $message = constant($constantName);
144 // Output message in template
145 return LOAD_TEMPLATE("removeip_level", true, $message);
148 // Filter for adding anonymity notice to the output stream
149 function FILTER_ADD_ANONYMITY_NOTICE ($data) {
153 // Extension removeip activated?
154 if ((EXT_IS_ACTIVE("removeip")) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == "Y")) {
155 // Add anoymity/privacy infos
156 $content['content'] .= REMOVEIP_ADD_INFOS()."<br />\n";