| 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; } |
| 13 | function name() { return _i18n('1_bogo'); } |
| 14 | |
| 15 | /* the plugin is only global */ |
| 16 | function is_global() { return true; } |
| 17 | |
| 18 | function to_string($_data) { |
| 19 | global $philter; |
| 20 | $bogo = $philter->config['path']['bogofilter']; |
| 21 | if($_data[1]==1) |
| 22 | return ":0 fw\n" |
| 23 | . "| $bogo -u -e -p\n" |
| 24 | . ":0 e\n" |
| 25 | . "{ EXITCODE=75 HOST }\n" |
| 26 | . "\n"; |
| 27 | |
| 28 | if($_data[1]==2) |
| 29 | return ":0 HB:\n" |
| 30 | . "* ? $bogo\n" |
| 31 | . "/dev/null\n"; |
| 32 | |
| 33 | return ""; |
| 34 | } |
| 35 | |
| 36 | function to_form($_data) { |
| 37 | $res = "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"1\">\n" |
| 38 | . "<tr><th width=\"25%\">"._i18n('1_bogo')."</th>\n"; |
| 39 | |
| 40 | $res .= "<td><input type='hidden' name='global[1][0]' value='1' />\n" |
| 41 | . " <input type='radio' name='global[1][1]' value='0' " |
| 42 | . ($_data[1]==0 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_off')."<br />\n" |
| 43 | . " <input type='radio' name='global[1][1]' value='1' " |
| 44 | . ($_data[1]==1 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_on')."<br />\n" |
| 45 | . " <input type='radio' name='global[1][1]' value='2' " |
| 46 | . ($_data[1]==2 ? 'checked="checked "' : '')."/>"._i18n('1_bogo_drop')."<br />\n" |
| 47 | . "</td>\n"; |
| 48 | |
| 49 | $res .= "</tr>\n" |
| 50 | . "</table>\n"; |
| 51 | |
| 52 | return $res; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | /******************************************************************************** |
| 57 | * $Id$ |
| 58 | * vim: set expandtab shiftwidth=4 tabstop=4 softtabstop=4 textwidth=100: |
| 59 | ********************************************************************************/ |
| 60 | ?> |