849bdf42 |
1 | <?php |
15e6162e |
2 | /** |
b2d8bc6c |
3 | * Message and Spam Filter Plugin - Setup script |
15e6162e |
4 | * |
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$ |
b2d8bc6c |
22 | * @copyright (c) 1999-2004 The SquirrelMail Project Team |
23 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
ea5f4b8e |
24 | * @package plugins |
25 | * @subpackage filters |
15e6162e |
26 | */ |
849bdf42 |
27 | |
ea5f4b8e |
28 | /** SquirrelMail required files. */ |
08185f2a |
29 | require_once(SM_PATH . 'plugins/filters/filters.php'); |
30 | |
0a1dc88e |
31 | /** |
32 | * Imap connection control |
33 | * |
10a26cea |
34 | * Set this to true if you have problems -- check the README file |
35 | * Note: This doesn't work all of the time (No idea why) |
36 | * Seems to be related to UW |
0a1dc88e |
37 | * @global bool $UseSeparateImapConnection |
10a26cea |
38 | */ |
39 | global $UseSeparateImapConnection; |
40 | $UseSeparateImapConnection = false; |
3fd1252d |
41 | |
0a1dc88e |
42 | /** |
43 | * User level spam filters control |
44 | * |
10a26cea |
45 | * Set this to false if you do not want the user to be able to enable |
46 | * spam filters |
0a1dc88e |
47 | * @global bool $AllowSpamFilters |
10a26cea |
48 | */ |
49 | global $AllowSpamFilters; |
50 | $AllowSpamFilters = true; |
3fd1252d |
51 | |
0a1dc88e |
52 | /** |
53 | * SpamFilters YourHop Setting |
54 | * |
10a26cea |
55 | * Set this to a string containing something unique to the line in the |
56 | * header you want me to find IPs to scan the databases with. For example, |
57 | * All the email coming IN from the internet to my site has a line in |
58 | * the header that looks like (all on one line): |
59 | * Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net |
60 | * [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam |
61 | * 0.2) with |
62 | * Since this line indicates the FIRST hop the email takes into my network, |
63 | * I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any |
64 | * case-sensitive string will do. You can set it to something found on |
65 | * every line in the header (like ' ') if you want to scan all IPs in |
66 | * the header (lots of false alarms here tho). |
0a1dc88e |
67 | * @global string $SpamFilters_YourHop |
10a26cea |
68 | */ |
69 | global $SpamFilters_YourHop; |
70 | $SpamFilters_YourHop = ' '; |
849bdf42 |
71 | |
0a1dc88e |
72 | /** |
73 | * Commercial Spam Filters Control |
74 | * |
51199e7a |
75 | * Some of the SPAM filters are COMMERCIAL and require a fee. If your users |
76 | * select them and you're not allowed to use them, it will make SPAM filtering |
77 | * very slow. If you don't want them to even be offered to the users, you |
a2a566eb |
78 | * should set SpamFilters_ShowCommercial to false. |
0a1dc88e |
79 | * @global bool $SpamFilters_ShowCommercial |
51199e7a |
80 | */ |
81 | global $SpamFilters_ShowCommercial; |
a2a566eb |
82 | $SpamFilters_ShowCommercial = false; |
51199e7a |
83 | |
0a1dc88e |
84 | /** |
85 | * SpamFiltring Cache |
86 | * |
10a26cea |
87 | * A cache of IPs we've already checked or are known bad boys or good boys |
88 | * ie. $SpamFilters_DNScache["210.54.220.18"] = true; |
89 | * would tell filters to not even bother doing the DNS queries for that |
90 | * IP and any email coming from it are SPAM - false would mean that any |
91 | * email coming from it would NOT be SPAM |
0a1dc88e |
92 | * @global array $SpamFilters_DNScache |
10a26cea |
93 | */ |
94 | global $SpamFilters_DNScache; |
849bdf42 |
95 | |
0a1dc88e |
96 | /** |
97 | * Path to bulkquery program |
98 | * |
a2a566eb |
99 | * Absolute path to the bulkquery program. Leave blank if you don't have |
100 | * bulkquery compiled, installed, and lwresd running. See the README file |
101 | * in the bulkquery directory for more information on using bulkquery. |
0a1dc88e |
102 | * @global string $SpamFilters_BulkQuery |
a2a566eb |
103 | */ |
104 | global $SpamFilters_BulkQuery; |
ae48f757 |
105 | $SpamFilters_BulkQuery = ''; |
a2a566eb |
106 | |
0a1dc88e |
107 | /** |
108 | * Shared filtering cache control |
109 | * |
a2a566eb |
110 | * Do you want to use a shared file for the DNS cache or a session variable? |
111 | * Using a shared file means that every user can benefit from any queries |
112 | * made by other users. The shared file is named "dnscache" and is in the |
113 | * data directory. |
0a1dc88e |
114 | * @global bool $SpamFilters_SharedCache |
a2a566eb |
115 | */ |
116 | global $SpamFilters_SharedCache; |
117 | $SpamFilters_SharedCache = true; |
118 | |
0a1dc88e |
119 | /** |
120 | * DNS query TTL |
121 | * |
a2a566eb |
122 | * How long should DNS query results be cached for by default (in seconds)? |
0a1dc88e |
123 | * @global integer $SpamFilters_CacheTTL |
a2a566eb |
124 | */ |
125 | global $SpamFilters_CacheTTL; |
126 | $SpamFilters_CacheTTL = 7200; |
127 | |
0a1dc88e |
128 | /** |
129 | * Init plugin |
130 | * @access private |
131 | */ |
10a26cea |
132 | function squirrelmail_plugin_init_filters() { |
133 | global $squirrelmail_plugin_hooks; |
41100fce |
134 | |
0a1dc88e |
135 | if (sqgetGlobalVar('mailbox',$mailbox,SQ_FORM)) { |
91e0dccc |
136 | sqgetGlobalVar('mailbox',$mailbox,SQ_FORM); |
0a1dc88e |
137 | } else { |
41100fce |
138 | $mailbox = 'INBOX'; |
139 | } |
849bdf42 |
140 | |
10a26cea |
141 | $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters'; |
41100fce |
142 | if (isset($mailbox) && $mailbox == 'INBOX') { |
10a26cea |
143 | $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters'; |
144 | } |
f1b526cd |
145 | $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block'; |
c3fe0644 |
146 | $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox'; |
f5ab1fb9 |
147 | $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder'; |
753ce838 |
148 | $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters'; |
10a26cea |
149 | } |
a2a566eb |
150 | |
0a1dc88e |
151 | /** |
0d725b45 |
152 | * Report spam folder as special mailbox |
0a1dc88e |
153 | * @param string $mb variable used by hook |
154 | * @return string spam folder name |
91e0dccc |
155 | * @access private |
0a1dc88e |
156 | */ |
10a26cea |
157 | function filters_special_mailbox( $mb ) { |
0a1dc88e |
158 | global $data_dir, $username; |
2586d588 |
159 | |
10a26cea |
160 | return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) ); |
2586d588 |
161 | |
10a26cea |
162 | } |
849bdf42 |
163 | |
0a1dc88e |
164 | /** |
165 | * Register option blocks |
166 | * @access private |
167 | */ |
f1b526cd |
168 | function filters_optpage_register_block() { |
10a26cea |
169 | global $optpage_blocks; |
170 | global $AllowSpamFilters; |
849bdf42 |
171 | |
10a26cea |
172 | $optpage_blocks[] = array( |
173 | 'name' => _("Message Filters"), |
174 | 'url' => '../plugins/filters/options.php', |
175 | 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."), |
176 | 'js' => false |
177 | ); |
eec81600 |
178 | |
10a26cea |
179 | if ($AllowSpamFilters) { |
180 | $optpage_blocks[] = array( |
eec81600 |
181 | 'name' => _("SPAM Filters"), |
182 | 'url' => '../plugins/filters/spamoptions.php', |
183 | '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)."), |
184 | 'js' => false |
10a26cea |
185 | ); |
186 | } |
187 | } |
91e0dccc |
188 | ?> |