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)  

options.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 . 'functions/imap_mailbox.php');
39 require_once(SM_PATH . 'include/load_prefs.php');
40 require_once(SM_PATH . 'functions/forms.php');
41 require_once(SM_PATH . 'plugins/filters/filters.php');
42 
43 global $AllowSpamFilters;
44 
45 displayPageHeader($color, 'None');
46 
47 /* get globals */
48 sqgetGlobalVar('username', $username, SQ_SESSION);
49 sqgetGlobalVar('key', $key, SQ_COOKIE);
50 sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
51 sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
52 
53 sqgetGlobalVar('theid', $theid);
54 sqgetGlobalVar('action', $action, SQ_GET);
55 
56 if (sqgetGlobalVar('filter_submit',$filter_submit,SQ_POST)) {
57 
58  if(! isset($theid) ) $theid = 0;
59 
60  $complete_post=true;
61 
62  // FIXME: write human readable error messages
63  sqgetGlobalVar('filter_what', $filter_what, SQ_POST);
64  if (!sqgetGlobalVar('filter_what', $filter_what, SQ_POST)) {
65  do_error("Post error");
66  $complete_post=false;
67  }
68 
69  sqgetGlobalVar('filter_where', $filter_where, SQ_POST);
70  if (!sqgetGlobalVar('filter_where', $filter_where, SQ_POST)) {
71  do_error("Post error");
72  $complete_post=false;
73  }
74 
75  sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST);
76  if (!sqgetGlobalVar('filter_folder', $filter_folder, SQ_POST)) {
77  do_error("Post error");
78  $complete_post=false;
79  }
80 
81  if ($complete_post) {
82  $filter_what = str_replace(',', '###COMMA###', $filter_what);
83  $filter_what = str_replace("\\\\", "\\", $filter_what);
84  $filter_what = str_replace("\\\"", '"', $filter_what);
85  $filter_what = str_replace('"', '&quot;', $filter_what);
86 
87  if (empty($filter_what)) {
88  do_error(_("WARNING! You must enter something to search for."));
89  $action = 'edit';
90  }
91 
92  if (($filter_where == 'Header') && (strchr($filter_what,':') == '')) {
93  do_error(_("WARNING! Header filters should be of the format &quot;Header: value&quot;"));
94  $action = 'edit';
95  }
96  if ($action != 'edit') {
97  setPref($data_dir, $username, 'filter'.$theid, $filter_where.','.$filter_what.','.$filter_folder);
98  }
99  $filters[$theid]['where'] = $filter_where;
100  $filters[$theid]['what'] = $filter_what;
101  $filters[$theid]['folder'] = $filter_folder;
102  }
103 } elseif (isset($action) && $action == 'delete') {
104  remove_filter($theid);
105 } elseif (isset($action) && $action == 'move_up') {
106  filter_swap($theid, $theid - 1);
107 } elseif (isset($action) && $action == 'move_down') {
108  filter_swap($theid, $theid + 1);
109 } elseif (sqgetGlobalVar('user_submit',$user_submit,SQ_POST)) {
110  sqgetGlobalVar('filters_user_scan_set',$filters_user_scan_set,SQ_POST);
111  setPref($data_dir, $username, 'filters_user_scan', $filters_user_scan_set);
112  echo '<br /><center><b>'._("Saved Scan type")."</b></center>\n";
113 }
114 
116  $filters_user_scan = getPref($data_dir, $username, 'filters_user_scan');
117 
118  echo html_tag( 'table',
119  html_tag( 'tr',
120  html_tag( 'td',
121  '<center><b>' . _("Options") . ' - ' . _("Message Filtering") . '</b></center>' ,
122  'left', $color[0]
123  )
124  ),
125  'center', '', 'width="95%" border="0" cellpadding="2" cellspacing="0"'
126  ) .
127  '<br /><form method="post" action="options.php">'.
128  '<center>'.
129  html_tag( 'table', '', '', '', 'border="0" cellpadding="2" cellspacing="0"' ) .
130  html_tag( 'tr' ) .
131  html_tag( 'th', _("What to Scan:"), 'right', '', 'nowrap' ) .
132  html_tag( 'td', '', 'left' ) .
133  '<select name="filters_user_scan_set">'.
134  '<option value=""';
135  if ($filters_user_scan == '') {
136  echo ' selected';
137  }
138  echo '>' . _("All messages") . '</option>'.
139  '<option value="new"';
140  if ($filters_user_scan == 'new') {
141  echo ' selected';
142  }
143  echo '>' . _("Only unread messages") . '</option>' .
144  '</select>'.
145  '</td>'.
146  html_tag( 'td', '<input type="submit" name="user_submit" value="' . _("Save") . '" />', 'left' ) .
147  '</table>'.
148  '</center>'.
149  '</form>'.
150 
151  html_tag( 'div', '[<a href="options.php?action=add">' . _("New") .
152  '</a>] - [<a href="'.SM_PATH.'src/options.php">' . _("Done") . '</a>]' ,
153  'center' ) . '<br />';
154 
155  if (isset($action) && ($action == 'add' || $action == 'edit')) {
156 
159 
160  for ($a = 0, $cnt = count($boxes); $a < $cnt; $a++) {
161  if (strtolower($boxes[$a]['formatted']) == 'inbox') {
162  unset($boxes[$a]);
163  }
164  }
165 
167  if ( !isset($theid) ) {
168  $theid = count($filters);
169  }
170  echo html_tag( 'div', '', 'center' ) .
171  '<form action="options.php" method="post">'.
172  html_tag( 'table', '', '', '', 'border="0" cellpadding="2" cellspacing="0"' ) .
173  html_tag( 'tr' ) .
174  html_tag( 'td', _("Match:"), 'left' ) .
175  html_tag( 'td', '', 'left' ) .
176  '<select name="filter_where">';
177 
178  $L = isset($filters[$theid]['where']);
179 
180  $sel = (($L && $filters[$theid]['where'] == 'From')?'selected':'');
181  echo "<option value=\"From\" $sel>" . _("From") . '</option>';
182 
183  $sel = (($L && $filters[$theid]['where'] == 'To')?'selected':'');
184  echo "<option value=\"To\" $sel>" . _("To") . '</option>';
185 
186  $sel = (($L && $filters[$theid]['where'] == 'Cc')?'selected':'');
187  echo "<option value=\"Cc\" $sel>" . _("Cc") . '</option>';
188 
189  $sel = (($L && $filters[$theid]['where'] == 'To or Cc')?'selected':'');
190  echo "<option value=\"To or Cc\" $sel>" . _("To or Cc") . '</option>';
191 
192  $sel = (($L && $filters[$theid]['where'] == 'Subject')?'selected':'');
193  echo "<option value=\"Subject\" $sel>" . _("Subject") . '</option>';
194 
195  $sel = (($L && $filters[$theid]['where'] == 'Header')?'selected':'');
196  echo "<option value=\"Header\" $sel>" . _("Header") . '</option>';
197 
198  echo '</select>'.
199  '</td>'.
200  '</tr>'.
201  html_tag( 'tr' ) .
202  html_tag( 'td', _("Contains:"), 'right' ) .
203  html_tag( 'td', '', 'left' ) .
204  '<input type="text" size="32" name="filter_what" value="';
205  if (isset($filters[$theid]['what'])) {
206  echo htmlspecialchars($filters[$theid]['what']);
207  }
208  echo '" />'.
209  '</td>'.
210  '</tr>'.
211  html_tag( 'tr' ) .
212  html_tag( 'td', _("Move to:"), 'left' ) .
213  html_tag( 'td', '', 'left' ) .
214  '<tt>'.
215  '<select name="filter_folder">';
216  $selected = 0;
217  if ( isset($filters[$theid]['folder']) )
218  $selected = array(strtolower($filters[$theid]['folder']));
220  echo '</tt>'.
221  '</select>'.
222  '</td>'.
223  '</tr>'.
224  '</table>'.
225  '<input type="submit" name="filter_submit" value="' . _("Submit") . "\" />\n".
226  addHidden('theid', $theid).
227  '</form>'.
228  '</div>';
229 
230  }
231 
232  echo html_tag( 'table', '', 'center', '', 'border="0" cellpadding="3" cellspacing="0"' );
233 
234  for ($i=0, $num = count($filters); $i < $num; $i++) {
235 
236  $clr = (($i % 2)?$color[0]:$color[9]);
237  $fdr = ($folder_prefix)?str_replace($folder_prefix, "", $filters[$i]["folder"]):$filters[$i]["folder"];
238  echo html_tag( 'tr', '', '', $clr ) .
239  html_tag( 'td',
240  '<small>' .
241  "[<a href=\"options.php?theid=$i&amp;action=edit\">" . _("Edit") . '</a>]'.
242  '</small>' ,
243  'left' ) .
244  html_tag( 'td',
245  '<small>' .
246  "[<a href=\"options.php?theid=$i&amp;action=delete\">" . _("Delete") . '</a>]'.
247  '</small>' ,
248  'left' );
249 
250  if ($num > 1) {
251  echo html_tag( 'td', '', 'center' ) . '<small>[';
252  if (isset($filters[$i + 1])) {
253  echo "<a href=\"options.php?theid=$i&amp;action=move_down\">" . _("Down") . '</a>';
254  if ($i > 0) {
255  echo '&nbsp;|&nbsp;';
256  }
257  }
258  if ($i > 0) {
259  echo "<a href=\"options.php?theid=$i&amp;action=move_up\">" . _("Up") . '</a>';
260  }
261  echo ']</small></td>';
262  }
263  echo html_tag( 'td', '-', 'left' ) .
264  html_tag( 'td', '', 'left' );
265  printf( _("If %s contains %s then move to %s"),
266  '<b>'.$filters[$i]['where'].'</b>',
267  '<b>'.$filters[$i]['what'].'</b>',
268  '<b>'.htmlspecialchars(imap_utf7_decode_local($fdr)).'</b>');
269  echo '</td></tr>';
270 
271  }
272  echo '</table>'.
273  html_tag( 'table',
274  html_tag( 'tr',
275  html_tag( 'td', '&nbsp;', 'left' )
276  ) ,
277  'center', '', 'width="80%" border="0" cellpadding="2" cellspacing="0"' );
278  echo '</body></html>';
279 ?>
load_filters
load_filters()
Definition: filters.php:550
elseif
if(! sqgetGlobalVar('sound', $sound, SQ_GET)) elseif($sound=='(none)')
Definition: testsound.php:25
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
$cnt
$cnt
Definition: options_identities.php:86
html_tag
html_tag( $tag, $val='', $align='', $bgcolor='', $xtra='')
Definition: html.php:27
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
filter_swap
filter_swap($id1, $id2)
Definition: filters.php:834
SM_PATH
const SM_PATH
Definition: options.php:222
sqimap_login
sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
Definition: imap_general.php:481
$num
else $num
Definition: options_order.php:37
SQ_SESSION
const SQ_SESSION
Definition: global.php:18
displayPageHeader
displayPageHeader($color, $mailbox, $xtra='', $session=false)
Definition: page_header.php:105
setPref
setPref($data_dir, $username, $string, $set_to)
Definition: db_prefs.php:352
$folder_prefix
global $folder_prefix
Definition: options.php:19
$boxes
$boxes
Definition: empty_trash.php:49
$AllowSpamFilters
global $AllowSpamFilters
Definition: options.php:35
$filters
if(sqgetGlobalVar('filter_submit', $filter_submit, SQ_POST)) elseif(isset($action) && $action=='delete') elseif(isset($action) && $action=='move_up') elseif(isset($action) && $action=='move_down') elseif(sqgetGlobalVar('user_submit', $user_submit, SQ_POST)) $filters
Definition: options.php:115
$filters_user_scan
$filters_user_scan
Definition: options.php:116
sqimap_logout
sqimap_logout($imap_stream)
Definition: imap_general.php:639
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
do_error
do_error($string)
Definition: filters.php:884
addHidden
addHidden($name, $value)
Definition: forms.php:58
SQ_POST
const SQ_POST
Definition: global.php:17
remove_filter
remove_filter($id)
Definition: filters.php:817
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
$sel
$sel
Definition: login.php:44
SQ_COOKIE
const SQ_COOKIE
Definition: global.php:19
$color
global $color
Definition: options.php:19
$username
global $username
Definition: options.php:225
$data_dir
global $data_dir
Definition: options.php:225
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