Commit | Line | Data |
---|---|---|
dd8de1ec PH |
1 | <?php |
2 | /******************************************************************************** | |
3 | * include/plugin_bogofilter.inc.php : A Match Plugin using bogofilter | |
4 | * --------------------------------- | |
5 | * | |
6 | * This file is part of the philter distribution | |
7 | * Copyright: See COPYING files that comes with this distribution | |
8 | ********************************************************************************/ | |
9 | ||
10 | class BogoPlugin extends MatchPlugin { | |
11 | function BogoPlugin($_glob=false) { $this->MatchPlugin($_glob); } | |
12 | function rtti() { return 1; } | |
de47756d | 13 | function name() { return _i18n('1_bogo'); } |
dd8de1ec PH |
14 | |
15 | /* the plugin is only global */ | |
16 | function is_global() { return true; } | |
17 | ||
dd8de1ec PH |
18 | function to_string($_data) { |
19 | if($_data['data']=='off') | |
20 | return ""; | |
21 | ||
22 | $res = ":0 HB\n" | |
23 | . "* ? bogofilter\n" | |
24 | . "{\n" | |
25 | . " :0 c\n" | |
26 | . " /var/mail/spam/\n" | |
27 | . " :0 h\n" | |
28 | . " SUBJECT=| formail -xSubject:\n" | |
29 | . " :0 fhW\n" | |
30 | . " | formail -I \"X-Spam-Flag: YES\" -i \"Subject: [Xorg:SPAM]$"."SUBJECT\"\n" | |
31 | . ($_data["data"] == "drop" ? " :0\n /dev/null\n" : "") | |
32 | . "}\n" | |
33 | . ":0 Ec\n" | |
34 | . "/var/mail/nonspam/\n" | |
35 | . "\n"; | |
36 | ||
37 | return $res; | |
38 | } | |
39 | ||
de47756d | 40 | function to_form($_data) { |
86b5093c | 41 | $res = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"1\">\n" |
fe9450a2 | 42 | . "<tr><th width=\"25%\">"._i18n('1_bogo')."</th>\n"; |
dd8de1ec | 43 | |
de47756d PH |
44 | $res .= "<td><input type='hidden' name='global[1][0]' value='1' />\n" |
45 | . " <input type='radio' name='global[1][1]' value='0' " | |
46 | . ($_data[1]==0 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_off')."<br />\n" | |
47 | . " <input type='radio' name='global[1][1]' value='1' " | |
48 | . ($_data[1]==1 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_on')."<br />\n" | |
49 | . " <input type='radio' name='global[1][1]' value='2' " | |
50 | . ($_data[1]==2 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_drop')."<br />\n" | |
51 | . "</td>\n"; | |
dd8de1ec PH |
52 | |
53 | $res .= "</tr>\n" | |
54 | . "</table>\n"; | |
55 | ||
56 | return $res; | |
57 | } | |
58 | } | |
59 | ||
60 | /******************************************************************************** | |
61 | * $Id$ | |
62 | * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: | |
63 | ********************************************************************************/ | |
64 | ?> |