b228298f3fc2bf6b3fd22816e52795dfd20bf8b6
4 * Message and Spam Filter Plugin - Spam Options
6 * @copyright © 1999-2006 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('username', $username, SQ_SESSION
);
24 sqgetGlobalVar('key', $key, SQ_COOKIE
);
25 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
26 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
28 sqgetGlobalVar('action', $action, SQ_GET
);
31 displayPageHeader($color, 'None');
33 if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST
)) {
34 $spam_filters = load_spam_filters();
36 // setting spam folder
37 sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST
);
38 if (isset($filters_spam_folder_set)) {
39 setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
41 echo _("You must select a spam folder.");
45 sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST
);
46 if (isset($filters_spam_scan_set)) {
47 setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
49 echo _("You must select a scan type.");
52 foreach ($spam_filters as $Key => $Value) {
53 $input = $spam_filters[$Key]['prefname'] . '_set';
54 if ( sqgetGlobalVar($input,$input_key,SQ_POST
) ) {
55 setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
57 removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
62 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
63 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
64 $filters = load_filters();
66 echo html_tag( 'table',
68 html_tag( 'th', _("Spam Filtering"), 'center' )
70 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
72 if ($SpamFilters_YourHop == ' ') {
74 html_tag( 'div', '<b>' .
75 sprintf(_("WARNING! Tell the administrator to set the %s variable."), '"SpamFilters_YourHop"') .
82 if (isset($action) && $action == 'spam') {
83 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
84 $boxes = sqimap_mailbox_list($imapConnection);
85 sqimap_logout($imapConnection);
86 $numboxes = count($boxes);
88 for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++
) {
89 if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
90 (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
91 (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
92 $filters_spam_folder = $boxes[$i]['unformatted'];
96 echo '<form method="post" action="spamoptions.php">'.
97 '<div style="text-align: center;">'.
98 html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
100 html_tag( 'th', _("Move spam to:"), 'right', '', 'style="white-space: nowrap;"' ) .
101 html_tag( 'td', '', 'left' ) .
102 '<select name="filters_spam_folder_set">';
105 if ( isset($filters_spam_folder) )
106 $selected = array(strtolower($filters_spam_folder));
107 echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
112 html_tag( 'td', ' ' ) .
114 _("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.") ,
118 html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) .
120 '<select name="filters_spam_scan_set">'.
122 if ($filters_spam_scan == '') {
123 echo ' selected="selected"';
125 echo '>' . _("All messages") . '</option>'.
126 '<option value="new"';
127 if ($filters_spam_scan == 'new') {
128 echo ' selected="selected"';
130 echo '>' . _("Unread messages only") . '</option>' .
135 html_tag( 'td', ' ' ) .
137 _("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.") ,
141 $spam_filters = load_spam_filters();
143 foreach ($spam_filters as $Key => $Value) {
144 echo html_tag( 'tr' ) .
145 html_tag( 'th', $Key, 'right', '', 'style="white-space: nowrap;"' ) ."\n" .
147 '<input type="checkbox" name="' .
148 $spam_filters[$Key]['prefname'] .
150 if ($spam_filters[$Key]['enabled']) {
151 echo ' checked="checked"';
154 if ($spam_filters[$Key]['link']) {
156 $spam_filters[$Key]['link'] .
157 '" target="_blank">';
159 echo $spam_filters[$Key]['name'];
160 if ($spam_filters[$Key]['link']) {
165 html_tag( 'td', ' ' ) .
166 html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
171 html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
177 // action is not set or action is not spam
178 echo html_tag( 'p', '', 'center' ) .
179 '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
180 ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</div><br /><br />';
181 printf( _("Spam is sent to %s."), ($filters_spam_folder?
'<b>'.htmlspecialchars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
183 printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?
_("Unread messages only"):_("All messages") ) . '</b>' );
185 '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
187 $spam_filters = load_spam_filters();
189 foreach ($spam_filters as $Key => $Value) {
190 echo html_tag( 'tr' ) .
191 html_tag( 'th', '', 'center' );
193 if ($spam_filters[$Key]['enabled']) {
200 html_tag( 'td', ' - ', 'left' ) .
201 html_tag( 'td', '', 'left' );
203 if ($spam_filters[$Key]['link']) {
205 $spam_filters[$Key]['link'] .
206 '" target="_blank">';
209 echo $spam_filters[$Key]['name'];
210 if ($spam_filters[$Key]['link']) {