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