]> git.mxchange.org Git - mailer.git/blob - inc/libs/removeip_functions.php
Reverted of changes in 1704, see ticket #160
[mailer.git] / inc / libs / removeip_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                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  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if (!defined('__SECURITY')) {
42         die();
43 }
44
45 // "Getter" for anonymous remote IP number
46 function getAnonymousRemoteAddress ($remoteAddr) {
47         // Is config enabled?
48         if (getConfig('removeip_anon_ip') == 'Y') {
49                 // Switch way do we like?
50                 switch (getConfig('anonymous_ip')) {
51                         case 'LOCAL': // localhost
52                                 $remoteAddr = '127.0.0.1';
53                                 break;
54
55                         case 'ZERO': // All four numbers zero
56                                 $remoteAddr = '0.0.0.0';
57                                 break;
58
59                         case 'RANDOM': // Generate random ip
60                                 $remoteAddr = mt_rand(1, 254) . '.' . mt_rand(0, 254) . '.'.mt_rand(0, 254) . '.' . mt_rand(1, 254);
61                                 break;
62                 } // END - switch
63         } // END - if
64
65         // Return it
66         return $remoteAddr;
67 }
68
69 // "Getter" for anonymous remote hostname
70 function getAnonymousRemoteHost ($remoteHost) {
71         // Is config enabled?
72         if (getConfig('removeip_anon_host') == 'Y') {
73                 // Set anon hostname
74                 $remoteHost = 'localhost.localnet';
75         } // END - if
76
77         // Return it
78         return $remoteHost;
79 }
80
81 // "Getter" for anonymous user agent
82 function getAnonymousUserAgent ($userAgent) {
83         // Is config enabled?
84         if (getConfig('removeip_anon_ua') == 'Y') {
85                 // Set anon user agent
86                 $userAgent = '-';
87         } // END - if
88
89         // Return it
90         return $userAgent;
91 }
92
93 // "Getter" for anonymous referer
94 function getAnonymousReferer ($referer) {
95         // Is config enabled?
96         if (getConfig('removeip_anon_ref') == 'Y') {
97                 // Set anon user agent
98                 $referer = '-';
99         } // END - if
100
101         // Return it
102         return $referer;
103 }
104
105 // Adds informations about anonymity/privacy to the menu
106 function addAnonymityLevel () {
107         // "Base-privacy" is by default low (we add more later)
108         $anonymity = '0';
109
110         // Is some data anonymized?
111         if (getConfig('removeip_anon_ip')   == 'Y') $anonymity++;
112         if (getConfig('removeip_anon_host') == 'Y') $anonymity++;
113         if (getConfig('removeip_anon_ua')   == 'Y') $anonymity++;
114         if (getConfig('removeip_anon_ref')  == 'Y') $anonymity++;
115
116         // Calculate anonymity level
117         $level = round($anonymity / 4 * 3);
118
119         // Set constant name suffix depending on that level
120         $suffix = 'unsupported_' . $level;
121         switch ($level) {
122                 case '0':
123                         $suffix = 'none';
124                         break;
125
126                 case '1':
127                         $suffix = 'low';
128                         break;
129
130                 case '2':
131                         $suffix = 'medium';
132                         break;
133
134                 case '3': // High level
135                         $suffix = 'high';
136                         break;
137         } // END - while
138
139         // Construct constant name
140         $constantName = sprintf("REMOVEIP_LEVEL_%s", strtoupper($suffix));
141
142         // Default message
143         $message = getMaskedMessage('REMOVEIP_UNKNOWN_LEVEL', $suffix);
144
145         // Is that constant there?
146         if (isMessageIdValid($constantName)) {
147                 // Use that string
148                 $message = getMessage($constantName);
149         } // END - if
150
151         // Output message in template
152         return loadTemplate('removeip_level', true, $message);
153 }
154
155 // Filter for adding anonymity notice to the output stream
156 function FILTER_ADD_ANONYMITY_NOTICE ($data) {
157         // Init content
158         $content = $data;
159
160         // Extension removeip activated?
161         if ((isExtensionActive('removeip')) && (getConfig('removeip_'.strtolower($data['access_level']).'_show') == 'Y')) {
162                 // Add anoymity/privacy infos
163                 $content['content'] .= addAnonymityLevel() . "<br />\n";
164         } // END - if
165
166         // Return it
167         return $content;
168 }
169
170 // [EOF]
171 ?>