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