849bdf42 |
1 | <?php |
15e6162e |
2 | /** |
0a1dc88e |
3 | * Message and Spam Filter Plugin - Filtering Functions |
15e6162e |
4 | * |
15e6162e |
5 | * This plugin filters your inbox into different folders based upon given |
6 | * criteria. It is most useful for people who are subscibed to mailing lists |
7 | * to help organize their messages. The argument stands that filtering is |
8 | * not the place of the client, which is why this has been made a plugin for |
9 | * SquirrelMail. You may be better off using products such as Sieve or |
10 | * Procmail to do your filtering so it happens even when SquirrelMail isn't |
11 | * running. |
12 | * |
13 | * If you need help with this, or see improvements that can be made, please |
14 | * email me directly at the address above. I definately welcome suggestions |
15 | * and comments. This plugin, as is the case with all SquirrelMail plugins, |
16 | * is not directly supported by the developers. Please come to me off the |
17 | * mailing list if you have trouble with it. |
18 | * |
19 | * Also view plugins/README.plugins for more information. |
20 | * |
5b4ba967 |
21 | * @version $Id$ |
6c84ba1e |
22 | * @copyright (c) 1999-2005 The SquirrelMail Project Team |
b2d8bc6c |
23 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
ea5f4b8e |
24 | * @package plugins |
25 | * @subpackage filters |
15e6162e |
26 | */ |
4eee5968 |
27 | |
ea5f4b8e |
28 | /** |
0a1dc88e |
29 | * FIXME: Undocumented function |
30 | * @access private |
5b4ba967 |
31 | */ |
a2a566eb |
32 | function filters_SaveCache () { |
33 | global $data_dir, $SpamFilters_DNScache; |
34 | |
ae48f757 |
35 | if (file_exists($data_dir . '/dnscache')) { |
36 | $fp = fopen($data_dir . '/dnscache', 'r'); |
a2a566eb |
37 | } else { |
38 | $fp = false; |
39 | } |
40 | if ($fp) { |
41 | flock($fp,LOCK_EX); |
42 | } else { |
ae48f757 |
43 | $fp = fopen($data_dir . '/dnscache', 'w+'); |
a2a566eb |
44 | fclose($fp); |
ae48f757 |
45 | $fp = fopen($data_dir . '/dnscache', 'r'); |
a2a566eb |
46 | flock($fp,LOCK_EX); |
47 | } |
ae48f757 |
48 | $fp1=fopen($data_dir . '/dnscache', 'w+'); |
a2a566eb |
49 | |
50 | foreach ($SpamFilters_DNScache as $Key=> $Value) { |
51 | $tstr = $Key . ',' . $Value['L'] . ',' . $Value['T'] . "\n"; |
52 | fputs ($fp1, $tstr); |
53 | } |
54 | fclose($fp1); |
55 | flock($fp,LOCK_UN); |
56 | fclose($fp); |
57 | } |
58 | |
0a1dc88e |
59 | /** |
60 | * FIXME: Undocumented function |
61 | * @access private |
62 | */ |
a2a566eb |
63 | function filters_LoadCache () { |
64 | global $data_dir, $SpamFilters_DNScache; |
65 | |
ae48f757 |
66 | if (file_exists($data_dir . '/dnscache')) { |
6ade76e0 |
67 | $SpamFilters_DNScache = array(); |
ae48f757 |
68 | if ($fp = fopen ($data_dir . '/dnscache', 'r')) { |
a2a566eb |
69 | flock($fp,LOCK_SH); |
70 | while ($data=fgetcsv($fp,1024)) { |
71 | if ($data[2] > time()) { |
72 | $SpamFilters_DNScache[$data[0]]['L'] = $data[1]; |
73 | $SpamFilters_DNScache[$data[0]]['T'] = $data[2]; |
74 | } |
75 | } |
76 | |
77 | flock($fp,LOCK_UN); |
78 | } |
79 | } |
80 | } |
81 | |
0a1dc88e |
82 | /** |
83 | * FIXME: Undocumented function |
84 | * @access private |
85 | */ |
fb577a4d |
86 | function filters_bulkquery($filters, $IPs) { |
ce68b76b |
87 | global $attachment_dir, $username, |
6ade76e0 |
88 | $SpamFilters_DNScache, $SpamFilters_BulkQuery, |
89 | $SpamFilters_CacheTTL; |
a2a566eb |
90 | |
a2a566eb |
91 | if (count($IPs) > 0) { |
92 | $rbls = array(); |
93 | foreach ($filters as $key => $value) { |
94 | if ($filters[$key]['enabled']) { |
95 | if ($filters[$key]['dns']) { |
96 | $rbls[$filters[$key]['dns']] = true; |
97 | } |
98 | } |
99 | } |
100 | |
ae48f757 |
101 | $bqfil = $attachment_dir . $username . '-bq.in'; |
102 | $fp = fopen($bqfil, 'w'); |
6ade76e0 |
103 | fputs ($fp, $SpamFilters_CacheTTL . "\n"); |
a2a566eb |
104 | foreach ($rbls as $key => $value) { |
ae48f757 |
105 | fputs ($fp, '.' . $key . "\n"); |
a2a566eb |
106 | } |
107 | fputs ($fp, "----------\n"); |
108 | foreach ($IPs as $key => $value) { |
109 | fputs ($fp, $key . "\n"); |
110 | } |
111 | fclose ($fp); |
112 | $bqout = array(); |
ae48f757 |
113 | exec ($SpamFilters_BulkQuery . ' < ' . $bqfil, $bqout); |
a2a566eb |
114 | foreach ($bqout as $value) { |
115 | $Chunks = explode(',', $value); |
116 | $SpamFilters_DNScache[$Chunks[0]]['L'] = $Chunks[1]; |
117 | $SpamFilters_DNScache[$Chunks[0]]['T'] = $Chunks[2] + time(); |
118 | } |
119 | unlink($bqfil); |
120 | } |
121 | } |
122 | |
0a1dc88e |
123 | /** |
124 | * FIXME: Undocumented function |
125 | * @access private |
126 | */ |
10a26cea |
127 | function start_filters() { |
ce68b76b |
128 | global $imapServerAddress, $imapPort, $imap_stream, $imapConnection, |
3c66c567 |
129 | $UseSeparateImapConnection, $AllowSpamFilters; |
41100fce |
130 | |
3c66c567 |
131 | sqgetGlobalVar('username', $username, SQ_SESSION); |
132 | sqgetGlobalVar('key', $key, SQ_COOKIE); |
10a26cea |
133 | |
2714d4ff |
134 | // Detect if we have already connected to IMAP or not. |
135 | // Also check if we are forced to use a separate IMAP connection |
136 | if ((!isset($imap_stream) && !isset($imapConnection)) || |
137 | $UseSeparateImapConnection ) { |
138 | $stream = sqimap_login($username, $key, $imapServerAddress, |
139 | $imapPort, 10); |
140 | $previously_connected = false; |
141 | } else if (isset($imapConnection)) { |
142 | $stream = $imapConnection; |
143 | $previously_connected = true; |
144 | } else { |
145 | $previously_connected = true; |
146 | $stream = $imap_stream; |
147 | } |
148 | $aStatus = sqimap_status_messages ($stream, 'INBOX', array('MESSAGES')); |
4eee5968 |
149 | |
2714d4ff |
150 | if ($aStatus['MESSAGES']) { |
151 | sqimap_mailbox_select($stream, 'INBOX'); |
152 | // Filter spam from inbox before we sort them into folders |
153 | if ($AllowSpamFilters) { |
154 | spam_filters($stream); |
10a26cea |
155 | } |
4eee5968 |
156 | |
2714d4ff |
157 | // Sort into folders |
158 | user_filters($stream); |
159 | } |
160 | |
161 | if (!$previously_connected) { |
162 | sqimap_logout($stream); |
163 | } |
10a26cea |
164 | } |
165 | |
0a1dc88e |
166 | /** |
167 | * FIXME: Undocumented function |
168 | * @access private |
169 | */ |
10a26cea |
170 | function user_filters($imap_stream) { |
c8a2c24d |
171 | global $data_dir, $username; |
10a26cea |
172 | $filters = load_filters(); |
173 | if (! $filters) return; |
c8a2c24d |
174 | $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan'); |
10a26cea |
175 | |
fb577a4d |
176 | $expunge = false; |
53fcc494 |
177 | // For every rule |
ae48f757 |
178 | for ($i=0, $num = count($filters); $i < $num; $i++) { |
10a26cea |
179 | // If it is the "combo" rule |
180 | if ($filters[$i]['where'] == 'To or Cc') { |
53fcc494 |
181 | /* |
182 | * If it's "TO OR CC", we have to do two searches, one for TO |
183 | * and the other for CC. |
184 | */ |
fb577a4d |
185 | $expunge = filter_search_and_delete($imap_stream, 'TO', |
186 | $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge); |
187 | $expunge = filter_search_and_delete($imap_stream, 'CC', |
188 | $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge); |
10a26cea |
189 | } else { |
53fcc494 |
190 | /* |
191 | * If it's a normal TO, CC, SUBJECT, or FROM, then handle it |
192 | * normally. |
193 | */ |
fb577a4d |
194 | $expunge = filter_search_and_delete($imap_stream, $filters[$i]['where'], |
195 | $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $expunge); |
4eee5968 |
196 | } |
4eee5968 |
197 | } |
53fcc494 |
198 | // Clean out the mailbox whether or not auto_expunge is on |
199 | // That way it looks like it was redirected properly |
fb577a4d |
200 | if ($expunge) { |
4f6915b0 |
201 | sqimap_mailbox_expunge($imap_stream, 'INBOX'); |
53fcc494 |
202 | } |
10a26cea |
203 | } |
204 | |
0a1dc88e |
205 | /** |
206 | * FIXME: Undocumented function |
207 | * @access private |
208 | */ |
2714d4ff |
209 | function filter_search_and_delete($imap_stream, $where, $what, $where_to, $user_scan, |
fb577a4d |
210 | $should_expunge) { |
6201339c |
211 | global $languages, $squirrelmail_language, $allow_charset_search, $imap_server_type; |
212 | |
174523e3 |
213 | if (strtolower($where_to) == 'inbox') { |
214 | return array(); |
215 | } |
216 | |
217 | |
c8a2c24d |
218 | if ($user_scan == 'new') { |
219 | $category = 'UNSEEN'; |
220 | } else { |
221 | $category = 'ALL'; |
222 | } |
223 | |
3eea00ca |
224 | if ($allow_charset_search && |
225 | isset($languages[$squirrelmail_language]['CHARSET']) && |
53fcc494 |
226 | $languages[$squirrelmail_language]['CHARSET']) { |
3eea00ca |
227 | $search_str = 'SEARCH CHARSET ' |
228 | . strtoupper($languages[$squirrelmail_language]['CHARSET']) |
229 | . ' ' . $category; |
f9ca4be0 |
230 | } else { |
3eea00ca |
231 | $search_str = 'SEARCH CHARSET US-ASCII ' . $category; |
f9ca4be0 |
232 | } |
ae48f757 |
233 | if ($where == 'Header') { |
3eea00ca |
234 | $what = explode(':', $what); |
235 | $where = trim($where . ' ' . $what[0]); |
236 | $what = addslashes(trim($what[1])); |
9da6bdde |
237 | } |
f18ea37e |
238 | |
cf2aa192 |
239 | // see comments in squirrelmail sqimap_search function |
240 | if ($imap_server_type == 'macosx' || $imap_server_type == 'hmailserver') { |
91e0dccc |
241 | $search_str .= ' ' . $where . ' ' . $what; |
f18ea37e |
242 | } else { |
91e0dccc |
243 | $search_str .= ' ' . $where . ' {' . strlen($what) . "}\r\n" |
f18ea37e |
244 | . $what . "\r\n"; |
245 | } |
10a26cea |
246 | |
53fcc494 |
247 | /* read data back from IMAP */ |
6201339c |
248 | $read = sqimap_run_command($imap_stream, $search_str, true, $response, $message, TRUE); |
2714d4ff |
249 | if (isset($read[0])) { |
250 | $ids = array(); |
251 | for ($i=0,$iCnt=count($read);$i<$iCnt;++$i) { |
252 | if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) { |
253 | $ids = preg_split("/ /", trim($regs[1])); |
254 | break; |
fb577a4d |
255 | } |
2714d4ff |
256 | } |
257 | if ($response == 'OK' && count($ids)) { |
258 | if (sqimap_mailbox_exists($imap_stream, $where_to)) { |
259 | $should_expunge = true; |
260 | sqimap_msgs_list_move ($imap_stream, $ids, $where_to); |
4eee5968 |
261 | } |
262 | } |
263 | } |
fb577a4d |
264 | return $should_expunge; |
10a26cea |
265 | } |
4eee5968 |
266 | |
0a1dc88e |
267 | /** |
268 | * FIXME: Undocumented function |
269 | * @access private |
270 | */ |
10a26cea |
271 | function spam_filters($imap_stream) { |
6201339c |
272 | global $data_dir, $username; |
10a26cea |
273 | global $SpamFilters_YourHop; |
274 | global $SpamFilters_DNScache; |
a2a566eb |
275 | global $SpamFilters_SharedCache; |
276 | global $SpamFilters_BulkQuery; |
fb577a4d |
277 | global $SpamFilters_CacheTTL; |
4eee5968 |
278 | |
10a26cea |
279 | $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan'); |
280 | $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder'); |
281 | $filters = load_spam_filters(); |
4eee5968 |
282 | |
a2a566eb |
283 | if ($SpamFilters_SharedCache) { |
284 | filters_LoadCache(); |
285 | } |
286 | |
fb577a4d |
287 | $run = false; |
4eee5968 |
288 | |
fb577a4d |
289 | foreach ($filters as $Key => $Value) { |
10a26cea |
290 | if ($Value['enabled']) { |
fb577a4d |
291 | $run = true; |
292 | break; |
4eee5968 |
293 | } |
10a26cea |
294 | } |
4eee5968 |
295 | |
10a26cea |
296 | // short-circuit |
fb577a4d |
297 | if (!$run) { |
10a26cea |
298 | return; |
299 | } |
4eee5968 |
300 | |
10a26cea |
301 | // Ask for a big list of all "Received" headers in the inbox with |
302 | // flags for each message. Kinda big. |
2714d4ff |
303 | |
304 | if ($filters_spam_scan == 'new') { |
305 | $search_array = array(); |
6201339c |
306 | $read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, TRUE); |
2714d4ff |
307 | if (isset($read[0])) { |
308 | for ($i=0,$iCnt=count($read);$i<$iCnt;++$i) { |
309 | if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) { |
6174dcc7 |
310 | $search_array = preg_split("/ /", trim($regs[1])); |
2714d4ff |
311 | break; |
6174dcc7 |
312 | } |
c8a2c24d |
313 | } |
2714d4ff |
314 | } |
c8a2c24d |
315 | } |
2714d4ff |
316 | if ($filters_spam_scan == 'new' && count($search_array)) { |
d3fae94f |
317 | $headers = sqimap_get_small_header_list ($imap_stream, $search_array, array('Received'),array()); |
2714d4ff |
318 | } else if ($filters_spam_scan != 'new') { |
d3fae94f |
319 | $headers = sqimap_get_small_header_list ($imap_stream, null , array('Received'),array()); |
2714d4ff |
320 | } else { |
321 | return; |
322 | } |
323 | if (!count($headers)) { |
10a26cea |
324 | return; |
325 | } |
fb577a4d |
326 | $bulkquery = (strlen($SpamFilters_BulkQuery) > 0 ? true : false); |
327 | $IPs = array(); |
328 | $aSpamIds = array(); |
329 | foreach ($headers as $id => $aValue) { |
2714d4ff |
330 | if (isset($aValue['UID'])) { |
fb577a4d |
331 | $MsgNum = $aValue['UID']; |
332 | } else { |
333 | $MsgNum = $id; |
10a26cea |
334 | } |
10a26cea |
335 | // Look through all of the Received headers for IP addresses |
2714d4ff |
336 | if (isset($aValue['RECEIVED'])) { |
337 | foreach ($aValue['RECEIVED'] as $received) { |
fb577a4d |
338 | // Check to see if this line is the right "Received from" line |
339 | // to check |
2714d4ff |
340 | |
341 | // $aValue['Received'] is an array with all the received lines. |
fb577a4d |
342 | // We should check them from bottom to top and only check the first 2. |
343 | // Currently we check only the header where $SpamFilters_YourHop in occures |
2714d4ff |
344 | |
fb577a4d |
345 | if (is_int(strpos($received, $SpamFilters_YourHop))) { |
346 | if (preg_match('/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/',$received,$aMatch)) { |
347 | $isspam = false; |
348 | if (filters_spam_check_site($aMatch[1],$aMatch[2],$aMatch[3],$aMatch[4],$filters)) { |
349 | $aSpamIds[] = $MsgNum; |
350 | $isspam = true; |
351 | } |
352 | if ($bulkquery) { |
353 | array_shift($aMatch); |
354 | $IP = explode('.',$aMatch); |
355 | foreach ($filters as $key => $value) { |
356 | if ($filters[$key]['enabled'] && $filters[$key]['dns']) { |
357 | if (strlen($SpamFilters_DNScache[$IP.'.'.$filters[$key]['dns']]) == 0) { |
358 | $IPs[$IP] = true; |
359 | break; |
360 | } |
361 | } |
362 | } |
c8a2c24d |
363 | } |
364 | // If we've checked one IP and YourHop is |
365 | // just a space |
fb577a4d |
366 | if ($SpamFilters_YourHop == ' ' || $isspam) { |
c8a2c24d |
367 | break; // don't check any more |
a9aa7ab7 |
368 | } |
a9aa7ab7 |
369 | } |
4eee5968 |
370 | } |
4eee5968 |
371 | } |
4eee5968 |
372 | } |
10a26cea |
373 | } |
fb577a4d |
374 | // Lookie! It's spam! Yum! |
375 | if (count($aSpamIds) && sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) { |
376 | sqimap_msgs_list_move ($imap_stream, $aSpamIds, $filters_spam_folder); |
377 | sqimap_mailbox_expunge($imap_stream, 'INBOX'); |
378 | } |
4eee5968 |
379 | |
fb577a4d |
380 | if ($bulkquery && count($IPs)) { |
381 | filters_bulkquery($filters, $IPs); |
382 | } |
4eee5968 |
383 | |
a2a566eb |
384 | if ($SpamFilters_SharedCache) { |
385 | filters_SaveCache(); |
386 | } else { |
41100fce |
387 | sqsession_register($SpamFilters_DNScache, 'SpamFilters_DNScache'); |
a2a566eb |
388 | } |
10a26cea |
389 | } |
4eee5968 |
390 | |
0a1dc88e |
391 | /** |
392 | * FIXME: Undocumented function |
393 | * Does the loop through each enabled filter for the specified IP address. |
394 | * IP format: $a.$b.$c.$d |
395 | * @access private |
396 | */ |
10a26cea |
397 | function filters_spam_check_site($a, $b, $c, $d, &$filters) { |
a2a566eb |
398 | global $SpamFilters_DNScache, $SpamFilters_CacheTTL; |
10a26cea |
399 | foreach ($filters as $key => $value) { |
400 | if ($filters[$key]['enabled']) { |
401 | if ($filters[$key]['dns']) { |
402 | $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' . |
403 | $filters[$key]['dns']; |
ae48f757 |
404 | |
405 | if(!isset($SpamFilters_DNScache[$filter_revip]['L'])) |
406 | $SpamFilters_DNScache[$filter_revip]['L'] = ''; |
407 | |
408 | if(!isset($SpamFilters_DNScache[$filter_revip]['T'])) |
409 | $SpamFilters_DNScache[$filter_revip]['T'] = ''; |
410 | |
a7cd90dd |
411 | if (strlen($SpamFilters_DNScache[$filter_revip]['L']) == 0) { |
412 | $SpamFilters_DNScache[$filter_revip]['L'] = |
413 | gethostbyname($filter_revip); |
414 | $SpamFilters_DNScache[$filter_revip]['T'] = |
415 | time() + $SpamFilters_CacheTTL; |
416 | } |
417 | if ($SpamFilters_DNScache[$filter_revip]['L'] == |
418 | $filters[$key]['result']) { |
419 | return 1; |
4eee5968 |
420 | } |
421 | } |
422 | } |
4eee5968 |
423 | } |
10a26cea |
424 | return 0; |
425 | } |
426 | |
0a1dc88e |
427 | /** |
428 | * FIXME: Undocumented function |
429 | * @access private |
430 | */ |
10a26cea |
431 | function load_filters() { |
432 | global $data_dir, $username; |
c8a2c24d |
433 | |
10a26cea |
434 | $filters = array(); |
435 | for ($i=0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) { |
436 | $ary = explode(',', $fltr); |
437 | $filters[$i]['where'] = $ary[0]; |
438 | $filters[$i]['what'] = $ary[1]; |
439 | $filters[$i]['folder'] = $ary[2]; |
4eee5968 |
440 | } |
10a26cea |
441 | return $filters; |
442 | } |
443 | |
0a1dc88e |
444 | /** |
445 | * FIXME: Undocumented function |
446 | * @access private |
447 | */ |
10a26cea |
448 | function load_spam_filters() { |
51199e7a |
449 | global $data_dir, $username, $SpamFilters_ShowCommercial; |
450 | |
451 | if ($SpamFilters_ShowCommercial) { |
452 | $filters['MAPS RBL']['prefname'] = 'filters_spam_maps_rbl'; |
453 | $filters['MAPS RBL']['name'] = 'MAPS Realtime Blackhole List'; |
454 | $filters['MAPS RBL']['link'] = 'http://www.mail-abuse.org/rbl/'; |
455 | $filters['MAPS RBL']['dns'] = 'blackholes.mail-abuse.org'; |
456 | $filters['MAPS RBL']['result'] = '127.0.0.2'; |
457 | $filters['MAPS RBL']['comment'] = |
458 | _("COMMERCIAL - This list contains servers that are verified spam senders. It is a pretty reliable list to scan spam from."); |
459 | |
460 | $filters['MAPS RSS']['prefname'] = 'filters_spam_maps_rss'; |
461 | $filters['MAPS RSS']['name'] = 'MAPS Relay Spam Stopper'; |
462 | $filters['MAPS RSS']['link'] = 'http://www.mail-abuse.org/rss/'; |
463 | $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org'; |
464 | $filters['MAPS RSS']['result'] = '127.0.0.2'; |
465 | $filters['MAPS RSS']['comment'] = |
99aaff8b |
466 | _("COMMERCIAL - Servers that are configured (or misconfigured) to allow spam to be relayed through their system will be banned with this. Another good one to use."); |
51199e7a |
467 | |
468 | $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul'; |
469 | $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List'; |
470 | $filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/'; |
471 | $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org'; |
472 | $filters['MAPS DUL']['result'] = '127.0.0.3'; |
473 | $filters['MAPS DUL']['comment'] = |
99aaff8b |
474 | _("COMMERCIAL - Dial-up users are often filtered out since they should use their ISP's mail servers to send mail. Spammers typically get a dial-up account and send spam directly from there."); |
51199e7a |
475 | |
476 | $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl'; |
477 | $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List'; |
478 | $filters['MAPS RBLplus-RBL']['link'] = 'http://www.mail-abuse.org/'; |
479 | $filters['MAPS RBLplus-RBL']['dns'] = 'rbl-plus.mail-abuse.org'; |
480 | $filters['MAPS RBLplus-RBL']['result'] = '127.0.0.2'; |
481 | $filters['MAPS RBLplus-RBL']['comment'] = |
482 | _("COMMERCIAL - RBL+ Blackhole entries."); |
483 | |
484 | $filters['MAPS RBLplus-RSS']['prefname'] = 'filters_spam_maps_rblplus_rss'; |
485 | $filters['MAPS RBLplus-RSS']['name'] = 'MAPS RBL+ List RSS entries'; |
486 | $filters['MAPS RBLplus-RSS']['link'] = 'http://www.mail-abuse.org/'; |
487 | $filters['MAPS RBLplus-RSS']['dns'] = 'rbl-plus.mail-abuse.org'; |
488 | $filters['MAPS RBLplus-RSS']['result'] = '127.0.0.2'; |
489 | $filters['MAPS RBLplus-RSS']['comment'] = |
490 | _("COMMERCIAL - RBL+ OpenRelay entries."); |
491 | |
492 | $filters['MAPS RBLplus-DUL']['prefname'] = 'filters_spam_maps_rblplus_dul'; |
493 | $filters['MAPS RBLplus-DUL']['name'] = 'MAPS RBL+ List DUL entries'; |
494 | $filters['MAPS RBLplus-DUL']['link'] = 'http://www.mail-abuse.org/'; |
495 | $filters['MAPS RBLplus-DUL']['dns'] = 'rbl-plus.mail-abuse.org'; |
496 | $filters['MAPS RBLplus-DUL']['result'] = '127.0.0.3'; |
497 | $filters['MAPS RBLplus-DUL']['comment'] = |
498 | _("COMMERCIAL - RBL+ Dial-up entries."); |
499 | } |
10a26cea |
500 | |
10a26cea |
501 | $filters['ORDB']['prefname'] = 'filters_spam_ordb'; |
502 | $filters['ORDB']['name'] = 'Open Relay Database List'; |
503 | $filters['ORDB']['link'] = 'http://www.ordb.org/'; |
504 | $filters['ORDB']['dns'] = 'relays.ordb.org'; |
505 | $filters['ORDB']['result'] = '127.0.0.2'; |
506 | $filters['ORDB']['comment'] = |
507 | _("FREE - ORDB was born when ORBS went off the air. It seems to have fewer false positives than ORBS did though."); |
508 | |
10a26cea |
509 | $filters['FiveTen Direct']['prefname'] = 'filters_spam_fiveten_src'; |
510 | $filters['FiveTen Direct']['name'] = 'Five-Ten-sg.com Direct SPAM Sources'; |
511 | $filters['FiveTen Direct']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
512 | $filters['FiveTen Direct']['dns'] = 'blackholes.five-ten-sg.com'; |
513 | $filters['FiveTen Direct']['result'] = '127.0.0.2'; |
514 | $filters['FiveTen Direct']['comment'] = |
515 | _("FREE - Five-Ten-sg.com - Direct SPAM sources."); |
516 | |
517 | $filters['FiveTen DUL']['prefname'] = 'filters_spam_fiveten_dul'; |
518 | $filters['FiveTen DUL']['name'] = 'Five-Ten-sg.com DUL Lists'; |
519 | $filters['FiveTen DUL']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
520 | $filters['FiveTen DUL']['dns'] = 'blackholes.five-ten-sg.com'; |
521 | $filters['FiveTen DUL']['result'] = '127.0.0.3'; |
522 | $filters['FiveTen DUL']['comment'] = |
523 | _("FREE - Five-Ten-sg.com - Dial-up lists - includes some DSL IPs."); |
524 | |
525 | $filters['FiveTen Unc. OptIn']['prefname'] = 'filters_spam_fiveten_oi'; |
526 | $filters['FiveTen Unc. OptIn']['name'] = 'Five-Ten-sg.com Unconfirmed OptIn Lists'; |
527 | $filters['FiveTen Unc. OptIn']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
528 | $filters['FiveTen Unc. OptIn']['dns'] = 'blackholes.five-ten-sg.com'; |
529 | $filters['FiveTen Unc. OptIn']['result'] = '127.0.0.4'; |
530 | $filters['FiveTen Unc. OptIn']['comment'] = |
531 | _("FREE - Five-Ten-sg.com - Bulk mailers that do not use confirmed opt-in."); |
532 | |
533 | $filters['FiveTen Others']['prefname'] = 'filters_spam_fiveten_oth'; |
534 | $filters['FiveTen Others']['name'] = 'Five-Ten-sg.com Other Misc. Servers'; |
535 | $filters['FiveTen Others']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
536 | $filters['FiveTen Others']['dns'] = 'blackholes.five-ten-sg.com'; |
537 | $filters['FiveTen Others']['result'] = '127.0.0.5'; |
538 | $filters['FiveTen Others']['comment'] = |
539 | _("FREE - Five-Ten-sg.com - Other misc. servers."); |
540 | |
541 | $filters['FiveTen Single Stage']['prefname'] = 'filters_spam_fiveten_ss'; |
542 | $filters['FiveTen Single Stage']['name'] = 'Five-Ten-sg.com Single Stage Servers'; |
543 | $filters['FiveTen Single Stage']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
544 | $filters['FiveTen Single Stage']['dns'] = 'blackholes.five-ten-sg.com'; |
545 | $filters['FiveTen Single Stage']['result'] = '127.0.0.6'; |
546 | $filters['FiveTen Single Stage']['comment'] = |
547 | _("FREE - Five-Ten-sg.com - Single Stage servers."); |
548 | |
549 | $filters['FiveTen SPAM Support']['prefname'] = 'filters_spam_fiveten_supp'; |
550 | $filters['FiveTen SPAM Support']['name'] = 'Five-Ten-sg.com SPAM Support Servers'; |
551 | $filters['FiveTen SPAM Support']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
552 | $filters['FiveTen SPAM Support']['dns'] = 'blackholes.five-ten-sg.com'; |
553 | $filters['FiveTen SPAM Support']['result'] = '127.0.0.7'; |
554 | $filters['FiveTen SPAM Support']['comment'] = |
555 | _("FREE - Five-Ten-sg.com - SPAM Support servers."); |
556 | |
557 | $filters['FiveTen Web forms']['prefname'] = 'filters_spam_fiveten_wf'; |
558 | $filters['FiveTen Web forms']['name'] = 'Five-Ten-sg.com Web Form IPs'; |
559 | $filters['FiveTen Web forms']['link'] = 'http://www.five-ten-sg.com/blackhole.php'; |
560 | $filters['FiveTen Web forms']['dns'] = 'blackholes.five-ten-sg.com'; |
561 | $filters['FiveTen Web forms']['result'] = '127.0.0.8'; |
562 | $filters['FiveTen Web forms']['comment'] = |
563 | _("FREE - Five-Ten-sg.com - Web Form IPs."); |
564 | |
565 | $filters['Dorkslayers']['prefname'] = 'filters_spam_dorks'; |
566 | $filters['Dorkslayers']['name'] = 'Dorkslayers Lists'; |
567 | $filters['Dorkslayers']['link'] = 'http://www.dorkslayers.com'; |
568 | $filters['Dorkslayers']['dns'] = 'orbs.dorkslayers.com'; |
569 | $filters['Dorkslayers']['result'] = '127.0.0.2'; |
570 | $filters['Dorkslayers']['comment'] = |
571 | _("FREE - Dorkslayers appears to include only really bad open relays outside the US to avoid being sued. Interestingly enough, their website recommends you NOT use their service."); |
572 | |
573 | $filters['SPAMhaus']['prefname'] = 'filters_spam_spamhaus'; |
574 | $filters['SPAMhaus']['name'] = 'SPAMhaus Lists'; |
575 | $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org'; |
576 | $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org'; |
577 | $filters['SPAMhaus']['result'] = '127.0.0.6'; |
578 | $filters['SPAMhaus']['comment'] = |
579 | _("FREE - SPAMhaus - A list of well-known SPAM sources."); |
580 | |
581 | $filters['SPAMcop']['prefname'] = 'filters_spam_spamcop'; |
582 | $filters['SPAMcop']['name'] = 'SPAM Cop Lists'; |
583 | $filters['SPAMcop']['link'] = 'http://spamcop.net/bl.shtml'; |
584 | $filters['SPAMcop']['dns'] = 'bl.spamcop.net'; |
585 | $filters['SPAMcop']['result'] = '127.0.0.2'; |
586 | $filters['SPAMcop']['comment'] = |
ace4e0d3 |
587 | _("FREE, for now - SpamCop - An interesting solution that lists servers that have a very high spam to legit email ratio (85 percent or more)."); |
10a26cea |
588 | |
46a184ff |
589 | $filters['dev.null.dk']['prefname'] = 'filters_spam_devnull'; |
590 | $filters['dev.null.dk']['name'] = 'dev.null.dk Lists'; |
591 | $filters['dev.null.dk']['link'] = 'http://dev.null.dk/'; |
592 | $filters['dev.null.dk']['dns'] = 'dev.null.dk'; |
593 | $filters['dev.null.dk']['result'] = '127.0.0.2'; |
594 | $filters['dev.null.dk']['comment'] = |
595 | _("FREE - dev.null.dk - I don't have any detailed info on this list."); |
596 | |
597 | $filters['visi.com']['prefname'] = 'filters_spam_visi'; |
598 | $filters['visi.com']['name'] = 'visi.com Relay Stop List'; |
599 | $filters['visi.com']['link'] = 'http://relays.visi.com'; |
600 | $filters['visi.com']['dns'] = 'relays.visi.com'; |
601 | $filters['visi.com']['result'] = '127.0.0.2'; |
602 | $filters['visi.com']['comment'] = |
603 | _("FREE - visi.com - Relay Stop List. Very conservative OpenRelay List."); |
604 | |
bd35ab2b |
605 | $filters['ahbl.org Open Relays']['prefname'] = 'filters_spam_2mb_or'; |
606 | $filters['ahbl.org Open Relays']['name'] = 'ahbl.org Open Relays List'; |
607 | $filters['ahbl.org Open Relays']['link'] = 'http://www.ahbl.org/'; |
608 | $filters['ahbl.org Open Relays']['dns'] = 'dnsbl.ahbl.org'; |
609 | $filters['ahbl.org Open Relays']['result'] = '127.0.0.2'; |
610 | $filters['ahbl.org Open Relays']['comment'] = |
611 | _("FREE - ahbl.org Open Relays - Another list of Open Relays."); |
612 | |
613 | $filters['ahbl.org SPAM Source']['prefname'] = 'filters_spam_2mb_ss'; |
614 | $filters['ahbl.org SPAM Source']['name'] = 'ahbl.org SPAM Source List'; |
615 | $filters['ahbl.org SPAM Source']['link'] = 'http://www.ahbl.org/'; |
616 | $filters['ahbl.org SPAM Source']['dns'] = 'dnsbl.ahbl.org'; |
617 | $filters['ahbl.org SPAM Source']['result'] = '127.0.0.4'; |
618 | $filters['ahbl.org SPAM Source']['comment'] = |
619 | _("FREE - ahbl.org SPAM Source - List of Direct SPAM Sources."); |
620 | |
621 | $filters['ahbl.org SPAM ISPs']['prefname'] = 'filters_spam_2mb_isp'; |
622 | $filters['ahbl.org SPAM ISPs']['name'] = 'ahbl.org SPAM-friendly ISP List'; |
623 | $filters['ahbl.org SPAM ISPs']['link'] = 'http://www.ahbl.org/'; |
624 | $filters['ahbl.org SPAM ISPs']['dns'] = 'dnsbl.ahbl.org'; |
625 | $filters['ahbl.org SPAM ISPs']['result'] = '127.0.0.7'; |
626 | $filters['ahbl.org SPAM ISPs']['comment'] = |
627 | _("FREE - ahbl.org SPAM ISPs - List of SPAM-friendly ISPs."); |
46a184ff |
628 | |
629 | $filters['Leadmon DUL']['prefname'] = 'filters_spam_lm_dul'; |
630 | $filters['Leadmon DUL']['name'] = 'Leadmon.net DUL List'; |
631 | $filters['Leadmon DUL']['link'] = 'http://www.leadmon.net/spamguard/'; |
632 | $filters['Leadmon DUL']['dns'] = 'spamguard.leadmon.net'; |
633 | $filters['Leadmon DUL']['result'] = '127.0.0.2'; |
634 | $filters['Leadmon DUL']['comment'] = |
635 | _("FREE - Leadmon DUL - Another list of Dial-up or otherwise dynamically assigned IPs."); |
636 | |
637 | $filters['Leadmon SPAM Source']['prefname'] = 'filters_spam_lm_ss'; |
638 | $filters['Leadmon SPAM Source']['name'] = 'Leadmon.net SPAM Source List'; |
639 | $filters['Leadmon SPAM Source']['link'] = 'http://www.leadmon.net/spamguard/'; |
640 | $filters['Leadmon SPAM Source']['dns'] = 'spamguard.leadmon.net'; |
641 | $filters['Leadmon SPAM Source']['result'] = '127.0.0.3'; |
642 | $filters['Leadmon SPAM Source']['comment'] = |
643 | _("FREE - Leadmon SPAM Source - List of IPs Leadmon.net has received SPAM directly from."); |
644 | |
645 | $filters['Leadmon Bulk Mailers']['prefname'] = 'filters_spam_lm_bm'; |
646 | $filters['Leadmon Bulk Mailers']['name'] = 'Leadmon.net Bulk Mailers List'; |
647 | $filters['Leadmon Bulk Mailers']['link'] = 'http://www.leadmon.net/spamguard/'; |
648 | $filters['Leadmon Bulk Mailers']['dns'] = 'spamguard.leadmon.net'; |
649 | $filters['Leadmon Bulk Mailers']['result'] = '127.0.0.4'; |
650 | $filters['Leadmon Bulk Mailers']['comment'] = |
651 | _("FREE - Leadmon Bulk Mailers - Bulk mailers that do not require confirmed opt-in or that have allowed known spammers to become clients and abuse their services."); |
652 | |
653 | $filters['Leadmon Open Relays']['prefname'] = 'filters_spam_lm_or'; |
654 | $filters['Leadmon Open Relays']['name'] = 'Leadmon.net Open Relays List'; |
655 | $filters['Leadmon Open Relays']['link'] = 'http://www.leadmon.net/spamguard/'; |
656 | $filters['Leadmon Open Relays']['dns'] = 'spamguard.leadmon.net'; |
657 | $filters['Leadmon Open Relays']['result'] = '127.0.0.5'; |
658 | $filters['Leadmon Open Relays']['comment'] = |
659 | _("FREE - Leadmon Open Relays - Single Stage Open Relays that are not listed on other active RBLs."); |
660 | |
661 | $filters['Leadmon Multi-stage']['prefname'] = 'filters_spam_lm_ms'; |
662 | $filters['Leadmon Multi-stage']['name'] = 'Leadmon.net Multi-Stage Relay List'; |
663 | $filters['Leadmon Multi-stage']['link'] = 'http://www.leadmon.net/spamguard/'; |
664 | $filters['Leadmon Multi-stage']['dns'] = 'spamguard.leadmon.net'; |
665 | $filters['Leadmon Multi-stage']['result'] = '127.0.0.6'; |
666 | $filters['Leadmon Multi-stage']['comment'] = |
667 | _("FREE - Leadmon Multi-stage - Multi-Stage Open Relays that are not listed on other active RBLs and that have sent SPAM to Leadmon.net."); |
668 | |
669 | $filters['Leadmon SpamBlock']['prefname'] = 'filters_spam_lm_sb'; |
670 | $filters['Leadmon SpamBlock']['name'] = 'Leadmon.net SpamBlock Sites List'; |
671 | $filters['Leadmon SpamBlock']['link'] = 'http://www.leadmon.net/spamguard/'; |
672 | $filters['Leadmon SpamBlock']['dns'] = 'spamguard.leadmon.net'; |
673 | $filters['Leadmon SpamBlock']['result'] = '127.0.0.7'; |
674 | $filters['Leadmon SpamBlock']['comment'] = |
675 | _("FREE - Leadmon SpamBlock - Sites on this listing have sent Leadmon.net direct SPAM from IPs in netblocks where the entire block has no DNS mappings. It's a list of BLOCKS of IPs being used by people who have SPAMmed Leadmon.net."); |
676 | |
677 | $filters['NJABL Open Relays']['prefname'] = 'filters_spam_njabl_or'; |
678 | $filters['NJABL Open Relays']['name'] = 'NJABL Open Relay/Direct Spam Source List'; |
679 | $filters['NJABL Open Relays']['link'] = 'http://www.njabl.org/'; |
680 | $filters['NJABL Open Relays']['dns'] = 'dnsbl.njabl.org'; |
681 | $filters['NJABL Open Relays']['result'] = '127.0.0.2'; |
682 | $filters['NJABL Open Relays']['comment'] = |
683 | _("FREE, for now - Not Just Another Blacklist - Both Open Relays and Direct SPAM Sources."); |
684 | |
685 | $filters['NJABL DUL']['prefname'] = 'filters_spam_njabl_dul'; |
686 | $filters['NJABL DUL']['name'] = 'NJABL Dial-ups List'; |
687 | $filters['NJABL DUL']['link'] = 'http://www.njabl.org/'; |
688 | $filters['NJABL DUL']['dns'] = 'dnsbl.njabl.org'; |
689 | $filters['NJABL DUL']['result'] = '127.0.0.3'; |
690 | $filters['NJABL DUL']['comment'] = |
691 | _("FREE, for now - Not Just Another Blacklist - Dial-up IPs."); |
692 | |
18b078e9 |
693 | $filters['Conf DSBL.ORG Relay']['prefname'] = 'filters_spam_dsbl_conf_ss'; |
694 | $filters['Conf DSBL.ORG Relay']['name'] = 'DSBL.org Confirmed Relay List'; |
695 | $filters['Conf DSBL.ORG Relay']['link'] = 'http://www.dsbl.org/'; |
696 | $filters['Conf DSBL.ORG Relay']['dns'] = 'list.dsbl.org'; |
697 | $filters['Conf DSBL.ORG Relay']['result'] = '127.0.0.2'; |
698 | $filters['Conf DSBL.ORG Relay']['comment'] = |
699 | _("FREE - Distributed Sender Boycott List - Confirmed Relays"); |
700 | |
701 | $filters['Conf DSBL.ORG Multi-Stage']['prefname'] = 'filters_spam_dsbl_conf_ms'; |
702 | $filters['Conf DSBL.ORG Multi-Stage']['name'] = 'DSBL.org Confirmed Multi-Stage Relay List'; |
703 | $filters['Conf DSBL.ORG Multi-Stage']['link'] = 'http://www.dsbl.org/'; |
704 | $filters['Conf DSBL.ORG Multi-Stage']['dns'] = 'multihop.dsbl.org'; |
705 | $filters['Conf DSBL.ORG Multi-Stage']['result'] = '127.0.0.2'; |
706 | $filters['Conf DSBL.ORG Multi-Stage']['comment'] = |
707 | _("FREE - Distributed Sender Boycott List - Confirmed Multi-stage Relays"); |
708 | |
709 | $filters['UN-Conf DSBL.ORG']['prefname'] = 'filters_spam_dsbl_unc'; |
710 | $filters['UN-Conf DSBL.ORG']['name'] = 'DSBL.org UN-Confirmed Relay List'; |
711 | $filters['UN-Conf DSBL.ORG']['link'] = 'http://www.dsbl.org/'; |
712 | $filters['UN-Conf DSBL.ORG']['dns'] = 'unconfirmed.dsbl.org'; |
713 | $filters['UN-Conf DSBL.ORG']['result'] = '127.0.0.2'; |
714 | $filters['UN-Conf DSBL.ORG']['comment'] = |
715 | _("FREE - Distributed Sender Boycott List - UN-Confirmed Relays"); |
716 | |
10a26cea |
717 | foreach ($filters as $Key => $Value) { |
718 | $filters[$Key]['enabled'] = getPref($data_dir, $username, |
719 | $filters[$Key]['prefname']); |
4eee5968 |
720 | } |
721 | |
10a26cea |
722 | return $filters; |
723 | } |
4eee5968 |
724 | |
0a1dc88e |
725 | /** |
726 | * FIXME: Undocumented function |
727 | * @access private |
728 | */ |
10a26cea |
729 | function remove_filter ($id) { |
730 | global $data_dir, $username; |
4eee5968 |
731 | |
10a26cea |
732 | while ($nextFilter = getPref($data_dir, $username, 'filter' . |
733 | ($id + 1))) { |
734 | setPref($data_dir, $username, 'filter' . $id, $nextFilter); |
735 | $id ++; |
4eee5968 |
736 | } |
737 | |
10a26cea |
738 | removePref($data_dir, $username, 'filter' . $id); |
739 | } |
4eee5968 |
740 | |
0a1dc88e |
741 | /** |
742 | * FIXME: Undocumented function |
743 | * @access private |
744 | */ |
10a26cea |
745 | function filter_swap($id1, $id2) { |
746 | global $data_dir, $username; |
4eee5968 |
747 | |
10a26cea |
748 | $FirstFilter = getPref($data_dir, $username, 'filter' . $id1); |
749 | $SecondFilter = getPref($data_dir, $username, 'filter' . $id2); |
750 | |
751 | if ($FirstFilter && $SecondFilter) { |
752 | setPref($data_dir, $username, 'filter' . $id2, $FirstFilter); |
753 | setPref($data_dir, $username, 'filter' . $id1, $SecondFilter); |
4eee5968 |
754 | } |
10a26cea |
755 | } |
4eec80a7 |
756 | |
0a1dc88e |
757 | /** |
758 | * This update the filter rules when renaming or deleting folders |
759 | * @param array $args |
b2d8bc6c |
760 | * @access private |
0a1dc88e |
761 | */ |
f5ab1fb9 |
762 | function update_for_folder ($args) { |
763 | $old_folder = $args[0]; |
a2a566eb |
764 | $new_folder = $args[2]; |
765 | $action = $args[1]; |
ce68b76b |
766 | global $data_dir, $username; |
4eec80a7 |
767 | $filters = array(); |
768 | $filters = load_filters(); |
769 | $filter_count = count($filters); |
770 | $p = 0; |
771 | for ($i=0;$i<$filter_count;$i++) { |
772 | if (!empty($filters)) { |
773 | if ($old_folder == $filters[$i]['folder']) { |
774 | if ($action == 'rename') { |
775 | $filters[$i]['folder'] = $new_folder; |
776 | setPref($data_dir, $username, 'filter'.$i, |
777 | $filters[$i]['where'].','.$filters[$i]['what'].','.$new_folder); |
778 | } |
779 | elseif ($action == 'delete') { |
780 | remove_filter($p); |
781 | $p = $p-1; |
782 | } |
783 | } |
784 | $p++; |
785 | } |
786 | } |
787 | } |
0a1dc88e |
788 | |
0a1dc88e |
789 | /** |
790 | * Display formated error message |
791 | * @param string $string text message |
792 | * @return string html formated text message |
793 | * @access private |
794 | */ |
795 | function do_error($string) { |
796 | global $color; |
797 | echo "<p align=\"center\"><font color=\"$color[2]\">"; |
798 | echo $string; |
799 | echo "</font></p>\n"; |
800 | } |
174523e3 |
801 | ?> |