HTML Tidy... no such tag as nobr according to W3C.
[squirrelmail.git] / plugins / mail_fetch / options.php
CommitLineData
d622d38a 1<?php
d3c89357 2
8d6a115b 3/**
4 * mail_fetch/options.php
5 *
6c84ba1e 6 * Copyright (c) 1999-2005 The SquirrelMail Project Team
8d6a115b 7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Setup of the mailfetch plugin.
10 *
11 * $Id$
ea5f4b8e 12 * @package plugins
13 * @subpackage mail_fetch
8d6a115b 14 */
d622d38a 15
ea5f4b8e 16/** @ignore */
8d6a115b 17define('SM_PATH','../../');
aa7fb30c 18
8d6a115b 19require_once(SM_PATH . 'include/validate.php');
20require_once(SM_PATH . 'functions/imap.php');
21require_once(SM_PATH . 'include/load_prefs.php');
d622d38a 22
3c66c567 23/* globals */
24sqgetGlobalVar('username', $username, SQ_SESSION);
25sqgetGlobalVar('key', $key, SQ_COOKIE);
26sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION);
27sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
91e0dccc 28
3c66c567 29if(!sqgetGlobalVar('mf_cypher', $mf_cypher, SQ_POST)) {
30 $mf_cypher = '';
31}
32if(! sqgetGlobalVar('mf_action', $mf_action, SQ_POST) ) {
a747d971 33 if (sqgetGlobalVar('mf_action_mod', $mf_action_mod, SQ_POST)) {
34 $mf_action = 'Modify';
35 }
36 elseif (sqgetGlobalVar('mf_action_del', $mf_action_del, SQ_POST)) {
37 $mf_action = 'Delete';
38 }
39 else {
40 $mf_action = 'config';
41 }
3c66c567 42}
86bb8549 43
162cd2c6 44sqgetGlobalVar('mf_sn', $mf_sn, SQ_POST);
3c66c567 45sqgetGlobalVar('mf_server', $mf_server, SQ_POST);
46sqgetGlobalVar('mf_port', $mf_port, SQ_POST);
47sqgetGlobalVar('mf_alias', $mf_alias, SQ_POST);
48sqgetGlobalVar('mf_user', $mf_user, SQ_POST);
49sqgetGlobalVar('mf_pass', $mf_pass, SQ_POST);
50sqgetGlobalVar('mf_subfolder', $mf_subfolder, SQ_POST);
51sqgetGlobalVar('mf_login', $mf_login, SQ_POST);
52sqgetGlobalVar('mf_fref', $mf_fref, SQ_POST);
53sqgetGlobalVar('mf_lmos', $mf_lmos, SQ_POST);
54sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST);
d622d38a 55
a747d971 56
3c66c567 57/* end globals */
58
59 displayPageHeader( $color, 'None' );
d622d38a 60
d3c89357 61 switch( $mf_action ) {
62 case 'add':
63 if ($mf_sn<1) $mf_sn=0;
64 if (!isset($mf_server)) return;
65 setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
85756247 66 setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
d3c89357 67 setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
68 setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
69 setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass ) :""));
86bb8549 70 if( isset($mf_cypher) && $mf_cypher <> 'on' ) SetPref($data_dir,$username,'mailfetch_cypher', 'on');
d3c89357 71 setPref($data_dir,$username,"mailfetch_lmos_$mf_sn",(isset($mf_lmos)?$mf_lmos:""));
72 setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
73 setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
74 setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn",(isset($mf_subfolder)?$mf_subfolder:""));
75 $mf_sn++;
76 setPref($data_dir,$username,'mailfetch_server_number', $mf_sn);
77 $mf_action = 'config';
78 break;
79 case 'confirm_modify':
80 //modify a server
81 if (!isset($mf_server)) return;
82 setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
85756247 83 setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
d3c89357 84 setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
85 setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
86 setPref($data_dir,$username,"mailfetch_pass_$mf_sn",(isset($mf_pass)?encrypt( $mf_pass ) :""));
87 if( $mf_cypher <> 'on' ) setPref($data_dir,$username,"mailfetch_cypher", 'on');
88 setPref($data_dir,$username,"mailfetch_lmos_$mf_sn",(isset($mf_lmos)?$mf_lmos:""));
89 setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
90 setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
91 setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn",(isset($mf_subfolder)?$mf_subfolder:""));
92 $mf_action = 'config';
93 break;
94 case 'confirm_delete':
95 //delete a server
96 $mailfetch_server_number = getPref($data_dir, $username, "mailfetch_server_number");
97 if ($mf_sn+1==$mailfetch_server_number) {
98 //is the last server, whe can only decrase $mailfetch_server_number
99 $mailfetch_server_number--;
100 setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
101 } else {
102 //if not the last, all the sequel server come up one step
103 //then whe decrase $mailfetch_server_number
104 $mailfetch_server_number--;
105 for ($i=$mf_sn;$i<$mailfetch_server_number;$i++) {
106 $tmp=$i+1;
162cd2c6 107 setPref($data_dir,$username,'mailfetch_server_'.$i,
108 getPref($data_dir,$username, 'mailfetch_server_'.$tmp));
109 setPref($data_dir,$username,'mailfetch_port_'.$i,
110 getPref($data_dir,$username, 'mailfetch_port_'.$tmp));
111 setPref($data_dir,$username,'mailfetch_alias_'.$i,
112 getPref($data_dir,$username, 'mailfetch_alias_'.$tmp));
113 setPref($data_dir,$username,'mailfetch_user_'.$i,
114 getPref($data_dir,$username, 'mailfetch_user_'.$tmp));
115 setPref($data_dir,$username,'mailfetch_pass_'.$i,
116 getPref($data_dir,$username, 'mailfetch_pass_'.$tmp));
117 setPref($data_dir,$username,'mailfetch_lmos_'.$i,
118 getPref($data_dir,$username, 'mailfetch_lmos_'.$tmp));
119 setPref($data_dir,$username,'mailfetch_login_'.$i,
120 getPref($data_dir,$username, 'mailfetch_login_'.$tmp));
121 setPref($data_dir,$username,'mailfetch_fref_'.$i,
122 getPref($data_dir,$username, 'mailfetch_fref_'.$tmp));
123 setPref($data_dir,$username,'mailfetch_subfolder_'.$i,
124 getPref($data_dir,$username, 'mailfetch_subfolder_'.$tmp));
91e0dccc 125 setPref($data_dir,$username,'mailfetch_uidl_'.$i,
162cd2c6 126 getPref($data_dir,$username, 'mailfetch_uidl_'.$tmp));
d3c89357 127 }
128 setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
129 }
130 $mf_action = 'config';
131 break;
132 }
133
134 $mailfetch_server_number = getPref($data_dir, $username, 'mailfetch_server_number', 0);
135 $mailfetch_cypher = getPref( $data_dir, $username, 'mailfetch_cypher' );
136 if ($mailfetch_server_number<1) {
137 $mailfetch_server_number=0;
138 }
d622d38a 139 for ($i=0;$i<$mailfetch_server_number;$i++) {
140 $mailfetch_server_[$i] = getPref($data_dir, $username, "mailfetch_server_$i");
e42b0dd2 141 $mailfetch_port_[$i] = getPref($data_dir, $username, "mailfetch_port_$i");
d622d38a 142 $mailfetch_alias_[$i] = getPref($data_dir, $username, "mailfetch_alias_$i");
143 $mailfetch_user_[$i] = getPref($data_dir, $username, "mailfetch_user_$i");
144 $mailfetch_pass_[$i] = getPref($data_dir, $username, "mailfetch_pass_$i");
145 $mailfetch_lmos_[$i] = getPref($data_dir, $username, "mailfetch_lmos_$i");
146 $mailfetch_login_[$i] = getPref($data_dir, $username, "mailfetch_login_$i");
147 $mailfetch_fref_[$i] = getPref($data_dir, $username, "mailfetch_fref_$i");
148 $mailfetch_uidl_[$i] = getPref($data_dir, $username, "mailfetch_uidl_$i");
149 $mailfetch_subfolder_[$i] = getPref($data_dir, $username, "mailfetch_subfolder_$i");
150 if( $mailfetch_cypher == 'on' ) $mailfetch_pass_[$i] = decrypt( $mailfetch_pass_[$i] );
151 }
152
153
6fd95361 154 echo '<br /><form method="post" action="'.$PHP_SELF.'">' .
4cf43843 155 html_tag( 'table',
156 html_tag( 'tr',
157 html_tag( 'td',
158 '<b>' . _("Remote POP server settings") . '</b>',
159 'center', $color[0] )
160 ),
658b4c55 161 'center', '', 'width="95%"' ) .
4cf43843 162 html_tag( 'table',
163 html_tag( 'tr',
164 html_tag( 'td',
6fd95361 165 _("You should be aware that the encryption used to store your password is not perfectly secure. However, if you are using pop, there is inherently no encryption anyway. Additionally, the encryption that we do to save it on the server can be undone by a hacker reading the source to this file.") ,
4cf43843 166 'left' )
167 ) .
168 html_tag( 'tr',
169 html_tag( 'td',
170 _("If you leave password empty, it will be required when you fetch mail.") ,
171 'left' )
172 ) .
173 html_tag( 'tr',
174 html_tag( 'td',
6fd95361 175 '<input type="checkbox" name="mf_cypher" ' .
176 (($mailfetch_cypher=='on')?'checked="checked" />':' />') .
4cf43843 177 _("Encrypt passwords (informative only)") ,
178 'right' )
179 ) ,
658b4c55 180 'center', '', 'width="95%"' );
d622d38a 181
d3c89357 182 switch( $mf_action ) {
183 case 'config':
658b4c55 184 echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
4cf43843 185 html_tag( 'tr',
186 html_tag( 'td', '<b>' . _("Add Server") . '</b>', 'center', $color[9] )
187 ) .
188 html_tag( 'tr' ) .
189 html_tag( 'td', '', 'center', $color[0] ) .
190
6fd95361 191 "<input type=\"hidden\" name=\"mf_sn\" value=\"$mailfetch_server_number\" />" .
192 '<input type="hidden" name="mf_action" value="add" />' .
4cf43843 193 html_tag( 'table' ) .
194 html_tag( 'tr',
195 html_tag( 'th', _("Server:"), 'right' ) .
6fd95361 196 html_tag( 'td', '<input type="text" name="mf_server" value="" size="40" />', 'left' )
4cf43843 197 ) .
b33b71fc 198 html_tag( 'tr',
e42b0dd2 199 html_tag( 'th', _("Port:"), 'right') .
6fd95361 200 html_tag( 'td', '<input type="text" name="mf_port" value="110" size="20" />', 'left')
e42b0dd2 201 ) .
4cf43843 202 html_tag( 'tr',
203 html_tag( 'th', _("Alias:"), 'right' ) .
6fd95361 204 html_tag( 'td', '<input type="text" name="mf_alias" value="" size="20" />', 'left' )
4cf43843 205 ) .
206 html_tag( 'tr',
207 html_tag( 'th', _("Username:"), 'right' ) .
6fd95361 208 html_tag( 'td', '<input type="text" name="mf_user" value="" size="20" />', 'left' )
4cf43843 209 ) .
210 html_tag( 'tr',
211 html_tag( 'th', _("Password:"), 'right' ) .
6fd95361 212 html_tag( 'td', '<input type="password" name="mf_pass" value="" size="20" />', 'left' )
4cf43843 213 ) .
214 html_tag( 'tr' ) .
215 html_tag( 'th', _("Store in Folder:"), 'right' ) .
216 html_tag( 'td', '', 'left' );
d3c89357 217 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
218 $boxes = sqimap_mailbox_list($imapConnection);
4cf43843 219 echo '<select name="mf_subfolder">';
ae8a7931 220
221 $selected = 0;
222 if ( isset($mf_subfolder) )
223 $selected = array(strtolower($mf_subfolder));
224 echo sqimap_mailbox_option_list($imapConnection, $selected);
4cf43843 225 echo '</select></td></tr>' .
226 html_tag( 'tr',
227 html_tag( 'th', '&nbsp;', 'right' ) .
6fd95361 228 html_tag( 'td', '<input type="checkbox" name="mf_lmos" checked="checked" />' . _("Leave Mail on Server"), 'left' )
4cf43843 229 ) .
230 html_tag( 'tr',
231 html_tag( 'th', '&nbsp;', 'right' ) .
6fd95361 232 html_tag( 'td', '<input type="checkbox" name="mf_login" />' . _("Check mail during login"), 'left' )
4cf43843 233 ) .
234 html_tag( 'tr',
235 html_tag( 'th', '&nbsp;', 'right' ) .
6fd95361 236 html_tag( 'td', '<input type="checkbox" name="mf_fref" />' . _("Check mail during folder refresh"), 'left' )
4cf43843 237 ) .
238 html_tag( 'tr',
239 html_tag( 'td',
6fd95361 240 '<input type="submit" name="submit_mailfetch" value="' . _("Add Server") . '" />',
4cf43843 241 'center', '', 'colspan="2"' )
242 ) .
658b4c55 243 '</table></td></tr></table></form>';
d622d38a 244
d3c89357 245 // Modify Server
6fd95361 246 echo '<font size="-5"><br /></font>' .
658b4c55 247 html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
4cf43843 248 html_tag( 'tr',
249 html_tag( 'td', '<b>' . _("Modify Server") . '</b>', 'center', $color[9] )
250 ) .
251 html_tag( 'tr' ) .
252 html_tag( 'td', '', 'center', $color[0] );
d3c89357 253 if ($mailfetch_server_number>0) {
4cf43843 254 echo "<form action=\"$PHP_SELF\" method=\"post\" target=\"_self\">";
255 echo '<b>' . _("Server Name:") . '</b> <select name="mf_sn">';
d3c89357 256 for ($i=0;$i<$mailfetch_server_number;$i++) {
4cf43843 257 echo "<option value=\"$i\">" .
658b4c55 258 htmlspecialchars( (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i])) . "</option>";
d3c89357 259 }
4cf43843 260 echo '</select>'.
6fd95361 261 '&nbsp;&nbsp;<input type="submit" name="mf_action_mod" value="' . _("Modify") . '" />'.
262 '&nbsp;&nbsp;<input type="submit" name="mf_action_del" value="' . _("Delete") . '" />'.
d3c89357 263 '</form>';
264 } else {
265 echo _("No-one server in use. Try to add.");
266 }
4cf43843 267 echo '</td></tr></table>';
d3c89357 268 break;
a747d971 269 case 'Delete': //erase confirmation about a server
4cf43843 270 echo html_tag( 'table',
271 html_tag( 'tr',
272 html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
273 ) ,
658b4c55 274 'center', '', 'width="95%" cellpadding="5" cellspacing="1"' ) .
6fd95361 275 '<br />' .
4cf43843 276 html_tag( 'table',
277 html_tag( 'tr',
278 html_tag( 'td', '<b>' . _("Confirm Deletion of a Server") . '</b>', 'center', $color[9] )
279 ) .
280 html_tag( 'tr',
281 html_tag( 'td',
6fd95361 282 "<input type=\"hidden\" name=\"mf_sn\" value=\"$mf_sn\" />" .
283 '<input type="hidden" name="mf_action" value="confirm_delete" />' .
284 '<br />' . _("Selected Server:") . " <b>" . htmlspecialchars($mailfetch_server_[$mf_sn]) . "</b><br />" .
285 _("Confirm delete of selected server?") . '<br /><br />' .
286 '<input type="submit" name="submit_mailfetch" value="' . _("Confirm Delete") . '" />' .
287 '<br /></form>' ,
4cf43843 288 'center', $color[9] )
289 ) ,
658b4c55 290 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' );
d3c89357 291 break; //modify a server
a747d971 292 case 'Modify':
4cf43843 293 echo html_tag( 'table',
294 html_tag( 'tr',
295 html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
296 ) ,
658b4c55 297 'center', '', 'width="95%" cellpadding="5" cellspacing="1"' ) .
6fd95361 298 '<br />' .
658b4c55 299 html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
4cf43843 300 html_tag( 'tr',
09c5aef1 301 html_tag( 'td', '<b>' . _("Modify Server") . '</b>', 'center', $color[9] )
4cf43843 302 ) .
303 html_tag( 'tr' ) .
304 html_tag( 'td', '', 'center', $color[0] ) .
305
6fd95361 306 "<input type=\"hidden\" name=\"mf_sn\" value=\"$mf_sn\" />" .
307 '<input type="hidden" name="mf_action" value="confirm_modify" />' .
4cf43843 308 html_tag( 'table' ) .
309 html_tag( 'tr',
310 html_tag( 'th', _("Server:"), 'right' ) .
a9e1e670 311 html_tag( 'td', '<input type="text" name="mf_server" value="' .
6fd95361 312 htmlspecialchars($mailfetch_server_[$mf_sn]) . '" size="40" />', 'left' )
4cf43843 313 ) .
314 html_tag( 'tr',
e42b0dd2 315 html_tag( 'th', _("Port:"), 'right' ) .
a9e1e670 316 html_tag( 'td', '<input type="text" name="mf_port" value="' .
6fd95361 317 htmlspecialchars($mailfetch_port_[$mf_sn]) . '" size="40" />', 'left' )
e42b0dd2 318 ) .
319 html_tag( 'tr',
4cf43843 320 html_tag( 'th', _("Alias:"), 'right' ) .
a9e1e670 321 html_tag( 'td', '<input type="text" name="mf_alias" value="' .
6fd95361 322 htmlspecialchars($mailfetch_alias_[$mf_sn]) . '" size="40" />', 'left' )
4cf43843 323 ) .
324 html_tag( 'tr',
325 html_tag( 'th', _("Username:"), 'right' ) .
91e0dccc 326 html_tag( 'td', '<input type="text" name="mf_user" value="' .
6fd95361 327 htmlspecialchars($mailfetch_user_[$mf_sn]) . '" size="20" />', 'left' )
4cf43843 328 ) .
329 html_tag( 'tr',
330 html_tag( 'th', _("Password:"), 'right' ) .
a9e1e670 331 html_tag( 'td', '<input type="password" name="mf_pass" value="' .
6fd95361 332 htmlspecialchars($mailfetch_pass_[$mf_sn]) . '" size="20" />', 'left' )
4cf43843 333 ) .
334 html_tag( 'tr' ) .
335 html_tag( 'th', _("Store in Folder:"), 'right' ) .
336 html_tag( 'td', '', 'left' );
337
d3c89357 338 $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0);
339 $boxes = sqimap_mailbox_list($imapConnection);
4cf43843 340 echo '<select name="mf_subfolder">';
ae8a7931 341 $selected = 0;
956f0980 342 if ( isset($mailfetch_subfolder_[$mf_sn]) ) {
343 $selected = array(strtolower($mailfetch_subfolder_[$mf_sn]));
91e0dccc 344 }
956f0980 345 echo sqimap_mailbox_option_list($imapConnection, $selected) .
346 '</select></td></tr>' .
4cf43843 347
348 html_tag( 'tr',
349 html_tag( 'th', '&nbsp;', 'right' ) .
350 html_tag( 'td',
6fd95361 351 '<input type="checkbox" name="mf_lmos" ' . (($mailfetch_lmos_[$mf_sn] == 'on')?'checked="checked"':'') .
352 ' />' . _("Leave Mail on Server") ,
4cf43843 353 'left' )
354 ) .
355 html_tag( 'tr',
356 html_tag( 'th', '&nbsp;', 'right' ) .
357 html_tag( 'td',
6fd95361 358 '<input type="checkbox" name="mf_login" ' . ( ($mailfetch_login_[$mf_sn] == 'on')?'checked="checked"':'') .
359 ' />' . _("Check mail during login"),
4cf43843 360 'left' )
361 ) .
362 html_tag( 'tr',
363 html_tag( 'th', '&nbsp;', 'right' ) .
364 html_tag( 'td',
6fd95361 365 '<input type="checkbox" name="mf_fref" ' . ( ($mailfetch_fref_[$mf_sn] == 'on')?'checked="checked"':'') .
366 ' />' . _("Check mail during folder refresh") ,
4cf43843 367 'left' )
368 ) .
369 html_tag( 'tr',
370 html_tag( 'td',
6fd95361 371 '<input type="submit" name="submit_mailfetch" value="' . _("Modify Server") . '" />',
4cf43843 372 'center', '', 'colspan="2"' )
373 ) .
374
375 '</table></form></td></tr></table>';
d3c89357 376 break;
377 default: //unsupported action
4cf43843 378 echo '</form>' .
379 html_tag( 'table',
380 html_tag( 'tr',
381 html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
382 ) ,
658b4c55 383 'center', '', 'width="95%"' ) .
6fd95361 384 '<br />' .
4cf43843 385 html_tag( 'table',
386 html_tag( 'tr',
387 html_tag( 'td', '<b>' . _("Undefined Function") . '</b>', 'center', $color[9] ) .
388 html_tag( 'td', '<b>' . _("Hey! Wath do You are looking for?") . '</b>', 'center', $color[0] )
389 ) ,
658b4c55 390 'center', '', 'width="70%"' );
d3c89357 391 }
dcc1cc82 392
393 ?>
91e0dccc 394</body></html>