Calendar rg=0
[squirrelmail.git] / plugins / filters / setup.php
CommitLineData
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
08185f2a 27/* Path for SquirrelMail required files. */
28define('SM_PATH','../../');
29
30/* SquirrelMail required files. */
31require_once(SM_PATH . 'plugins/filters/filters.php');
32
10a26cea 33/*
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
37 */
38global $UseSeparateImapConnection;
39$UseSeparateImapConnection = false;
3fd1252d 40
10a26cea 41/*
42 * Set this to false if you do not want the user to be able to enable
43 * spam filters
44 */
45global $AllowSpamFilters;
46$AllowSpamFilters = true;
3fd1252d 47
10a26cea 48/*
49 * Set this to a string containing something unique to the line in the
50 * header you want me to find IPs to scan the databases with. For example,
51 * All the email coming IN from the internet to my site has a line in
52 * the header that looks like (all on one line):
53 * Received: [from usw-sf-list1.sourceforge.net (usw-sf-fw2.sourceforge.net
54 * [216.136.171.252]) by firewall.persistence.com (SYSADMIN-antispam
55 * 0.2) with
56 * Since this line indicates the FIRST hop the email takes into my network,
57 * I set my SpamFilters_YourHop to 'by firewall.persistence.com' but any
58 * case-sensitive string will do. You can set it to something found on
59 * every line in the header (like ' ') if you want to scan all IPs in
60 * the header (lots of false alarms here tho).
61 */
62global $SpamFilters_YourHop;
63$SpamFilters_YourHop = ' ';
849bdf42 64
10a26cea 65/*
51199e7a 66 * Some of the SPAM filters are COMMERCIAL and require a fee. If your users
67 * select them and you're not allowed to use them, it will make SPAM filtering
68 * very slow. If you don't want them to even be offered to the users, you
a2a566eb 69 * should set SpamFilters_ShowCommercial to false.
51199e7a 70 */
71global $SpamFilters_ShowCommercial;
a2a566eb 72$SpamFilters_ShowCommercial = false;
51199e7a 73
74/*
10a26cea 75 * A cache of IPs we've already checked or are known bad boys or good boys
76 * ie. $SpamFilters_DNScache["210.54.220.18"] = true;
77 * would tell filters to not even bother doing the DNS queries for that
78 * IP and any email coming from it are SPAM - false would mean that any
79 * email coming from it would NOT be SPAM
80 */
81global $SpamFilters_DNScache;
849bdf42 82
a2a566eb 83/*
84 * Absolute path to the bulkquery program. Leave blank if you don't have
85 * bulkquery compiled, installed, and lwresd running. See the README file
86 * in the bulkquery directory for more information on using bulkquery.
87 */
88global $SpamFilters_BulkQuery;
89$SpamFilters_BulkQuery = "";
90
91/*
92 * Do you want to use a shared file for the DNS cache or a session variable?
93 * Using a shared file means that every user can benefit from any queries
94 * made by other users. The shared file is named "dnscache" and is in the
95 * data directory.
96 */
97global $SpamFilters_SharedCache;
98$SpamFilters_SharedCache = true;
99
100/*
101 * How long should DNS query results be cached for by default (in seconds)?
102 */
103global $SpamFilters_CacheTTL;
104$SpamFilters_CacheTTL = 7200;
105
10a26cea 106function squirrelmail_plugin_init_filters() {
107 global $squirrelmail_plugin_hooks;
108 global $mailbox, $imap_stream, $imapConnection;
849bdf42 109
10a26cea 110 $squirrelmail_plugin_hooks['left_main_before']['filters'] = 'start_filters';
111 if ($mailbox == 'INBOX') {
112 $squirrelmail_plugin_hooks['right_main_after_header']['filters'] = 'start_filters';
113 }
f1b526cd 114 $squirrelmail_plugin_hooks['optpage_register_block']['filters'] = 'filters_optpage_register_block';
d9a8ac55 115# $squirrelmail_plugin_hooks['special_mailbox']['filters'] = 'filters_special_mailbox';
f5ab1fb9 116 $squirrelmail_plugin_hooks['rename_or_delete_folder']['filters'] = 'update_for_folder';
753ce838 117 $squirrelmail_plugin_hooks['webmail_bottom']['filters'] = 'start_filters';
10a26cea 118}
a2a566eb 119
10a26cea 120function filters_special_mailbox( $mb ) {
121 GLOBAL $data_dir, $username;
2586d588 122
10a26cea 123 return( $mb == getPref($data_dir, $username, 'filters_spam_folder', 'na' ) );
2586d588 124
10a26cea 125}
849bdf42 126
f1b526cd 127function filters_optpage_register_block() {
10a26cea 128 global $optpage_blocks;
129 global $AllowSpamFilters;
849bdf42 130
10a26cea 131 $optpage_blocks[] = array(
132 'name' => _("Message Filters"),
133 'url' => '../plugins/filters/options.php',
134 'desc' => _("Filtering enables messages with different criteria to be automatically filtered into different folders for easier organization."),
135 'js' => false
136 );
eec81600 137
10a26cea 138 if ($AllowSpamFilters) {
139 $optpage_blocks[] = array(
eec81600 140 'name' => _("SPAM Filters"),
141 'url' => '../plugins/filters/spamoptions.php',
142 '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)."),
143 'js' => false
10a26cea 144 );
145 }
146}
cbe5423b 147?>