]> git.mxchange.org Git - mailer.git/blob - inc/libs/removeip_functions.php
A lot eval() commands rewritten to constant() function
[mailer.git] / inc / libs / removeip_functions.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 10/01/2008 *
4  * ===============                              Last change: 10/01/2008 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : removeip_functions.php                           *
8  * -------------------------------------------------------------------- *
9  * Short description : Special functions for removeip extension         *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Spezielle Funktion fuer removeip-Erweiterung     *
12  * -------------------------------------------------------------------- *
13  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if (!defined('__SECURITY')) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // "Getter" for anonymous remote IP number
41 function GET_ANONYMOUS_REMOTE_ADDR ($remoteAddr) {
42         global $_CONFIG;
43
44         // Is config enabled?
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'];
51                                 break;
52
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);
55                                 break;
56                 } // END - switch
57         } // END - if
58
59         // Return it
60         return $remoteAddr;
61 }
62 // "Getter" for anonymous remote hostname
63 function GET_ANONYMOUS_REMOTE_HOST ($remoteHost) {
64         global $_CONFIG;
65
66         // Is config enabled?
67         if ($_CONFIG['removeip_anon_host'] == "Y") {
68                 // Set anon hostname
69                 $remoteHost = "localhost.localnet";
70         } // END - if
71
72         // Return it
73         return $remoteHost;
74 }
75 // "Getter" for anonymous user agent
76 function GET_ANONYMOUS_USER_AGENT ($userAgent) {
77         global $_CONFIG;
78
79         // Is config enabled?
80         if ($_CONFIG['removeip_anon_ua'] == "Y") {
81                 // Set anon user agent
82                 $userAgent = "-";
83         } // END - if
84
85         // Return it
86         return $userAgent;
87 }
88 // "Getter" for anonymous referer
89 function GET_ANONYMOUS_REFERER ($referer) {
90         global $_CONFIG;
91
92         // Is config enabled?
93         if ($_CONFIG['removeip_anon_ref'] == "Y") {
94                 // Set anon user agent
95                 $referer = "-";
96         } // END - if
97
98         // Return it
99         return $referer;
100 }
101 // Adds informations about anonymity/privacy to the menu
102 function REMOVEIP_ADD_INFOS () {
103         global $_CONFIG;
104
105         // "Base-privacy" is by default low (we add more later)
106         $anonymity = 0;
107
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++;
113
114         // Calculate anonymity level
115         $level = round($anonymity / 4 * 3);
116
117         // Set constant name suffix depending on that level
118         $suffix = "unsupported_{$level}";
119         switch ($level) {
120                 case 0:
121                         $suffix = "none";
122                         break;
123
124                 case 1:
125                         $suffix = "low";
126                         break;
127
128                 case 2:
129                         $suffix = "medium";
130                         break;
131
132                 case 3: // High level
133                         $suffix = "high";
134                         break;
135         } // END - while
136
137         // Construct constant name
138         $constantName = strtoupper(sprintf("REMOVEIP_LEVEL_%s", $suffix));
139
140         // Default message
141         $message = sprintf(REMOVEIP_UNKNOWN_LEVEL, $suffix);
142
143         // Is that constant there?
144         if (defined($constantName)) {
145                 // Use that string
146                 $message = constant($constantName);
147         } // END - if
148
149         // Output message in template
150         return LOAD_TEMPLATE("removeip_level", true, $message);
151 }
152
153 //
154 ?>