squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

spamoptions.php
Go to the documentation of this file.
1 <?php
32 define('SM_PATH','../../');
33 
34 /* SquirrelMail required files. */
35 require_once(SM_PATH . 'include/validate.php');
36 require_once(SM_PATH . 'functions/page_header.php');
37 require_once(SM_PATH . 'functions/imap.php');
38 require_once(SM_PATH . 'include/load_prefs.php');
39 require_once(SM_PATH . 'functions/html.php');
40 require_once(SM_PATH . 'plugins/filters/filters.php');
41 global $AllowSpamFilters;
42 
43 /* get globals */
44 sqgetGlobalVar('username', $username, SQ_SESSION);
45 sqgetGlobalVar('key', $key, SQ_COOKIE);
46 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
47 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
48 
49 sqgetGlobalVar('action', $action, SQ_GET);
50 /* end globals */
51 
52 displayPageHeader($color, 'None');
53 
54 if (sqgetGlobalVar('spam_submit',$spam_submit,SQ_POST)) {
56 
57  // setting spam folder
58  sqgetGlobalVar('filters_spam_folder_set',$filters_spam_folder_set,SQ_POST);
59  if (isset($filters_spam_folder_set)) {
60  setPref($data_dir, $username, 'filters_spam_folder', $filters_spam_folder_set);
61  } else {
62  echo _("You must select a spam folder.");
63  }
64 
65  // setting scan type
66  sqgetGlobalVar('filters_spam_scan_set',$filters_spam_scan_set,SQ_POST);
67  if (isset($filters_spam_scan_set)) {
68  setPref($data_dir, $username, 'filters_spam_scan', $filters_spam_scan_set);
69  } else {
70  echo _("You must select a scan type.");
71  }
72 
73  foreach ($spam_filters as $Key => $Value) {
74  $input = $spam_filters[$Key]['prefname'] . '_set';
75  if ( sqgetGlobalVar($input,$input_key,SQ_POST) ) {
76  setPref( $data_dir, $username, $spam_filters[$Key]['prefname'],$input_key);
77  } else {
78  removePref($data_dir, $username, $spam_filters[$Key]['prefname']);
79  }
80  }
81 }
82 
83 $filters_spam_folder = getPref($data_dir, $username, 'filters_spam_folder');
84 $filters_spam_scan = getPref($data_dir, $username, 'filters_spam_scan');
86 
87 echo html_tag( 'table',
88  html_tag( 'tr',
89  html_tag( 'th', _("Spam Filtering"), 'center' )
90  ) ,
91  'center', $color[0], 'width="95%" border="0" cellpadding="2" cellspacing="0"' );
92 
93 if ($SpamFilters_YourHop == ' ') {
94  echo '<br />' .
95  html_tag( 'div', '<b>' .
96  sprintf(_("WARNING! Tell the administrator to set the %s variable."), '&quot;SpamFilters_YourHop&quot;') .
97  '</b>' ,
98  'center' ) .
99  '<br />';
100 }
101 
102 
103 if (isset($action) && $action == 'spam') {
107  $numboxes = count($boxes);
108 
109  for ($i = 0; $i < $numboxes && $filters_spam_folder == ''; $i++) {
110  if ((isset($boxes[$i]['flags'][0]) && $boxes[$i]['flags'][0] != 'noselect') &&
111  (isset($boxes[$i]['flags'][1]) && $boxes[$i]['flags'][1] != 'noselect') &&
112  (isset($boxes[$i]['flags'][2]) && $boxes[$i]['flags'][2] != 'noselect')) {
113  $filters_spam_folder = $boxes[$i]['unformatted'];
114  }
115  }
116 
117  echo '<form method="post" action="spamoptions.php">'.
118  '<center>'.
119  html_tag( 'table', '', '', '', 'width="85%" border="0" cellpadding="2" cellspacing="0"' ) .
120  html_tag( 'tr' ) .
121  html_tag( 'th', _("Move spam to:"), 'right', '', 'nowrap' ) .
122  html_tag( 'td', '', 'left' ) .
123  '<select name="filters_spam_folder_set">';
124 
125  $selected = 0;
126  if ( isset($filters_spam_folder) )
127  $selected = array(strtolower($filters_spam_folder));
129  echo '</select>'.
130  '</td>'.
131  '</tr>'.
132  html_tag( 'tr',
133  html_tag( 'td', '&nbsp;' ) .
134  html_tag( 'td',
135  _("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.") ,
136  'left' )
137  ) .
138  html_tag( 'tr' ) .
139  html_tag( 'th', _("What to Scan:"), 'right', '', 'nowrap' ) .
140  html_tag( 'td' ) .
141  '<select name="filters_spam_scan_set">'.
142  '<option value=""';
143  if ($filters_spam_scan == '') {
144  echo ' selected="selected"';
145  }
146  echo '>' . _("All messages") . '</option>'.
147  '<option value="new"';
148  if ($filters_spam_scan == 'new') {
149  echo ' selected="selected"';
150  }
151  echo '>' . _("Unread messages only") . '</option>' .
152  '</select>'.
153  '</td>'.
154  '</tr>'.
155  html_tag( 'tr',
156  html_tag( 'td', '&nbsp;' ) .
157  html_tag( 'td',
158  _("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.") ,
159  'left' )
160  );
161 
163 
164  foreach ($spam_filters as $Key => $Value) {
165  echo html_tag( 'tr' ) .
166  html_tag( 'th', $Key, 'right', '', 'nowrap' ) ."\n" .
167  html_tag( 'td' ) .
168  '<input type="checkbox" name="' .
169  $spam_filters[$Key]['prefname'] .
170  '_set"';
171  if ($spam_filters[$Key]['enabled']) {
172  echo ' checked="checked"';
173  }
174  echo ' /> - ';
175  if ($spam_filters[$Key]['link']) {
176  echo '<a href="' .
177  $spam_filters[$Key]['link'] .
178  '" target="_blank">';
179  }
180  echo $spam_filters[$Key]['name'];
181  if ($spam_filters[$Key]['link']) {
182  echo '</a>';
183  }
184  echo '</td></tr>' .
185  html_tag( 'tr',
186  html_tag( 'td', '&nbsp;' ) .
187  html_tag( 'td', $spam_filters[$Key]['comment'], 'left' )
188  ) . "\n";
189 
190  }
191  echo html_tag( 'tr',
192  html_tag( 'td', '<input type="submit" name="spam_submit" value="' . _("Save") . '" />', 'center', '', 'colspan="2"' )
193  ) . "\n" .
194  '</table>'.
195  '</center>'.
196  '</form>';
197 } else {
198  // action is not set or action is not spam
199  echo html_tag( 'p', '', 'center' ) .
200  '[<a href="spamoptions.php?action=spam">' . _("Edit") . '</a>]' .
201  ' - [<a href="../../src/options.php">' . _("Done") . '</a>]</center><br /><br />';
202  printf( _("Spam is sent to %s."), ($filters_spam_folder?'<b>'.htmlspecialchars(imap_utf7_decode_local($filters_spam_folder)).'</b>':'[<i>'._("not set yet").'</i>]' ) );
203  echo '<br />';
204  printf( _("Spam scan is limited to %s."), '<b>' . ( ($filters_spam_scan == 'new')?_("Unread messages only"):_("All messages") ) . '</b>' );
205  echo '</p>'.
206  '<table border="0" cellpadding="3" cellspacing="0" align="center" bgcolor="' . $color[0] . "\">\n";
207 
209 
210  foreach ($spam_filters as $Key => $Value) {
211  echo html_tag( 'tr' ) .
212  html_tag( 'th', '', 'center' );
213 
214  if ($spam_filters[$Key]['enabled']) {
215  echo _("ON");
216  } else {
217  echo _("OFF");
218  }
219 
220  echo '</th>' .
221  html_tag( 'td', '&nbsp;-&nbsp;', 'left' ) .
222  html_tag( 'td', '', 'left' );
223 
224  if ($spam_filters[$Key]['link']) {
225  echo '<a href="' .
226  $spam_filters[$Key]['link'] .
227  '" target="_blank">';
228  }
229 
230  echo $spam_filters[$Key]['name'];
231  if ($spam_filters[$Key]['link']) {
232  echo '</a>';
233  }
234  echo "</td></tr>\n";
235  }
236  echo '</table>';
237 }
238 ?>
239 </body></html>
load_filters
load_filters()
Definition: filters.php:550
load_spam_filters
load_spam_filters()
Definition: filters.php:568
sqgetGlobalVar
sqgetGlobalVar($name, &$value, $search=SQ_INORDER)
Definition: global.php:344
$imapConnection
$imapConnection
Definition: message_details_bottom.php:74
getPref
getPref($data_dir, $username, $string, $default='')
Definition: db_prefs.php:316
$SpamFilters_YourHop
global $SpamFilters_YourHop
Definition: setup.php:69
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$data_dir
$data_dir
Definition: config_default.php:499
$filters_spam_folder
if(sqgetGlobalVar('spam_submit', $spam_submit, SQ_POST)) $filters_spam_folder
Definition: spamoptions.php:83
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
SM_PATH
const SM_PATH
Definition: spamoptions.php:32
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
sprintf
powered by Systran sprintf(_("Number of supported language pairs: %s"), '36').' '
Definition: options.php:107
html
Definition: html.class.php:18
$username
global $username
Definition: validate.php:55
$filters
$filters
Definition: spamoptions.php:85
$filters_spam_scan
$filters_spam_scan
Definition: spamoptions.php:84
$boxes
$boxes
Definition: empty_trash.php:49
$spam_filters
$spam_filters
Definition: spamoptions.php:208
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
removePref
removePref($data_dir, $username, $string)
Definition: db_prefs.php:331
SQ_GET
const SQ_GET
Definition: global.php:16
sqimap_mailbox_option_list
sqimap_mailbox_option_list($imap_stream, $show_selected=0, $folder_skip=0, $boxes=0, $flag='noselect', $use_long_format=false)
Definition: imap_mailbox.php:521
SQ_POST
const SQ_POST
Definition: global.php:17
$AllowSpamFilters
global $AllowSpamFilters
Definition: spamoptions.php:35
imap_utf7_decode_local
imap_utf7_decode_local($s)
Definition: imap_utf7_local.php:88
$action
$action
Definition: options.php:34
_
_($str)
Definition: gettext.php:160
$imapPort
$imapPort
Definition: config_default.php:210
$color
$color
Definition: load_prefs.php:28
$numboxes
$numboxes
Definition: empty_trash.php:58
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
sqimap_mailbox_list
sqimap_mailbox_list($imap_stream, $force=false)
Definition: imap_mailbox.php:597
$selected
if($spamcop_quick_report) $selected
Definition: options.php:107