4 # Copyright (c) 1999-2003 The SquirrelMail Project Team
5 # Licensed under the GNU GPL. For full terms see COPYING.
7 # A simple configure script to configure SquirrelMail
10 ############################################################
11 $conf_pl_version = "1.4.0";
13 ############################################################
14 # Check what directory we're supposed to be running in, and
15 # change there if necessary. File::Basename has been in
16 # Perl since at least 5.003_7, and nobody sane runs anything
17 # before that, but just in case.
18 ############################################################
20 if ( eval q{require "File/Basename.pm"} ) {
21 $dir = File
::Basename
::dirname
($0);
25 ############################################################
26 # Some people try to run this as a CGI. That's wrong!
27 ############################################################
28 if ( defined( $ENV{'PATH_INFO'} )
29 || defined( $ENV{'QUERY_STRING'} )
30 || defined( $ENV{'REQUEST_METHOD'} ) ) {
31 print "Content-Type: text/html\n\n";
32 print "You must run this script from the command line.";
36 ############################################################
37 # If we got here, use Cwd to get the full directory path
38 # (the Basename stuff above will sometimes return '.' as
39 # the base directory, which is not helpful here).
40 ############################################################
45 ############################################################
46 # First, lets read in the data already in there...
47 ############################################################
48 if ( -e
"config.php" ) {
49 open( FILE
, "config.php" );
50 while ( $line = <FILE
> ) {
56 if ( $var =~ /^([a-z])/i ) {
57 @o = split ( /\s*EQUALS\s*/, $var );
58 if ( $o[0] eq "config_version" ) {
60 $o[1] =~ s/[\'\"];\s*$//;
64 $config_version = $o[1];
71 if ( $config_version ne $conf_pl_version ) {
73 print $WHT. "WARNING:\n" . $NRM;
74 print " The file \"config/config.php\" was found, but it is for\n";
75 print " an older version of SquirrelMail. It is possible to still\n";
76 print " read the defaults from this file but be warned that many\n";
77 print " preferences change between versions. It is recommended that\n";
78 print " you start with a clean config.php for each upgrade that you\n";
79 print " do. To do this, just move config/config.php out of the way.\n";
81 print "Continue loading with the old config.php [y/N]? ";
84 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
88 print "\nDo you want me to stop warning you [y/N]? ";
90 if ( $ctu =~ /^y\n/i ) {
91 $print_config_version = $conf_pl_version;
93 $print_config_version = $config_version;
96 $print_config_version = $config_version;
100 open( FILE
, "config.php" );
101 } elsif ( -e
"config_default.php" ) {
102 open( FILE
, "config_default.php" );
103 while ( $line = <FILE
> ) {
109 if ( $var =~ /^([a-z])/i ) {
110 @o = split ( /\s*EQUALS\s*/, $var );
111 if ( $o[0] eq "config_version" ) {
112 $o[1] =~ s/[\n\r]//g;
113 $o[1] =~ s/[\'\"];\s*$//;
115 $o[1] =~ s/^[\'\"]//;
117 $config_version = $o[1];
124 if ( $config_version ne $conf_pl_version ) {
126 print $WHT. "WARNING:\n" . $NRM;
127 print " You are trying to use a 'config_default.php' from an older\n";
128 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
129 print " should get the 'config_default.php' that matches the version\n";
130 print " of SquirrelMail that you are running. You can get this from\n";
131 print " the SquirrelMail web page by going to the following URL:\n";
132 print " http://www.squirrelmail.org.\n";
134 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
137 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
141 print "\nDo you want me to stop warning you [y/N]? ";
143 if ( $ctu =~ /^y\n/i ) {
144 $print_config_version = $conf_pl_version;
146 $print_config_version = $config_version;
149 $print_config_version = $config_version;
152 open( FILE
, "config_default.php" );
154 print "No configuration file found. Please get config_default.php\n";
155 print "or config.php before running this again. This program needs\n";
156 print "a default config file to get default values.\n";
160 # Read and parse the current configuration file
161 # (either config.php or config_default.php).
162 while ( $line = <FILE
> ) {
168 if ( $var =~ /^([a-z])/i ) {
169 @options = split ( /\s*EQUALS\s*/, $var );
170 $options[1] =~ s/[\n\r]//g;
171 $options[1] =~ s/[\'\"];\s*$//;
172 $options[1] =~ s/;$//;
173 $options[1] =~ s/^[\'\"]//;
174 # de-escape escaped strings
175 $options[1] =~ s/\\'/'/g;
176 $options[1] =~ s/\\\\/\\/g;
178 if ( $options[0] =~ /^theme\[[0-9]+\]\[['"]PATH['"]\]/ ) {
180 $sub =~ s/\]\[['"]PATH['"]\]//;
182 if ( -e
"../themes" ) {
183 $options[1] =~ s/^\.\.\/config/\
.\
.\
/themes/;
185 $theme_path[$sub] = &change_to_rel_path
($options[1]);
186 } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['"]NAME['"]\]/ ) {
188 $sub =~ s/\]\[['"]NAME['"]\]//;
190 $theme_name[$sub] = $options[1];
191 } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
194 $sub =~ s/^plugins\[//;
195 $plugins[$sub] = $options[1];
196 } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
199 $sub =~ s/^ldap_server\[//;
201 while ( ( $tmp = <FILE
> ) && ( $continue != 1 ) ) {
202 if ( $tmp =~ /\);\s*$/ ) {
206 if ( $tmp =~ /^\s*[\'\"]host[\'\"]/i ) {
207 $tmp =~ s/^\s*[\'\"]host[\'\"]\s*=>\s*[\'\"]//i;
208 $tmp =~ s/[\'\"],?\s*$//;
209 $tmp =~ s/[\'\"]\);\s*$//;
211 } elsif ( $tmp =~ /^\s*[\'\"]base[\'\"]/i ) {
212 $tmp =~ s/^\s*[\'\"]base[\'\"]\s*=>\s*[\'\"]//i;
213 $tmp =~ s/[\'\"],?\s*$//;
214 $tmp =~ s/[\'\"]\);\s*$//;
216 } elsif ( $tmp =~ /^\s*[\'\"]charset[\'\"]/i ) {
217 $tmp =~ s/^\s*[\'\"]charset[\'\"]\s*=>\s*[\'\"]//i;
218 $tmp =~ s/[\'\"],?\s*$//;
219 $tmp =~ s/[\'\"]\);\s*$//;
221 } elsif ( $tmp =~ /^\s*[\'\"]port[\'\"]/i ) {
222 $tmp =~ s/^\s*[\'\"]port[\'\"]\s*=>\s*[\'\"]?//i;
223 $tmp =~ s/[\'\"]?,?\s*$//;
224 $tmp =~ s/[\'\"]?\);\s*$//;
226 } elsif ( $tmp =~ /^\s*[\'\"]maxrows[\'\"]/i ) {
227 $tmp =~ s/^\s*[\'\"]maxrows[\'\"]\s*=>\s*[\'\"]?//i;
228 $tmp =~ s/[\'\"]?,?\s*$//;
229 $tmp =~ s/[\'\"]?\);\s*$//;
231 } elsif ( $tmp =~ /^\s*[\'\"]name[\'\"]/i ) {
232 $tmp =~ s/^\s*[\'\"]name[\'\"]\s*=>\s*[\'\"]//i;
233 $tmp =~ s/[\'\"],?\s*$//;
234 $tmp =~ s/[\'\"]\);\s*$//;
236 } elsif ( $tmp =~ /^\s*[\'\"]binddn[\'\"]/i ) {
237 $tmp =~ s/^\s*[\'\"]binddn[\'\"]\s*=>\s*[\'\"]//i;
238 $tmp =~ s/[\'\"],?\s*$//;
239 $tmp =~ s/[\'\"]\);\s*$//;
241 } elsif ( $tmp =~ /^\s*[\'\"]bindpw[\'\"]/i ) {
242 $tmp =~ s/^\s*[\'\"]bindpw[\'\"]\s*=>\s*[\'\"]//i;
243 $tmp =~ s/[\'\"],?\s*$//;
244 $tmp =~ s/[\'\"]\);\s*$//;
246 } elsif ( $tmp =~ /^\s*[\'\"]protocol[\'\"]/i ) {
247 $tmp =~ s/^\s*[\'\"]protocol[\'\"]\s*=>\s*[\'\"]?//i;
248 $tmp =~ s/[\'\"]?,?\s*$//;
249 $tmp =~ s/[\'\"]?\);\s*$//;
253 $ldap_host[$sub] = $host;
254 $ldap_base[$sub] = $base;
255 $ldap_name[$sub] = $name;
256 $ldap_port[$sub] = $port;
257 $ldap_maxrows[$sub] = $maxrows;
258 $ldap_charset[$sub] = $charset;
259 $ldap_binddn[$sub] = $binddn;
260 $ldap_bindpw[$sub] = $bindpw;
261 $ldap_protocol[$sub] = $protocol;
262 } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
263 ${ $options[0] } = &change_to_rel_path
($options[1]);
265 ${ $options[0] } = $options[1];
271 $useSendmail = 'false' if ( lc($useSendmail) ne 'true' );
272 $sendmail_path = "/usr/sbin/sendmail" if ( !$sendmail_path );
273 $pop_before_smtp = 'false' if ( !$pop_before_smtp );
274 $default_unseen_notify = 2 if ( !$default_unseen_notify );
275 $default_unseen_type = 1 if ( !$default_unseen_type );
276 $config_use_color = 0 if ( !$config_use_color );
277 $invert_time = 'false' if ( !$invert_time );
278 $force_username_lowercase = 'false' if ( !$force_username_lowercase );
279 $optional_delimiter = "detect" if ( !$optional_delimiter );
280 $auto_create_special = 'false' if ( !$auto_create_special );
281 $default_use_priority = 'true' if ( !$default_use_priority );
282 $hide_sm_attributions = 'false' if ( !$hide_sm_attributions );
283 $default_use_mdn = 'true' if ( !$default_use_mdn );
284 $delete_folder = 'false' if ( !$delete_folder );
285 $noselect_fix_enable = 'false' if ( !$noselect_fix_enable );
286 $frame_top = "_top" if ( !$frame_top );
287 $provider_uri = '' if ( !$provider_uri );
288 $provider_name = '' if ( !$provider_name );
289 $edit_identity = 'true' if ( !$edit_identity );
290 $edit_name = 'true' if ( !$edit_name );
291 $allow_thread_sort = 'false' if ( !$allow_thread_sort );
292 $allow_server_sort = 'false' if ( !$allow_server_sort );
293 $no_list_for_subscribe = 'false' if ( !$no_list_for_subscribe );
294 $allow_charset_search = 'true' if ( !$allow_charset_search );
295 $allow_advanced_search = 0 if ( !$allow_advanced_search) ;
296 $prefs_user_field = 'user' if ( !$prefs_user_field );
297 $prefs_key_field = 'prefkey' if ( !$prefs_key_field );
298 $prefs_val_field = 'prefval' if ( !$prefs_val_field );
299 $addrbook_global_table = 'global_abook' if ( !$addrbook_global_table );
300 $addrbook_global_writeable = 'false' if ( !$addrbook_global_writeable );
301 $addrbook_global_listing = 'false' if ( !$addrbook_global_listing );
302 $use_smtp_tls= 'false' if ( !$use_smtp_tls);
303 $smtp_auth_mech = 'none' if ( !$smtp_auth_mech );
304 $use_imap_tls = 'false' if ( !$use_imap_tls );
305 $imap_auth_mech = 'login' if ( !$imap_auth_mech );
306 $session_name = 'SQMSESSID' if ( !$session_name );
307 $show_alternative_names = 'false' if ( !$show_alternative_names );
308 $available_languages = 'all' if ( !$available_languages );
309 $aggressive_decoding = 'false' if ( !$aggressive_decoding );
310 $loosy_encoding = 'false' if ( !$loosy_encoding );
311 $advanced_tree = 'false' if ( !$advanced_tree );
312 $oldway = 'false' if ( !$oldway );
313 $use_icons = 'false' if ( !$use_icons );
314 $use_php_recode = 'false' if ( !$use_php_recode );
315 $use_php_iconv = 'false' if ( !$use_php_iconv );
316 $skip_SM_header = 'false' if ( !$skip_SM_header );
318 if ( $ARGV[0] eq '--install-plugin' ) {
319 print "Activating plugin " . $ARGV[1] . "\n";
320 push @plugins, $ARGV[1];
323 } elsif ( $ARGV[0] eq '--remove-plugin' ) {
324 print "Removing plugin " . $ARGV[1] . "\n";
325 foreach $plugin (@plugins) {
326 if ( $plugin ne $ARGV[1] ) {
327 push @newplugins, $plugin;
330 @plugins = @newplugins;
335 #####################################################################################
336 if ( $config_use_color == 1 ) {
342 $config_use_color = 2;
345 while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
347 print $WHT. "SquirrelMail Configuration : " . $NRM;
348 if ( $config == 1 ) { print "Read: config.php"; }
349 elsif ( $config == 2 ) { print "Read: config_default.php"; }
350 print " ($print_config_version)\n";
351 print "---------------------------------------------------------\n";
354 print $WHT. "Main Menu --\n" . $NRM;
355 print "1. Organization Preferences\n";
356 print "2. Server Settings\n";
357 print "3. Folder Defaults\n";
358 print "4. General Options\n";
360 print "6. Address Books (LDAP)\n";
361 print "7. Message of the Day (MOTD)\n";
362 print "8. Plugins\n";
363 print "9. Database\n";
364 print "10. Language settings\n";
365 print "11. Tweaks\n";
367 print "D. Set pre-defined settings for specific IMAP servers\n";
369 } elsif ( $menu == 1 ) {
370 print $WHT. "Organization Preferences\n" . $NRM;
371 print "1. Organization Name : $WHT$org_name$NRM\n";
372 print "2. Organization Logo : $WHT$org_logo$NRM\n";
373 print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
374 print "4. Organization Title : $WHT$org_title$NRM\n";
375 print "5. Signout Page : $WHT$signout_page$NRM\n";
376 print "6. Top Frame : $WHT$frame_top$NRM\n";
377 print "7. Provider link : $WHT$provider_uri$NRM\n";
378 print "8. Provider name : $WHT$provider_name$NRM\n";
381 print "R Return to Main Menu\n";
382 } elsif ( $menu == 2 ) {
383 print $WHT. "Server Settings\n\n" . $NRM;
384 print $WHT . "General" . $NRM . "\n";
386 print "1. Domain : $WHT$domain$NRM\n";
387 print "2. Invert Time : $WHT$invert_time$NRM\n";
388 print "3. Sendmail or SMTP : $WHT";
389 if ( lc($useSendmail) eq 'true' ) {
397 if ( $show_imap_settings ) {
398 print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
399 print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
400 print "5. IMAP Port : $WHT$imapPort$NRM\n";
401 print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
402 print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n";
403 print "8. Server software : $WHT$imap_server_type$NRM\n";
404 print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
406 } elsif ( $show_smtp_settings ) {
407 if ( lc($useSendmail) eq 'true' ) {
408 print $WHT . "Sendmail" . $NRM . "\n--------\n";
409 print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
410 print "5. Suppress SM header : $WHT$skip_SM_header$NRM\n";
413 print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
414 print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
415 print "5. SMTP Port : $WHT$smtpPort$NRM\n";
416 print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
417 print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n";
418 print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n";
419 print "9. Suppress SM header : $WHT$skip_SM_header$NRM\n";
424 if ($show_imap_settings == 0) {
425 print "A. Update IMAP Settings : ";
426 print "$WHT$imapServerAddress$NRM:";
427 print "$WHT$imapPort$NRM ";
428 print "($WHT$imap_server_type$NRM)\n";
430 if ($show_smtp_settings == 0) {
431 if ( lc($useSendmail) eq 'true' ) {
432 print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
434 print "B. Update SMTP Settings : ";
435 print "$WHT$smtpServerAddress$NRM:";
436 print "$WHT$smtpPort$NRM\n";
439 if ( $show_smtp_settings || $show_imap_settings )
442 ($show_imap_settings ?
"IMAP Server" :
443 (lc($useSendmail) eq 'true') ?
"Sendmail" : "SMTP") . " Settings\n";
447 print "R Return to Main Menu\n";
448 } elsif ( $menu == 3 ) {
449 print $WHT. "Folder Defaults\n" . $NRM;
450 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
451 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
452 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
453 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
454 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
455 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
456 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
457 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
458 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
459 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
460 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
461 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
462 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
463 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
464 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
465 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
466 print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
467 print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
469 print "R Return to Main Menu\n";
470 } elsif ( $menu == 4 ) {
471 print $WHT. "General Options\n" . $NRM;
472 print "1. Data Directory : $WHT$data_dir$NRM\n";
473 print "2. Attachment Directory : $WHT$attachment_dir$NRM\n";
474 print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
475 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
476 print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
477 print "6. Allow use of priority : $WHT$default_use_priority$NRM\n";
478 print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
479 print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
480 print "9. Allow editing of identity : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
481 print "10. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
482 print "11. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
483 print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
484 print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n";
485 print "14. PHP session name : $WHT$session_name$NRM\n";
487 print "R Return to Main Menu\n";
488 } elsif ( $menu == 5 ) {
489 print $WHT. "Themes\n" . $NRM;
490 print "1. Change Themes\n";
491 for ( $count = 0 ; $count <= $#theme_name/2 ; $count++ ) {
492 $temp_name = $theme_name[$count*2];
493 printf " %s%*s %s\n", $temp_name,
494 40 - length($temp_name), " ",
495 $theme_name[($count*2)+1];
497 print "2. CSS File : $WHT$theme_css$NRM\n";
499 print "R Return to Main Menu\n";
500 } elsif ( $menu == 6 ) {
501 print $WHT. "Address Books (LDAP)\n" . $NRM;
502 print "1. Change Servers\n";
503 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
504 print " > $ldap_host[$count]\n";
507 "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
509 print "R Return to Main Menu\n";
510 } elsif ( $menu == 7 ) {
511 print $WHT. "Message of the Day (MOTD)\n" . $NRM;
514 print "1 Edit the MOTD\n";
516 print "R Return to Main Menu\n";
517 } elsif ( $menu == 8 ) {
518 print $WHT. "Plugins\n" . $NRM;
519 print " Installed Plugins\n";
521 for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
523 print " $num. $plugins[$count]\n";
525 print "\n Available Plugins:\n";
526 opendir( DIR
, "../plugins" );
527 @files = readdir(DIR
);
529 @unused_plugins = ();
530 for ( $i = 0 ; $i <= $#files ; $i++ ) {
531 if ( -d
"../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
533 for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
534 if ( $plugins[$k] eq $files[$i] ) {
539 $unused_plugins[$pos] = $files[$i];
545 for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
547 print " $num. $unused_plugins[$i]\n";
552 print "R Return to Main Menu\n";
553 } elsif ( $menu == 9 ) {
554 print $WHT. "Database\n" . $NRM;
555 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
556 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
558 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
559 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
560 print "5. Field for username : $WHT$prefs_user_field$NRM\n";
561 print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
562 print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
564 print "8. DSN for Global Address Book : $WHT$addrbook_global_dsn$NRM\n";
565 print "9. Table for Global Address Book : $WHT$addrbook_global_table$NRM\n";
566 print "10. Allow writing into Global Address Book : $WHT$addrbook_global_writeable$NRM\n";
567 print "11. Allow listing of Global Address Book : $WHT$addrbook_global_listing$NRM\n";
569 print "R Return to Main Menu\n";
570 } elsif ( $menu == 10 ) {
571 print $WHT. "Language settings\n" . $NRM;
572 print "1. Default Language : $WHT$squirrelmail_default_language$NRM\n";
573 print "2. Default Charset : $WHT$default_charset$NRM\n";
574 print "3. Show alternative language names : $WHT$show_alternative_names$NRM\n";
575 print "4. Available languages : $WHT$available_languages$NRM\n";
576 print "5. Enable aggressive decoding : $WHT$aggressive_decoding$NRM\n";
577 print "6. Enable loosy encoding : $WHT$loosy_encoding$NRM\n";
579 print "R Return to Main Menu\n";
580 } elsif ( $menu == 11 ) {
581 print $WHT. "Interface tweaks\n" . $NRM;
582 print "1. Advanced tree : $WHT$advanced_tree$NRM\n";
583 print "2. Oldway : $WHT$oldway$NRM\n";
584 print "3. Use Icons : $WHT$use_icons$NRM\n";
586 print $WHT. "PHP tweaks\n" . $NRM;
587 print "4. Use php recode functions : $WHT$use_php_recode$NRM\n";
588 print "5. Use php iconv functions : $WHT$use_php_iconv$NRM\n";
590 print "R Return to Main Menu\n";
592 if ( $config_use_color == 1 ) {
593 print "C Turn color off\n";
595 print "C Turn color on\n";
597 print "S Save data\n";
601 print "Command >> " . $WHT;
603 $command =~ s/[\n\r]//g;
604 $command =~ tr/A-Z/a-z/;
607 # Read the commands they entered.
608 if ( $command eq "r" ) {
610 } elsif ( $command eq "s" ) {
612 print "Press enter to continue...";
615 } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
616 print "You have not saved your data.\n";
617 print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
619 if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
622 } elsif ( $command eq "c" ) {
623 if ( $config_use_color == 1 ) {
624 $config_use_color = 2;
628 $config_use_color = 1;
632 } elsif ( $command eq "d" && $menu == 0 ) {
637 if ( ( $command > 0 ) && ( $command < 12 ) ) {
640 } elsif ( $menu == 1 ) {
641 if ( $command == 1 ) { $org_name = command1
(); }
642 elsif ( $command == 2 ) { $org_logo = command2
(); }
643 elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a
(); }
644 elsif ( $command == 4 ) { $org_title = command3
(); }
645 elsif ( $command == 5 ) { $signout_page = command4
(); }
646 elsif ( $command == 6 ) { $frame_top = command6
(); }
647 elsif ( $command == 7 ) { $provider_uri = command7
(); }
648 elsif ( $command == 8 ) { $provider_name = command8
(); }
650 } elsif ( $menu == 2 ) {
651 if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
652 elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
653 elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
654 elsif ( $command <= 3 ) {
655 if ( $command == 1 ) { $domain = command11
(); }
656 elsif ( $command == 2 ) { $invert_time = command110
(); }
657 elsif ( $command == 3 ) { $useSendmail = command14
(); }
658 $show_imap_settings = 0; $show_smtp_settings = 0;
659 } elsif ( $show_imap_settings ) {
660 if ( $command == 4 ) { $imapServerAddress = command12
(); }
661 elsif ( $command == 5 ) { $imapPort = command13
(); }
662 elsif ( $command == 6 ) { $imap_auth_mech = command112a
(); }
663 elsif ( $command == 7 ) { $use_imap_tls = command113
("IMAP",$use_imap_tls); }
664 elsif ( $command == 8 ) { $imap_server_type = command19
(); }
665 elsif ( $command == 9 ) { $optional_delimiter = command111
(); }
666 } elsif ( $show_smtp_settings && lc($useSendmail) eq 'true' ) {
667 if ( $command == 4 ) { $sendmail_path = command15
(); }
668 } elsif ( $show_smtp_settings ) {
669 if ( $command == 4 ) { $smtpServerAddress = command16
(); }
670 elsif ( $command == 5 ) { $smtpPort = command17
(); }
671 elsif ( $command == 6 ) { $pop_before_smtp = command18a
(); }
672 elsif ( $command == 7 ) { $smtp_auth_mech = command112b
(); }
673 elsif ( $command == 8 ) { $use_smtp_tls = command113
("SMTP",$use_smtp_tls); }
674 elsif ( $command == 9 ) { $skip_SM_header = command114
(); }
676 } elsif ( $menu == 3 ) {
677 if ( $command == 1 ) { $default_folder_prefix = command21
(); }
678 elsif ( $command == 2 ) { $show_prefix_option = command22
(); }
679 elsif ( $command == 3 ) { $trash_folder = command23a
(); }
680 elsif ( $command == 4 ) { $sent_folder = command23b
(); }
681 elsif ( $command == 5 ) { $draft_folder = command23c
(); }
682 elsif ( $command == 6 ) { $default_move_to_trash = command24a
(); }
683 elsif ( $command == 7 ) { $default_move_to_sent = command24b
(); }
684 elsif ( $command == 8 ) { $default_save_as_draft = command24c
(); }
685 elsif ( $command == 9 ) { $list_special_folders_first = command27
(); }
686 elsif ( $command == 10 ) { $use_special_folder_color = command28
(); }
687 elsif ( $command == 11 ) { $auto_expunge = command29
(); }
688 elsif ( $command == 12 ) { $default_sub_of_inbox = command210
(); }
689 elsif ( $command == 13 ) { $show_contain_subfolders_option = command211
(); }
690 elsif ( $command == 14 ) { $default_unseen_notify = command212
(); }
691 elsif ( $command == 15 ) { $default_unseen_type = command213
(); }
692 elsif ( $command == 16 ) { $auto_create_special = command214
(); }
693 elsif ( $command == 17 ) { $delete_folder = command215
(); }
694 elsif ( $command == 18 ) { $noselect_fix_enable = command216
(); }
695 } elsif ( $menu == 4 ) {
696 if ( $command == 1 ) { $data_dir = command33a
(); }
697 elsif ( $command == 2 ) { $attachment_dir = command33b
(); }
698 elsif ( $command == 3 ) { $dir_hash_level = command33c
(); }
699 elsif ( $command == 4 ) { $default_left_size = command35
(); }
700 elsif ( $command == 5 ) { $force_username_lowercase = command36
(); }
701 elsif ( $command == 6 ) { $default_use_priority = command37
(); }
702 elsif ( $command == 7 ) { $hide_sm_attributions = command38
(); }
703 elsif ( $command == 8 ) { $default_use_mdn = command39
(); }
704 elsif ( $command == 9 ) { $edit_identity = command310
(); }
705 elsif ( $command == 10 ) { $allow_thread_sort = command312
(); }
706 elsif ( $command == 11 ) { $allow_server_sort = command313
(); }
707 elsif ( $command == 12 ) { $allow_charset_search = command314
(); }
708 elsif ( $command == 13 ) { $allow_advanced_search = command316
(); }
709 elsif ( $command == 14 ) { $session_name = command317
(); }
710 } elsif ( $menu == 5 ) {
711 if ( $command == 1 ) { command41
(); }
712 elsif ( $command == 2 ) { $theme_css = command42
(); }
713 } elsif ( $menu == 6 ) {
714 if ( $command == 1 ) { command61
(); }
715 elsif ( $command == 2 ) { command62
(); }
716 } elsif ( $menu == 7 ) {
717 if ( $command == 1 ) { $motd = command71
(); }
718 } elsif ( $menu == 8 ) {
719 if ( $command =~ /^[0-9]+/ ) { @plugins = command81
(); }
720 } elsif ( $menu == 9 ) {
721 if ( $command == 1 ) { $addrbook_dsn = command91
(); }
722 elsif ( $command == 2 ) { $addrbook_table = command92
(); }
723 elsif ( $command == 3 ) { $prefs_dsn = command93
(); }
724 elsif ( $command == 4 ) { $prefs_table = command94
(); }
725 elsif ( $command == 5 ) { $prefs_user_field = command95
(); }
726 elsif ( $command == 6 ) { $prefs_key_field = command96
(); }
727 elsif ( $command == 7 ) { $prefs_val_field = command97
(); }
728 elsif ( $command == 8 ) { $addrbook_global_dsn = command98
(); }
729 elsif ( $command == 9 ) { $addrbook_global_table = command99
(); }
730 elsif ( $command == 10 ) { $addrbook_global_writeable = command910
(); }
731 elsif ( $command == 11 ) { $addrbook_global_listing = command911
(); }
732 } elsif ( $menu == 10 ) {
733 if ( $command == 1 ) { $squirrelmail_default_language = commandA1
(); }
734 elsif ( $command == 2 ) { $default_charset = commandA2
(); }
735 elsif ( $command == 3 ) { $show_alternative_names = commandA3
(); }
736 elsif ( $command == 4 ) { $available_languages = commandA4
(); }
737 elsif ( $command == 5 ) { $aggressive_decoding = commandA5
(); }
738 elsif ( $command == 6 ) { $loosy_encoding = commandA6
(); }
739 } elsif ( $menu == 11 ) {
740 if ( $command == 1 ) { $advanced_tree = commandB1
(); }
741 elsif ( $command == 2 ) { $oldway = commandB2
(); }
742 elsif ( $command == 3 ) { $use_icons = commandB3
(); }
743 elsif ( $command == 4 ) { $use_php_recode = commandB4
(); }
744 elsif ( $command == 5 ) { $use_php_iconv = commandB5
(); }
750 print "\nExiting conf.pl.\n".
751 "You might want to test your configuration by browsing to\n".
752 "http://your-squirrelmail-location/src/configtest.php\n".
753 "Happy SquirrelMailing!\n\n";
756 ####################################################################################
760 print "We have tried to make the name SquirrelMail as transparent as\n";
761 print "possible. If you set up an organization name, most places where\n";
762 print "SquirrelMail would take credit will be credited to your organization.\n";
764 print "If your Organization Name includes a '\$', please precede it with a \\. \n";
765 print "Other '\$' will be considered the beginning of a variable that\n";
766 print "must be defined before the \$org_name is printed.\n";
767 print "\$version, for example, is included by default, and will print the\n";
768 print "string representing the current SquirrelMail version.\n";
770 print "[$WHT$org_name$NRM]: $WHT";
771 $new_org_name = <STDIN
>;
772 if ( $new_org_name eq "\n" ) {
773 $new_org_name = $org_name;
775 $new_org_name =~ s/[\r\n]//g;
776 $new_org_name =~ s/\"/"/g;
778 return $new_org_name;
783 print "Your organization's logo is an image that will be displayed at\n";
784 print "different times throughout SquirrelMail. ";
786 print "Please be aware of the following: \n";
787 print " - Relative URLs are relative to the config dir\n";
788 print " to use the default logo, use ../images/sm_logo.png\n";
789 print " - To specify a logo defined outside the SquirrelMail source tree\n";
790 print " use the absolute URL the webserver would use to include the file\n";
791 print " e.g. http://some.host.com/images/mylogo.gif or /images/mylogo.jpg\n";
793 print "[$WHT$org_logo$NRM]: $WHT";
794 $new_org_logo = <STDIN
>;
795 if ( $new_org_logo eq "\n" ) {
796 $new_org_logo = $org_logo;
798 $new_org_logo =~ s/[\r\n]//g;
800 return $new_org_logo;
805 print "Your organization's logo is an image that will be displayed at\n";
806 print "different times throughout SquirrelMail. Width\n";
807 print "and Height of your logo image. Use '0' to disable.\n";
809 print "Width: [$WHT$org_logo_width$NRM]: $WHT";
810 $new_org_logo_width = <STDIN
>;
811 $new_org_logo_width =~ tr/0-9//cd; # only want digits!
812 if ( $new_org_logo_width eq '' ) {
813 $new_org_logo_width = $org_logo_width;
815 if ( $new_org_logo_width > 0 ) {
816 print "Height: [$WHT$org_logo_height$NRM]: $WHT";
817 $new_org_logo_height = <STDIN
>;
818 $new_org_logo_height =~ tr/0-9//cd; # only want digits!
819 if( $new_org_logo_height eq '' ) {
820 $new_org_logo_height = $org_logo_height;
823 $new_org_logo_height = 0;
825 return ($new_org_logo_width, $new_org_logo_height);
830 print "A title is what is displayed at the top of the browser window in\n";
831 print "the titlebar. Usually this will end up looking something like:\n";
832 print "\"Netscape: $org_title\"\n";
834 print "If your Organization Title includes a '\$', please precede it with a \\. \n";
835 print "Other '\$' will be considered the beginning of a variable that\n";
836 print "must be defined before the \$org_title is printed.\n";
837 print "\$version, for example, is included by default, and will print the\n";
838 print "string representing the current SquirrelMail version.\n";
840 print "[$WHT$org_title$NRM]: $WHT";
841 $new_org_title = <STDIN
>;
842 if ( $new_org_title eq "\n" ) {
843 $new_org_title = $org_title;
845 $new_org_title =~ s/[\r\n]//g;
846 $new_org_title =~ s/\"/\'/g;
848 return $new_org_title;
853 print "When users click the Sign Out button they will be logged out and\n";
854 print "then sent to signout_page. If signout_page is left empty,\n";
855 print "(hit space and then return) they will be taken, as normal,\n";
856 print "to the default and rather sparse SquirrelMail signout page.\n";
858 print "[$WHT$signout_page$NRM]: $WHT";
859 $new_signout_page = <STDIN
>;
860 if ( $new_signout_page eq "\n" ) {
861 $new_signout_page = $signout_page;
863 $new_signout_page =~ s/[\r\n]//g;
864 $new_signout_page =~ s/^\s+$//g;
866 return $new_signout_page;
871 print "SquirrelMail defaults to using the whole of the browser window.\n";
872 print "This allows you to keep it within a specified frame. The default\n";
875 print "[$WHT$frame_top$NRM]: $WHT";
876 $new_frame_top = <STDIN
>;
877 if ( $new_frame_top eq "\n" ) {
878 $new_frame_top = '_top';
880 $new_frame_top =~ s/[\r\n]//g;
881 $new_frame_top =~ s/^\s+$//g;
883 return $new_frame_top;
886 # Default link to provider
888 print "Here you can set the link on the right of the page.\n";
889 print "The default is 'http://www.squirrelmail.org/'\n";
891 print "[$WHT$provider_uri$NRM]: $WHT";
892 $new_provider_uri = <STDIN
>;
893 if ( $new_provider_uri eq "\n" ) {
894 $new_provider_uri = 'http://www.squirrelmail.org/';
896 $new_provider_uri =~ s/[\r\n]//g;
897 $new_provider_uri =~ s/^\s+$//g;
899 return $new_provider_uri;
903 print "Here you can set the name of the link on the right of the page.\n";
904 print "The default is 'SquirrelMail/'\n";
906 print "[$WHT$provider_name$NRM]: $WHT";
907 $new_provider_name = <STDIN
>;
908 if ( $new_provider_name eq "\n" ) {
909 $new_provider_name = 'SquirrelMail';
911 $new_provider_name =~ s/[\r\n]//g;
912 $new_provider_name =~ s/^\s+$//g;
914 return $new_provider_name;
917 ####################################################################################
921 print "The domain name is the suffix at the end of all email addresses. If\n";
922 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
923 print "would be myorg.com.\n";
925 print "[$WHT$domain$NRM]: $WHT";
926 $new_domain = <STDIN
>;
927 if ( $new_domain eq "\n" ) {
928 $new_domain = $domain;
930 $new_domain =~ s/[\r\n]//g;
937 print "This is the hostname where your IMAP server can be contacted.\n";
938 print "[$WHT$imapServerAddress$NRM]: $WHT";
939 $new_imapServerAddress = <STDIN
>;
940 if ( $new_imapServerAddress eq "\n" ) {
941 $new_imapServerAddress = $imapServerAddress;
943 $new_imapServerAddress =~ s/[\r\n]//g;
945 return $new_imapServerAddress;
950 print "This is the port that your IMAP server is on. Usually this is 143.\n";
951 print "[$WHT$imapPort$NRM]: $WHT";
952 $new_imapPort = <STDIN
>;
953 if ( $new_imapPort eq "\n" ) {
954 $new_imapPort = $imapPort;
956 $new_imapPort =~ s/[\r\n]//g;
958 return $new_imapPort;
963 print "You now need to choose the method that you will use for sending\n";
964 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
965 print "or use sendmail directly.\n";
966 if ( lc($useSendmail) eq 'true' ) {
967 $default_value = "1";
969 $default_value = "2";
972 print " 1. Sendmail\n";
974 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
975 $use_sendmail = <STDIN
>;
976 if ( ( $use_sendmail =~ /^1\n/i )
977 || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
978 $useSendmail = 'true';
980 $useSendmail = 'false';
987 if ( $sendmail_path[0] !~ /./ ) {
988 $sendmail_path = "/usr/sbin/sendmail";
990 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
991 print "[$WHT$sendmail_path$NRM]: $WHT";
992 $new_sendmail_path = <STDIN
>;
993 if ( $new_sendmail_path eq "\n" ) {
994 $new_sendmail_path = $sendmail_path;
996 $new_sendmail_path =~ s/[\r\n]//g;
998 return $new_sendmail_path;
1003 print "This is the hostname of your SMTP server.\n";
1004 print "[$WHT$smtpServerAddress$NRM]: $WHT";
1005 $new_smtpServerAddress = <STDIN
>;
1006 if ( $new_smtpServerAddress eq "\n" ) {
1007 $new_smtpServerAddress = $smtpServerAddress;
1009 $new_smtpServerAddress =~ s/[\r\n]//g;
1011 return $new_smtpServerAddress;
1016 print "This is the port to connect to for SMTP. Usually 25.\n";
1017 print "[$WHT$smtpPort$NRM]: $WHT";
1018 $new_smtpPort = <STDIN
>;
1019 if ( $new_smtpPort eq "\n" ) {
1020 $new_smtpPort = $smtpPort;
1022 $new_smtpPort =~ s/[\r\n]//g;
1024 return $new_smtpPort;
1027 # authenticated server
1030 # This sub disabled by tassium - it has been replaced with smtp_auth_mech
1031 print "Do you wish to use an authenticated SMTP server? Your server must\n";
1032 print "support this in order for SquirrelMail to work with it. We implemented\n";
1033 print "it according to RFC 2554.\n";
1036 $YesNo = 'y' if ( lc($use_authenticated_smtp) eq 'true' );
1038 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
1040 $new_use_authenticated_smtp = <STDIN
>;
1041 $new_use_authenticated_smtp =~ tr/yn//cd;
1042 return 'true' if ( $new_use_authenticated_smtp eq "y" );
1043 return 'false' if ( $new_use_authenticated_smtp eq "n" );
1044 return $use_authenticated_smtp;
1049 print "Do you wish to use POP3 before SMTP? Your server must\n";
1050 print "support this in order for SquirrelMail to work with it.\n";
1053 $YesNo = 'y' if ( lc($pop_before_smtp) eq 'true' );
1055 print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
1057 $new_pop_before_smtp = <STDIN
>;
1058 $new_pop_before_smtp =~ tr/yn//cd;
1059 return 'true' if ( $new_pop_before_smtp eq "y" );
1060 return 'false' if ( $new_pop_before_smtp eq "n" );
1061 return $pop_before_smtp;
1066 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
1067 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
1068 print "the same principles. We have made some work-arounds for some of\n";
1069 print "these servers. If you would like to use them, please select your\n";
1070 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
1071 print "set this to \"other\", and none will be used.\n";
1072 print " cyrus = Cyrus IMAP server\n";
1073 print " uw = University of Washington's IMAP server\n";
1074 print " exchange = Microsoft Exchange IMAP server\n";
1075 print " courier = Courier IMAP server\n";
1076 print " macosx = Mac OS X Mailserver\n";
1077 print " other = Not one of the above servers\n";
1078 print "[$WHT$imap_server_type$NRM]: $WHT";
1079 $new_imap_server_type = <STDIN
>;
1081 if ( $new_imap_server_type eq "\n" ) {
1082 $new_imap_server_type = $imap_server_type;
1084 $new_imap_server_type =~ s/[\r\n]//g;
1086 return $new_imap_server_type;
1091 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
1092 print "on some machines). Typically this happens if the system doesn't support\n";
1093 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
1094 print "This most often occurs on Solaris 7 machines in the United States.\n";
1095 print "By default, this is off. It should be kept off unless problems surface\n";
1096 print "about the time that messages are sent.\n";
1097 print " no = Do NOT fix time -- almost always correct\n";
1098 print " yes = Fix the time for this system\n";
1101 $YesNo = 'y' if ( lc($invert_time) eq 'true' );
1103 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
1105 $new_invert_time = <STDIN
>;
1106 $new_invert_time =~ tr/yn//cd;
1107 return 'true' if ( $new_invert_time eq "y" );
1108 return 'false' if ( $new_invert_time eq "n" );
1109 return $invert_time;
1113 print "This is the delimiter that your IMAP server uses to distinguish between\n";
1114 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
1115 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
1116 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
1117 print "but if you are sure you know what delimiter your server uses, you can\n";
1118 print "specify it here.\n";
1119 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
1120 print "[$WHT$optional_delimiter$NRM]: $WHT";
1121 $new_optional_delimiter = <STDIN
>;
1123 if ( $new_optional_delimiter eq "\n" ) {
1124 $new_optional_delimiter = $optional_delimiter;
1126 $new_optional_delimiter =~ s/[\r\n]//g;
1128 return $new_optional_delimiter;
1130 # IMAP authentication type
1131 # Possible values: login, plain, cram-md5, digest-md5
1132 # Now offers to detect supported mechs, assuming server & port are set correctly
1135 if ($use_imap_tls =~ /^true\b/i) {
1136 print "Auto-detection of login methods is unavailable when using TLS.\n";
1138 print "If you have already set the hostname and port number, I can try to\n";
1139 print "detect the mechanisms your IMAP server supports.\n";
1140 print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n";
1141 print "for \"login\" or \"plain\" without knowing a username and password.\n";
1142 print "Auto-detecting is optional - you can safely say \"n\" here.\n";
1143 print "\nTry to detect supported mechanisms? [y/N]: ";
1146 if ($inval =~ /^y\b/i) {
1147 # Yes, let's try to detect.
1148 print "Trying to detect IMAP capabilities...\n";
1149 my $host = $imapServerAddress . ':'. $imapPort;
1150 print "CRAM-MD5:\t";
1151 my $tmp = detect_auth_support
('IMAP',$host,'CRAM-MD5');
1152 if (defined($tmp)) {
1153 if ($tmp eq 'YES') {
1154 print "$WHT SUPPORTED$NRM\n";
1156 print "$WHT NOT SUPPORTED$NRM\n";
1159 print $WHT . " ERROR DETECTING$NRM\n";
1162 print "DIGEST-MD5:\t";
1163 $tmp = detect_auth_support
('IMAP',$host,'DIGEST-MD5');
1164 if (defined($tmp)) {
1165 if ($tmp eq 'YES') {
1166 print "$WHT SUPPORTED$NRM\n";
1168 print "$WHT NOT SUPPORTED$NRM\n";
1171 print $WHT . " ERROR DETECTING$NRM\n";
1176 print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
1177 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1178 print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
1179 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
1180 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1181 print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
1182 print "If you don't understand or are unsure, you probably want \"login\"\n\n";
1183 print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
1186 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
1189 # user entered garbage or default value so nothing needs to be set
1190 return $imap_auth_mech;
1195 # SMTP authentication type
1196 # Possible choices: none, plain, cram-md5, digest-md5
1198 if ($use_smtp_tls =~ /^true\b/i) {
1199 print "Auto-detection of login methods is unavailable when using TLS.\n";
1201 print "If you have already set the hostname and port number, I can try to\n";
1202 print "automatically detect some of the mechanisms your SMTP server supports.\n";
1203 print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
1204 print "\nTry to detect auth mechanisms? [y/N]: ";
1207 if ($inval =~ /^y\b/i) {
1208 # Yes, let's try to detect.
1209 print "Trying to detect supported methods (SMTP)...\n";
1212 # Check none by trying to relay to junk@microsoft.com
1213 $host = $smtpServerAddress . ':' . $smtpPort;
1215 my $sock = IO
::Socket
::INET
->new($host);
1216 print "Testing none:\t\t$WHT";
1217 if (!defined($sock)) {
1218 print " ERROR TESTING\n";
1221 print $sock "mail from: tester\@squirrelmail.org\n";
1222 $got = <$sock>; # Discard
1223 print $sock "rcpt to: junk\@microsoft.com\n";
1224 $got = <$sock>; # This is the important line
1225 if ($got =~ /^250\b/) { # SMTP will relay without auth
1226 print "SUPPORTED$NRM\n";
1228 print "NOT SUPPORTED$NRM\n";
1230 print $sock "rset\n";
1231 print $sock "quit\n";
1234 # Try login (SquirrelMail default)
1235 print "Testing login:\t\t";
1236 $tmp=detect_auth_support
('SMTP',$host,'LOGIN');
1237 if (defined($tmp)) {
1238 if ($tmp eq 'YES') {
1239 print $WHT . "SUPPORTED$NRM\n";
1241 print $WHT . "NOT SUPPORTED$NRM\n";
1244 print $WHT . "ERROR DETECTING$NRM\n";
1248 print "Testing CRAM-MD5:\t";
1249 $tmp=detect_auth_support
('SMTP',$host,'CRAM-MD5');
1250 if (defined($tmp)) {
1251 if ($tmp eq 'YES') {
1252 print $WHT . "SUPPORTED$NRM\n";
1254 print $WHT . "NOT SUPPORTED$NRM\n";
1257 print $WHT . "ERROR DETECTING$NRM\n";
1261 print "Testing DIGEST-MD5:\t";
1262 $tmp=detect_auth_support
('SMTP',$host,'DIGEST-MD5');
1263 if (defined($tmp)) {
1264 if ($tmp eq 'YES') {
1265 print $WHT . "SUPPORTED$NRM\n";
1267 print $WHT . "NOT SUPPORTED$NRM\n";
1270 print $WHT . "ERROR DETECTING$NRM\n";
1274 print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
1275 print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
1276 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1277 print $WHT . "plain" . $NRM . " - SASL PLAIN. You already know it if you need this.\n";
1278 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1279 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1280 print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
1281 print "If you don't understand or are unsure, you probably want \"none\"\n\n";
1282 print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
1285 if ($inval =~ /^none\b/i) {
1286 # SMTP doesn't necessarily require logins
1289 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
1290 ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
1293 # user entered garbage, or default value so nothing needs to be set
1294 return $smtp_auth_mech;
1299 # This sub is reused for IMAP and SMTP
1300 # Args: service name, default value
1302 my($default_val,$service,$inval);
1305 print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
1306 print "If you're familiar with SSL, you get the idea.\n";
1307 print "To use this feature, your " . $service . " server must offer TLS\n";
1308 print "capability, plus PHP 4.3.x with OpenSSL support.\n";
1309 print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
1310 print "If it is remote, you may wish to seriously consider enabling this.\n";
1311 print "Enable TLS (y/n) [$WHT";
1312 if ($default_val eq 'true') {
1317 print "$NRM]: $WHT";
1319 $inval =~ tr/yn//cd;
1320 return 'true' if ( $inval eq "y" );
1321 return 'false' if ( $inval eq "n" );
1322 return $default_val;
1326 print "\nUse this to suppress insertion of SquirrelMail Received: headers\n";
1327 print "in outbound messages.\n\n";
1330 $YesNo = 'y' if ( lc($skip_SM_header) eq 'true' );
1332 print "Suppress SM header (y/n) [$WHT$YesNo$NRM]: $WHT";
1333 $new_skip_SM_header = <STDIN
>;
1334 chomp($new_skip_SM_header);
1336 return 'true' if ( lc($new_skip_SM_header) eq 'y' );
1337 return 'false' if ( lc($new_skip_SM_header) eq 'n' );
1338 return $skip_SM_header;
1343 print "\nYou can now create the welcome message that is displayed\n";
1344 print "every time a user logs on. You can use HTML or just plain\n";
1346 "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1352 $line =~ s/[\r\n]//g;
1353 if ( $line ne "@" ) {
1354 $line =~ s/ /\ \ /g;
1355 $line =~ s/\t/\ \ \ \ /g;
1357 $line =~ s/\"/"/g;
1359 $new_motd = $new_motd . $line;
1361 } while ( $line ne "@" );
1365 ################# PLUGINS ###################
1368 $command =~ s/[\s\n\r]*//g;
1369 if ( $command > 0 ) {
1370 $command = $command - 1;
1371 if ( $command <= $#plugins ) {
1374 while ( $ct <= $#plugins ) {
1375 if ( $ct != $command ) {
1376 @newplugins = ( @newplugins, $plugins[$ct] );
1380 @plugins = @newplugins;
1381 } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
1382 $num = $command - $#plugins - 1;
1383 @newplugins = @plugins;
1385 while ( $ct <= $#unused_plugins ) {
1386 if ( $ct == $num ) {
1387 @newplugins = ( @newplugins, $unused_plugins[$ct] );
1391 @plugins = @newplugins;
1397 ################# FOLDERS ###################
1399 # default_folder_prefix
1401 print "Some IMAP servers (UW, for example) store mail and folders in\n";
1402 print "your user space in a separate subdirectory. This is where you\n";
1403 print "specify what that directory is.\n";
1405 print "EXAMPLE: mail/";
1407 print "NOTE: If you use Cyrus, or some server that would not use this\n";
1408 print " option, you must set this to 'none'.\n";
1410 print "[$WHT$default_folder_prefix$NRM]: $WHT";
1411 $new_default_folder_prefix = <STDIN
>;
1413 if ( $new_default_folder_prefix eq "\n" ) {
1414 $new_default_folder_prefix = $default_folder_prefix;
1416 $new_default_folder_prefix =~ s/[\r\n]//g;
1418 if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
1419 $new_default_folder_prefix = "";
1421 # add the trailing delimiter only if we know what the server is.
1422 if (($imap_server_type eq 'cyrus' and
1423 $optional_delimiter eq 'detect') or
1424 ($imap_server_type eq 'courier' and
1425 $optional_delimiter eq 'detect')) {
1426 $new_default_folder_prefix =~ s/\.*$/\./;
1427 } elsif ($imap_server_type eq 'uw' and
1428 $optional_delimiter eq 'detect') {
1429 $new_default_folder_prefix =~ s/\/*$/\
//;
1432 return $new_default_folder_prefix;
1435 # Show Folder Prefix
1437 print "It is possible to set up the default folder prefix as a user\n";
1438 print "specific option, where each user can specify what their mail\n";
1439 print "folder is. If you set this to false, they will never see the\n";
1440 print "option, but if it is true, this option will appear in the\n";
1441 print "'options' section.\n";
1443 print "NOTE: You set the default folder prefix in option '1' of this\n";
1444 print " section. That will be the default if the user doesn't\n";
1445 print " specify anything different.\n";
1448 if ( lc($show_prefix_option) eq 'true' ) {
1449 $default_value = "y";
1451 $default_value = "n";
1454 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1455 $new_show = <STDIN
>;
1456 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1457 $show_prefix_option = 'true';
1459 $show_prefix_option = 'false';
1461 return $show_prefix_option;
1466 print "You can now specify where the default trash folder is located.\n";
1467 print "On servers where you do not want this, you can set it to anything\n";
1468 print "and set option 6 to false.\n";
1470 print "This is relative to where the rest of your email is kept. You do\n";
1471 print "not need to worry about their mail directory. If this folder\n";
1472 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1473 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1476 print "[$WHT$trash_folder$NRM]: $WHT";
1477 $new_trash_folder = <STDIN
>;
1478 if ( $new_trash_folder eq "\n" ) {
1479 $new_trash_folder = $trash_folder;
1481 $new_trash_folder =~ s/[\r\n]//g;
1483 return $new_trash_folder;
1488 print "This is where messages that are sent will be stored. SquirrelMail\n";
1489 print "by default puts a copy of all outgoing messages in this folder.\n";
1491 print "This is relative to where the rest of your email is kept. You do\n";
1492 print "not need to worry about their mail directory. If this folder\n";
1493 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1494 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1497 print "[$WHT$sent_folder$NRM]: $WHT";
1498 $new_sent_folder = <STDIN
>;
1499 if ( $new_sent_folder eq "\n" ) {
1500 $new_sent_folder = $sent_folder;
1502 $new_sent_folder =~ s/[\r\n]//g;
1504 return $new_sent_folder;
1509 print "You can now specify where the default draft folder is located.\n";
1510 print "On servers where you do not want this, you can set it to anything\n";
1511 print "and set option 9 to false.\n";
1513 print "This is relative to where the rest of your email is kept. You do\n";
1514 print "not need to worry about their mail directory. If this folder\n";
1515 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1516 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1519 print "[$WHT$draft_folder$NRM]: $WHT";
1520 $new_draft_folder = <STDIN
>;
1521 if ( $new_draft_folder eq "\n" ) {
1522 $new_draft_folder = $draft_folder;
1524 $new_draft_folder =~ s/[\r\n]//g;
1526 return $new_draft_folder;
1529 # default move to trash
1531 print "By default, should messages get moved to the trash folder? You\n";
1532 print "can specify the default trash folder in option 3. If this is set\n";
1533 print "to false, messages will get deleted immediately without moving\n";
1534 print "to the trash folder.\n";
1536 print "Trash folder is currently: $trash_folder\n";
1539 if ( lc($default_move_to_trash) eq 'true' ) {
1540 $default_value = "y";
1542 $default_value = "n";
1544 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1545 $new_show = <STDIN
>;
1546 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1547 $default_move_to_trash = 'true';
1549 $default_move_to_trash = 'false';
1551 return $default_move_to_trash;
1554 # default move to sent
1556 print "By default, should messages get moved to the sent folder? You\n";
1557 print "can specify the default sent folder in option 4. If this is set\n";
1558 print "to false, messages will get sent and no copy will be made.\n";
1560 print "Sent folder is currently: $sent_folder\n";
1563 if ( lc($default_move_to_sent) eq 'true' ) {
1564 $default_value = "y";
1566 $default_value = "n";
1568 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1569 $new_show = <STDIN
>;
1570 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1571 $default_move_to_sent = 'true';
1573 $default_move_to_sent = 'false';
1575 return $default_move_to_sent;
1578 # default save as draft
1580 print "By default, should the save to draft option be shown? You can\n";
1581 print "specify the default drafts folder in option 5. If this is set\n";
1582 print "to false, users will not be shown the save to draft option.\n";
1584 print "Drafts folder is currently: $draft_folder\n";
1587 if ( lc($default_move_to_draft) eq 'true' ) {
1588 $default_value = "y";
1590 $default_value = "n";
1592 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1593 $new_show = <STDIN
>;
1594 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1595 $default_save_as_draft = 'true';
1597 $default_save_as_draft = 'false';
1599 return $default_save_as_draft;
1602 # List special folders first
1604 print "SquirrelMail has what we call 'special folders' that are not\n";
1605 print "manipulated and viewed like normal folders. Some examples of\n";
1606 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1607 print "Simply asks if you want these folders listed first in the folder\n";
1611 if ( lc($list_special_folders_first) eq 'true' ) {
1612 $default_value = "y";
1614 $default_value = "n";
1617 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1618 $new_show = <STDIN
>;
1619 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1620 $list_special_folders_first = 'true';
1622 $list_special_folders_first = 'false';
1624 return $list_special_folders_first;
1627 # Show special folders color
1629 print "SquirrelMail has what we call 'special folders' that are not\n";
1630 print "manipulated and viewed like normal folders. Some examples of\n";
1631 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1632 print "wants to know if we should display special folders in a\n";
1633 print "color than the other folders.\n";
1636 if ( lc($use_special_folder_color) eq 'true' ) {
1637 $default_value = "y";
1639 $default_value = "n";
1642 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1643 $new_show = <STDIN
>;
1644 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1645 $use_special_folder_color = 'true';
1647 $use_special_folder_color = 'false';
1649 return $use_special_folder_color;
1654 print "The way that IMAP handles deleting messages is as follows. You\n";
1655 print "mark the message as deleted, and then to 'really' delete it, you\n";
1656 print "expunge it. This option asks if you want to just have messages\n";
1657 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1658 print "messages too.\n";
1661 if ( lc($auto_expunge) eq 'true' ) {
1662 $default_value = "y";
1664 $default_value = "n";
1666 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1667 $new_show = <STDIN
>;
1668 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1669 $auto_expunge = 'true';
1671 $auto_expunge = 'false';
1673 return $auto_expunge;
1676 # Default sub of inbox
1678 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1679 print "This can cause some confusion in folder creation for users when\n";
1680 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1681 print "and get permission errors. This option asks if you want folders\n";
1682 print "to be subfolders of INBOX by default.\n";
1685 if ( lc($default_sub_of_inbox) eq 'true' ) {
1686 $default_value = "y";
1688 $default_value = "n";
1690 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1691 $new_show = <STDIN
>;
1692 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1693 $default_sub_of_inbox = 'true';
1695 $default_sub_of_inbox = 'false';
1697 return $default_sub_of_inbox;
1700 # Show contain subfolder option
1702 print "Some IMAP servers (UW) make it so that there are two types of\n";
1703 print "folders. Those that contain messages, and those that contain\n";
1704 print "subfolders. If this is the case for your server, set this to\n";
1705 print "true, and it will ask the user whether the folder they are\n";
1706 print "creating contains subfolders or messages.\n";
1709 if ( lc($show_contain_subfolders_option) eq 'true' ) {
1710 $default_value = "y";
1712 $default_value = "n";
1714 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1715 $new_show = <STDIN
>;
1716 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1717 $show_contain_subfolders_option = 'true';
1719 $show_contain_subfolders_option = 'false';
1721 return $show_contain_subfolders_option;
1724 # Default Unseen Notify
1726 print "This option specifies where the users will receive notification\n";
1727 print "about unseen messages by default. This is of course an option that\n";
1728 print "can be changed on a user level.\n";
1729 print " 1 = No notification\n";
1730 print " 2 = Only on the INBOX\n";
1731 print " 3 = On all folders\n";
1734 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1735 $new_show = <STDIN
>;
1736 if ( $new_show =~ /^[123]\n/i ) {
1737 $default_unseen_notify = $new_show;
1739 $default_unseen_notify =~ s/[\r\n]//g;
1740 return $default_unseen_notify;
1743 # Default Unseen Type
1745 print "Here you can define the default way that unseen messages will be displayed\n";
1746 print "to the user in the folder listing on the left side.\n";
1747 print " 1 = Only unseen messages (4)\n";
1748 print " 2 = Unseen and Total messages (4/27)\n";
1751 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1752 $new_show = <STDIN
>;
1753 if ( $new_show =~ /^[12]\n/i ) {
1754 $default_unseen_type = $new_show;
1756 $default_unseen_type =~ s/[\r\n]//g;
1757 return $default_unseen_type;
1760 # Auto create special folders
1762 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1763 print "automatically print for you when a user logs in? If the user\n";
1764 print "accidentally deletes their special folders, this option will\n";
1765 print "automatically create it again for them.\n";
1768 if ( lc($auto_create_special) eq 'true' ) {
1769 $default_value = "y";
1771 $default_value = "n";
1773 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1774 $new_show = <STDIN
>;
1775 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1776 $auto_create_special = 'true';
1778 $auto_create_special = 'false';
1780 return $auto_create_special;
1783 # Automatically delete folders
1785 if ( $imap_server_type eq "uw" ) {
1786 print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
1787 print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
1788 print "If this is not the correct value for your server,\n";
1789 print "please use option D on the Main Menu to configure your server correctly.\n\n";
1790 print "Press any key to continue...\n";
1791 $new_delete = <STDIN
>;
1792 $delete_folder = 'true';
1794 if ( $imap_server_type eq "courier" ) {
1795 print "Courier (or Courier-IMAP) IMAP servers may not support ";
1796 print "subfolders of Trash. \n";
1797 print "Specifically, if Courier is set to always move messages to Trash, \n";
1798 print "Trash will be treated by Courier as a special folder that does not \n";
1799 print "allow subfolders. \n\n";
1800 print "Please verify your Courier configuration, and test folder deletion \n";
1801 print "when changing this setting.\n\n";
1804 print "Are subfolders of the Trash supported by your IMAP server?\n";
1805 print "If so, should deleted folders be sent to Trash?\n";
1806 print "If not, say no (deleted folders should not be sent to Trash)\n\n";
1807 # reversal of logic.
1808 # question was: Should folders be automatically deleted instead of sent to trash..
1809 # we've changed the question to make it more clear,
1810 # and are here handling that to avoid changing the answers..
1811 if ( lc($delete_folder) eq 'true' ) {
1812 $default_value = "n";
1814 $default_value = "y";
1816 print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
1817 $new_delete = <STDIN
>;
1818 if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1819 $delete_folder = 'false';
1821 $delete_folder = 'true';
1824 return $delete_folder;
1829 print "Some IMAP server allow subfolders to exist even if the parent\n";
1830 print "folders do not. This fixes some problems with the folder list\n";
1831 print "when this is the case, causing the /NoSelect folders to be displayed\n";
1834 if ( lc($noselect_fix_enable) eq 'true' ) {
1835 $default_value = "y";
1837 $default_value = "n";
1839 print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
1840 $noselect_fix_enable = <STDIN
>;
1841 if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1842 $noselect_fix_enable = 'true';
1844 $noselect_fix_enable = 'false';
1846 return $noselect_fix_enable;
1848 ############# GENERAL OPTIONS #####################
1852 print "Specify the location for your data directory.\n";
1853 print "The path name can be absolute or relative (to the config directory).\n";
1854 print "It doesn't matter. Here are two examples:\n";
1855 print " Absolute: /var/spool/data/\n";
1856 print " Relative: ../data/\n";
1857 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1858 print "will be converted to their absolute path equivalents in config.php.\n\n";
1859 print "Note: There are potential security risks with having a writeable directory\n";
1860 print "under the web server's root directory (ex: /home/httpd/html).\n";
1861 print "For this reason, it is recommended to put the data directory\n";
1862 print "in an alternate location of your choice. \n";
1865 print "[$WHT$data_dir$NRM]: $WHT";
1866 $new_data_dir = <STDIN
>;
1867 if ( $new_data_dir eq "\n" ) {
1868 $new_data_dir = $data_dir;
1870 $new_data_dir =~ s/[\r\n]//g;
1872 if ( $new_data_dir =~ /^\s*$/ ) {
1875 $new_data_dir =~ s/\/*$//g
;
1876 $new_data_dir =~ s/$/\//g
;
1878 return $new_data_dir;
1881 # Attachment directory
1883 print "Path to directory used for storing attachments while a mail is\n";
1884 print "being sent. The path name can be absolute or relative (to the config directory).\n";
1885 print "It doesn't matter. Here are two examples:\n";
1886 print " Absolute: /var/spool/attach/\n";
1887 print " Relative: ../attach/\n";
1888 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1889 print "will be converted to their absolute path equivalents in config.php.\n\n";
1890 print "Note: There are a few security considerations regarding this\n";
1891 print "directory:\n";
1892 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1893 print " impossible for a random person with access to the webserver\n";
1894 print " to list files in this directory. Confidential data might\n";
1895 print " be laying around in there.\n";
1896 print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
1897 print " may be possible, and more secure (e.g. root:apache)\n";
1898 print " 2. Since the webserver is not able to list the files in the\n";
1899 print " content is also impossible for the webserver to delete files\n";
1900 print " lying around there for too long.\n";
1901 print " 3. It should probably be another directory than the data\n";
1902 print " directory specified in option 3.\n";
1905 print "[$WHT$attachment_dir$NRM]: $WHT";
1906 $new_attachment_dir = <STDIN
>;
1907 if ( $new_attachment_dir eq "\n" ) {
1908 $new_attachment_dir = $attachment_dir;
1910 $new_attachment_dir =~ s/[\r\n]//g;
1912 if ( $new_attachment_dir =~ /^\s*$/ ) {
1913 $new_attachment_dir = "";
1915 $new_attachment_dir =~ s/\/*$//g
;
1916 $new_attachment_dir =~ s/$/\//g
;
1918 return $new_attachment_dir;
1922 print "The directory hash level setting allows you to configure the level\n";
1923 print "of hashing that Squirremail employs in your data and attachment\n";
1924 print "directories. This value must be an integer ranging from 0 to 4.\n";
1925 print "When this value is set to 0, Squirrelmail will simply store all\n";
1926 print "files as normal in the data and attachment directories. However,\n";
1927 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1928 print "used to organize the files in this directory. In short, the crc32\n";
1929 print "value for a username will be computed. Then, up to the first 4\n";
1930 print "digits of the hash, as set by this configuration value, will be\n";
1931 print "used to directory hash the files for that user in the data and\n";
1932 print "attachment directory. This allows for better performance on\n";
1933 print "servers with larger numbers of users.\n";
1936 print "[$WHT$dir_hash_level$NRM]: $WHT";
1937 $new_dir_hash_level = <STDIN
>;
1938 if ( $new_dir_hash_level eq "\n" ) {
1939 $new_dir_hash_level = $dir_hash_level;
1941 $new_dir_hash_level =~ s/[\r\n]//g;
1943 if ( ( int($new_dir_hash_level) < 0 )
1944 || ( int($new_dir_hash_level) > 4 )
1945 || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
1946 print "Invalid Directory Hash Level.\n";
1947 print "Value must be an integer ranging from 0 to 4\n";
1948 print "Hit enter to continue.\n";
1949 $enter_key = <STDIN
>;
1951 $new_dir_hash_level = $dir_hash_level;
1954 return $new_dir_hash_level;
1958 print "This is the default size (in pixels) of the left folder list.\n";
1959 print "Default is 200, but you can set it to whatever you wish. This\n";
1960 print "is a user preference, so this will only show up as their default.\n";
1962 print "[$WHT$default_left_size$NRM]: $WHT";
1963 $new_default_left_size = <STDIN
>;
1964 if ( $new_default_left_size eq "\n" ) {
1965 $new_default_left_size = $default_left_size;
1967 $new_default_left_size =~ s/[\r\n]//g;
1969 return $new_default_left_size;
1973 print "Some IMAP servers only have lowercase letters in the usernames\n";
1974 print "but they still allow people with uppercase to log in. This\n";
1975 print "causes a problem with the user's preference files. This option\n";
1976 print "transparently changes all usernames to lowercase.";
1979 if ( lc($force_username_lowercase) eq 'true' ) {
1980 $default_value = "y";
1982 $default_value = "n";
1984 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1985 $new_show = <STDIN
>;
1986 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1996 if ( lc($default_use_priority) eq 'true' ) {
1997 $default_value = "y";
1999 $default_value = "n";
2002 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
2003 $new_show = <STDIN
>;
2004 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2014 if ( lc($default_hide_attribution) eq 'true' ) {
2015 $default_value = "y";
2017 $default_value = "n";
2020 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
2021 $new_show = <STDIN
>;
2022 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2032 if ( lc($default_use_mdn) eq 'true' ) {
2033 $default_value = "y";
2035 $default_value = "n";
2038 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
2039 $new_show = <STDIN
>;
2040 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2047 print "This allows you to prevent the editing of the user's name and ";
2048 print "email address. This is mainly useful when used with the ";
2049 print "retrieveuserdata plugin\n";
2052 if ( lc($edit_identity) eq 'true' ) {
2053 $default_value = "y";
2055 $default_value = "n";
2057 print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
2058 $new_edit = <STDIN
>;
2059 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2060 $edit_identity = 'true';
2061 $edit_name = 'true';
2063 $edit_identity = 'false';
2064 $edit_name = command311
();
2066 return $edit_identity;
2070 print "As a follow-up, this option allows you to choose if the user ";
2071 print "can edit their full name even when you don't want them to ";
2072 print "change their username\n";
2075 if ( lc($edit_name) eq 'true' ) {
2076 $default_value = "y";
2078 $default_value = "n";
2080 print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
2081 $new_edit = <STDIN
>;
2082 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2083 $edit_name = 'true';
2085 $edit_name = 'false';
2091 print "This option allows you to choose if users can use thread sorting\n";
2092 print "Your IMAP server must support the THREAD command for this to work\n";
2093 print "PHP versions later than 4.0.3 recommended\n";
2096 if ( lc($allow_thread_sort) eq 'true' ) {
2097 $default_value = "y";
2099 $default_value = "n";
2101 print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2102 $allow_thread_sort = <STDIN
>;
2103 if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2104 $allow_thread_sort = 'true';
2106 $allow_thread_sort = 'false';
2108 return $allow_thread_sort;
2112 print "This option allows you to choose if SM uses server-side sorting\n";
2113 print "Your IMAP server must support the SORT command for this to work\n";
2116 if ( lc($allow_server_sort) eq 'true' ) {
2117 $default_value = "y";
2119 $default_value = "n";
2121 print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2122 $allow_server_sort = <STDIN
>;
2123 if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2124 $allow_server_sort = 'true';
2126 $allow_server_sort = 'false';
2128 return $allow_server_sort;
2132 print "This option allows you to choose if SM uses charset search\n";
2133 print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2136 if ( lc($allow_charset_search) eq 'true' ) {
2137 $default_value = "y";
2139 $default_value = "n";
2141 print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
2142 $allow_charset_search = <STDIN
>;
2143 if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2144 $allow_charset_search = 'true';
2146 $allow_charset_search = 'false';
2148 return $allow_charset_search;
2151 # command315 (UID support) obsoleted.
2153 # advanced search option
2155 print "This option allows you to control the use of advanced search form.\n";
2156 print " 0 = enable basic search only\n";
2157 print " 1 = enable advanced search only\n";
2158 print " 2 = enable both\n";
2161 print "Allowed search (0,1,2)? [$WHT$allow_advanced_search$NRM]: $WHT";
2162 $new_allow_advanced_search = <STDIN
>;
2163 if ( $new_allow_advanced_search =~ /^[012]\n/i ) {
2164 $allow_advanced_search = $new_allow_advanced_search;
2166 $allow_advanced_search =~ s/[\r\n]//g;
2167 return $allow_advanced_search;
2172 print "This option allows you to change the name of the PHP session used\n";
2173 print "by SquirrelMail. Unless you know what you are doing, you probably\n";
2174 print "don't need or want to change this from the default of SQMSESSID.\n";
2175 print "[$WHT$session_name$NRM]: $WHT";
2176 $new_session_name = <STDIN
>;
2177 chomp($new_session_name);
2178 if ( $new_session_name eq "" ) {
2179 $new_session_name = $session_name;
2181 return $new_session_name;
2187 print "\nDefine the themes that you wish to use. If you have added ";
2188 print "a theme of your own, just follow the instructions (?) about how to add ";
2189 print "them. You can also change the default theme.\n";
2190 print "[theme] command (?=help) > ";
2192 $input =~ s/[\r\n]//g;
2193 while ( $input ne "d" ) {
2194 if ( $input =~ /^\s*l\s*/i ) {
2196 while ( $count <= $#theme_name ) {
2197 if ( $count == $theme_default ) {
2202 if ( $count < 10 ) {
2205 $name = $theme_name[$count];
2206 $num_spaces = 35 - length($name);
2207 for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
2208 $name = $name . " ";
2211 print " $count. $name";
2212 print "($theme_path[$count])\n";
2216 } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
2217 $old_def = $theme_default;
2218 $theme_default = $input;
2219 $theme_default =~ s/^\s*m\s*//;
2220 if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
2221 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
2222 $theme_default = $old_def;
2224 } elsif ( $input =~ /^\s*\+/ ) {
2225 print "What is the name of this theme: ";
2227 $name =~ s/[\r\n]//g;
2228 $theme_name[ $#theme_name + 1 ] = $name;
2229 print "Be sure to put ../themes/ before the filename.\n";
2230 print "What file is this stored in (ex: ../themes/default_theme.php): ";
2232 $name =~ s/[\r\n]//g;
2233 $theme_path[ $#theme_path + 1 ] = $name;
2234 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2235 if ( $input =~ /[0-9]+\s*$/ ) {
2237 $rem_num =~ s/^\s*-\s*//g;
2238 $rem_num =~ s/\s*$//;
2240 $rem_num = $#theme_name;
2242 if ( $rem_num == $theme_default ) {
2243 print "You cannot remove the default theme!\n";
2246 @new_theme_name = ();
2247 @new_theme_path = ();
2248 while ( $count <= $#theme_name ) {
2249 if ( $count != $rem_num ) {
2250 @new_theme_name = ( @new_theme_name, $theme_name[$count] );
2251 @new_theme_path = ( @new_theme_path, $theme_path[$count] );
2255 @theme_name = @new_theme_name;
2256 @theme_path = @new_theme_path;
2257 if ( $theme_default > $rem_num ) {
2261 } elsif ( $input =~ /^\s*t\s*/i ) {
2262 print "\nStarting detection...\n\n";
2264 opendir( DIR
, "../themes" );
2265 @files = grep { /\.php$/i } readdir(DIR
);
2267 while ( $cnt <= $#files ) {
2268 $filename = "../themes/" . $files[$cnt];
2269 if ( $filename ne "../themes/index.php" ) {
2271 for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
2272 if ( $theme_path[$x] eq $filename ) {
2276 if ( $found != 1 ) {
2277 print "** Found theme: $filename\n";
2278 print " What is its name? ";
2281 $theme_name[ $#theme_name + 1 ] = $nm;
2282 $theme_path[ $#theme_path + 1 ] = $filename;
2288 for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
2289 $filename = $theme_path[$cnt];
2290 if ( !( -e
$filename ) ) {
2291 print " Removing $filename (file not found)\n";
2293 @new_theme_name = ();
2294 @new_theme_path = ();
2295 for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
2296 if ( $theme_path[$x] eq $filename ) {
2299 if ( $offset == 1 ) {
2300 $new_theme_name[$x] = $theme_name[ $x + 1 ];
2301 $new_theme_path[$x] = $theme_path[ $x + 1 ];
2303 $new_theme_name[$x] = $theme_name[$x];
2304 $new_theme_path[$x] = $theme_path[$x];
2307 @theme_name = @new_theme_name;
2308 @theme_path = @new_theme_path;
2311 print "\nDetection complete!\n\n";
2314 } elsif ( $input =~ /^\s*\?\s*/ ) {
2315 print ".-------------------------.\n";
2316 print "| t (detect themes) |\n";
2317 print "| + (add theme) |\n";
2318 print "| - N (remove theme) |\n";
2319 print "| m N (mark default) |\n";
2320 print "| l (list themes) |\n";
2321 print "| d (done) |\n";
2322 print "`-------------------------'\n";
2324 print "[theme] command (?=help) > ";
2326 $input =~ s/[\r\n]//g;
2332 print "You may specify a cascading style-sheet (CSS) file to be included\n";
2333 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
2334 print "for specifying a site-wide font. If you're not familiar with CSS\n";
2335 print "files, leave this blank.\n";
2337 print "To clear out an existing value, just type a space for the input.\n";
2339 print "Please be aware of the following: \n";
2340 print " - Relative URLs are relative to the config dir\n";
2341 print " to use the themes directory, use ../themes/css/newdefault.css\n";
2342 print " - To specify a css file defined outside the SquirrelMail source tree\n";
2343 print " use the absolute URL the webserver would use to include the file\n";
2344 print " e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
2346 print "[$WHT$theme_css$NRM]: $WHT";
2347 $new_theme_css = <STDIN
>;
2349 if ( $new_theme_css eq "\n" ) {
2350 $new_theme_css = $theme_css;
2352 $new_theme_css =~ s/[\r\n]//g;
2354 $new_theme_css =~ s/^\s*//;
2355 return $new_theme_css;
2359 print "You can now define different LDAP servers.\n";
2360 print "[ldap] command (?=help) > ";
2362 $input =~ s/[\r\n]//g;
2363 while ( $input ne "d" ) {
2364 if ( $input =~ /^\s*l\s*/i ) {
2366 while ( $count <= $#ldap_host ) {
2367 print "$count. $ldap_host[$count]\n";
2368 print " base: $ldap_base[$count]\n";
2369 if ( $ldap_charset[$count] ) {
2370 print " charset: $ldap_charset[$count]\n";
2372 if ( $ldap_port[$count] ) {
2373 print " port: $ldap_port[$count]\n";
2375 if ( $ldap_name[$count] ) {
2376 print " name: $ldap_name[$count]\n";
2378 if ( $ldap_maxrows[$count] ) {
2379 print " maxrows: $ldap_maxrows[$count]\n";
2381 if ( $ldap_binddn[$count] ) {
2382 print " binddn: $ldap_binddn[$count]\n";
2383 if ( $ldap_bindpw[$count] ) {
2384 print " bindpw: $ldap_bindpw[$count]\n";
2387 if ( $ldap_protocol[$count] ) {
2388 print " protocol: $ldap_protocol[$count]\n";
2394 } elsif ( $input =~ /^\s*\+/ ) {
2395 $sub = $#ldap_host + 1;
2397 print "First, we need to have the hostname or the IP address where\n";
2398 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
2401 $name =~ s/[\r\n]//g;
2402 $ldap_host[$sub] = $name;
2406 print "Next, we need the server root (base dn). For this, an empty\n";
2407 print "string is allowed.\n";
2408 print "Example: ou=member_directory,o=netcenter.com\n";
2411 $name =~ s/[\r\n]//g;
2412 $ldap_base[$sub] = $name;
2416 print "This is the TCP/IP port number for the LDAP server. Default\n";
2417 print "port is 389. This is optional. Press ENTER for default.\n";
2420 $name =~ s/[\r\n]//g;
2421 $ldap_port[$sub] = $name;
2425 print "This is the charset for the server. Default is utf-8. This\n";
2426 print "is also optional. Press ENTER for default.\n";
2429 $name =~ s/[\r\n]//g;
2430 $ldap_charset[$sub] = $name;
2434 print "This is the name for the server, used to tag the results of\n";
2435 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
2438 $name =~ s/[\r\n]//g;
2439 $ldap_name[$sub] = $name;
2443 print "You can specify the maximum number of rows in the search result.\n";
2444 print "Default is unlimited. Press ENTER for default.\n";
2447 $name =~ s/[\r\n]//g;
2448 $ldap_maxrows[$sub] = $name;
2452 print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
2453 print "Default is none, anonymous bind. Press ENTER for default.\n";
2456 $name =~ s/[\r\n]//g;
2457 $ldap_binddn[$sub] = $name;
2461 if ( $ldap_binddn[$sub] ne '' ) {
2463 print "Now, please specify password for that DN.\n";
2466 $name =~ s/[\r\n]//g;
2467 $ldap_bindpw[$sub] = $name;
2472 print "You can specify bind protocol version here.\n";
2473 print "Default protocol version depends on your php ldap settings.\n";
2474 print "Press ENTER for default.\n";
2477 $name =~ s/[\r\n]//g;
2478 $ldap_protocol[$sub] = $name;
2482 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2483 if ( $input =~ /[0-9]+\s*$/ ) {
2485 $rem_num =~ s/^\s*-\s*//g;
2486 $rem_num =~ s/\s*$//;
2488 $rem_num = $#ldap_host;
2491 @new_ldap_host = ();
2492 @new_ldap_base = ();
2493 @new_ldap_port = ();
2494 @new_ldap_name = ();
2495 @new_ldap_charset = ();
2496 @new_ldap_maxrows = ();
2497 @new_ldap_bindpw = ();
2498 @new_ldap_binddn = ();
2499 @new_ldap_protocol = ();
2501 while ( $count <= $#ldap_host ) {
2502 if ( $count != $rem_num ) {
2503 @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
2504 @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
2505 @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
2506 @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
2507 @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
2508 @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
2509 @new_ldap_binddn = ( @new_ldap_binddn, $ldap_binddn[$count] );
2510 @new_ldap_bindpw = ( @new_ldap_bindpw, $ldap_bindpw[$count] );
2511 @new_ldap_protocol = ( @new_ldap_protocol, $ldap_protocol[$count] );
2515 @ldap_host = @new_ldap_host;
2516 @ldap_base = @new_ldap_base;
2517 @ldap_port = @new_ldap_port;
2518 @ldap_name = @new_ldap_name;
2519 @ldap_charset = @new_ldap_charset;
2520 @ldap_maxrows = @new_ldap_maxrows;
2521 @ldap_binddn = @new_ldap_binddn;
2522 @ldap_bindpw = @new_ldap_bindpw;
2523 @ldap_protocol = @new_ldap_protocol;
2525 } elsif ( $input =~ /^\s*\?\s*/ ) {
2526 print ".-------------------------.\n";
2527 print "| + (add host) |\n";
2528 print "| - N (remove host) |\n";
2529 print "| l (list hosts) |\n";
2530 print "| d (done) |\n";
2531 print "`-------------------------'\n";
2533 print "[ldap] command (?=help) > ";
2535 $input =~ s/[\r\n]//g;
2540 print "Some of our developers have come up with very good javascript interface\n";
2541 print "for searching through address books, however, our original goals said\n";
2542 print "that we would be 100% HTML. In order to make it possible to use their\n";
2543 print "interface, and yet stick with our goals, we have also written a plain\n";
2544 print "HTML version of the search. Here, you can choose which version to use.\n";
2546 print "This is just the default value. It is also a user option that each\n";
2547 print "user can configure individually\n";
2550 if ( lc($default_use_javascript_addr_book) eq 'true' ) {
2551 $default_value = "y";
2553 $default_use_javascript_addr_book = 'false';
2554 $default_value = "n";
2556 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
2557 $new_show = <STDIN
>;
2558 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2559 $default_use_javascript_addr_book = 'true';
2561 $default_use_javascript_addr_book = 'false';
2563 return $default_use_javascript_addr_book;
2567 print "If you want to store your users address book details in a database then\n";
2568 print "you need to set this DSN to a valid value. The format for this is:\n";
2569 print "mysql://user:pass\@hostname/dbname\n";
2570 print "Where mysql can be one of the databases PHP supports, the most common\n";
2571 print "of these are mysql, msql and pgsql\n";
2572 print "If the DSN is left empty (hit space and then return) the database\n";
2573 print "related code for address books will not be used\n";
2576 if ( $addrbook_dsn eq "" ) {
2577 $default_value = "Disabled";
2579 $default_value = $addrbook_dsn;
2581 print "[$WHT$addrbook_dsn$NRM]: $WHT";
2583 if ( $new_dsn eq "\n" ) {
2586 $new_dsn =~ s/[\r\n]//g;
2587 $new_dsn =~ s/^\s+$//g;
2593 print "This is the name of the table you want to store the address book\n";
2594 print "data in, it defaults to 'address'\n";
2596 print "[$WHT$addrbook_table$NRM]: $WHT";
2597 $new_table = <STDIN
>;
2598 if ( $new_table eq "\n" ) {
2599 $new_table = $addrbook_table;
2601 $new_table =~ s/[\r\n]//g;
2607 print "If you want to store your users preferences in a database then\n";
2608 print "you need to set this DSN to a valid value. The format for this is:\n";
2609 print "mysql://user:pass\@hostname/dbname\n";
2610 print "Where mysql can be one of the databases PHP supports, the most common\n";
2611 print "of these are mysql, msql and pgsql\n";
2612 print "If the DSN is left empty (hit space and then return) the database\n";
2613 print "related code for address books will not be used\n";
2616 if ( $prefs_dsn eq "" ) {
2617 $default_value = "Disabled";
2619 $default_value = $prefs_dsn;
2621 print "[$WHT$prefs_dsn$NRM]: $WHT";
2623 if ( $new_dsn eq "\n" ) {
2626 $new_dsn =~ s/[\r\n]//g;
2627 $new_dsn =~ s/^\s+$//g;
2633 print "This is the name of the table you want to store the preferences\n";
2634 print "data in, it defaults to 'userprefs'\n";
2636 print "[$WHT$prefs_table$NRM]: $WHT";
2637 $new_table = <STDIN
>;
2638 if ( $new_table eq "\n" ) {
2639 $new_table = $prefs_table;
2641 $new_table =~ s/[\r\n]//g;
2647 print "This is the name of the field in which you want to store the\n";
2648 print "username of the person the prefs are for. It default to 'user'\n";
2649 print "which clashes with a reserved keyword in PostgreSQL so this\n";
2650 print "will need to be changed for that database at least\n";
2652 print "[$WHT$prefs_user_field$NRM]: $WHT";
2653 $new_field = <STDIN
>;
2654 if ( $new_field eq "\n" ) {
2655 $new_field = $prefs_user_field;
2657 $new_field =~ s/[\r\n]//g;
2663 print "This is the name of the field in which you want to store the\n";
2664 print "preferences keyword. It defaults to 'prefkey'\n";
2666 print "[$WHT$prefs_key_field$NRM]: $WHT";
2667 $new_field = <STDIN
>;
2668 if ( $new_field eq "\n" ) {
2669 $new_field = $prefs_key_field;
2671 $new_field =~ s/[\r\n]//g;
2677 print "This is the name of the field in which you want to store the\n";
2678 print "preferences value. It defaults to 'prefval'\n";
2680 print "[$WHT$prefs_val_field$NRM]: $WHT";
2681 $new_field = <STDIN
>;
2682 if ( $new_field eq "\n" ) {
2683 $new_field = $prefs_val_field;
2685 $new_field =~ s/[\r\n]//g;
2691 print "If you want to store your global address book in a database then\n";
2692 print "you need to set this DSN to a valid value. The format for this is:\n";
2693 print "mysql://user:pass\@hostname/dbname\n";
2694 print "Where mysql can be one of the databases PHP supports, the most common\n";
2695 print "of these are mysql, msql and pgsql\n";
2696 print "If the DSN is left empty (hit space and then return) the database\n";
2697 print "related code for global SQL address book will not be used\n";
2700 if ( $addrbook_global_dsn eq "" ) {
2701 $default_value = "Disabled";
2703 $default_value = $addrbook_global_dsn;
2705 print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
2707 if ( $new_dsn eq "\n" ) {
2710 $new_dsn =~ s/[\r\n]//g;
2711 $new_dsn =~ s/^\s+$//g;
2717 print "This is the name of the table you want to store the global address book\n";
2718 print "data in, it defaults to 'global_address'\n";
2720 print "[$WHT$addrbook_global_table$NRM]: $WHT";
2721 $new_table = <STDIN
>;
2722 if ( $new_table eq "\n" ) {
2723 $new_table = $addrbook_global_table;
2725 $new_table =~ s/[\r\n]//g;
2731 print "This option controls users\' ability to add or modify records stored \n";
2732 print "in global address book\n";
2734 if ( lc($addrbook_global_writeable) eq 'true' ) {
2735 $default_value = "y";
2737 $default_value = "n";
2739 print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2740 $addrbook_global_writeable = <STDIN
>;
2741 if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2742 $addrbook_global_writeable = 'true';
2744 $addrbook_global_writeable = 'false';
2746 return $addrbook_global_writeable;
2750 print "Enable this option if you want to see listing of addresses stored \n";
2751 print "in global address book\n";
2753 if ( lc($addrbook_global_listing) eq 'true' ) {
2754 $default_value = "y";
2756 $default_value = "n";
2758 print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2759 $addrbook_global_listing = <STDIN
>;
2760 if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2761 $addrbook_global_listing = 'true';
2763 $addrbook_global_listing = 'false';
2765 return $addrbook_global_listing;
2771 print "SquirrelMail attempts to set the language in many ways. If it\n";
2772 print "can not figure it out in another way, it will default to this\n";
2773 print "language. Please use the code for the desired language.\n";
2775 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
2776 $new_squirrelmail_default_language = <STDIN
>;
2777 if ( $new_squirrelmail_default_language eq "\n" ) {
2778 $new_squirrelmail_default_language = $squirrelmail_default_language;
2780 $new_squirrelmail_default_language =~ s/[\r\n]//g;
2781 $new_squirrelmail_default_language =~ s/^\s+$//g;
2783 return $new_squirrelmail_default_language;
2787 print "This option controls what character set is used when sending\n";
2788 print "mail and when sending HTML to the browser. Option works only\n";
2789 print "with US English (en_US) translation. Other translations use\n";
2790 print "charsets that are set in functions/i18n.php.\n";
2793 print "[$WHT$default_charset$NRM]: $WHT";
2794 $new_default_charset = <STDIN
>;
2795 if ( $new_default_charset eq "\n" ) {
2796 $new_default_charset = $default_charset;
2798 $new_default_charset =~ s/[\r\n]//g;
2800 return $new_default_charset;
2802 # Alternative language names
2804 print "Enable this option if you want to see localized language names in\n";
2805 print "language selection box. Note, that if don't limit list of available\n";
2806 print "languages, this option can trigger installation of foreign language\n";
2807 print "support modules in some browsers.\n";
2810 if ( lc($show_alternative_names) eq 'true' ) {
2811 $default_value = "y";
2813 $default_value = "n";
2815 print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
2816 $show_alternative_names = <STDIN
>;
2817 if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2818 $show_alternative_names = 'true';
2820 $show_alternative_names = 'false';
2822 return $show_alternative_names;
2824 # Available languages
2826 print "This option allows to limit number of languages available in\n";
2827 print "language selection box. You can enter as code of every language that\n";
2828 print "you want to enable. Language codes should be separated by space. If you\n";
2829 print "enter name unsupported by SquirrelMail, it will be ignored. If you enter\n";
2830 print "special key \'all\' - all languages available in SquirrelMail will be\n";
2831 print "listed. If you enter special key \'none\' - user won't be able to change";
2832 print "language and interface will use language set it \"Default language\" option.\n";
2834 print "You can find valid language names in doc/i18n.txt.\n";
2836 print "[$WHT$available_languages$NRM]: $WHT";
2837 $new_available_languages = <STDIN
>;
2838 if ( $new_available_languages eq "\n" ) {
2839 $new_available_languages = $available_languages;
2841 $new_available_languages =~ s/[\r\n]//g;
2842 $new_available_languages =~ s/^\s+$//g;
2844 return $new_available_languages;
2846 # Aggressive decoding
2848 print "Enable this option if you want to use CPU and memory intensive decoding\n";
2849 print "functions. This option allows reading multibyte charset, that are used\n";
2850 print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
2851 print "even when you have disabled use of recode in Tweaks section.\n";
2854 if ( lc($aggressive_decoding) eq 'true' ) {
2855 $default_value = "y";
2857 $default_value = "n";
2859 print "Enable aggressive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
2860 $aggressive_decoding = <STDIN
>;
2861 if ( ( $aggressive_decoding =~ /^y\n/i ) || ( ( $aggressive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2862 $aggressive_decoding = 'true';
2864 $aggressive_decoding = 'false';
2866 return $aggressive_decoding;
2871 print "Enable this option if you want to allow loosy charset encoding in message\n";
2872 print "composition pages. This option allows charset conversions when output\n";
2873 print "charset does not support all symbols used in original charset. Symbols\n";
2874 print "unsupported by output charset will be replaced with question marks.\n";
2877 if ( lc($loosy_encoding) eq 'true' ) {
2878 $default_value = "y";
2880 $default_value = "n";
2882 print "Enable loosy encoding? (y/n) [$WHT$default_value$NRM]: $WHT";
2883 $loosy_encoding = <STDIN
>;
2884 if ( ( $loosy_encoding =~ /^y\n/i ) || ( ( $loosy_encoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2885 $loosy_encoding = 'true';
2887 $loosy_encoding = 'false';
2889 return $loosy_encoding;
2895 print "Enable this option if you want to use DHTML based folder listing.\n";
2896 print "Code is experimental, works only with some browsers and there might\n";
2897 print "be some glitches.\n";
2900 if ( lc($advanced_tree) eq 'true' ) {
2901 $default_value = "y";
2903 $default_value = "n";
2905 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2906 $advanced_tree = <STDIN
>;
2907 if ( ( $advanced_tree =~ /^y\n/i ) || ( ( $advanced_tree =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2908 $advanced_tree = 'true';
2910 $advanced_tree = 'false';
2912 return $advanced_tree;
2916 print "Setting \$oldway to false causes left_main.php to use the new\n";
2917 print "experimental way of getting the mailbox-tree.\n";
2920 if ( lc($oldway) eq 'true' ) {
2921 $default_value = "y";
2923 $default_value = "n";
2925 print "Use old way of folder list display? (y/n) [$WHT$default_value$NRM]: $WHT";
2927 if ( ( $oldway =~ /^y\n/i ) || ( ( $oldway =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2936 print "Enabling this option will cause icons to be used instead of text\n";
2937 print "markers next to each message in mailbox lists that represent\n";
2938 print "new, read, flagged, and deleted messages, as well as those that\n";
2939 print "have been replied to and forwarded. Icons are also used next to\n";
2940 print "(un)expanded folders in the folder list (Oldway = false). These\n";
2941 print "icons are quite small, but will obviously be more of a resource\n";
2942 print "drain than text markers.\n";
2945 if ( lc($use_icons) eq 'true' ) {
2946 $default_value = "y";
2948 $default_value = "n";
2950 print "Use icons? (y/n) [$WHT$default_value$NRM]: $WHT";
2951 $use_icons = <STDIN
>;
2952 if ( ( $use_icons =~ /^y\n/i ) || ( ( $use_icons =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2953 $use_icons = 'true';
2955 $use_icons = 'false';
2961 print "Enable this option if you want to use php recode functions to read\n";
2962 print "emails written in charset that differs from the one that is set in\n";
2963 print "translation selected by user. Code is experimental, it might cause\n";
2964 print "errors, if email contains charset unsupported by recode or if your\n";
2965 print "php does not have recode support.\n";
2968 if ( lc($use_php_recode) eq 'true' ) {
2969 $default_value = "y";
2971 $default_value = "n";
2973 print "Use php recode functions? (y/n) [$WHT$default_value$NRM]: $WHT";
2974 $use_php_recode = <STDIN
>;
2975 if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2976 $use_php_recode = 'true';
2978 $use_php_recode = 'false';
2980 return $use_php_recode;
2984 print "Enable this option if you want to use php iconv functions to read\n";
2985 print "emails written in charset that differs from the one that is set in\n";
2986 print "translation selected by user. Code is experimental, it works only\n";
2987 print "with translations that use utf-8 charset. Code might cause errors,\n";
2988 print "if email contains charset unsupported by iconv or if your php does\n";
2989 print "not have iconv support.\n";
2992 if ( lc($use_php_iconv) eq 'true' ) {
2993 $default_value = "y";
2995 $default_value = "n";
2997 print "Use php iconv functions? (y/n) [$WHT$default_value$NRM]: $WHT";
2998 $use_php_iconv = <STDIN
>;
2999 if ( ( $use_php_iconv =~ /^y\n/i ) || ( ( $use_php_iconv =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3000 $use_php_iconv = 'true';
3002 $use_php_iconv = 'false';
3004 return $use_php_iconv;
3010 if ( open( CF
, ">config.php" ) ) {
3015 print CF
" * SquirrelMail Configuration File\n";
3016 print CF
" * Created using the configure script, conf.pl\n";
3019 print CF
"global \$version;\n";
3021 if ($print_config_version) {
3022 print CF
"\$config_version = '$print_config_version';\n";
3025 print CF
"\$config_use_color = $config_use_color;\n";
3029 print CF
"\$org_name = \"$org_name\";\n";
3031 print CF
"\$org_logo = " . &change_to_SM_path
($org_logo) . ";\n";
3032 $org_logo_width |= 0;
3033 $org_logo_height |= 0;
3035 print CF
"\$org_logo_width = '$org_logo_width';\n";
3037 print CF
"\$org_logo_height = '$org_logo_height';\n";
3038 # string that can contain variables.
3039 print CF
"\$org_title = \"$org_title\";\n";
3041 print CF
"\$signout_page = " . &change_to_SM_path
($signout_page) . ";\n";
3043 print CF
"\$frame_top = '$frame_top';\n";
3046 print CF
"\$provider_uri = '$provider_uri';\n";
3049 print CF
"\$provider_name = '$provider_name';\n";
3052 # string that can contain variables
3053 print CF
"\$motd = \"$motd\";\n";
3057 print CF
"\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
3059 print CF
"\$default_charset = '$default_charset';\n";
3061 print CF
"\$show_alternative_names = $show_alternative_names;\n";
3063 print CF
"\$available_languages = '$available_languages';\n";
3065 print CF
"\$aggressive_decoding = $aggressive_decoding;\n";
3067 print CF
"\$loosy_encoding = $loosy_encoding;\n";
3071 print CF
"\$domain = '$domain';\n";
3073 print CF
"\$imapServerAddress = '$imapServerAddress';\n";
3075 print CF
"\$imapPort = $imapPort;\n";
3077 print CF
"\$useSendmail = $useSendmail;\n";
3079 print CF
"\$smtpServerAddress = '$smtpServerAddress';\n";
3081 print CF
"\$smtpPort = $smtpPort;\n";
3083 print CF
"\$sendmail_path = '$sendmail_path';\n";
3085 # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
3087 print CF
"\$pop_before_smtp = $pop_before_smtp;\n";
3089 print CF
"\$imap_server_type = '$imap_server_type';\n";
3091 print CF
"\$invert_time = $invert_time;\n";
3093 print CF
"\$optional_delimiter = '$optional_delimiter';\n";
3095 print CF
"\$skip_SM_header = $skip_SM_header;\n";
3099 print CF
"\$default_folder_prefix = '$default_folder_prefix';\n";
3101 print CF
"\$trash_folder = '$trash_folder';\n";
3103 print CF
"\$sent_folder = '$sent_folder';\n";
3105 print CF
"\$draft_folder = '$draft_folder';\n";
3107 print CF
"\$default_move_to_trash = $default_move_to_trash;\n";
3109 print CF
"\$default_move_to_sent = $default_move_to_sent;\n";
3111 print CF
"\$default_save_as_draft = $default_save_as_draft;\n";
3113 print CF
"\$show_prefix_option = $show_prefix_option;\n";
3115 print CF
"\$list_special_folders_first = $list_special_folders_first;\n";
3117 print CF
"\$use_special_folder_color = $use_special_folder_color;\n";
3119 print CF
"\$auto_expunge = $auto_expunge;\n";
3121 print CF
"\$default_sub_of_inbox = $default_sub_of_inbox;\n";
3123 print CF
"\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
3125 print CF
"\$default_unseen_notify = $default_unseen_notify;\n";
3127 print CF
"\$default_unseen_type = $default_unseen_type;\n";
3129 print CF
"\$auto_create_special = $auto_create_special;\n";
3131 print CF
"\$delete_folder = $delete_folder;\n";
3133 print CF
"\$noselect_fix_enable = $noselect_fix_enable;\n";
3138 print CF
"\$data_dir = " . &change_to_SM_path
($data_dir) . ";\n";
3139 # string that can contain a variable
3140 print CF
"\$attachment_dir = " . &change_to_SM_path
($attachment_dir) . ";\n";
3142 print CF
"\$dir_hash_level = $dir_hash_level;\n";
3144 print CF
"\$default_left_size = '$default_left_size';\n";
3146 print CF
"\$force_username_lowercase = $force_username_lowercase;\n";
3148 print CF
"\$default_use_priority = $default_use_priority;\n";
3150 print CF
"\$hide_sm_attributions = $hide_sm_attributions;\n";
3152 print CF
"\$default_use_mdn = $default_use_mdn;\n";
3154 print CF
"\$edit_identity = $edit_identity;\n";
3156 print CF
"\$edit_name = $edit_name;\n";
3158 print CF
"\$allow_thread_sort = $allow_thread_sort;\n";
3160 print CF
"\$allow_server_sort = $allow_server_sort;\n";
3162 print CF
"\$allow_charset_search = $allow_charset_search;\n";
3164 print CF
"\$allow_advanced_search = $allow_advanced_search;\n";
3167 # all plugins are strings
3168 for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
3169 print CF
"\$plugins[$ct] = '$plugins[$ct]';\n";
3174 print CF
"\$theme_css = " . &change_to_SM_path
($theme_css) . ";\n";
3175 if ( $theme_default eq '' ) { $theme_default = '0'; }
3176 print CF
"\$theme_default = $theme_default;\n";
3178 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
3179 print CF
"\$theme[$count]['PATH'] = " . &change_to_SM_path
($theme_path[$count]) . ";\n";
3180 # escape theme name so it can contain single quotes.
3181 $esc_name = $theme_name[$count];
3182 $esc_name =~ s/\\/\\\\/g;
3183 $esc_name =~ s/'/\\'/g;
3184 print CF
"\$theme[$count]['NAME'] = '$esc_name';\n";
3188 if ( $default_use_javascript_addr_book ne 'true' ) {
3189 $default_use_javascript_addr_book = 'false';
3193 print CF
"\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
3194 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
3195 print CF
"\$ldap_server[$count] = array(\n";
3197 print CF
" 'host' => '$ldap_host[$count]',\n";
3199 print CF
" 'base' => '$ldap_base[$count]'";
3200 if ( $ldap_name[$count] ) {
3203 print CF
" 'name' => '$ldap_name[$count]'";
3205 if ( $ldap_port[$count] ) {
3208 print CF
" 'port' => $ldap_port[$count]";
3210 if ( $ldap_charset[$count] ) {
3213 print CF
" 'charset' => '$ldap_charset[$count]'";
3215 if ( $ldap_maxrows[$count] ) {
3218 print CF
" 'maxrows' => $ldap_maxrows[$count]";
3220 if ( $ldap_binddn[$count] ) {
3223 print CF
" 'binddn' => '$ldap_binddn[$count]'";
3224 if ( $ldap_bindpw[$count] ) {
3227 print CF
" 'bindpw' => '$ldap_bindpw[$count]'";
3230 if ( $ldap_protocol[$count] ) {
3233 print CF
" 'protocol' => $ldap_protocol[$count]";
3241 print CF
"\$addrbook_dsn = '$addrbook_dsn';\n";
3243 print CF
"\$addrbook_table = '$addrbook_table';\n\n";
3245 print CF
"\$prefs_dsn = '$prefs_dsn';\n";
3247 print CF
"\$prefs_table = '$prefs_table';\n";
3249 print CF
"\$prefs_user_field = '$prefs_user_field';\n";
3251 print CF
"\$prefs_key_field = '$prefs_key_field';\n";
3253 print CF
"\$prefs_val_field = '$prefs_val_field';\n\n";
3255 print CF
"\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
3257 print CF
"\$addrbook_global_table = '$addrbook_global_table';\n";
3259 print CF
"\$addrbook_global_writeable = $addrbook_global_writeable;\n\n";
3261 print CF
"\$addrbook_global_listing = $addrbook_global_listing;\n\n";
3263 print CF
"\$no_list_for_subscribe = $no_list_for_subscribe;\n";
3266 print CF
"\$smtp_auth_mech = '$smtp_auth_mech';\n";
3268 print CF
"\$imap_auth_mech = '$imap_auth_mech';\n";
3270 print CF
"\$use_imap_tls = $use_imap_tls;\n";
3272 print CF
"\$use_smtp_tls = $use_smtp_tls;\n";
3274 print CF
"\$session_name = '$session_name';\n";
3279 print CF
"\$advanced_tree = $advanced_tree;\n";
3282 print CF
"\$oldway = $oldway;\n";
3285 print CF
"\$use_icons = $use_icons;\n";
3288 print CF
"\$use_php_recode = $use_php_recode;\n";
3291 print CF
"\$use_php_iconv = $use_php_iconv;\n";
3294 print CF
"\@include SM_PATH . 'config/config_local.php';\n";
3297 print CF
" * Make sure there are no characters after the PHP closing\n";
3298 print CF
" * tag below (including newline characters and whitespace).\n";
3299 print CF
" * Otherwise, that character will cause the headers to be\n";
3300 print CF
" * sent and regular output to begin, which will majorly screw\n";
3301 print CF
" * things up when we try to send more headers later.\n";
3307 print "Data saved in config.php\n";
3309 print "Error saving config.php: $!\n";
3315 print $WHT. "SquirrelMail Configuration : " . $NRM;
3316 if ( $config == 1 ) { print "Read: config.php"; }
3317 elsif ( $config == 2 ) { print "Read: config_default.php"; }
3319 print "---------------------------------------------------------\n";
3321 print "While we have been building SquirrelMail, we have discovered some\n";
3322 print "preferences that work better with some servers that don't work so\n";
3323 print "well with others. If you select your IMAP server, this option will\n";
3324 print "set some pre-defined settings for that server.\n";
3326 print "Please note that you will still need to go through and make sure\n";
3327 print "everything is correct. This does not change everything. There are\n";
3328 print "only a few settings that this will change.\n";
3332 while ( $continue != 1 ) {
3333 print "Please select your IMAP server:\n";
3334 print " cyrus = Cyrus IMAP server\n";
3335 print " uw = University of Washington's IMAP server\n";
3336 print " exchange = Microsoft Exchange IMAP server\n";
3337 print " courier = Courier IMAP server\n";
3338 print " macosx = Mac OS X Mailserver\n";
3339 print " mercury32 = Mercury/32\n";
3340 print " quit = Do not change anything\n";
3341 print "Command >> ";
3343 $server =~ s/[\r\n]//g;
3346 if ( $server eq "cyrus" ) {
3347 $imap_server_type = "cyrus";
3348 $default_folder_prefix = "";
3349 $trash_folder = "INBOX.Trash";
3350 $sent_folder = "INBOX.Sent";
3351 $draft_folder = "INBOX.Drafts";
3352 $show_prefix_option = false
;
3353 $default_sub_of_inbox = true
;
3354 $show_contain_subfolders_option = false
;
3355 $optional_delimiter = ".";
3356 $disp_default_folder_prefix = "<none>";
3357 $force_username_lowercase = false
;
3360 } elsif ( $server eq "uw" ) {
3361 $imap_server_type = "uw";
3362 $default_folder_prefix = "mail/";
3363 $trash_folder = "Trash";
3364 $sent_folder = "Sent";
3365 $draft_folder = "Drafts";
3366 $show_prefix_option = true
;
3367 $default_sub_of_inbox = false
;
3368 $show_contain_subfolders_option = true
;
3369 $optional_delimiter = "/";
3370 $disp_default_folder_prefix = $default_folder_prefix;
3371 $delete_folder = true
;
3372 $force_username_lowercase = true
;
3375 } elsif ( $server eq "exchange" ) {
3376 $imap_server_type = "exchange";
3377 $default_folder_prefix = "";
3378 $default_sub_of_inbox = true
;
3379 $trash_folder = "INBOX/Deleted Items";
3380 $sent_folder = "INBOX/Sent Items";
3381 $drafts_folder = "INBOX/Drafts";
3382 $show_prefix_option = false
;
3383 $show_contain_subfolders_option = false
;
3384 $optional_delimiter = "detect";
3385 $disp_default_folder_prefix = "<none>";
3386 $force_username_lowercase = true
;
3389 } elsif ( $server eq "courier" ) {
3390 $imap_server_type = "courier";
3391 $default_folder_prefix = "INBOX.";
3392 $trash_folder = "Trash";
3393 $sent_folder = "Sent";
3394 $draft_folder = "Drafts";
3395 $show_prefix_option = false
;
3396 $default_sub_of_inbox = false
;
3397 $show_contain_subfolders_option = false
;
3398 $optional_delimiter = ".";
3399 $disp_default_folder_prefix = $default_folder_prefix;
3400 $delete_folder = true
;
3401 $force_username_lowercase = false
;
3404 } elsif ( $server eq "macosx" ) {
3405 $imap_server_type = "macosx";
3406 $default_folder_prefix = "INBOX/";
3407 $trash_folder = "Trash";
3408 $sent_folder = "Sent";
3409 $draft_folder = "Drafts";
3410 $show_prefix_option = false
;
3411 $default_sub_of_inbox = true
;
3412 $show_contain_subfolders_option = false
;
3413 $optional_delimiter = "detect";
3414 $allow_charset_search = false
;
3415 $disp_default_folder_prefix = $default_folder_prefix;
3418 } elsif ( $server eq "mercury32" ) {
3419 $imap_server_type = "mercury32";
3420 $default_folder_prefix = "";
3421 $trash_folder = "INBOX.Trash";
3422 $sent_folder = "INBOX.Sent";
3423 $draft_folder = "INBOX.Drafts";
3424 $show_prefix_option = false
;
3425 $default_sub_of_inbox = true
;
3426 $show_contain_subfolders_option = true
;
3427 $optional_delimiter = "detect";
3428 $delete_folder = true
;
3429 $force_username_lowercase = true
;
3432 } elsif ( $server eq "quit" ) {
3435 $disp_default_folder_prefix = $default_folder_prefix;
3436 print "Unrecognized server: $server\n";
3440 print " imap_server_type = $imap_server_type\n";
3441 print " default_folder_prefix = $disp_default_folder_prefix\n";
3442 print " trash_folder = $trash_folder\n";
3443 print " sent_folder = $sent_folder\n";
3444 print " draft_folder = $draft_folder\n";
3445 print " show_prefix_option = $show_prefix_option\n";
3446 print " default_sub_of_inbox = $default_sub_of_inbox\n";
3447 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3448 print " optional_delimiter = $optional_delimiter\n";
3449 print " delete_folder = $delete_folder\n";
3450 print " force_username_lowercase = $force_username_lowercase\n";
3452 print "\nPress enter to continue...";
3456 # This subroutine corrects relative paths to ensure they
3457 # will work within the SM space. If the path falls within
3458 # the SM directory tree, the SM_PATH variable will be
3459 # prepended to the path, if not, then the path will be
3460 # converted to an absolute path, e.g.
3461 # '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
3462 # '../../someplace/data' --> '/absolute/path/someplace/data'
3463 # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
3464 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3465 # 'http://whatever/' --> 'http://whatever'
3466 # $some_var/path --> "$some_var/path"
3467 sub change_to_SM_path
() {
3468 my ($old_path) = @_;
3474 # If the path is absolute, don't bother.
3475 return "\'" . $old_path . "\'" if ( $old_path eq '');
3476 return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http
)/ );
3477 return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:\// );
3478 return $old_path if ( $old_path =~ /^\'(\/|http
)/ );
3479 return $old_path if ( $old_path =~ /^\'\w:\// );
3480 return $old_path if ( $old_path =~ /^SM_PATH/);
3482 if ( $old_path =~ /^\$/ ) {
3483 # check if it's a single var, or a $var/path combination
3484 # if it's $var/path, enclose in ""
3485 if ( $old_path =~ /\// ) {
3486 return '"'.$old_path.'"';
3491 # Remove remaining '
3492 $old_path =~ s/\'//g;
3494 # For relative paths, split on '../'
3495 @rel_path = split(/\.\.\//, $old_path);
3497 if ( $#rel_path > 1 ) {
3498 # more than two levels away. Make it absolute.
3499 @abs_path = split(/\//, $dir);
3501 # Lop off the relative pieces of the absolute path..
3502 for ( $i = 0; $i <= $#rel_path; $i++ ) {
3506 push @abs_path, @rel_path;
3507 $new_path = "\'" . join('/', @abs_path) . "\'";
3508 } elsif ( $#rel_path > 0 ) {
3509 # it's within the SM tree, prepend SM_PATH
3510 $new_path = $old_path;
3511 $new_path =~ s/^\.\.\//SM_PATH
. \'/;
3514 # Last, it's a relative path without any leading '.'
3515 # Prepend SM_PATH and config, since the paths are
3516 # relative to the config directory
3517 $new_path = "SM_PATH . \'config/" . $old_path . "\'";
3523 # Change SM_PATH to admin-friendly version, e.g.:
3524 # SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
3525 # SM_PATH . 'config/some.php' --> 'some.php'
3526 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3527 # 'http://whatever/' --> 'http://whatever'
3528 sub change_to_rel_path
() {
3529 my ($old_path) = @_;
3530 my $new_path = $old_path;
3532 if ( $old_path =~ /^SM_PATH/ ) {
3533 $new_path =~ s/^SM_PATH . \'/\.\.\//;
3534 $new_path =~ s/\.\.\/config\///;
3540 sub detect_auth_support
{
3541 # Attempts to auto-detect if a specific auth mechanism is supported.
3542 # Called by 'command112a' and 'command112b'
3543 # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3547 my $service = shift;
3551 if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3552 # Error - wrong # of args
3553 print "BAD ARGS!\n";
3557 if ($service eq 'SMTP') {
3558 $cmd = "AUTH $mech\n";
3560 } elsif ($service eq 'IMAP') {
3561 $cmd = "A01 AUTHENTICATE $mech\n";
3562 $logout = "C01 LOGOUT\n";
3564 # unknown service - whoops.
3568 # Get this show on the road
3569 my $sock=IO
::Socket
::INET
->new($host);
3570 if (!defined($sock)) {
3574 my $discard = <$sock>; # Server greeting/banner - who cares..
3576 if ($service eq 'SMTP') {
3578 print $sock "helo $domain\n";
3579 $discard = <$sock>; # Yeah yeah, you're happy to see me..
3583 my $response = <$sock>;
3585 if (!defined($response)) {
3589 # So at this point, we have a response, and it is (hopefully) valid.
3590 if ($service eq 'SMTP') {
3591 if (($response =~ /^535/) or ($response =~/^502/)) {
3595 } elsif ($response =~ /^503/) {
3596 #Something went wrong
3599 } elsif ($service eq 'IMAP') {
3600 if ($response =~ /^A01/) {
3606 # Unknown service - this shouldn't be able to happen.
3611 # If it gets here, the mech is supported
3612 print $sock "*\n"; # Attempt to cancel authentication
3613 print $sock $logout; # Try to log out, but we don't really care if this fails
3618 sub clear_screen
() {
3619 if ( $^O
=~ /^mswin/i) {