8455dc52739676c166c68005068d35388c17e583
4 * Message and Spam Filter Plugin - Spam Options
6 * @copyright 1999-2011 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
);
28 displayPageHeader($color);
30 if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST
)) {
31 $spam_filters = load_spam_filters();
33 // setting spam folder
34 sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST
);
35 if (isset($filters_spam_folder_set)) {
36 setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
38 echo _("You must select a spam folder.");
42 sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST
);
43 if (isset($filters_spam_scan_set)) {
44 setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
46 echo _("You must select a scan type.");
49 foreach ($spam_filters as $Key => $Value) {
50 $input = $spam_filters[$Key]['prefname'] . '_set';
51 if ( sqgetGlobalVar($input,$input_key,SQ_POST
) ) {
52 setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
54 removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
59 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
60 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
61 $filters = load_filters();
63 echo html_tag( 'table',
65 html_tag( 'th', _("Spam Filtering"), 'center' )
67 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
69 if ($SpamFilters_YourHop == ' ') {
71 html_tag( 'div', '<b>' .
72 sprintf(_("WARNING! Tell the administrator to set the %s variable."), '"SpamFilters_YourHop"') .
79 if (isset($action) && $action == 'spam') {
80 $imapConnection = sqimap_login($username, false, $imapServerAddress, $imapPort, 0);
81 $boxes = sqimap_mailbox_list($imapConnection);
82 sqimap_logout($imapConnection);
83 $numboxes = count($boxes);
85 for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++
) {
86 if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
87 (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
88 (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
89 $filters_spam_folder = $boxes[$i]['unformatted'];
93 echo '<form method="post" action="spamoptions.php">'.
94 '<div style="text-align: center;">'.
95 html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
97 html_tag( 'th', _("Move spam to:"), 'right', '', 'style="white-space: nowrap;"' ) .
98 html_tag( 'td', '', 'left' ) .
99 '<select name="filters_spam_folder_set">';
102 if ( isset($filters_spam_folder) )
103 $selected = array(strtolower($filters_spam_folder));
104 echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
109 html_tag( 'td', ' ' ) .
111 _("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.") ,
115 html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) .
117 '<select name="filters_spam_scan_set">'.
119 if ($filters_spam_scan == '') {
120 echo ' selected="selected"';
122 echo '>' . _("All messages") . '</option>'.
123 '<option value="new"';
124 if ($filters_spam_scan == 'new') {
125 echo ' selected="selected"';
127 echo '>' . _("Unread messages only") . '</option>' .
132 html_tag( 'td', ' ' ) .
134 _("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.") ,
138 $spam_filters = load_spam_filters();
140 foreach ($spam_filters as $Key => $Value) {
141 echo html_tag( 'tr' ) .
142 html_tag( 'th', $Key, 'right', '', 'style="white-space: nowrap;"' ) ."\n" .
144 '<input type="checkbox" name="' .
145 $spam_filters[$Key]['prefname'] .
147 if ($spam_filters[$Key]['enabled']) {
148 echo ' checked="checked"';
151 if ($spam_filters[$Key]['link']) {
153 $spam_filters[$Key]['link'] .
154 '" target="_blank">';
156 echo $spam_filters[$Key]['name'];
157 if ($spam_filters[$Key]['link']) {
162 html_tag( 'td', ' ' ) .
163 html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
168 html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
174 // action is not set or action is not spam
175 echo html_tag( 'p', '', 'center' ) .
176 '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
177 ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</div><br /><br />';
178 printf( _("Spam is sent to %s."), ($filters_spam_folder?
'<b>'.htmlspecialchars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
180 printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?
_("Unread messages only"):_("All messages") ) . '</b>' );
182 '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
184 $spam_filters = load_spam_filters();
186 foreach ($spam_filters as $Key => $Value) {
187 echo html_tag( 'tr' ) .
188 html_tag( 'th', '', 'center' );
190 if ($spam_filters[$Key]['enabled']) {
197 html_tag( 'td', ' - ', 'left' ) .
198 html_tag( 'td', '', 'left' );
200 if ($spam_filters[$Key]['link']) {
202 $spam_filters[$Key]['link'] .
203 '" target="_blank">';
206 echo $spam_filters[$Key]['name'];
207 if ($spam_filters[$Key]['link']) {