c7f8b739b2342c0c79f0ee11ba4c943becf59dcf
4 * Message and Spam Filter Plugin - Spam Options
6 * @copyright 1999-2014 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 * Include the SquirrelMail initialization file.
16 require('../../include/init.php');
18 include_once(SM_PATH
. 'functions/imap_general.php');
19 include_once(SM_PATH
. 'functions/imap_messages.php');
20 include_once(SM_PATH
. 'plugins/filters/filters.php');
23 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
25 sqgetGlobalVar('action', $action, SQ_GET
);
26 global $imap_stream_options; // in case not defined in config
29 displayPageHeader($color);
31 if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST
)) {
32 $spam_filters = load_spam_filters();
34 // setting spam folder
35 sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST
);
36 if (isset($filters_spam_folder_set)) {
37 setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
39 echo _("You must select a spam folder.");
43 sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST
);
44 if (isset($filters_spam_scan_set)) {
45 setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
47 echo _("You must select a scan type.");
50 foreach ($spam_filters as $Key => $Value) {
51 $input = $spam_filters[$Key]['prefname'] . '_set';
52 if ( sqgetGlobalVar($input,$input_key,SQ_POST
) ) {
53 setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
55 removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
60 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
61 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
62 $filters = load_filters();
64 echo html_tag( 'table',
66 html_tag( 'th', _("Spam Filtering"), 'center' )
68 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
70 if ($SpamFilters_YourHop == ' ') {
72 html_tag( 'div', '<b>' .
73 sprintf(_("WARNING! Tell the administrator to set the %s variable."), '"SpamFilters_YourHop"') .
80 if (isset($action) && $action == 'spam') {
81 $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
82 $boxes = sqimap_mailbox_list($imapConnection);
83 sqimap_logout($imapConnection);
84 $numboxes = count($boxes);
86 for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++
) {
87 if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
88 (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
89 (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
90 $filters_spam_folder = $boxes[$i]['unformatted'];
94 echo '<form method="post" action="spamoptions.php">'.
95 '<div style="text-align: center;">'.
96 html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
98 html_tag( 'th', _("Move spam to:"), 'right', '', 'style="white-space: nowrap;"' ) .
99 html_tag( 'td', '', 'left' ) .
100 '<select name="filters_spam_folder_set">';
103 if ( isset($filters_spam_folder) )
104 $selected = array(strtolower($filters_spam_folder));
105 echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
110 html_tag( 'td', ' ' ) .
112 _("Moving spam directly to the trash may not be a good idea at first, since messages from friends and mailing lists might accidentally be marked as spam. Whatever folder you set this to, make sure that it gets cleaned out periodically, so that you don't have an excessively large mailbox hanging around.") ,
116 html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) .
118 '<select name="filters_spam_scan_set">'.
120 if ($filters_spam_scan == '') {
121 echo ' selected="selected"';
123 echo '>' . _("All messages") . '</option>'.
124 '<option value="new"';
125 if ($filters_spam_scan == 'new') {
126 echo ' selected="selected"';
128 echo '>' . _("Unread messages only") . '</option>' .
133 html_tag( 'td', ' ' ) .
135 _("The more messages scanned, the longer it takes. It's recommended to scan unread messages only. If a change to the filters is made, it's recommended to set it to scan all messages, then go view the INBOX, then come back and set it to scan unread messages only. That way, the new spam filters will be applied and even the spam you didn't catch with the old filters will be scanned.") ,
139 $spam_filters = load_spam_filters();
141 foreach ($spam_filters as $Key => $Value) {
142 echo html_tag( 'tr' ) .
143 html_tag( 'th', $Key, 'right', '', 'style="white-space: nowrap;"' ) ."\n" .
145 '<input type="checkbox" name="' .
146 $spam_filters[$Key]['prefname'] .
148 if ($spam_filters[$Key]['enabled']) {
149 echo ' checked="checked"';
152 if ($spam_filters[$Key]['link']) {
154 $spam_filters[$Key]['link'] .
155 '" target="_blank">';
157 echo $spam_filters[$Key]['name'];
158 if ($spam_filters[$Key]['link']) {
163 html_tag( 'td', ' ' ) .
164 html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
169 html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
175 // action is not set or action is not spam
176 echo html_tag( 'p', '', 'center' ) .
177 '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
178 ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</div><br /><br />';
179 printf( _("Spam is sent to %s."), ($filters_spam_folder?
'<b>'.sm_encode_html_special_chars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
181 printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?
_("Unread messages only"):_("All messages") ) . '</b>' );
183 '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
185 $spam_filters = load_spam_filters();
187 foreach ($spam_filters as $Key => $Value) {
188 echo html_tag( 'tr' ) .
189 html_tag( 'th', '', 'center' );
191 if ($spam_filters[$Key]['enabled']) {
198 html_tag( 'td', ' - ', 'left' ) .
199 html_tag( 'td', '', 'left' );
201 if ($spam_filters[$Key]['link']) {
203 $spam_filters[$Key]['link'] .
204 '" target="_blank">';
207 echo $spam_filters[$Key]['name'];
208 if ($spam_filters[$Key]['link']) {