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 * Path for SquirrelMail required files.
17 define('SM_PATH','../../');
19 /* SquirrelMail required files. */
20 require_once(SM_PATH
. 'include/validate.php');
21 include_once(SM_PATH
. 'functions/imap.php');
22 include_once(SM_PATH
. 'plugins/filters/filters.php');
25 sqgetGlobalVar('username', $username, SQ_SESSION
);
26 sqgetGlobalVar('key', $key, SQ_COOKIE
);
27 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION
);
28 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION
);
30 sqgetGlobalVar('action', $action, SQ_GET
);
33 displayPageHeader($color, 'None');
35 if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST
)) {
36 $spam_filters = load_spam_filters();
38 // setting spam folder
39 sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST
);
40 if (isset($filters_spam_folder_set)) {
41 setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
43 echo _("You must select a spam folder.");
47 sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST
);
48 if (isset($filters_spam_scan_set)) {
49 setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
51 echo _("You must select a scan type.");
54 foreach ($spam_filters as $Key => $Value) {
55 $input = $spam_filters[$Key]['prefname'] . '_set';
56 if ( sqgetGlobalVar($input,$input_key,SQ_POST
) ) {
57 setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
59 removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
64 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
65 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
66 $filters = load_filters();
68 echo html_tag( 'table',
70 html_tag( 'th', _("Spam Filtering"), 'center' )
72 'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
74 if ($SpamFilters_YourHop == ' ') {
76 html_tag( 'div', '<b>' .
77 sprintf(_("WARNING! Tell the administrator to set the %s variable."), '"SpamFilters_YourHop"') .
84 if (isset($action) && $action == 'spam') {
85 $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0);
86 $boxes = sqimap_mailbox_list($imapConnection);
87 sqimap_logout($imapConnection);
88 $numboxes = count($boxes);
90 for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++
) {
91 if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
92 (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
93 (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
94 $filters_spam_folder = $boxes[$i]['unformatted'];
98 echo '<form method="post" action="spamoptions.php">'.
100 html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
102 html_tag( 'th', _("Move spam to:"), 'right', '', 'style="white-space: nowrap;"' ) .
103 html_tag( 'td', '', 'left' ) .
104 '<select name="filters_spam_folder_set">';
107 if ( isset($filters_spam_folder) )
108 $selected = array(strtolower($filters_spam_folder));
109 echo sqimap_mailbox_option_list(0, $selected, 0, $boxes);
114 html_tag( 'td', ' ' ) .
116 _("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.") ,
120 html_tag( 'th', _("What to Scan:"), 'right', '', 'style="white-space: nowrap;"' ) .
122 '<select name="filters_spam_scan_set">'.
124 if ($filters_spam_scan == '') {
125 echo ' selected="selected"';
127 echo '>' . _("All messages") . '</option>'.
128 '<option value="new"';
129 if ($filters_spam_scan == 'new') {
130 echo ' selected="selected"';
132 echo '>' . _("Unread messages only") . '</option>' .
137 html_tag( 'td', ' ' ) .
139 _("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.") ,
143 $spam_filters = load_spam_filters();
145 foreach ($spam_filters as $Key => $Value) {
146 echo html_tag( 'tr' ) .
147 html_tag( 'th', $Key, 'right', '', 'style="white-space: nowrap;"' ) ."\n" .
149 '<input type="checkbox" name="' .
150 $spam_filters[$Key]['prefname'] .
152 if ($spam_filters[$Key]['enabled']) {
153 echo ' checked="checked"';
156 if ($spam_filters[$Key]['link']) {
158 $spam_filters[$Key]['link'] .
159 '" target="_blank">';
161 echo $spam_filters[$Key]['name'];
162 if ($spam_filters[$Key]['link']) {
167 html_tag( 'td', ' ' ) .
168 html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
173 html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
179 // action is not set or action is not spam
180 echo html_tag( 'p', '', 'center' ) .
181 '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
182 ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</center><br /><br />';
183 printf( _("Spam is sent to %s."), ($filters_spam_folder?
'<b>'.htmlspecialchars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
185 printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?
_("Unread messages only"):_("All messages") ) . '</b>' );
187 '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
189 $spam_filters = load_spam_filters();
191 foreach ($spam_filters as $Key => $Value) {
192 echo html_tag( 'tr' ) .
193 html_tag( 'th', '', 'center' );
195 if ($spam_filters[$Key]['enabled']) {
202 html_tag( 'td', ' - ', 'left' ) .
203 html_tag( 'td', '', 'left' );
205 if ($spam_filters[$Key]['link']) {
207 $spam_filters[$Key]['link'] .
208 '" target="_blank">';
211 echo $spam_filters[$Key]['name'];
212 if ($spam_filters[$Key]['link']) {