849bdf42 |
1 | <?php |
15e6162e |
2 | /** |
3 | * Message and Spam Filter Plugin |
4 | * |
5 | * Copyright (c) 1999-2002 The SquirrelMail Project Team |
6 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
7 | * |
8 | * This plugin filters your inbox into different folders based upon given |
9 | * criteria. It is most useful for people who are subscibed to mailing lists |
10 | * to help organize their messages. The argument stands that filtering is |
11 | * not the place of the client, which is why this has been made a plugin for |
12 | * SquirrelMail. You may be better off using products such as Sieve or |
13 | * Procmail to do your filtering so it happens even when SquirrelMail isn't |
14 | * running. |
15 | * |
16 | * If you need help with this, or see improvements that can be made, please |
17 | * email me directly at the address above. I definately welcome suggestions |
18 | * and comments. This plugin, as is the case with all SquirrelMail plugins, |
19 | * is not directly supported by the developers. Please come to me off the |
20 | * mailing list if you have trouble with it. |
21 | * |
22 | * Also view plugins/README.plugins for more information. |
23 | * |
24 | * $Id$ |
25 | */ |
849bdf42 |
26 | |
10a26cea |
27 | /* |
28 | * Set this to true if you have problems -- check the README file |
29 | * Note: This doesn't work all of the time (No idea why) |
30 | * Seems to be related to UW |
31 | */ |
32 | global $UseSeparateImapConnection; |
33 | $UseSeparateImapConnection = false; |
3fd1252d |
34 | |
10a26cea |
35 | /* |
36 | * Set this to false if you do not want the user to be able to enable |
37 | * spam filters |
38 | */ |
39 | global $AllowSpamFilters; |
40 | $AllowSpamFilters = true; |
3fd1252d |
41 | |
10a26cea |
42 | /* |
43 | * Set this to a string containing something unique to the line in the |
44 | * header you want me to find IPs to scan the databases with. For example, |
45 | * All the email coming IN from the internet to my site has a line in |
46 | * the header that looks like (all on one line): |
47 | * Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net |
48 | * [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam |
49 | * 0.2) with |
50 | * Since this line indicates the FIRST hop the email takes into my network, |
51 | * I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any |
52 | * case-sensitive string will do. You can set it to something found on |
53 | * every line in the header (like ' ') if you want to scan all IPs in |
54 | * the header (lots of false alarms here tho). |
55 | */ |
56 | global $SpamFilters_YourHop; |
57 | $SpamFilters_YourHop = ' '; |
849bdf42 |
58 | |
51199e7a |
59 | /* |
60 | * Some of the SPAM filters are COMMERCIAL and require a fee. If your users |
61 | * select them and you're not allowed to use them, it will make SPAM filtering |
62 | * very slow. If you don't want them to even be offered to the users, you |
63 | * set SpamFilters_ShowCommercial to false. |
64 | */ |
65 | global $SpamFilters_ShowCommercial; |
66 | $SpamFilters_ShowCommercial = true; |
67 | |
10a26cea |
68 | /* |
69 | * A cache of IPs we've already checked or are known bad boys or good boys |
70 | * ie. $SpamFilters_DNScache["210.54.220.18"] = true; |
71 | * would tell filters to not even bother doing the DNS queries for that |
72 | * IP and any email coming from it are SPAM - false would mean that any |
73 | * email coming from it would NOT be SPAM |
74 | */ |
75 | global $SpamFilters_DNScache; |
849bdf42 |
76 | |
10a26cea |
77 | require_once ('../plugins/filters/filters.php'); |
849bdf42 |
78 | |
10a26cea |
79 | function squirrelmail_plugin_init_filters() { |
80 | global $squirrelmail_plugin_hooks; |
81 | global $mailbox, $imap_stream, $imapConnection; |
849bdf42 |
82 | |
10a26cea |
83 | $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters'; |
84 | if ($mailbox == 'INBOX') { |
85 | $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters'; |
86 | } |
87 | $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'squirrelmail_plugin_optpage_register_block'; |
d9a8ac55 |
88 | # $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; |
10a26cea |
89 | } |
849bdf42 |
90 | |
10a26cea |
91 | function filters_special_mailbox( $mb ) { |
92 | GLOBAL $data_dir, $username; |
2586d588 |
93 | |
10a26cea |
94 | return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) ); |
2586d588 |
95 | |
10a26cea |
96 | } |
849bdf42 |
97 | |
10a26cea |
98 | function squirrelmail_plugin_optpage_register_block() { |
99 | global $optpage_blocks; |
100 | global $AllowSpamFilters; |
849bdf42 |
101 | |
10a26cea |
102 | $optpage_blocks[] = array( |
103 | 'name' => _("Message Filters"), |
104 | 'url' => '../plugins/filters/options.php', |
105 | 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."), |
106 | 'js' => false |
107 | ); |
eec81600 |
108 | |
10a26cea |
109 | if ($AllowSpamFilters) { |
110 | $optpage_blocks[] = array( |
eec81600 |
111 | 'name' => _("SPAM Filters"), |
112 | 'url' => '../plugins/filters/spamoptions.php', |
113 | 'desc' => _("SPAM filters allow you to select from various DNS based blacklists to detect junk email in your INBOX and move it to another folder (like Trash)."), |
114 | 'js' => false |
10a26cea |
115 | ); |
116 | } |
117 | } |
cbe5423b |
118 | ?> |