options.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <?php
  2. /**
  3. * mail_fetch/options.php
  4. *
  5. * Setup of the mailfetch plugin.
  6. *
  7. * @copyright 1999-2025 The SquirrelMail Project Team
  8. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  9. * @version $Id$
  10. * @package plugins
  11. * @subpackage mail_fetch
  12. */
  13. /**
  14. * Include the SquirrelMail initialization file.
  15. */
  16. require('../../include/init.php');
  17. include_once(SM_PATH . 'plugins/mail_fetch/functions.php' );
  18. include_once(SM_PATH . 'functions/imap_general.php');
  19. include_once(SM_PATH . 'functions/forms.php');
  20. // don't load this page if this plugin is not enabled
  21. //
  22. global $plugins;
  23. if (!in_array('mail_fetch', $plugins)) exit;
  24. /* globals */
  25. sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION);
  26. if(!sqgetGlobalVar('mf_cypher', $mf_cypher, SQ_POST)) {
  27. $mf_cypher = '';
  28. }
  29. if(! sqgetGlobalVar('mf_action', $mf_action, SQ_POST) ) {
  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. }
  39. }
  40. sqgetGlobalVar('mf_sn', $mf_sn, SQ_POST);
  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('mf_auth', $mf_auth, SQ_POST);
  51. sqgetGlobalVar('mf_type', $mf_type, SQ_POST);
  52. sqgetGlobalVar('submit_mailfetch', $submit_mailfetch, SQ_POST);
  53. $mf_port = trim($mf_port);
  54. $mf_server = trim($mf_server);
  55. global $imap_stream_options; // in case not defined in config
  56. /* end globals */
  57. displayPageHeader( $color );
  58. switch( $mf_action ) {
  59. case 'add':
  60. $mf_action = 'config';
  61. // restrict port number if necessary
  62. //
  63. $message = validate_mail_fetch_port_number($mf_port);
  64. if (!empty($message)) break;
  65. // restrict server address if necessary
  66. //
  67. $message = validate_mail_fetch_server_address($mf_server);
  68. if (!empty($message)) break;
  69. if ($mf_sn<1) $mf_sn=0;
  70. if (!isset($mf_server)) return;
  71. setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
  72. setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
  73. setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
  74. setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
  75. $pass = "";
  76. if ( isset($mf_pass) ) {
  77. if ( isset($mf_cypher) && $mf_cypher == 'on' ) {
  78. setPref($data_dir,$username,"mailfetch_cypher", ($mf_cypher == 'on' ? 'on' : ''));
  79. $pass = encrypt($mf_pass);
  80. } else {
  81. $pass = $mf_pass;
  82. }
  83. }
  84. setPref($data_dir,$username,"mailfetch_pass_$mf_sn",$pass);
  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. setPref($data_dir,$username,"mailfetch_auth_$mf_sn",(isset($mf_auth)?$mf_auth:MAIL_FETCH_AUTH_USER));
  90. setPref($data_dir,$username,"mailfetch_type_$mf_sn",(isset($mf_type)?$mf_type:MAIL_FETCH_USE_PLAIN));
  91. $mf_sn++;
  92. setPref($data_dir,$username,'mailfetch_server_number', $mf_sn);
  93. break;
  94. // modify a server
  95. //
  96. case 'confirm_modify':
  97. // restrict port number if necessary
  98. //
  99. $message = validate_mail_fetch_port_number($mf_port);
  100. if (!empty($message)) {
  101. $mf_action = 'Modify';
  102. break;
  103. }
  104. // restrict server address if necessary
  105. //
  106. $message = validate_mail_fetch_server_address($mf_server);
  107. if (!empty($message)) {
  108. $mf_action = 'Modify';
  109. break;
  110. }
  111. if (!isset($mf_server)) return;
  112. setPref($data_dir,$username,"mailfetch_server_$mf_sn", (isset($mf_server)?$mf_server:""));
  113. setPref($data_dir,$username,"mailfetch_port_$mf_sn", (isset($mf_port)?$mf_port:110));
  114. setPref($data_dir,$username,"mailfetch_alias_$mf_sn", (isset($mf_alias)?$mf_alias:""));
  115. setPref($data_dir,$username,"mailfetch_user_$mf_sn",(isset($mf_user)?$mf_user:""));
  116. $pass = "";
  117. if ( isset($mf_pass) ) {
  118. if ( isset($mf_cypher) && $mf_cypher == 'on' ) {
  119. setPref($data_dir,$username,"mailfetch_cypher", 'on');
  120. $pass = encrypt($mf_pass);
  121. } else {
  122. setPref($data_dir,$username,"mailfetch_cypher", '');
  123. $pass = $mf_pass;
  124. }
  125. }
  126. setPref($data_dir,$username,"mailfetch_pass_$mf_sn",$pass);
  127. setPref($data_dir,$username,"mailfetch_lmos_$mf_sn",(isset($mf_lmos)?$mf_lmos:""));
  128. setPref($data_dir,$username,"mailfetch_login_$mf_sn",(isset($mf_login)?$mf_login:""));
  129. setPref($data_dir,$username,"mailfetch_fref_$mf_sn",(isset($mf_fref)?$mf_fref:""));
  130. setPref($data_dir,$username,"mailfetch_subfolder_$mf_sn",(isset($mf_subfolder)?$mf_subfolder:""));
  131. setPref($data_dir,$username,"mailfetch_auth_$mf_sn",(isset($mf_auth)?$mf_auth:MAIL_FETCH_AUTH_USER));
  132. setPref($data_dir,$username,"mailfetch_type_$mf_sn",(isset($mf_type)?$mf_type:MAIL_FETCH_USE_PLAIN));
  133. $mf_action = 'config';
  134. break;
  135. case 'confirm_delete':
  136. //delete a server
  137. $mailfetch_server_number = getPref($data_dir, $username, "mailfetch_server_number");
  138. if ($mf_sn+1==$mailfetch_server_number) {
  139. //is the last server, whe can only decrase $mailfetch_server_number
  140. $mailfetch_server_number--;
  141. setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
  142. } else {
  143. //if not the last, all the sequel server come up one step
  144. //then whe decrase $mailfetch_server_number
  145. $mailfetch_server_number--;
  146. for ($i=$mf_sn;$i<$mailfetch_server_number;$i++) {
  147. $tmp=$i+1;
  148. setPref($data_dir,$username,'mailfetch_server_'.$i,
  149. getPref($data_dir,$username, 'mailfetch_server_'.$tmp));
  150. setPref($data_dir,$username,'mailfetch_port_'.$i,
  151. getPref($data_dir,$username, 'mailfetch_port_'.$tmp));
  152. setPref($data_dir,$username,'mailfetch_alias_'.$i,
  153. getPref($data_dir,$username, 'mailfetch_alias_'.$tmp));
  154. setPref($data_dir,$username,'mailfetch_user_'.$i,
  155. getPref($data_dir,$username, 'mailfetch_user_'.$tmp));
  156. setPref($data_dir,$username,'mailfetch_pass_'.$i,
  157. getPref($data_dir,$username, 'mailfetch_pass_'.$tmp));
  158. setPref($data_dir,$username,'mailfetch_lmos_'.$i,
  159. getPref($data_dir,$username, 'mailfetch_lmos_'.$tmp));
  160. setPref($data_dir,$username,'mailfetch_login_'.$i,
  161. getPref($data_dir,$username, 'mailfetch_login_'.$tmp));
  162. setPref($data_dir,$username,'mailfetch_fref_'.$i,
  163. getPref($data_dir,$username, 'mailfetch_fref_'.$tmp));
  164. setPref($data_dir,$username,'mailfetch_subfolder_'.$i,
  165. getPref($data_dir,$username, 'mailfetch_subfolder_'.$tmp));
  166. setPref($data_dir,$username,'mailfetch_auth_'.$i,
  167. getPref($data_dir,$username, 'mailfetch_auth_'.$tmp,MAIL_FETCH_AUTH_USER));
  168. setPref($data_dir,$username,'mailfetch_type_'.$i,
  169. getPref($data_dir,$username, 'mailfetch_type_'.$tmp,MAIL_FETCH_USE_PLAIN));
  170. setPref($data_dir,$username,'mailfetch_uidl_'.$i,
  171. getPref($data_dir,$username, 'mailfetch_uidl_'.$tmp));
  172. }
  173. setPref($data_dir,$username,"mailfetch_server_number", $mailfetch_server_number);
  174. }
  175. $mf_action = 'config';
  176. break;
  177. }
  178. $mailfetch_server_number = getPref($data_dir, $username, 'mailfetch_server_number', 0);
  179. $mailfetch_cypher = getPref( $data_dir, $username, 'mailfetch_cypher' );
  180. if ($mailfetch_server_number<1) {
  181. $mailfetch_server_number=0;
  182. }
  183. for ($i=0;$i<$mailfetch_server_number;$i++) {
  184. $mailfetch_server_[$i] = getPref($data_dir, $username, "mailfetch_server_$i");
  185. $mailfetch_port_[$i] = getPref($data_dir, $username, "mailfetch_port_$i");
  186. $mailfetch_alias_[$i] = getPref($data_dir, $username, "mailfetch_alias_$i");
  187. $mailfetch_user_[$i] = getPref($data_dir, $username, "mailfetch_user_$i");
  188. $mailfetch_pass_[$i] = getPref($data_dir, $username, "mailfetch_pass_$i");
  189. $mailfetch_lmos_[$i] = getPref($data_dir, $username, "mailfetch_lmos_$i");
  190. $mailfetch_login_[$i] = getPref($data_dir, $username, "mailfetch_login_$i");
  191. $mailfetch_fref_[$i] = getPref($data_dir, $username, "mailfetch_fref_$i");
  192. $mailfetch_uidl_[$i] = getPref($data_dir, $username, "mailfetch_uidl_$i");
  193. $mailfetch_subfolder_[$i] = getPref($data_dir, $username, "mailfetch_subfolder_$i");
  194. $mailfetch_auth_[$i] = getPref($data_dir, $username, "mailfetch_auth_$i",MAIL_FETCH_AUTH_USER);
  195. $mailfetch_type_[$i] = getPref($data_dir, $username, "mailfetch_type_$i",MAIL_FETCH_USE_PLAIN);
  196. if( $mailfetch_cypher == 'on' ) $mailfetch_pass_[$i] = decrypt( $mailfetch_pass_[$i] );
  197. }
  198. echo '<br /><form method="post" action="'.$PHP_SELF.'">' .
  199. html_tag( 'table',
  200. html_tag( 'tr',
  201. html_tag('td',
  202. '<b>' . _("Remote POP server settings") . '</b>',
  203. 'center', $color[0] )
  204. ),
  205. 'center', '', 'width="95%"' ) .
  206. html_tag( 'table',
  207. html_tag( 'tr',
  208. html_tag( 'td',
  209. _("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.") ,
  210. 'left' )
  211. ) .
  212. html_tag( 'tr',
  213. html_tag( 'td',
  214. _("If you leave password empty, it will be asked when you fetch mail.") ,
  215. 'left' )
  216. ) .
  217. html_tag( 'tr',
  218. html_tag( 'td',
  219. '<input type="checkbox" name="mf_cypher" ' .
  220. (($mailfetch_cypher=='on')?'checked="checked" />':' />') .
  221. _("Encrypt passwords (informative only)") ,
  222. 'right' )
  223. ) ,
  224. 'center', '', 'width="95%"' );
  225. // display error or other messages if necessary
  226. //
  227. if (!empty($message)) {
  228. echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
  229. html_tag( 'tr',
  230. html_tag( 'td', '<b>' . $message . '</b>', 'center', $color[2] ));
  231. }
  232. switch( $mf_action ) {
  233. case 'config':
  234. echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
  235. html_tag( 'tr',
  236. html_tag( 'td', '<b>' . _("Add Server") . '</b>', 'center', $color[9] )
  237. ) .
  238. html_tag( 'tr' ) .
  239. html_tag( 'td', '', 'center', $color[0] ) .
  240. "<input type=\"hidden\" name=\"mf_sn\" value=\"$mailfetch_server_number\" />" .
  241. '<input type="hidden" name="mf_action" value="add" />' .
  242. html_tag( 'table' ) .
  243. html_tag( 'tr',
  244. html_tag( 'th', _("Server:"), 'right' ) .
  245. html_tag( 'td', '<input type="text" name="mf_server" value="" size="40" />', 'left' )
  246. ) .
  247. html_tag( 'tr',
  248. html_tag( 'th', _("Port:"), 'right') .
  249. html_tag( 'td', '<input type="text" name="mf_port" value="110" size="20" />', 'left')
  250. ) .
  251. html_tag( 'tr',
  252. html_tag( 'th', _("Alias:"), 'right' ) .
  253. html_tag( 'td', '<input type="text" name="mf_alias" value="" size="20" />', 'left' )
  254. ) .
  255. html_tag( 'tr',
  256. html_tag( 'th', _("Username:"), 'right' ) .
  257. html_tag( 'td', '<input type="text" name="mf_user" value="" size="20" />', 'left' )
  258. ) .
  259. html_tag( 'tr',
  260. html_tag( 'th', _("Password:"), 'right' ) .
  261. html_tag( 'td', '<input type="password" name="mf_pass" value="" size="20" />', 'left' )
  262. ) .
  263. html_tag( 'tr',
  264. html_tag( 'th', _("Authentication type:"), 'right' ) .
  265. html_tag( 'td', addSelect('mf_auth',
  266. array(MAIL_FETCH_AUTH_USER => _("USER"),
  267. MAIL_FETCH_AUTH_APOP => _("APOP"),
  268. MAIL_FETCH_AUTH_RFC1939 => _("APOP or USER")),
  269. MAIL_FETCH_AUTH_USER,true), 'left' )
  270. ) .
  271. html_tag( 'tr',
  272. html_tag( 'th', _("Connection type:"), 'right' ) .
  273. html_tag( 'td', addSelect('mf_type',
  274. array(MAIL_FETCH_USE_PLAIN => _("Plain text"),
  275. MAIL_FETCH_USE_TLS => _("Use TLS"),
  276. MAIL_FETCH_USE_STLS => _("Use StartTLS")),
  277. MAIL_FETCH_USE_PLAIN,true), 'left' )
  278. ) .
  279. html_tag( 'tr' ) .
  280. html_tag( 'th', _("Store in Folder:"), 'right' ) .
  281. html_tag( 'td', '', 'left' );
  282. $imapConnection = sqimap_login ($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  283. $boxes = sqimap_mailbox_list($imapConnection);
  284. echo '<select name="mf_subfolder">';
  285. $selected = 0;
  286. if ( isset($mf_subfolder) )
  287. $selected = array(strtolower($mf_subfolder));
  288. echo sqimap_mailbox_option_list($imapConnection, $selected);
  289. echo '</select></td></tr>' .
  290. html_tag( 'tr',
  291. html_tag( 'th', '&nbsp;', 'right' ) .
  292. html_tag( 'td', '<input type="checkbox" name="mf_lmos" checked="checked" />' . _("Leave Mail on Server"), 'left' )
  293. ) .
  294. html_tag( 'tr',
  295. html_tag( 'th', '&nbsp;', 'right' ) .
  296. html_tag( 'td', '<input type="checkbox" name="mf_login" />' . _("Check mail at login"), 'left' )
  297. ) .
  298. html_tag( 'tr',
  299. html_tag( 'th', '&nbsp;', 'right' ) .
  300. html_tag( 'td', '<input type="checkbox" name="mf_fref" />' . _("Check mail at folder refresh"), 'left' )
  301. ) .
  302. html_tag( 'tr',
  303. html_tag( 'td',
  304. '<input type="submit" name="submit_mailfetch" value="' . _("Add Server") . '" />',
  305. 'center', '', 'colspan="2"' )
  306. ) .
  307. '</table></td></tr></table></form>';
  308. // Modify Server
  309. echo '<font size="-5"><br /></font>' .
  310. html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
  311. html_tag( 'tr',
  312. html_tag( 'td', '<b>' . _("Modify Server") . '</b>', 'center', $color[9] )
  313. ) .
  314. html_tag( 'tr' ) .
  315. html_tag( 'td', '', 'center', $color[0] );
  316. if ($mailfetch_server_number>0) {
  317. echo "<form action=\"$PHP_SELF\" method=\"post\" target=\"_self\">";
  318. echo '<b>' . _("Server Name:") . '</b> <select name="mf_sn">';
  319. for ($i=0;$i<$mailfetch_server_number;$i++) {
  320. echo "<option value=\"$i\">" .
  321. sm_encode_html_special_chars( (($mailfetch_alias_[$i]=='')?$mailfetch_server_[$i]:$mailfetch_alias_[$i])) . "</option>";
  322. }
  323. echo '</select>'.
  324. '&nbsp;&nbsp;<input type="submit" name="mf_action_mod" value="' . _("Modify") . '" />'.
  325. '&nbsp;&nbsp;<input type="submit" name="mf_action_del" value="' . _("Delete") . '" />'.
  326. '</form>';
  327. } else {
  328. echo _("No servers known.");
  329. }
  330. echo '</td></tr></table>';
  331. break;
  332. case 'Delete': //erase confirmation about a server
  333. echo html_tag( 'table',
  334. html_tag( 'tr',
  335. html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
  336. ) ,
  337. 'center', '', 'width="95%" cellpadding="5" cellspacing="1"' ) .
  338. '<br />' .
  339. html_tag( 'table',
  340. html_tag( 'tr',
  341. html_tag( 'td', '<b>' . _("Confirm Deletion of a Server") . '</b>', 'center', $color[9] )
  342. ) .
  343. html_tag( 'tr',
  344. html_tag( 'td',
  345. "<input type=\"hidden\" name=\"mf_sn\" value=\"$mf_sn\" />" .
  346. '<input type="hidden" name="mf_action" value="confirm_delete" />' .
  347. '<br />' . _("Selected Server:") . " <b>" . sm_encode_html_special_chars($mailfetch_server_[$mf_sn]) . "</b><br />" .
  348. _("Confirm delete of selected server?") . '<br /><br />' .
  349. '<input type="submit" name="submit_mailfetch" value="' . _("Confirm Delete") . '" />' .
  350. '<br /></form>' ,
  351. 'center', $color[9] )
  352. ) ,
  353. 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' );
  354. break; //modify a server
  355. case 'Modify':
  356. echo html_tag( 'table',
  357. html_tag( 'tr',
  358. html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
  359. ) ,
  360. 'center', '', 'width="95%" cellpadding="5" cellspacing="1"' ) .
  361. '<br />' .
  362. html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="5" cellspacing="1"' ) .
  363. html_tag( 'tr',
  364. html_tag( 'td', '<b>' . _("Modify Server") . '</b>', 'center', $color[9] )
  365. ) .
  366. html_tag( 'tr' ) .
  367. html_tag( 'td', '', 'center', $color[0] ) .
  368. "<input type=\"hidden\" name=\"mf_sn\" value=\"$mf_sn\" />" .
  369. '<input type="hidden" name="mf_action" value="confirm_modify" />' .
  370. html_tag( 'table' ) .
  371. html_tag( 'tr',
  372. html_tag( 'th', _("Server:"), 'right' ) .
  373. html_tag( 'td', '<input type="text" name="mf_server" value="' .
  374. sm_encode_html_special_chars($mailfetch_server_[$mf_sn]) . '" size="40" />', 'left' )
  375. ) .
  376. html_tag( 'tr',
  377. html_tag( 'th', _("Port:"), 'right' ) .
  378. html_tag( 'td', '<input type="text" name="mf_port" value="' .
  379. sm_encode_html_special_chars($mailfetch_port_[$mf_sn]) . '" size="40" />', 'left' )
  380. ) .
  381. html_tag( 'tr',
  382. html_tag( 'th', _("Alias:"), 'right' ) .
  383. html_tag( 'td', '<input type="text" name="mf_alias" value="' .
  384. sm_encode_html_special_chars($mailfetch_alias_[$mf_sn]) . '" size="40" />', 'left' )
  385. ) .
  386. html_tag( 'tr',
  387. html_tag( 'th', _("Username:"), 'right' ) .
  388. html_tag( 'td', '<input type="text" name="mf_user" value="' .
  389. sm_encode_html_special_chars($mailfetch_user_[$mf_sn]) . '" size="20" />', 'left' )
  390. ) .
  391. html_tag( 'tr',
  392. html_tag( 'th', _("Password:"), 'right' ) .
  393. html_tag( 'td', '<input type="password" name="mf_pass" value="' .
  394. sm_encode_html_special_chars($mailfetch_pass_[$mf_sn]) . '" size="20" />', 'left' )
  395. ) .
  396. html_tag( 'tr',
  397. html_tag( 'th', _("Authentication type:"), 'right' ) .
  398. html_tag( 'td', addSelect('mf_auth',array(MAIL_FETCH_AUTH_USER => _("USER"),
  399. MAIL_FETCH_AUTH_APOP => _("APOP"),
  400. MAIL_FETCH_AUTH_RFC1939 => _("APOP or USER")),
  401. $mailfetch_auth_[$mf_sn],true), 'left' )
  402. ) .
  403. html_tag( 'tr',
  404. html_tag( 'th', _("Connection type:"), 'right' ) .
  405. html_tag( 'td', addSelect('mf_type',array(MAIL_FETCH_USE_PLAIN => _("Plain text"),
  406. MAIL_FETCH_USE_TLS => _("Use TLS"),
  407. MAIL_FETCH_USE_STLS => _("Use StartTLS")),
  408. $mailfetch_type_[$mf_sn],true), 'left' )
  409. ) .
  410. html_tag( 'tr' ) .
  411. html_tag( 'th', _("Store in Folder:"), 'right' ) .
  412. html_tag( 'td', '', 'left' );
  413. $imapConnection = sqimap_login ($username, false, $imapServerAddress, $imapPort, 0, $imap_stream_options);
  414. $boxes = sqimap_mailbox_list($imapConnection);
  415. echo '<select name="mf_subfolder">';
  416. $selected = 0;
  417. if ( isset($mailfetch_subfolder_[$mf_sn]) ) {
  418. $selected = array(strtolower($mailfetch_subfolder_[$mf_sn]));
  419. }
  420. echo sqimap_mailbox_option_list($imapConnection, $selected) .
  421. '</select></td></tr>' .
  422. html_tag( 'tr',
  423. html_tag( 'th', '&nbsp;', 'right' ) .
  424. html_tag( 'td',
  425. '<input type="checkbox" name="mf_lmos" ' . (($mailfetch_lmos_[$mf_sn] == 'on')?'checked="checked"':'') .
  426. ' />' . _("Leave Mail on Server") ,
  427. 'left' )
  428. ) .
  429. html_tag( 'tr',
  430. html_tag( 'th', '&nbsp;', 'right' ) .
  431. html_tag( 'td',
  432. '<input type="checkbox" name="mf_login" ' . ( ($mailfetch_login_[$mf_sn] == 'on')?'checked="checked"':'') .
  433. ' />' . _("Check mail at login"),
  434. 'left' )
  435. ) .
  436. html_tag( 'tr',
  437. html_tag( 'th', '&nbsp;', 'right' ) .
  438. html_tag( 'td',
  439. '<input type="checkbox" name="mf_fref" ' . ( ($mailfetch_fref_[$mf_sn] == 'on')?'checked="checked"':'') .
  440. ' />' . _("Check mail at folder refresh") ,
  441. 'left' )
  442. ) .
  443. html_tag( 'tr',
  444. html_tag( 'td',
  445. '<input type="submit" name="submit_mailfetch" value="' . _("Modify Server") . '" />',
  446. 'center', '', 'colspan="2"' )
  447. ) .
  448. '</table></form></td></tr></table>';
  449. break;
  450. default: //unsupported action
  451. echo '</form>' .
  452. html_tag( 'table',
  453. html_tag( 'tr',
  454. html_tag( 'td', '<b>' . _("Fetching Servers") . '</b>', 'center', $color[0] )
  455. ) ,
  456. 'center', '', 'width="95%"' ) .
  457. '<br />' .
  458. html_tag( 'table',
  459. html_tag( 'tr',
  460. html_tag( 'td', '<b>' . _("Undefined Function") . '</b>', 'center', $color[9] ) .
  461. html_tag( 'td', '<b>' . _("The function you requested is unknown.") . '</b>', 'center', $color[0] )
  462. ) ,
  463. 'center', '', 'width="70%"' );
  464. }
  465. $oTemplate->display('footer.tpl');