squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

filters.php
Go to the documentation of this file.
1 <?php
32 function filters_SaveCache () {
34 
35  if (file_exists($data_dir . '/dnscache')) {
36  $fp = fopen($data_dir . '/dnscache', 'r');
37  } else {
38  $fp = false;
39  }
40  if ($fp) {
41  flock($fp,LOCK_EX);
42  } else {
43  $fp = fopen($data_dir . '/dnscache', 'w+');
44  fclose($fp);
45  $fp = fopen($data_dir . '/dnscache', 'r');
46  flock($fp,LOCK_EX);
47  }
48  $fp1 = fopen($data_dir . '/dnscache', 'w+');
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 
63 function filters_LoadCache () {
65 
66  if (file_exists($data_dir . '/dnscache')) {
67  $SpamFilters_DNScache = array();
68  if ($fp = fopen ($data_dir . '/dnscache', 'r')) {
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  flock($fp,LOCK_UN);
77  }
78  }
79 }
80 
92 
93  $IPs = array();
94  $i = 0;
95  while ($i < count($read)) {
96  // EIMS will give funky results
97  $Chunks = explode(' ', $read[$i]);
98  if ($Chunks[0] != '*') {
99  $i ++;
100  continue;
101  }
102  $MsgNum = $Chunks[1];
103 
104  $i ++;
105 
106  // Look through all of the Received headers for IP addresses
107  // Stop when I get ")" on a line
108  // Stop if I get "*" on a line (don't advance)
109  // and above all, stop if $i is bigger than the total # of lines
110  while (($i < count($read)) &&
111  ($read[$i][0] != ')' && $read[$i][0] != '*' &&
112  $read[$i][0] != "\n")) {
113  // Check to see if this line is the right "Received from" line
114  // to check
115  if (is_int(strpos($read[$i], $SpamFilters_YourHop))) {
116  $read[$i] = preg_replace('/[^0-9\.]/', ' ', $read[$i]);
117  $elements = explode(' ', $read[$i]);
118  foreach ($elements as $value) {
119  if ($value != '' &&
120  preg_match('/((\d{1,3}\.){3}\d{1,3})/',
121  $value)) {
122  $Chunks = explode('.', $value);
123  $IP = $Chunks[3] . '.' . $Chunks[2] . '.' .
124  $Chunks[1] . '.' . $Chunks[0];
125  foreach ($filters as $key => $value) {
126  if ($filters[$key]['enabled'] &&
127  $filters[$key]['dns']) {
128  if (strlen($SpamFilters_DNScache[$IP.'.'.$filters[$key]['dns']]) == 0) {
129  $IPs[$IP] = true;
130  break;
131  }
132  }
133  }
134  // If we've checked one IP and YourHop is
135  // just a space
136  if ($SpamFilters_YourHop == ' ') {
137  break; // don't check any more
138  }
139  }
140  }
141  }
142  $i ++;
143  }
144  }
145 
146  if (count($IPs) > 0) {
147  $rbls = array();
148  foreach ($filters as $key => $value) {
149  if ($filters[$key]['enabled']) {
150  if ($filters[$key]['dns']) {
151  $rbls[$filters[$key]['dns']] = true;
152  }
153  }
154  }
155 
156  $bqfil = $attachment_dir . $username . '-bq.in';
157  $fp = fopen($bqfil, 'w');
158  fputs ($fp, $SpamFilters_CacheTTL . "\n");
159  foreach ($rbls as $key => $value) {
160  fputs ($fp, '.' . $key . "\n");
161  }
162  fputs ($fp, "----------\n");
163  foreach ($IPs as $key => $value) {
164  fputs ($fp, $key . "\n");
165  }
166  fclose ($fp);
167  $bqout = array();
168  exec ($SpamFilters_BulkQuery . ' < ' . $bqfil, $bqout);
169  foreach ($bqout as $value) {
170  $Chunks = explode(',', $value);
171  $SpamFilters_DNScache[$Chunks[0]]['L'] = $Chunks[1];
172  $SpamFilters_DNScache[$Chunks[0]]['T'] = $Chunks[2] + time();
173  }
174  unlink($bqfil);
175  }
176 }
177 
182 function start_filters() {
183  global $mailbox, $imapServerAddress, $imapPort, $imap,
184  $imap_general, $filters, $imap_stream, $imapConnection,
186 
187  sqgetGlobalVar('username', $username, SQ_SESSION);
188  sqgetGlobalVar('key', $key, SQ_COOKIE);
189 
190 
192 
193  // No point running spam filters if there aren't any to run //
194  if ($AllowSpamFilters) {
195  $spamfilters = load_spam_filters();
196 
197  $AllowSpamFilters = false;
198  foreach($spamfilters as $filterkey => $value) {
199  if ($value['enabled'] == SMPREF_ON) {
200  $AllowSpamFilters = true;
201  break;
202  }
203  }
204  }
205 
206  // No user filters, and no spam filters, no need to continue //
207  if (!$AllowSpamFilters && empty($filters)) {
208  return;
209  }
210 
211 
212  // Detect if we have already connected to IMAP or not.
213  // Also check if we are forced to use a separate IMAP connection
214  if ((!isset($imap_stream) && !isset($imapConnection)) ||
217  $imapPort, 10);
218  $previously_connected = false;
219  } else if (isset($imapConnection)) {
221  $previously_connected = true;
222  } else {
223  $previously_connected = true;
225  }
226  $aStatus = sqimap_status_messages ($stream, 'INBOX', array('MESSAGES'));
227 
228  if ($aStatus['MESSAGES']) {
229  sqimap_mailbox_select($stream, 'INBOX');
230  // Filter spam from inbox before we sort them into folders
231  if ($AllowSpamFilters) {
233  }
234 
235  // Sort into folders
237  }
238 
239  if (!$previously_connected) {
241  }
242 }
243 
250  global $data_dir, $username;
252  if (! $filters) return;
253  $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan');
254 
256  $id = array();
257  // For every rule
258  for ($i=0, $num = count($filters); $i < $num; $i++) {
259  // Don't attempt to run filters if folder does not exist //
260  if (!sqimap_mailbox_exists($imap_stream, $filters[$i]['folder'])) {
261  continue;
262  }
263 
264 
265  // If it is the "combo" rule
266  if ($filters[$i]['where'] == 'To or Cc') {
267  /*
268  * If it's "TO OR CC", we have to do two searches, one for TO
269  * and the other for CC.
270  */
272  $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $id);
274  $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $id);
275  } else {
276  /*
277  * If it's a normal TO, CC, SUBJECT, or FROM, then handle it
278  * normally.
279  */
281  $filters[$i]['what'], $filters[$i]['folder'], $filters_user_scan, $id);
282  }
283  }
284  // Clean out the mailbox whether or not auto_expunge is on
285  // That way it looks like it was redirected properly
286  if (count($id)) {
288  }
289 }
290 
301 function filter_search_and_delete($imap, $where, $what, $where_to, $user_scan,
302  $del_id) {
305 
306  if (strtolower($where_to) == 'inbox') {
307  return array();
308  }
309 
310  if ($user_scan == 'new') {
311  $category = 'UNSEEN';
312  } else {
313  $category = 'ALL';
314  }
315  $category .= ' UNDELETED';
316 
317  if ($allow_charset_search &&
318  isset($languages[$squirrelmail_language]['CHARSET']) &&
319  $languages[$squirrelmail_language]['CHARSET']) {
320  $search_str = 'SEARCH CHARSET '
321  . strtoupper($languages[$squirrelmail_language]['CHARSET'])
322  . ' ' . $category;
323  } else {
324  $search_str = 'SEARCH CHARSET US-ASCII ' . $category;
325  }
326  if ($where == 'Header') {
327  $what = explode(':', $what);
328  $where = trim($where . ' ' . $what[0]);
329  $what = addslashes(trim($what[1]));
330  }
331 
332  // see comments in squirrelmail sqimap_search function
333  if ($imap_server_type == 'macosx' || $imap_server_type == 'hmailserver') {
334  $search_str .= ' ' . $where . ' ' . $what;
335  $read = sqimap_run_command_list($imap, $search_str, true, $response, $message, $uid_support);
336  } else {
337  $lit = array();
338  $lit['command'] = $search_str . ' ' . $where;
339  $lit['literal_args'][] = $what;
340 
341  $read = sqimap_run_literal_command($imap, $lit, true, $response, $message, $uid_support );
342  }
343 
344  /* read data back from IMAP */
345 
346 
347  // This may have problems with EIMS due to it being goofy
348 
349  for ($r=0, $num = count($read); $r < $num &&
350  substr($read[$r], 0, 8) != '* SEARCH'; $r++) {}
351  if ($response == 'OK') {
352  $ids = explode(' ', $read[$r]);
353  if (sqimap_mailbox_exists($imap, $where_to)) {
354  /*
355  * why we do n calls instead of just one. It is safer to copy
356  * messages one by one, but code does not call expunge after
357  * message is copied and quota limits are not resolved.
358  */
359  for ($j=2, $num = count($ids); $j < $num; $j++) {
360  $id = trim($ids[$j]);
361  if (sqimap_msgs_list_move($imap, $id, $where_to)) {
362  $del_id[] = $id;
363  }
364  }
365  }
366  }
367  return $del_id;
368 }
369 
377  global $SpamFilters_YourHop;
378  global $SpamFilters_DNScache;
380  global $SpamFilters_BulkQuery;
381 
382  $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
383  $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
385 
388  }
389 
390  $run = false;
391 
392  foreach ($filters as $Key => $Value) {
393  if ($Value['enabled']) {
394  $run = true;
395  break;
396  }
397  }
398 
399  // short-circuit
400  if (!$run) {
401  return;
402  }
403 
405 
406  $search_array = array();
407  if ($filters_spam_scan == 'new') {
408  $read = sqimap_run_command($imap_stream, 'SEARCH UNSEEN', true, $response, $message, $uid_support);
409  if (isset($read[0])) {
410  for ($i = 0, $iCnt = count($read); $i < $iCnt; ++$i) {
411  if (preg_match("/^\* SEARCH (.+)$/", $read[$i], $regs)) {
412  $search_array = explode(' ', trim($regs[1]));
413  break;
414  }
415  }
416  }
417  }
418 
419  if ($filters_spam_scan == 'new' && count($search_array)) {
420  $msg_str = sqimap_message_list_squisher($search_array);
421  $imap_query = 'FETCH ' . $msg_str . ' (FLAGS BODY.PEEK[HEADER.FIELDS (RECEIVED)])';
422  } else if ($filters_spam_scan != 'new') {
423  $imap_query = 'FETCH 1:* (FLAGS BODY.PEEK[HEADER.FIELDS (RECEIVED)])';
424  } else {
425  return;
426  }
427 
428  $read = sqimap_run_command_list($imap_stream, $imap_query, true, $response, $message, $uid_support);
429 
430  if (isset($response) && $response != 'OK') {
431  return;
432  }
433 
434  $messages = parseFetch($read);
435 
436  $bulkquery = (strlen($SpamFilters_BulkQuery) > 0 ? true : false);
437  $aSpamIds = array();
438  foreach($messages as $id=>$message) {
439  if (isset($message['UID'])) {
440  $MsgNum = $message['UID'];
441  } else {
442  $MsgNum = $id;
443  }
444 
445  if (isset($message['received'])) {
446  foreach($message['received'] as $received) {
447  if (is_int(strpos($received, $SpamFilters_YourHop))) {
448  if (preg_match('/([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})/', $received, $matches)) {
449  $IsSpam = false;
450  if (filters_spam_check_site($matches[1], $matches[2], $matches[3], $matches[4], $filters)) {
451  $aSpamIds[] = $MsgNum;
452  $IsSpam = true;
453  }
454 
455  if ($bulkquery) {
456  array_shift($matches);
457  $IP = explode('.', $matches);
458  foreach ($filters as $key => $value) {
459  if ($filters[$key]['enabled'] && $filters[$key]['dns']) {
460  if (strlen($SpamFilters_DNScache[$IP . '.' . $filters[$key]['dns']]) == 0) {
461  $IPs[$IP] = true;
462  break;
463  }
464  }
465  }
466  }
467  // If we've checked one IP and YourHop is
468  // just a space
469  if ($SpamFilters_YourHop == ' ' || $IsSpam) {
470  break; // don't check any more
471  }
472  }
473  }
474  }
475  }
476  }
477  // Lookie! It's spam! Yum!
478  if (count($aSpamIds) && sqimap_mailbox_exists($imap_stream, $filters_spam_folder)) {
480  sqimap_mailbox_expunge($imap_stream, 'INBOX', true, $aSpamIds);
481  }
482 
483  if ($bulkquery && count($IPs)) {
485  }
486 
489  } else {
490  sqsession_register($SpamFilters_DNScache, 'SpamFilters_DNScache');
491  }
492 }
493 
505 function filters_spam_check_site($a, $b, $c, $d, &$filters) {
507  foreach ($filters as $key => $value) {
508  if ($filters[$key]['enabled']) {
509  if ($filters[$key]['dns']) {
510 
516  $filter_revip = $d . '.' . $c . '.' . $b . '.' . $a . '.' .
517  $filters[$key]['dns'] . '.';
518 
519  if(!isset($SpamFilters_DNScache[$filter_revip]['L']))
520  $SpamFilters_DNScache[$filter_revip]['L'] = '';
521 
522  if(!isset($SpamFilters_DNScache[$filter_revip]['T']))
523  $SpamFilters_DNScache[$filter_revip]['T'] = '';
524 
525  if (strlen($SpamFilters_DNScache[$filter_revip]['L']) == 0) {
526  $SpamFilters_DNScache[$filter_revip]['L'] =
527  gethostbyname($filter_revip);
528  $SpamFilters_DNScache[$filter_revip]['T'] =
529  time() + $SpamFilters_CacheTTL;
530  }
531 
536  if ($SpamFilters_DNScache[$filter_revip]['L'] != $filter_revip) {
537  return 1;
538  }
539  }
540  }
541  }
542  return 0;
543 }
544 
550 function load_filters() {
551  global $data_dir, $username;
552 
553  $filters = array();
554  for ($i = 0; $fltr = getPref($data_dir, $username, 'filter' . $i); $i++) {
555  $ary = explode(',', $fltr);
556  $filters[$i]['where'] = $ary[0];
557  $filters[$i]['what'] = str_replace('###COMMA###', ',', $ary[1]);
558  $filters[$i]['folder'] = $ary[2];
559  }
560  return $filters;
561 }
562 
568 function load_spam_filters() {
570 
572  $filters['MAPS RBL']['prefname'] = 'filters_spam_maps_rbl';
573  $filters['MAPS RBL']['name'] = 'MAPS Realtime Blackhole List';
574  $filters['MAPS RBL']['link'] = 'http://www.mail-abuse.org/rbl/';
575  $filters['MAPS RBL']['dns'] = 'blackholes.mail-abuse.org';
576  $filters['MAPS RBL']['result'] = '127.0.0.2';
577  $filters['MAPS RBL']['comment'] =
578  _("COMMERCIAL - This list contains servers that are verified spam senders. It is a pretty reliable list to scan spam from.");
579 
580  $filters['MAPS RSS']['prefname'] = 'filters_spam_maps_rss';
581  $filters['MAPS RSS']['name'] = 'MAPS Relay Spam Stopper';
582  $filters['MAPS RSS']['link'] = 'http://www.mail-abuse.org/rss/';
583  $filters['MAPS RSS']['dns'] = 'relays.mail-abuse.org';
584  $filters['MAPS RSS']['result'] = '127.0.0.2';
585  $filters['MAPS RSS']['comment'] =
586  _("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.");
587 
588  $filters['MAPS DUL']['prefname'] = 'filters_spam_maps_dul';
589  $filters['MAPS DUL']['name'] = 'MAPS Dial-Up List';
590  $filters['MAPS DUL']['link'] = 'http://www.mail-abuse.org/dul/';
591  $filters['MAPS DUL']['dns'] = 'dialups.mail-abuse.org';
592  $filters['MAPS DUL']['result'] = '127.0.0.3';
593  $filters['MAPS DUL']['comment'] =
594  _("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.");
595 
596  $filters['MAPS RBLplus-RBL']['prefname'] = 'filters_spam_maps_rblplus_rbl';
597  $filters['MAPS RBLplus-RBL']['name'] = 'MAPS RBL+ RBL List';
598  $filters['MAPS RBLplus-RBL']['link'] = 'http://www.mail-abuse.org/';
599  $filters['MAPS RBLplus-RBL']['dns'] = 'rbl-plus.mail-abuse.org';
600  $filters['MAPS RBLplus-RBL']['result'] = '127.0.0.2';
601  $filters['MAPS RBLplus-RBL']['comment'] =
602  _("COMMERCIAL - RBL+ Blackhole entries.");
603 
604  $filters['MAPS RBLplus-RSS']['prefname'] = 'filters_spam_maps_rblplus_rss';
605  $filters['MAPS RBLplus-RSS']['name'] = 'MAPS RBL+ List RSS entries';
606  $filters['MAPS RBLplus-RSS']['link'] = 'http://www.mail-abuse.org/';
607  $filters['MAPS RBLplus-RSS']['dns'] = 'rbl-plus.mail-abuse.org';
608  $filters['MAPS RBLplus-RSS']['result'] = '127.0.0.2';
609  $filters['MAPS RBLplus-RSS']['comment'] =
610  _("COMMERCIAL - RBL+ OpenRelay entries.");
611 
612  $filters['MAPS RBLplus-DUL']['prefname'] = 'filters_spam_maps_rblplus_dul';
613  $filters['MAPS RBLplus-DUL']['name'] = 'MAPS RBL+ List DUL entries';
614  $filters['MAPS RBLplus-DUL']['link'] = 'http://www.mail-abuse.org/';
615  $filters['MAPS RBLplus-DUL']['dns'] = 'rbl-plus.mail-abuse.org';
616  $filters['MAPS RBLplus-DUL']['result'] = '127.0.0.3';
617  $filters['MAPS RBLplus-DUL']['comment'] =
618  _("COMMERCIAL - RBL+ Dial-up entries.");
619  }
620 
621  $filters['FiveTen Direct']['prefname'] = 'filters_spam_fiveten_src';
622  $filters['FiveTen Direct']['name'] = 'Five-Ten-sg.com Direct SPAM Sources';
623  $filters['FiveTen Direct']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
624  $filters['FiveTen Direct']['dns'] = 'blackholes.five-ten-sg.com';
625  $filters['FiveTen Direct']['result'] = '127.0.0.2';
626  $filters['FiveTen Direct']['comment'] =
627  _("FREE - Five-Ten-sg.com - Direct SPAM sources.");
628 
629  $filters['FiveTen DUL']['prefname'] = 'filters_spam_fiveten_dul';
630  $filters['FiveTen DUL']['name'] = 'Five-Ten-sg.com DUL Lists';
631  $filters['FiveTen DUL']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
632  $filters['FiveTen DUL']['dns'] = 'blackholes.five-ten-sg.com';
633  $filters['FiveTen DUL']['result'] = '127.0.0.3';
634  $filters['FiveTen DUL']['comment'] =
635  _("FREE - Five-Ten-sg.com - Dial-up lists - includes some DSL IPs.");
636 
637  $filters['FiveTen Unc. OptIn']['prefname'] = 'filters_spam_fiveten_oi';
638  $filters['FiveTen Unc. OptIn']['name'] = 'Five-Ten-sg.com Unconfirmed OptIn Lists';
639  $filters['FiveTen Unc. OptIn']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
640  $filters['FiveTen Unc. OptIn']['dns'] = 'blackholes.five-ten-sg.com';
641  $filters['FiveTen Unc. OptIn']['result'] = '127.0.0.4';
642  $filters['FiveTen Unc. OptIn']['comment'] =
643  _("FREE - Five-Ten-sg.com - Bulk mailers that do not use confirmed opt-in.");
644 
645  $filters['FiveTen Others']['prefname'] = 'filters_spam_fiveten_oth';
646  $filters['FiveTen Others']['name'] = 'Five-Ten-sg.com Other Misc. Servers';
647  $filters['FiveTen Others']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
648  $filters['FiveTen Others']['dns'] = 'blackholes.five-ten-sg.com';
649  $filters['FiveTen Others']['result'] = '127.0.0.5';
650  $filters['FiveTen Others']['comment'] =
651  _("FREE - Five-Ten-sg.com - Other misc. servers.");
652 
653  $filters['FiveTen Single Stage']['prefname'] = 'filters_spam_fiveten_ss';
654  $filters['FiveTen Single Stage']['name'] = 'Five-Ten-sg.com Single Stage Servers';
655  $filters['FiveTen Single Stage']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
656  $filters['FiveTen Single Stage']['dns'] = 'blackholes.five-ten-sg.com';
657  $filters['FiveTen Single Stage']['result'] = '127.0.0.6';
658  $filters['FiveTen Single Stage']['comment'] =
659  _("FREE - Five-Ten-sg.com - Single Stage servers.");
660 
661  $filters['FiveTen SPAM Support']['prefname'] = 'filters_spam_fiveten_supp';
662  $filters['FiveTen SPAM Support']['name'] = 'Five-Ten-sg.com SPAM Support Servers';
663  $filters['FiveTen SPAM Support']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
664  $filters['FiveTen SPAM Support']['dns'] = 'blackholes.five-ten-sg.com';
665  $filters['FiveTen SPAM Support']['result'] = '127.0.0.7';
666  $filters['FiveTen SPAM Support']['comment'] =
667  _("FREE - Five-Ten-sg.com - SPAM Support servers.");
668 
669  $filters['FiveTen Web forms']['prefname'] = 'filters_spam_fiveten_wf';
670  $filters['FiveTen Web forms']['name'] = 'Five-Ten-sg.com Web Form IPs';
671  $filters['FiveTen Web forms']['link'] = 'http://www.five-ten-sg.com/blackhole.php';
672  $filters['FiveTen Web forms']['dns'] = 'blackholes.five-ten-sg.com';
673  $filters['FiveTen Web forms']['result'] = '127.0.0.8';
674  $filters['FiveTen Web forms']['comment'] =
675  _("FREE - Five-Ten-sg.com - Web Form IPs.");
676 
677  $filters['Dorkslayers']['prefname'] = 'filters_spam_dorks';
678  $filters['Dorkslayers']['name'] = 'Dorkslayers Lists';
679  $filters['Dorkslayers']['link'] = 'http://www.dorkslayers.com';
680  $filters['Dorkslayers']['dns'] = 'orbs.dorkslayers.com';
681  $filters['Dorkslayers']['result'] = '127.0.0.2';
682  $filters['Dorkslayers']['comment'] =
683  _("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.");
684 
685  $filters['SPAMhaus']['prefname'] = 'filters_spam_spamhaus';
686  $filters['SPAMhaus']['name'] = 'SPAMhaus Lists';
687  $filters['SPAMhaus']['link'] = 'http://www.spamhaus.org';
688  $filters['SPAMhaus']['dns'] = 'sbl.spamhaus.org';
689  $filters['SPAMhaus']['result'] = '127.0.0.6';
690  $filters['SPAMhaus']['comment'] =
691  _("FREE - SPAMhaus - A list of well-known SPAM sources.");
692 
693  $filters['SPAMcop']['prefname'] = 'filters_spam_spamcop';
694  $filters['SPAMcop']['name'] = 'SPAM Cop Lists';
695  $filters['SPAMcop']['link'] = 'http://spamcop.net/bl.shtml';
696  $filters['SPAMcop']['dns'] = 'bl.spamcop.net';
697  $filters['SPAMcop']['result'] = '127.0.0.2';
698  $filters['SPAMcop']['comment'] =
699  _("FREE, for now - SpamCop - An interesting solution that lists servers that have a very high spam to legit email ratio (85 percent or more).");
700 
701  $filters['dev.null.dk']['prefname'] = 'filters_spam_devnull';
702  $filters['dev.null.dk']['name'] = 'dev.null.dk Lists';
703  $filters['dev.null.dk']['link'] = 'http://dev.null.dk/';
704  $filters['dev.null.dk']['dns'] = 'dev.null.dk';
705  $filters['dev.null.dk']['result'] = '127.0.0.2';
706  $filters['dev.null.dk']['comment'] =
707  _("FREE - dev.null.dk - I don't have any detailed info on this list.");
708 
709  $filters['visi.com']['prefname'] = 'filters_spam_visi';
710  $filters['visi.com']['name'] = 'visi.com Relay Stop List';
711  $filters['visi.com']['link'] = 'http://relays.visi.com';
712  $filters['visi.com']['dns'] = 'relays.visi.com';
713  $filters['visi.com']['result'] = '127.0.0.2';
714  $filters['visi.com']['comment'] =
715  _("FREE - visi.com - Relay Stop List. Very conservative OpenRelay List.");
716 
717  $filters['ahbl.org Open Relays']['prefname'] = 'filters_spam_2mb_or';
718  $filters['ahbl.org Open Relays']['name'] = 'ahbl.org Open Relays List';
719  $filters['ahbl.org Open Relays']['link'] = 'http://www.ahbl.org/';
720  $filters['ahbl.org Open Relays']['dns'] = 'dnsbl.ahbl.org';
721  $filters['ahbl.org Open Relays']['result'] = '127.0.0.2';
722  $filters['ahbl.org Open Relays']['comment'] =
723  _("FREE - ahbl.org Open Relays - Another list of Open Relays.");
724 
725  $filters['ahbl.org SPAM Source']['prefname'] = 'filters_spam_2mb_ss';
726  $filters['ahbl.org SPAM Source']['name'] = 'ahbl.org SPAM Source List';
727  $filters['ahbl.org SPAM Source']['link'] = 'http://www.ahbl.org/';
728  $filters['ahbl.org SPAM Source']['dns'] = 'dnsbl.ahbl.org';
729  $filters['ahbl.org SPAM Source']['result'] = '127.0.0.4';
730  $filters['ahbl.org SPAM Source']['comment'] =
731  _("FREE - ahbl.org SPAM Source - List of Direct SPAM Sources.");
732 
733  $filters['ahbl.org SPAM ISPs']['prefname'] = 'filters_spam_2mb_isp';
734  $filters['ahbl.org SPAM ISPs']['name'] = 'ahbl.org SPAM-friendly ISP List';
735  $filters['ahbl.org SPAM ISPs']['link'] = 'http://www.ahbl.org/';
736  $filters['ahbl.org SPAM ISPs']['dns'] = 'dnsbl.ahbl.org';
737  $filters['ahbl.org SPAM ISPs']['result'] = '127.0.0.7';
738  $filters['ahbl.org SPAM ISPs']['comment'] =
739  _("FREE - ahbl.org SPAM ISPs - List of SPAM-friendly ISPs.");
740 
741  $filters['Leadmon DUL']['prefname'] = 'filters_spam_lm_dul';
742  $filters['Leadmon DUL']['name'] = 'Leadmon.net DUL List';
743  $filters['Leadmon DUL']['link'] = 'http://www.leadmon.net/spamguard/';
744  $filters['Leadmon DUL']['dns'] = 'spamguard.leadmon.net';
745  $filters['Leadmon DUL']['result'] = '127.0.0.2';
746  $filters['Leadmon DUL']['comment'] =
747  _("FREE - Leadmon DUL - Another list of Dial-up or otherwise dynamically assigned IPs.");
748 
749  $filters['Leadmon SPAM Source']['prefname'] = 'filters_spam_lm_ss';
750  $filters['Leadmon SPAM Source']['name'] = 'Leadmon.net SPAM Source List';
751  $filters['Leadmon SPAM Source']['link'] = 'http://www.leadmon.net/spamguard/';
752  $filters['Leadmon SPAM Source']['dns'] = 'spamguard.leadmon.net';
753  $filters['Leadmon SPAM Source']['result'] = '127.0.0.3';
754  $filters['Leadmon SPAM Source']['comment'] =
755  _("FREE - Leadmon SPAM Source - List of IPs Leadmon.net has received SPAM directly from.");
756 
757  $filters['Leadmon Bulk Mailers']['prefname'] = 'filters_spam_lm_bm';
758  $filters['Leadmon Bulk Mailers']['name'] = 'Leadmon.net Bulk Mailers List';
759  $filters['Leadmon Bulk Mailers']['link'] = 'http://www.leadmon.net/spamguard/';
760  $filters['Leadmon Bulk Mailers']['dns'] = 'spamguard.leadmon.net';
761  $filters['Leadmon Bulk Mailers']['result'] = '127.0.0.4';
762  $filters['Leadmon Bulk Mailers']['comment'] =
763  _("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.");
764 
765  $filters['Leadmon Open Relays']['prefname'] = 'filters_spam_lm_or';
766  $filters['Leadmon Open Relays']['name'] = 'Leadmon.net Open Relays List';
767  $filters['Leadmon Open Relays']['link'] = 'http://www.leadmon.net/spamguard/';
768  $filters['Leadmon Open Relays']['dns'] = 'spamguard.leadmon.net';
769  $filters['Leadmon Open Relays']['result'] = '127.0.0.5';
770  $filters['Leadmon Open Relays']['comment'] =
771  _("FREE - Leadmon Open Relays - Single Stage Open Relays that are not listed on other active RBLs.");
772 
773  $filters['Leadmon Multi-stage']['prefname'] = 'filters_spam_lm_ms';
774  $filters['Leadmon Multi-stage']['name'] = 'Leadmon.net Multi-Stage Relay List';
775  $filters['Leadmon Multi-stage']['link'] = 'http://www.leadmon.net/spamguard/';
776  $filters['Leadmon Multi-stage']['dns'] = 'spamguard.leadmon.net';
777  $filters['Leadmon Multi-stage']['result'] = '127.0.0.6';
778  $filters['Leadmon Multi-stage']['comment'] =
779  _("FREE - Leadmon Multi-stage - Multi-Stage Open Relays that are not listed on other active RBLs and that have sent SPAM to Leadmon.net.");
780 
781  $filters['Leadmon SpamBlock']['prefname'] = 'filters_spam_lm_sb';
782  $filters['Leadmon SpamBlock']['name'] = 'Leadmon.net SpamBlock Sites List';
783  $filters['Leadmon SpamBlock']['link'] = 'http://www.leadmon.net/spamguard/';
784  $filters['Leadmon SpamBlock']['dns'] = 'spamguard.leadmon.net';
785  $filters['Leadmon SpamBlock']['result'] = '127.0.0.7';
786  $filters['Leadmon SpamBlock']['comment'] =
787  _("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.");
788 
789  $filters['NJABL Open Relays']['prefname'] = 'filters_spam_njabl_or';
790  $filters['NJABL Open Relays']['name'] = 'NJABL Open Relay/Direct Spam Source List';
791  $filters['NJABL Open Relays']['link'] = 'http://www.njabl.org/';
792  $filters['NJABL Open Relays']['dns'] = 'dnsbl.njabl.org';
793  $filters['NJABL Open Relays']['result'] = '127.0.0.2';
794  $filters['NJABL Open Relays']['comment'] =
795  _("FREE, for now - Not Just Another Blacklist - Both Open Relays and Direct SPAM Sources.");
796 
797  $filters['NJABL DUL']['prefname'] = 'filters_spam_njabl_dul';
798  $filters['NJABL DUL']['name'] = 'NJABL Dial-ups List';
799  $filters['NJABL DUL']['link'] = 'http://www.njabl.org/';
800  $filters['NJABL DUL']['dns'] = 'dnsbl.njabl.org';
801  $filters['NJABL DUL']['result'] = '127.0.0.3';
802  $filters['NJABL DUL']['comment'] =
803  _("FREE, for now - Not Just Another Blacklist - Dial-up IPs.");
804 
805  foreach ($filters as $Key => $Value) {
806  $filters[$Key]['enabled'] = (bool)getPref($data_dir, $username, $filters[$Key]['prefname']);
807  }
808 
809  return $filters;
810 }
811 
817 function remove_filter ($id) {
818  global $data_dir, $username;
819 
820  while ($nextFilter = getPref($data_dir, $username, 'filter' . ($id + 1))) {
821  setPref($data_dir, $username, 'filter' . $id, $nextFilter);
822  $id ++;
823  }
824 
825  removePref($data_dir, $username, 'filter' . $id);
826 }
827 
834 function filter_swap($id1, $id2) {
835  global $data_dir, $username;
836 
837  $FirstFilter = getPref($data_dir, $username, 'filter' . $id1);
838  $SecondFilter = getPref($data_dir, $username, 'filter' . $id2);
839 
840  if ($FirstFilter && $SecondFilter) {
841  setPref($data_dir, $username, 'filter' . $id2, $FirstFilter);
842  setPref($data_dir, $username, 'filter' . $id1, $SecondFilter);
843  }
844 }
845 
851 function update_for_folder ($args) {
852  $old_folder = $args[0];
853  $new_folder = $args[2];
854  $action = $args[1];
855  global $plugins, $data_dir, $username;
856  $filters = array();
858  $filter_count = count($filters);
859  $p = 0;
860  for ($i = 0; $i < $filter_count; $i++) {
861  if (!empty($filters)) {
862  if ($old_folder == $filters[$i]['folder']) {
863  if ($action == 'rename') {
864  $filters[$i]['folder'] = $new_folder;
865  setPref($data_dir, $username, 'filter'.$i,
866  $filters[$i]['where'].','.$filters[$i]['what'].','.$new_folder);
867  }
868  elseif ($action == 'delete') {
869  remove_filter($p);
870  $p = $p-1;
871  }
872  }
873  $p++;
874  }
875  }
876 }
877 
884 function do_error($string) {
885  global $color;
886  echo "<p align=\"center\"><font color=\"$color[2]\">";
887  echo $string;
888  echo "</font></p>\n";
889 }
load_filters
load_filters()
Definition: filters.php:550
load_spam_filters
load_spam_filters()
Definition: filters.php:568
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
$SpamFilters_ShowCommercial
global $SpamFilters_ShowCommercial
Definition: setup.php:81
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
getPref
getPref($data_dir, $username, $string, $default='')
Definition: db_prefs.php:316
sqimap_mailbox_expunge
sqimap_mailbox_expunge($imap_stream, $mailbox, $handle_errors=true, $id='')
Definition: imap_mailbox.php:198
$SpamFilters_YourHop
global $SpamFilters_YourHop
Definition: setup.php:69
filters_bulkquery
filters_bulkquery($filters_spam_scan, $filters, $read)
Definition: filters.php:88
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
filter_swap
filter_swap($id1, $id2)
Definition: filters.php:834
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$num
else $num
Definition: options_order.php:37
$data_dir
$data_dir
Definition: config_default.php:499
$filters_spam_folder
if(sqgetGlobalVar('spam_submit', $spam_submit, SQ_POST)) $filters_spam_folder
Definition: spamoptions.php:83
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
$imap_stream
$imap_stream
Definition: bug_report.php:119
$imap_server_type
$imap_server_type
Definition: config_default.php:231
$id
$id
Definition: move_messages.php:190
sqimap_mailbox_exists
sqimap_mailbox_exists($imap_stream, $mailbox)
Definition: imap_mailbox.php:226
$mailbox
$mailbox
Definition: options.php:28
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
user_filters
user_filters($imap_stream)
Definition: filters.php:249
parseFetch
parseFetch(&$aResponse, $aMessageList=array())
Definition: imap_messages.php:539
$username
global $username
Definition: validate.php:55
$plugins
global $plugins
Definition: plugin.php:196
sqimap_mailbox_select
sqimap_mailbox_select($imap_stream, $mailbox)
Definition: imap_mailbox.php:238
$filters_spam_scan
$filters_spam_scan
Definition: spamoptions.php:84
$SpamFilters_BulkQuery
global $SpamFilters_BulkQuery
Definition: setup.php:104
$uid_support
$uid_support
Definition: config_default.php:643
start_filters
start_filters()
Definition: filters.php:182
$AllowSpamFilters
global $AllowSpamFilters
Definition: options.php:35
$message
$message
Definition: download.php:54
$languages
global $languages
Definition: i18n.php:774
$filters
if(sqgetGlobalVar('filter_submit', $filter_submit, SQ_POST)) elseif(isset($action) && $action=='delete') elseif(isset($action) && $action=='move_up') elseif(isset($action) && $action=='move_down') elseif(sqgetGlobalVar('user_submit', $user_submit, SQ_POST)) $filters
Definition: options.php:115
sqimap_msgs_list_move
sqimap_msgs_list_move($imap_stream, $id, $mailbox, $handle_errors=true)
Definition: imap_messages.php:56
$attachment_dir
$attachment_dir
Definition: config_default.php:517
$filters_user_scan
$filters_user_scan
Definition: options.php:116
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
removePref
removePref($data_dir, $username, $string)
Definition: db_prefs.php:331
filter_search_and_delete
filter_search_and_delete($imap, $where, $what, $where_to, $user_scan, $del_id)
Definition: filters.php:301
sqimap_run_literal_command
sqimap_run_literal_command($imap_stream, $query, $handle_errors, &$response, &$message, $unique_id=false)
Definition: imap_general.php:79
$r
while(count($Left) > 0) $r
Definition: darkness.php:103
$j
for($i=0; $i< $numboxes; $i++) $j
Definition: empty_trash.php:72
do_error
do_error($string)
Definition: filters.php:884
$allow_charset_search
$allow_charset_search
Definition: config_default.php:635
sqimap_run_command_list
sqimap_run_command_list($imap_stream, $query, $handle_errors, &$response, &$message, $unique_id=false)
Definition: imap_general.php:40
filters_LoadCache
filters_LoadCache()
Definition: filters.php:63
$SpamFilters_SharedCache
global $SpamFilters_SharedCache
Definition: setup.php:116
$UseSeparateImapConnection
global $UseSeparateImapConnection
Definition: setup.php:29
remove_filter
remove_filter($id)
Definition: filters.php:817
$data
$data
Definition: mailto.php:83
sqimap_status_messages
sqimap_status_messages($imap_stream, $mailbox)
Definition: imap_general.php:932
$action
$action
Definition: options.php:34
sqsession_register
sqsession_register($var, $name)
Definition: global.php:289
_
_($str)
Definition: gettext.php:160
filters_SaveCache
filters_SaveCache()
Definition: filters.php:32
$read
$read
Definition: message_details_bottom.php:75
sqimap_message_list_squisher
sqimap_message_list_squisher($messages_array)
Definition: imap_messages.php:91
spam_filters
spam_filters($imap_stream)
Definition: filters.php:375
sqimap_run_command
sqimap_run_command($imap_stream, $query, $handle_errors, &$response, &$message, $unique_id=false, $filter=false, $outputstream=false, $no_return=false)
Definition: imap_general.php:58
$imapPort
$imapPort
Definition: config_default.php:210
$color
$color
Definition: load_prefs.php:28
$stream
$stream
Definition: configtest.php:429
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
$squirrelmail_language
global $squirrelmail_language
Definition: i18n.php:774
filters_spam_check_site
filters_spam_check_site($a, $b, $c, $d, &$filters)
Definition: filters.php:505
$SpamFilters_DNScache
global $SpamFilters_DNScache
Definition: setup.php:94
$SpamFilters_CacheTTL
global $SpamFilters_CacheTTL
Definition: setup.php:125
update_for_folder
update_for_folder($args)
Definition: filters.php:851
SMPREF_ON
const SMPREF_ON
Definition: constants.php:28