Added iso-ir-111 support. one of cyrillic charsets from mozilla's list.
[squirrelmail.git] / config / conf.pl
CommitLineData
23afd0bd 1#!/usr/bin/env perl
bbd30ac8 2# conf.pl
bbd30ac8 3#
6614128e 4# Copyright (c) 1999-2003 The SquirrelMail Project Team
5# Licensed under the GNU GPL. For full terms see COPYING.
6#
7# A simple configure script to configure SquirrelMail
245a6892 8#
9# $Id$
ccfb2029 10############################################################
6614128e 11$conf_pl_version = "1.4.0";
bbd30ac8 12
38b69acb 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############################################################
8bd9e0dd 19my $dir;
eaace00e 20if ( eval q{require "File/Basename.pm"} ) {
8bd9e0dd 21 $dir = File::Basename::dirname($0);
38b69acb 22 chdir($dir);
23}
24
d595e32e 25############################################################
26# Some people try to run this as a CGI. That's wrong!
27############################################################
eaace00e 28if ( 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.";
33 exit;
34 }
d595e32e 35
8bd9e0dd 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############################################################
41use Cwd;
42$dir = cwd();
25be56ab 43
8bd9e0dd 44
ccfb2029 45############################################################
bbd30ac8 46# First, lets read in the data already in there...
ccfb2029 47############################################################
eaace00e 48if ( -e "config.php" ) {
49 open( FILE, "config.php" );
50 while ( $line = <FILE> ) {
51 $line =~ s/^\s+//;
52 $line =~ s/^\$//;
53 $var = $line;
54
55 $var =~ s/=/EQUALS/;
56 if ( $var =~ /^([a-z]|[A-Z])/ ) {
57 @o = split ( /\s*EQUALS\s*/, $var );
58 if ( $o[0] eq "config_version" ) {
59 $o[1] =~ s/[\n|\r]//g;
60 $o[1] =~ s/[\'|\"];\s*$//;
61 $o[1] =~ s/;$//;
62 $o[1] =~ s/^[\'|\"]//;
63
64 $config_version = $o[1];
65 close(FILE);
66 }
67 }
68 }
69 close(FILE);
70
71 if ( $config_version ne $conf_pl_version ) {
f8c17cdd 72 clear_screen();
eaace00e 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";
80 print "\n";
81 print "Continue loading with the old config.php [y/N]? ";
82 $ctu = <STDIN>;
83
84 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
85 exit;
86 }
87
88 print "\nDo you want me to stop warning you [y/N]? ";
89 $ctu = <STDIN>;
90 if ( $ctu =~ /^y\n/i ) {
91 $print_config_version = $conf_pl_version;
92 } else {
93 $print_config_version = $config_version;
94 }
95 } else {
96 $print_config_version = $config_version;
97 }
98
99 $config = 1;
100 open( FILE, "config.php" );
101} elsif ( -e "config_default.php" ) {
102 open( FILE, "config_default.php" );
103 while ( $line = <FILE> ) {
104 $line =~ s/^\s+//;
105 $line =~ s/^\$//;
106 $var = $line;
107
108 $var =~ s/=/EQUALS/;
109 if ( $var =~ /^([a-z]|[A-Z])/ ) {
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*$//;
114 $o[1] =~ s/;$//;
115 $o[1] =~ s/^[\'|\"]//;
116
117 $config_version = $o[1];
118 close(FILE);
119 }
120 }
121 }
122 close(FILE);
123
124 if ( $config_version ne $conf_pl_version ) {
f8c17cdd 125 clear_screen();
eaace00e 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";
133 print "\n";
134 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
135 $ctu = <STDIN>;
136
137 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
138 exit;
139 }
140
141 print "\nDo you want me to stop warning you [y/N]? ";
142 $ctu = <STDIN>;
143 if ( $ctu =~ /^y\n/i ) {
144 $print_config_version = $conf_pl_version;
145 } else {
146 $print_config_version = $config_version;
147 }
148 } else {
149 $print_config_version = $config_version;
150 }
151 $config = 2;
152 open( FILE, "config_default.php" );
1e0628fb 153} else {
eaace00e 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";
157 exit;
bbd30ac8 158}
159
a3439b27 160# Read and parse the current configuration file
161# (either config.php or config_default.php).
eaace00e 162while ( $line = <FILE> ) {
8bd9e0dd 163 $line =~ s/^\s+//;
eaace00e 164 $line =~ s/^\$//;
165 $var = $line;
166
167 $var =~ s/=/EQUALS/;
168 if ( $var =~ /^([a-z]|[A-Z])/ ) {
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
175 if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
176 $sub = $options[0];
177 $sub =~ s/\]\[['|"]PATH['|"]\]//;
178 $sub =~ s/.*\[//;
179 if ( -e "../themes" ) {
180 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
a3439b27 181 }
8bd9e0dd 182 $theme_path[$sub] = &change_to_rel_path($options[1]);
eaace00e 183 } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
184 $sub = $options[0];
185 $sub =~ s/\]\[['|"]NAME['|"]\]//;
186 $sub =~ s/.*\[//;
187 $theme_name[$sub] = $options[1];
188 } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
189 $sub = $options[0];
190 $sub =~ s/\]//;
191 $sub =~ s/^plugins\[//;
192 $plugins[$sub] = $options[1];
193 } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
194 $sub = $options[0];
195 $sub =~ s/\]//;
196 $sub =~ s/^ldap_server\[//;
197 $continue = 0;
198 while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
199 if ( $tmp =~ /\);\s*$/ ) {
200 $continue = 1;
201 }
202
203 if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) {
204 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
205 $tmp =~ s/[\'|\"],?\s*$//;
206 $tmp =~ s/[\'|\"]\);\s*$//;
207 $host = $tmp;
208 } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) {
209 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
210 $tmp =~ s/[\'|\"],?\s*$//;
211 $tmp =~ s/[\'|\"]\);\s*$//;
212 $base = $tmp;
213 } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) {
214 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
215 $tmp =~ s/[\'|\"],?\s*$//;
216 $tmp =~ s/[\'|\"]\);\s*$//;
217 $charset = $tmp;
218 } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
748c796b 219 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
220 $tmp =~ s/[\'|\"]?,?\s*$//;
221 $tmp =~ s/[\'|\"]?\);\s*$//;
eaace00e 222 $port = $tmp;
223 } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
748c796b 224 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
225 $tmp =~ s/[\'|\"]?,?\s*$//;
226 $tmp =~ s/[\'|\"]?\);\s*$//;
eaace00e 227 $maxrows = $tmp;
228 } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
229 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
230 $tmp =~ s/[\'|\"],?\s*$//;
231 $tmp =~ s/[\'|\"]\);\s*$//;
232 $name = $tmp;
233 }
a3439b27 234 }
eaace00e 235 $ldap_host[$sub] = $host;
236 $ldap_base[$sub] = $base;
237 $ldap_name[$sub] = $name;
238 $ldap_port[$sub] = $port;
239 $ldap_maxrows[$sub] = $maxrows;
240 $ldap_charset[$sub] = $charset;
8bd9e0dd 241 } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
242 ${ $options[0] } = &change_to_rel_path($options[1]);
eaace00e 243 } else {
244 ${ $options[0] } = $options[1];
245 }
246 }
bbd30ac8 247}
1a7a2fcc 248close FILE;
8fb817e1 249if ( lc($useSendmail) ne "true" ) {
eaace00e 250 $useSendmail = "false";
828b4753 251}
eaace00e 252if ( !$sendmail_path ) {
253 $sendmail_path = "/usr/sbin/sendmail";
828b4753 254}
254ded61 255if ( !$pop_before_smtp ) {
256 $pop_before_smtp = "false";
257}
eaace00e 258if ( !$default_unseen_notify ) {
259 $default_unseen_notify = 2;
24fc5dd2 260}
eaace00e 261if ( !$default_unseen_type ) {
262 $default_unseen_type = 1;
24fc5dd2 263}
eaace00e 264if ( !$config_use_color ) {
265 $config_use_color = 0;
0ecb47e5 266}
eaace00e 267if ( !$invert_time ) {
268 $invert_time = "false";
a1f1f9bc 269}
eaace00e 270if ( !$force_username_lowercase ) {
a3439b27 271 $force_username_lowercase = "false";
23a8095f 272}
eaace00e 273if ( !$optional_delimiter ) {
a3439b27 274 $optional_delimiter = "detect";
40ba4d36 275}
eaace00e 276if ( !$auto_create_special ) {
a3439b27 277 $auto_create_special = "false";
f7bfc9de 278}
eaace00e 279if ( !$default_use_priority ) {
a3439b27 280 $default_use_priority = "true";
0d15cd19 281}
eaace00e 282if ( !$hide_sm_attributions ) {
a3439b27 283 $hide_sm_attributions = "false";
826b7f71 284}
eaace00e 285if ( !$default_use_mdn ) {
8c21da0c 286 $default_use_mdn = "true";
287}
6517cfd0 288if ( !$delete_folder ) {
289 $delete_folder = "false";
290}
ca85aabe 291if ( !$noselect_fix_enable ) {
292 $noselect_fix_enable = "false";
293}
eaace00e 294if ( !$frame_top ) {
3d043efc 295 $frame_top = "_top";
296}
0ae4c1f2 297
298if ( !$provider_uri ) {
299 $provider_uri = "http://www.squirrelmail.org/";
300}
301
302if ( !$provider_name ) {
303 $provider_name = "SquirrelMail";
304}
305
eaace00e 306if ( !$edit_identity ) {
8a7d0669 307 $edit_identity = "true";
308}
eaace00e 309if ( !$edit_name ) {
8a7d0669 310 $edit_name = "true";
311}
7c612fdd 312if ( !$allow_thread_sort ) {
313 $allow_thread_sort = 'false';
314}
aa0da530 315if ( !$allow_server_sort ) {
316 $allow_server_sort = 'false';
317}
69ea91ae 318if ( !$no_list_for_subscribe ) {
319 $no_list_for_subscribe = 'false';
320}
296f4c20 321if ( !$allow_charset_search ) {
322 $allow_charset_search = 'true';
323}
99a6c222 324if ( !$prefs_user_field ) {
325 $prefs_user_field = 'user';
326}
327if ( !$prefs_key_field ) {
328 $prefs_key_field = 'prefkey';
329}
330if ( !$prefs_val_field ) {
331 $prefs_val_field = 'prefval';
332}
bbd30ac8 333
47a29326 334if ( !$use_smtp_tls) {
335 $use_smtp_tls= 'false';
336}
337
338if ( !$smtp_auth_mech ) {
339 $smtp_auth_mech = 'none';
340}
341
342if ( !$use_imap_tls ) {
343 $use_imap_tls = 'false';
344}
345
346if ( !$imap_auth_mech ) {
fe0b18b3 347 $imap_auth_mech = 'login';
47a29326 348}
349
6c499577 350if (!$session_name ) {
351 $session_name = 'SQMSESSID';
352}
353
eaace00e 354if ( $ARGV[0] eq '--install-plugin' ) {
355 print "Activating plugin " . $ARGV[1] . "\n";
ebd13f55 356 push @plugins, $ARGV[1];
357 save_data();
358 exit(0);
eaace00e 359} elsif ( $ARGV[0] eq '--remove-plugin' ) {
360 print "Removing plugin " . $ARGV[1] . "\n";
ebd13f55 361 foreach $plugin (@plugins) {
eaace00e 362 if ( $plugin ne $ARGV[1] ) {
363 push @newplugins, $plugin;
ebd13f55 364 }
365 }
366 @plugins = @newplugins;
367 save_data();
368 exit(0);
369}
370
5b6ae78a 371#####################################################################################
eaace00e 372if ( $config_use_color == 1 ) {
373 $WHT = "\x1B[37;1m";
374 $NRM = "\x1B[0m";
0ecb47e5 375} else {
eaace00e 376 $WHT = "";
377 $NRM = "";
378 $config_use_color = 2;
379}
380
381while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
f8c17cdd 382 clear_screen();
eaace00e 383 print $WHT. "SquirrelMail Configuration : " . $NRM;
384 if ( $config == 1 ) { print "Read: config.php"; }
385 elsif ( $config == 2 ) { print "Read: config_default.php"; }
386 print " ($print_config_version)\n";
387 print "---------------------------------------------------------\n";
388
389 if ( $menu == 0 ) {
390 print $WHT. "Main Menu --\n" . $NRM;
391 print "1. Organization Preferences\n";
392 print "2. Server Settings\n";
393 print "3. Folder Defaults\n";
394 print "4. General Options\n";
395 print "5. Themes\n";
396 print "6. Address Books (LDAP)\n";
397 print "7. Message of the Day (MOTD)\n";
398 print "8. Plugins\n";
399 print "9. Database\n";
400 print "\n";
401 print "D. Set pre-defined settings for specific IMAP servers\n";
402 print "\n";
403 } elsif ( $menu == 1 ) {
404 print $WHT. "Organization Preferences\n" . $NRM;
b6e0c3b6 405 print "1. Organization Name : $WHT$org_name$NRM\n";
406 print "2. Organization Logo : $WHT$org_logo$NRM\n";
407 print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
408 print "4. Organization Title : $WHT$org_title$NRM\n";
409 print "5. Signout Page : $WHT$signout_page$NRM\n";
410 print "6. Default Language : $WHT$squirrelmail_default_language$NRM\n";
411 print "7. Top Frame : $WHT$frame_top$NRM\n";
0ae4c1f2 412 print "8. Provider link : $WHT$provider_uri$NRM\n";
413 print "9. Provider name : $WHT$provider_name$NRM\n";
414
eaace00e 415 print "\n";
416 print "R Return to Main Menu\n";
417 } elsif ( $menu == 2 ) {
47a29326 418 print $WHT. "Server Settings\n\n" . $NRM;
419 print $WHT . "General" . $NRM . "\n";
420 print "-------\n";
421 print "1. Domain : $WHT$domain$NRM\n";
422 print "2. Invert Time : $WHT$invert_time$NRM\n";
423 print "3. Sendmail or SMTP : $WHT";
eaace00e 424 if ( lc($useSendmail) eq "true" ) {
425 print "Sendmail";
426 } else {
427 print "SMTP";
428 }
429 print "$NRM\n";
47a29326 430 print "\n";
431
432 if ( $show_imap_settings ) {
433 print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
434 print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
435 print "5. IMAP Port : $WHT$imapPort$NRM\n";
436 print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
437 print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n";
438 print "8. Server software : $WHT$imap_server_type$NRM\n";
439 print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
440 print "\n";
441 } elsif ( $show_smtp_settings ) {
442 if ( lc($useSendmail) eq "true" ) {
443 print $WHT . "Sendmail" . $NRM . "\n--------\n";
444 print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
445 print "\n";
446 } else {
447 print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
448 print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
449 print "5. SMTP Port : $WHT$smtpPort$NRM\n";
450 print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
451 print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n";
452 print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n";
453 print "\n";
454 }
eaace00e 455 }
47a29326 456
457 if ($show_imap_settings == 0) {
458 print "A. Update IMAP Settings : ";
459 print "$WHT$imapServerAddress$NRM:";
460 print "$WHT$imapPort$NRM ";
461 print "($WHT$imap_server_type$NRM)\n";
462 }
463 if ($show_smtp_settings == 0) {
464 if ( lc($useSendmail) eq "true" ) {
465 print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
466 } else {
467 print "B. Update SMTP Settings : ";
468 print "$WHT$smtpServerAddress$NRM:";
469 print "$WHT$smtpPort$NRM\n";
470 }
471 }
472 if ( $show_smtp_settings || $show_imap_settings )
473 {
474 print "H. Hide " .
475 ($show_imap_settings ? "IMAP Server" :
476 (lc($useSendmail) eq "true") ? "Sendmail" : "SMTP") . " Settings\n";
477 }
478
eaace00e 479 print "\n";
480 print "R Return to Main Menu\n";
481 } elsif ( $menu == 3 ) {
482 print $WHT. "Folder Defaults\n" . $NRM;
483 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
484 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
485 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
486 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
487 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
488 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
489 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
490 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
491 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
492 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
493 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
494 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
495 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
496 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
497 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
498 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
2eec12b5 499 print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
ca85aabe 500 print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
eaace00e 501 print "\n";
502 print "R Return to Main Menu\n";
503 } elsif ( $menu == 4 ) {
504 print $WHT. "General Options\n" . $NRM;
6c499577 505 print "1. Default Charset : $WHT$default_charset$NRM\n";
506 print "2. Data Directory : $WHT$data_dir$NRM\n";
507 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
508 print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
509 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
510 print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
511 print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
512 print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
513 print "9. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
2eec12b5 514 print "10. Allow editing of identity : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
6c499577 515 print "11. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
516 print "12. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
2eec12b5 517 print "13. Allow server charset search : $WHT$allow_charset_search$NRM\n";
a2a7ac04 518 print "14. PHP session name : $WHT$session_name$NRM\n";
eaace00e 519 print "\n";
520 print "R Return to Main Menu\n";
521 } elsif ( $menu == 5 ) {
522 print $WHT. "Themes\n" . $NRM;
523 print "1. Change Themes\n";
2eec12b5 524 for ( $count = 0 ; $count <= $#theme_name/2 ; $count++ ) {
525 $temp_name = $theme_name[$count*2];
526 printf " %s%*s %s\n", $temp_name,
527 40 - length($temp_name), " ",
528 $theme_name[($count*2)+1];
eaace00e 529 }
530 print "2. CSS File : $WHT$theme_css$NRM\n";
531 print "\n";
532 print "R Return to Main Menu\n";
533 } elsif ( $menu == 6 ) {
534 print $WHT. "Address Books (LDAP)\n" . $NRM;
535 print "1. Change Servers\n";
536 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
537 print " > $ldap_host[$count]\n";
538 }
539 print
540 "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
541 print "\n";
542 print "R Return to Main Menu\n";
543 } elsif ( $menu == 7 ) {
544 print $WHT. "Message of the Day (MOTD)\n" . $NRM;
545 print "\n$motd\n";
546 print "\n";
547 print "1 Edit the MOTD\n";
548 print "\n";
549 print "R Return to Main Menu\n";
550 } elsif ( $menu == 8 ) {
551 print $WHT. "Plugins\n" . $NRM;
552 print " Installed Plugins\n";
553 $num = 0;
554 for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
555 $num = $count + 1;
556 print " $num. $plugins[$count]\n";
557 }
558 print "\n Available Plugins:\n";
559 opendir( DIR, "../plugins" );
560 @files = readdir(DIR);
561 $pos = 0;
562 @unused_plugins = ();
563 for ( $i = 0 ; $i <= $#files ; $i++ ) {
564 if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
565 $match = 0;
566 for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
567 if ( $plugins[$k] eq $files[$i] ) {
568 $match = 1;
569 }
570 }
571 if ( $match == 0 ) {
572 $unused_plugins[$pos] = $files[$i];
573 $pos++;
574 }
1a7a2fcc 575 }
eaace00e 576 }
577
578 for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
579 $num = $num + 1;
580 print " $num. $unused_plugins[$i]\n";
581 }
582 closedir DIR;
583
eaace00e 584 print "\n";
585 print "R Return to Main Menu\n";
586 } elsif ( $menu == 9 ) {
587 print $WHT. "Database\n" . $NRM;
588 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
589 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
99a6c222 590 print "\n";
eaace00e 591 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
592 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
99a6c222 593 print "5. Field for username : $WHT$prefs_user_field$NRM\n";
594 print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
595 print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
eaace00e 596 print "\n";
eaace00e 597 print "R Return to Main Menu\n";
598 }
599 if ( $config_use_color == 1 ) {
600 print "C. Turn color off\n";
601 } else {
602 print "C. Turn color on\n";
603 }
604 print "S Save data\n";
605 print "Q Quit\n";
606
607 print "\n";
608 print "Command >> " . $WHT;
609 $command = <STDIN>;
610 $command =~ s/[\n|\r]//g;
611 $command =~ tr/A-Z/a-z/;
612 print "$NRM\n";
613
614 # Read the commands they entered.
615 if ( $command eq "r" ) {
616 $menu = 0;
617 } elsif ( $command eq "s" ) {
618 save_data();
619 print "Press enter to continue...";
620 $tmp = <STDIN>;
621 $saved = 1;
622 } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
623 print "You have not saved your data.\n";
624 print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
625 $save = <STDIN>;
626 if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
627 save_data();
628 }
629 } elsif ( $command eq "c" ) {
630 if ( $config_use_color == 1 ) {
631 $config_use_color = 2;
632 $WHT = "";
633 $NRM = "";
634 } else {
635 $config_use_color = 1;
636 $WHT = "\x1B[37;1m";
637 $NRM = "\x1B[0m";
638 }
639 } elsif ( $command eq "d" && $menu == 0 ) {
640 set_defaults();
641 } else {
642 $saved = 0;
643 if ( $menu == 0 ) {
644 if ( ( $command > 0 ) && ( $command < 10 ) ) {
645 $menu = $command;
1a7a2fcc 646 }
eaace00e 647 } elsif ( $menu == 1 ) {
648 if ( $command == 1 ) { $org_name = command1(); }
649 elsif ( $command == 2 ) { $org_logo = command2(); }
b6e0c3b6 650 elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); }
651 elsif ( $command == 4 ) { $org_title = command3(); }
652 elsif ( $command == 5 ) { $signout_page = command4(); }
653 elsif ( $command == 6 ) { $squirrelmail_default_language = command5(); }
654 elsif ( $command == 7 ) { $frame_top = command6(); }
0ae4c1f2 655 elsif ( $command == 8 ) { $provider_uri = command7(); }
656 elsif ( $command == 9 ) { $provider_name = command8(); }
657
eaace00e 658 } elsif ( $menu == 2 ) {
47a29326 659 if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
660 elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
661 elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
662 elsif ( $command <= 3 ) {
663 if ( $command == 1 ) { $domain = command11(); }
664 elsif ( $command == 2 ) { $invert_time = command110(); }
665 elsif ( $command == 3 ) { $useSendmail = command14(); }
666 $show_imap_settings = 0; $show_smtp_settings = 0;
667 } elsif ( $show_imap_settings ) {
668 if ( $command == 4 ) { $imapServerAddress = command12(); }
669 elsif ( $command == 5 ) { $imapPort = command13(); }
b47821fb 670 elsif ( $command == 6 ) { $imap_auth_mech = command112a(); }
47a29326 671 elsif ( $command == 7 ) { $use_imap_tls = command113("IMAP",$use_imap_tls); }
672 elsif ( $command == 8 ) { $imap_server_type = command19(); }
673 elsif ( $command == 9 ) { $optional_delimiter = command111(); }
674 } elsif ( $show_smtp_settings && lc($useSendmail) eq "true" ) {
675 if ( $command == 4 ) { $sendmail_path = command15(); }
676 } elsif ( $show_smtp_settings ) {
677 if ( $command == 4 ) { $smtpServerAddress = command16(); }
678 elsif ( $command == 5 ) { $smtpPort = command17(); }
679 elsif ( $command == 6 ) { $pop_before_smtp = command18a(); }
b47821fb 680 elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); }
47a29326 681 elsif ( $command == 8 ) { $use_smtp_tls = command113("SMTP",$use_smtp_tls); }
682 }
eaace00e 683 } elsif ( $menu == 3 ) {
684 if ( $command == 1 ) { $default_folder_prefix = command21(); }
685 elsif ( $command == 2 ) { $show_prefix_option = command22(); }
686 elsif ( $command == 3 ) { $trash_folder = command23a(); }
687 elsif ( $command == 4 ) { $sent_folder = command23b(); }
688 elsif ( $command == 5 ) { $draft_folder = command23c(); }
689 elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
690 elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
691 elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
692 elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
693 elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
694 elsif ( $command == 11 ) { $auto_expunge = command29(); }
695 elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
696 elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
697 elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
698 elsif ( $command == 15 ) { $default_unseen_type = command213(); }
699 elsif ( $command == 16 ) { $auto_create_special = command214(); }
700 elsif ( $command == 17 ) { $delete_folder = command215(); }
ca85aabe 701 elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
eaace00e 702 } elsif ( $menu == 4 ) {
703 if ( $command == 1 ) { $default_charset = command31(); }
704 elsif ( $command == 2 ) { $data_dir = command33a(); }
705 elsif ( $command == 3 ) { $attachment_dir = command33b(); }
706 elsif ( $command == 4 ) { $dir_hash_level = command33c(); }
707 elsif ( $command == 5 ) { $default_left_size = command35(); }
708 elsif ( $command == 6 ) { $force_username_lowercase = command36(); }
709 elsif ( $command == 7 ) { $default_use_priority = command37(); }
710 elsif ( $command == 8 ) { $hide_sm_attributions = command38(); }
711 elsif ( $command == 9 ) { $default_use_mdn = command39(); }
712 elsif ( $command == 10 ) { $edit_identity = command310(); }
7c612fdd 713 elsif ( $command == 11 ) { $allow_thread_sort = command312(); }
aa0da530 714 elsif ( $command == 12 ) { $allow_server_sort = command313(); }
2eec12b5 715 elsif ( $command == 13 ) { $allow_charset_search = command314(); }
a2a7ac04 716 elsif ( $command == 14 ) { $session_name = command316(); }
eaace00e 717 } elsif ( $menu == 5 ) {
718 if ( $command == 1 ) { command41(); }
719 elsif ( $command == 2 ) { $theme_css = command42(); }
720 } elsif ( $menu == 6 ) {
721 if ( $command == 1 ) { command61(); }
722 elsif ( $command == 2 ) { command62(); }
723 } elsif ( $menu == 7 ) {
724 if ( $command == 1 ) { $motd = command71(); }
725 } elsif ( $menu == 8 ) {
726 if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
eaace00e 727 } elsif ( $menu == 9 ) {
99a6c222 728 if ( $command == 1 ) { $addrbook_dsn = command91(); }
729 elsif ( $command == 2 ) { $addrbook_table = command92(); }
730 elsif ( $command == 3 ) { $prefs_dsn = command93(); }
731 elsif ( $command == 4 ) { $prefs_table = command94(); }
732 elsif ( $command == 5 ) { $prefs_user_field = command95(); }
733 elsif ( $command == 6 ) { $prefs_key_field = command96(); }
734 elsif ( $command == 7 ) { $prefs_val_field = command97(); }
eaace00e 735 }
736 }
828b4753 737}
738
739####################################################################################
740
5b6ae78a 741# org_name
742sub command1 {
eaace00e 743 print "We have tried to make the name SquirrelMail as transparent as\n";
744 print "possible. If you set up an organization name, most places where\n";
745 print "SquirrelMail would take credit will be credited to your organization.\n";
746 print "\n";
360ef370 747 print "If your Organization Name includes a '\$', please precede it with a \\. \n";
748 print "Other '\$' will be considered the beginning of a variable that\n";
749 print "must be defined before the \$org_name is printed.\n";
750 print "\$version, for example, is included by default, and will print the\n";
751 print "string representing the current SquirrelMail version.\n";
752 print "\n";
eaace00e 753 print "[$WHT$org_name$NRM]: $WHT";
754 $new_org_name = <STDIN>;
755 if ( $new_org_name eq "\n" ) {
756 $new_org_name = $org_name;
757 } else {
758 $new_org_name =~ s/[\r|\n]//g;
d756b071 759 $new_org_name =~ s/\"/&quot;/g;
eaace00e 760 }
761 return $new_org_name;
5b6ae78a 762}
763
764# org_logo
765sub command2 {
eaace00e 766 print "Your organization's logo is an image that will be displayed at\n";
25be56ab 767 print "different times throughout SquirrelMail. ";
768 print "\n";
769 print "Please be aware of the following: \n";
770 print " - Relative URLs are relative to the config dir\n";
771 print " to use the default logo, use ../images/sm_logo.png\n";
772 print " - To specify a logo defined outside the SquirrelMail source tree\n";
773 print " use the absolute URL the webserver would use to include the file\n";
774 print " e.g. http://some.host.com/images/mylogo.gif or /images/mylogo.jpg\n";
eaace00e 775 print "\n";
776 print "[$WHT$org_logo$NRM]: $WHT";
777 $new_org_logo = <STDIN>;
778 if ( $new_org_logo eq "\n" ) {
779 $new_org_logo = $org_logo;
780 } else {
781 $new_org_logo =~ s/[\r|\n]//g;
782 }
783 return $new_org_logo;
5b6ae78a 784}
785
b6e0c3b6 786# org_logo_width
787sub command2a {
788 print "Your organization's logo is an image that will be displayed at\n";
789 print "different times throughout SquirrelMail. Width\n";
790 print "and Height of your logo image. Use '0' to disable.\n";
791 print "\n";
792 print "Width: [$WHT$org_logo_width$NRM]: $WHT";
793 $new_org_logo_width = <STDIN>;
794 $new_org_logo_width =~ tr/0-9//cd; # only want digits!
795 if ( $new_org_logo_width eq '' ) {
796 $new_org_logo_width = $org_logo_width;
797 }
0e21688d 798 if ( $new_org_logo_width > 0 ) {
799 print "Height: [$WHT$org_logo_height$NRM]: $WHT";
800 $new_org_logo_height = <STDIN>;
801 $new_org_logo_height =~ tr/0-9//cd; # only want digits!
e03345e1 802 if( $new_org_logo_height eq '' ) {
803 $new_org_logo_height = $org_logo_height;
804 }
00c4b08d 805 } else {
0e21688d 806 $new_org_logo_height = 0;
b6e0c3b6 807 }
808 return ($new_org_logo_width, $new_org_logo_height);
809}
810
5b6ae78a 811# org_title
812sub command3 {
eaace00e 813 print "A title is what is displayed at the top of the browser window in\n";
814 print "the titlebar. Usually this will end up looking something like:\n";
815 print "\"Netscape: $org_title\"\n";
816 print "\n";
360ef370 817 print "If your Organization Title includes a '\$', please precede it with a \\. \n";
818 print "Other '\$' will be considered the beginning of a variable that\n";
819 print "must be defined before the \$org_title is printed.\n";
820 print "\$version, for example, is included by default, and will print the\n";
821 print "string representing the current SquirrelMail version.\n";
822 print "\n";
eaace00e 823 print "[$WHT$org_title$NRM]: $WHT";
824 $new_org_title = <STDIN>;
825 if ( $new_org_title eq "\n" ) {
826 $new_org_title = $org_title;
827 } else {
828 $new_org_title =~ s/[\r|\n]//g;
d756b071 829 $new_org_title =~ s/\"/\'/g;
eaace00e 830 }
831 return $new_org_title;
5b6ae78a 832}
5b6ae78a 833
f923b93d 834# signout_page
835sub command4 {
eaace00e 836 print "When users click the Sign Out button they will be logged out and\n";
837 print "then sent to signout_page. If signout_page is left empty,\n";
838 print "(hit space and then return) they will be taken, as normal,\n";
839 print "to the default and rather sparse SquirrelMail signout page.\n";
840 print "\n";
841 print "[$WHT$signout_page$NRM]: $WHT";
842 $new_signout_page = <STDIN>;
843 if ( $new_signout_page eq "\n" ) {
844 $new_signout_page = $signout_page;
845 } else {
846 $new_signout_page =~ s/[\r|\n]//g;
847 $new_signout_page =~ s/^\s+$//g;
848 }
849 return $new_signout_page;
6ef7145f 850}
851
852# Default language
853sub command5 {
eaace00e 854 print "SquirrelMail attempts to set the language in many ways. If it\n";
855 print "can not figure it out in another way, it will default to this\n";
e1e4f932 856 print "language. Please use the code for the desired language.\n";
eaace00e 857 print "\n";
858 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
859 $new_signout_page = <STDIN>;
860 if ( $new_signout_page eq "\n" ) {
861 $new_signout_page = $squirrelmail_default_language;
862 } else {
863 $new_signout_page =~ s/[\r|\n]//g;
864 $new_signout_page =~ s/^\s+$//g;
865 }
866 return $new_signout_page;
f923b93d 867}
868
80e86e94 869# Default top frame
870sub command6 {
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";
873 print "is '_top'\n";
874 print "\n";
875 print "[$WHT$frame_top$NRM]: $WHT";
876 $new_frame_top = <STDIN>;
eaace00e 877 if ( $new_frame_top eq "\n" ) {
80e86e94 878 $new_frame_top = '_top';
879 } else {
880 $new_frame_top =~ s/[\r|\n]//g;
881 $new_frame_top =~ s/^\s+$//g;
882 }
883 return $new_frame_top;
884}
885
0ae4c1f2 886# Default link to provider
887sub command7 {
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";
890 print "\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/';
895 } else {
896 $new_provider_uri =~ s/[\r|\n]//g;
897 $new_provider_uri =~ s/^\s+$//g;
898 }
7b6563c0 899 return $new_provider_uri;
0ae4c1f2 900}
901
902sub command8 {
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";
905 print "\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';
910 } else {
911 $new_provider_name =~ s/[\r|\n]//g;
912 $new_provider_name =~ s/^\s+$//g;
913 }
7b6563c0 914 return $new_provider_name;
0ae4c1f2 915}
916
828b4753 917####################################################################################
5b6ae78a 918
828b4753 919# domain
920sub command11 {
e1e4f932 921 print "The domain name is the suffix at the end of all email addresses. If\n";
eaace00e 922 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
923 print "would be myorg.com.\n";
924 print "\n";
925 print "[$WHT$domain$NRM]: $WHT";
926 $new_domain = <STDIN>;
927 if ( $new_domain eq "\n" ) {
928 $new_domain = $domain;
929 } else {
930 $new_domain =~ s/[\r|\n]//g;
931 }
932 return $new_domain;
828b4753 933}
5b6ae78a 934
828b4753 935# imapServerAddress
936sub command12 {
47a29326 937 print "This is the hostname where your IMAP server can be contacted.\n";
eaace00e 938 print "[$WHT$imapServerAddress$NRM]: $WHT";
939 $new_imapServerAddress = <STDIN>;
940 if ( $new_imapServerAddress eq "\n" ) {
941 $new_imapServerAddress = $imapServerAddress;
942 } else {
943 $new_imapServerAddress =~ s/[\r|\n]//g;
944 }
945 return $new_imapServerAddress;
828b4753 946}
5b6ae78a 947
828b4753 948# imapPort
949sub command13 {
eaace00e 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;
955 } else {
956 $new_imapPort =~ s/[\r|\n]//g;
957 }
958 return $new_imapPort;
828b4753 959}
960
961# useSendmail
962sub command14 {
eaace00e 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";
968 } else {
969 $default_value = "2";
970 }
971 print "\n";
972 print " 1. Sendmail\n";
973 print " 2. SMTP\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";
979 } else {
980 $useSendmail = "false";
981 }
982 return $useSendmail;
828b4753 983}
5b6ae78a 984
828b4753 985# sendmail_path
986sub command15 {
eaace00e 987 if ( $sendmail_path[0] !~ /./ ) {
988 $sendmail_path = "/usr/sbin/sendmail";
989 }
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;
995 } else {
996 $new_sendmail_path =~ s/[\r|\n]//g;
997 }
998 return $new_sendmail_path;
828b4753 999}
5b6ae78a 1000
828b4753 1001# smtpServerAddress
1002sub command16 {
47a29326 1003 print "This is the hostname of your SMTP server.\n";
eaace00e 1004 print "[$WHT$smtpServerAddress$NRM]: $WHT";
1005 $new_smtpServerAddress = <STDIN>;
1006 if ( $new_smtpServerAddress eq "\n" ) {
1007 $new_smtpServerAddress = $smtpServerAddress;
1008 } else {
1009 $new_smtpServerAddress =~ s/[\r|\n]//g;
1010 }
1011 return $new_smtpServerAddress;
828b4753 1012}
1013
1014# smtpPort
1015sub command17 {
eaace00e 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;
1021 } else {
1022 $new_smtpPort =~ s/[\r|\n]//g;
1023 }
1024 return $new_smtpPort;
bbd30ac8 1025}
d2f4c914 1026
1027# authenticated server
a93b12ba 1028sub command18 {
47a29326 1029 return;
1030 # This sub disabled by tassium - it has been replaced with smtp_auth_mech
eaace00e 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";
1034
1035 $YesNo = 'n';
1036 $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" );
1037
1038 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
1039
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;
1045}
d2f4c914 1046
2044f95a 1047# pop before SMTP
1048sub command18a {
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";
1051
1052 $YesNo = 'n';
1053 $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
1054
1055 print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
1056
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;
1062}
1063
d2f4c914 1064# imap_server_type
1065sub command19 {
eaace00e 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";
d50e52d1 1076 print " macosx = Mac OS X Mailserver\n";
eaace00e 1077 print " other = Not one of the above servers\n";
1078 print "[$WHT$imap_server_type$NRM]: $WHT";
1079 $new_imap_server_type = <STDIN>;
1080
1081 if ( $new_imap_server_type eq "\n" ) {
1082 $new_imap_server_type = $imap_server_type;
1083 } else {
1084 $new_imap_server_type =~ s/[\r|\n]//g;
1085 }
1086 return $new_imap_server_type;
a93b12ba 1087}
3f8fe68e 1088
d47b2518 1089# invert_time
d2f4c914 1090sub command110 {
eaace00e 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";
1099
1100 $YesNo = 'n';
1101 $YesNo = 'y' if ( lc($invert_time) eq "true" );
1102
1103 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
1104
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;
1110}
d47b2518 1111
d2f4c914 1112sub command111 {
eaace00e 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>;
1122
1123 if ( $new_optional_delimiter eq "\n" ) {
1124 $new_optional_delimiter = $optional_delimiter;
1125 } else {
1126 $new_optional_delimiter =~ s/[\r|\n]//g;
1127 }
1128 return $new_optional_delimiter;
40ba4d36 1129}
b47821fb 1130# IMAP authentication type
33feaaec 1131# Possible values: login, plain, cram-md5, digest-md5
b47821fb 1132# Now offers to detect supported mechs, assuming server & port are set correctly
1133
1134sub command112a {
80e3fcf8 1135 if ($use_imap_tls =~ /^true\b/i) {
1136 print "Auto-detection of login methods is unavailable when using TLS.\n";
1137 } else {
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]: ";
1144 $inval=<STDIN>;
1145 chomp($inval);
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";
1155 } else {
1156 print "$WHT NOT SUPPORTED$NRM\n";
1157 }
1158 } else {
1159 print $WHT . " ERROR DETECTING$NRM\n";
1160 }
1161
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";
1167 } else {
1168 print "$WHT NOT SUPPORTED$NRM\n";
1169 }
1170 } else {
1171 print $WHT . " ERROR DETECTING$NRM\n";
1172 }
1173
1174 }
1175 }
b47821fb 1176 print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
fe0b18b3 1177 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
33feaaec 1178 print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
fe0b18b3 1179 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
639c7164 1180 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
b47821fb 1181 print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
fe0b18b3 1182 print "If you don't understand or are unsure, you probably want \"login\"\n\n";
33feaaec 1183 print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
b47821fb 1184 $inval=<STDIN>;
1185 chomp($inval);
33feaaec 1186 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
b47821fb 1187 return lc($inval);
1188 } else {
1189 # user entered garbage or default value so nothing needs to be set
1190 return $imap_auth_mech;
1191 }
1192}
40ba4d36 1193
b47821fb 1194
1195# SMTP authentication type
1196# Possible choices: none, plain, cram-md5, digest-md5
1197sub command112b {
80e3fcf8 1198 if ($use_smtp_tls =~ /^true\b/i) {
1199 print "Auto-detection of login methods is unavailable when using TLS.\n";
1200 } else {
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]: ";
1205 $inval=<STDIN>;
1206 chomp($inval);
1207 if ($inval =~ /^y\b/i) {
1208 # Yes, let's try to detect.
1209 print "Trying to detect supported methods (SMTP)...\n";
b47821fb 1210
80e3fcf8 1211 # Special case!
1212 # Check none by trying to relay to junk@microsoft.com
1213 $host = $smtpServerAddress . ':' . $smtpPort;
1214 use IO::Socket;
1215 my $sock = IO::Socket::INET->new($host);
1216 print "Testing none:\t\t$WHT";
1217 if (!defined($sock)) {
1218 print " ERROR TESTING\n";
1219 close $sock;
1220 } else {
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";
1227 } else {
1228 print "NOT SUPPORTED$NRM\n";
1229 }
1230 print $sock "rset\n";
1231 print $sock "quit\n";
1232 close $sock;
1233 }
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";
1240 } else {
1241 print $WHT . "NOT SUPPORTED$NRM\n";
1242 }
1243 } else {
1244 print $WHT . "ERROR DETECTING$NRM\n";
1245 }
1246
1247 # Try CRAM-MD5
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";
1253 } else {
1254 print $WHT . "NOT SUPPORTED$NRM\n";
1255 }
1256 } else {
1257 print $WHT . "ERROR DETECTING$NRM\n";
b47821fb 1258 }
80e3fcf8 1259
1260
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";
1266 } else {
1267 print $WHT . "NOT SUPPORTED$NRM\n";
1268 }
1269 } else {
1270 print $WHT . "ERROR DETECTING$NRM\n";
b47821fb 1271 }
80e3fcf8 1272 }
1273 }
1274 print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
b47821fb 1275 print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
fe0b18b3 1276 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
33feaaec 1277 print $WHT . "plain" . $NRM . " - SASL PLAIN. You already know it if you need this.\n";
639c7164 1278 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1279 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
fe0b18b3 1280 print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
b47821fb 1281 print "If you don't understand or are unsure, you probably want \"none\"\n\n";
fe0b18b3 1282 print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
47a29326 1283 $inval=<STDIN>;
1284 chomp($inval);
b47821fb 1285 if ($inval =~ /^none\b/i) {
47a29326 1286 # SMTP doesn't necessarily require logins
1287 return "none";
1288 }
1289 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
33feaaec 1290 ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
47a29326 1291 return lc($inval);
1292 } else {
b47821fb 1293 # user entered garbage, or default value so nothing needs to be set
1c6d997a 1294 return $smtp_auth_mech;
47a29326 1295 }
1296}
1297
1298# TLS
1299# This sub is reused for IMAP and SMTP
1300# Args: service name, default value
1301sub command113 {
1302 my($default_val,$service,$inval);
1303 $service=$_[0];
1304 $default_val=$_[1];
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") {
1313 print "y";
1314 } else {
1315 print "n";
1316 }
1317 print "$NRM]: $WHT";
1318 $inval=<STDIN>;
1319 $inval =~ tr/yn//cd;
1320 return "true" if ( $inval eq "y" );
1321 return "false" if ( $inval eq "n" );
1322 return $default_val;
1323
1324
1325}
1326
1327
3f8fe68e 1328# MOTD
1329sub command71 {
eaace00e 1330 print "\nYou can now create the welcome message that is displayed\n";
1331 print "every time a user logs on. You can use HTML or just plain\n";
1332 print
1333"text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1334
1335 $new_motd = "";
1336 do {
1337 print "] ";
1338 $line = <STDIN>;
1339 $line =~ s/[\r|\n]//g;
1340 if ( $line ne "@" ) {
1341 $line =~ s/ /\&nbsp;\&nbsp;/g;
1342 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
1343 $line =~ s/$/ /;
d756b071 1344 $line =~ s/\"/&quot;/g;
eaace00e 1345
1346 $new_motd = $new_motd . $line;
1347 }
1348 } while ( $line ne "@" );
1349 return $new_motd;
3f8fe68e 1350}
911ad01c 1351
9d0c7bee 1352################# PLUGINS ###################
1353
1354sub command81 {
eaace00e 1355 $command =~ s/[\s|\n|\r]*//g;
1356 if ( $command > 0 ) {
1357 $command = $command - 1;
1358 if ( $command <= $#plugins ) {
1359 @newplugins = ();
1360 $ct = 0;
1361 while ( $ct <= $#plugins ) {
1362 if ( $ct != $command ) {
1363 @newplugins = ( @newplugins, $plugins[$ct] );
1364 }
1365 $ct++;
9d0c7bee 1366 }
eaace00e 1367 @plugins = @newplugins;
1368 } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
1369 $num = $command - $#plugins - 1;
1370 @newplugins = @plugins;
1371 $ct = 0;
1372 while ( $ct <= $#unused_plugins ) {
1373 if ( $ct == $num ) {
1374 @newplugins = ( @newplugins, $unused_plugins[$ct] );
eaace00e 1375 }
1376 $ct++;
9d0c7bee 1377 }
eaace00e 1378 @plugins = @newplugins;
1379 }
1380 }
1381 return @plugins;
1382}
9d0c7bee 1383
911ad01c 1384################# FOLDERS ###################
1385
1386# default_folder_prefix
1387sub command21 {
eaace00e 1388 print "Some IMAP servers (UW, for example) store mail and folders in\n";
1389 print "your user space in a separate subdirectory. This is where you\n";
1390 print "specify what that directory is.\n";
1391 print "\n";
1392 print "EXAMPLE: mail/";
1393 print "\n";
1394 print "NOTE: If you use Cyrus, or some server that would not use this\n";
1395 print " option, you must set this to 'none'.\n";
1396 print "\n";
1397 print "[$WHT$default_folder_prefix$NRM]: $WHT";
1398 $new_default_folder_prefix = <STDIN>;
1399
1400 if ( $new_default_folder_prefix eq "\n" ) {
1401 $new_default_folder_prefix = $default_folder_prefix;
1402 } else {
d52532d5 1403 $new_default_folder_prefix =~ s/[\r\n]//g;
eaace00e 1404 }
d52532d5 1405 if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
eaace00e 1406 $new_default_folder_prefix = "";
1407 } else {
d52532d5 1408 # add the trailing delimiter only if we know what the server is.
ce9f808b 1409 if (($imap_server_type eq 'cyrus' and
1410 $optional_delimiter eq 'detect') or
1411 ($imap_server_type eq 'courier' and
1412 $optional_delimiter eq 'detect')) {
d52532d5 1413 $new_default_folder_prefix =~ s/\.*$/\./;
ce9f808b 1414 } elsif ($imap_server_type eq 'uw' and
1415 $optional_delimiter eq 'detect') {
d52532d5 1416 $new_default_folder_prefix =~ s/\/*$/\//;
0e21688d 1417 }
eaace00e 1418 }
1419 return $new_default_folder_prefix;
911ad01c 1420}
1421
1422# Show Folder Prefix
1423sub command22 {
eaace00e 1424 print "It is possible to set up the default folder prefix as a user\n";
1425 print "specific option, where each user can specify what their mail\n";
1426 print "folder is. If you set this to false, they will never see the\n";
1427 print "option, but if it is true, this option will appear in the\n";
1428 print "'options' section.\n";
1429 print "\n";
1430 print "NOTE: You set the default folder prefix in option '1' of this\n";
1431 print " section. That will be the default if the user doesn't\n";
1432 print " specify anything different.\n";
1433 print "\n";
1434
1435 if ( lc($show_prefix_option) eq "true" ) {
1436 $default_value = "y";
1437 } else {
1438 $default_value = "n";
1439 }
1440 print "\n";
1441 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1442 $new_show = <STDIN>;
1443 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1444 $show_prefix_option = "true";
1445 } else {
1446 $show_prefix_option = "false";
1447 }
1448 return $show_prefix_option;
911ad01c 1449}
1450
1451# Trash Folder
f7b1b3b1 1452sub command23a {
eaace00e 1453 print "You can now specify where the default trash folder is located.\n";
1454 print "On servers where you do not want this, you can set it to anything\n";
1455 print "and set option 6 to false.\n";
1456 print "\n";
1457 print "This is relative to where the rest of your email is kept. You do\n";
1458 print "not need to worry about their mail directory. If this folder\n";
1459 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1460 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1461 print "\n";
1462
1463 print "[$WHT$trash_folder$NRM]: $WHT";
1464 $new_trash_folder = <STDIN>;
1465 if ( $new_trash_folder eq "\n" ) {
1466 $new_trash_folder = $trash_folder;
1467 } else {
1468 $new_trash_folder =~ s/[\r|\n]//g;
1469 }
1470 return $new_trash_folder;
911ad01c 1471}
1472
1473# Sent Folder
f7b1b3b1 1474sub command23b {
eaace00e 1475 print "This is where messages that are sent will be stored. SquirrelMail\n";
1476 print "by default puts a copy of all outgoing messages in this folder.\n";
1477 print "\n";
1478 print "This is relative to where the rest of your email is kept. You do\n";
1479 print "not need to worry about their mail directory. If this folder\n";
1480 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1481 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1482 print "\n";
1483
1484 print "[$WHT$sent_folder$NRM]: $WHT";
1485 $new_sent_folder = <STDIN>;
1486 if ( $new_sent_folder eq "\n" ) {
1487 $new_sent_folder = $sent_folder;
1488 } else {
1489 $new_sent_folder =~ s/[\r|\n]//g;
1490 }
1491 return $new_sent_folder;
911ad01c 1492}
1493
f7b1b3b1 1494# Draft Folder
1495sub command23c {
eaace00e 1496 print "You can now specify where the default draft folder is located.\n";
1497 print "On servers where you do not want this, you can set it to anything\n";
1498 print "and set option 9 to false.\n";
1499 print "\n";
1500 print "This is relative to where the rest of your email is kept. You do\n";
1501 print "not need to worry about their mail directory. If this folder\n";
1502 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1503 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1504 print "\n";
1505
1506 print "[$WHT$draft_folder$NRM]: $WHT";
1507 $new_draft_folder = <STDIN>;
1508 if ( $new_draft_folder eq "\n" ) {
1509 $new_draft_folder = $draft_folder;
1510 } else {
1511 $new_draft_folder =~ s/[\r|\n]//g;
1512 }
1513 return $new_draft_folder;
f7b1b3b1 1514}
1515
2f287147 1516# default move to trash
f7b1b3b1 1517sub command24a {
eaace00e 1518 print "By default, should messages get moved to the trash folder? You\n";
1519 print "can specify the default trash folder in option 3. If this is set\n";
1520 print "to false, messages will get deleted immediately without moving\n";
1521 print "to the trash folder.\n";
1522 print "\n";
1523 print "Trash folder is currently: $trash_folder\n";
1524 print "\n";
1525
1526 if ( lc($default_move_to_trash) eq "true" ) {
1527 $default_value = "y";
1528 } else {
1529 $default_value = "n";
1530 }
1531 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1532 $new_show = <STDIN>;
1533 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1534 $default_move_to_trash = "true";
1535 } else {
1536 $default_move_to_trash = "false";
1537 }
1538 return $default_move_to_trash;
2f287147 1539}
1540
1541# default move to sent
f7b1b3b1 1542sub command24b {
eaace00e 1543 print "By default, should messages get moved to the sent folder? You\n";
1544 print "can specify the default sent folder in option 4. If this is set\n";
1545 print "to false, messages will get sent and no copy will be made.\n";
1546 print "\n";
6517cfd0 1547 print "Sent folder is currently: $sent_folder\n";
eaace00e 1548 print "\n";
1549
1550 if ( lc($default_move_to_sent) eq "true" ) {
1551 $default_value = "y";
1552 } else {
1553 $default_value = "n";
1554 }
1555 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1556 $new_show = <STDIN>;
1557 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1558 $default_move_to_sent = "true";
1559 } else {
1560 $default_move_to_sent = "false";
1561 }
1562 return $default_move_to_sent;
2f287147 1563}
1564
f7b1b3b1 1565# default save as draft
1566sub command24c {
eaace00e 1567 print "By default, should the save to draft option be shown? You can\n";
1568 print "specify the default drafts folder in option 5. If this is set\n";
1569 print "to false, users will not be shown the save to draft option.\n";
1570 print "\n";
1571 print "Drafts folder is currently: $draft_folder\n";
1572 print "\n";
1573
1574 if ( lc($default_move_to_draft) eq "true" ) {
1575 $default_value = "y";
1576 } else {
1577 $default_value = "n";
1578 }
1579 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1580 $new_show = <STDIN>;
1581 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1582 $default_save_as_draft = "true";
1583 } else {
1584 $default_save_as_draft = "false";
1585 }
1586 return $default_save_as_draft;
f7b1b3b1 1587}
1588
2f287147 1589# List special folders first
1590sub command27 {
eaace00e 1591 print "SquirrelMail has what we call 'special folders' that are not\n";
1592 print "manipulated and viewed like normal folders. Some examples of\n";
1593 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1594 print "Simply asks if you want these folders listed first in the folder\n";
1595 print "listing.\n";
1596 print "\n";
1597
1598 if ( lc($list_special_folders_first) eq "true" ) {
1599 $default_value = "y";
1600 } else {
1601 $default_value = "n";
1602 }
1603 print "\n";
1604 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1605 $new_show = <STDIN>;
1606 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1607 $list_special_folders_first = "true";
1608 } else {
1609 $list_special_folders_first = "false";
1610 }
1611 return $list_special_folders_first;
911ad01c 1612}
1613
1614# Show special folders color
2f287147 1615sub command28 {
eaace00e 1616 print "SquirrelMail has what we call 'special folders' that are not\n";
1617 print "manipulated and viewed like normal folders. Some examples of\n";
1618 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1619 print "wants to know if we should display special folders in a\n";
1620 print "color than the other folders.\n";
1621 print "\n";
1622
1623 if ( lc($use_special_folder_color) eq "true" ) {
1624 $default_value = "y";
1625 } else {
1626 $default_value = "n";
1627 }
1628 print "\n";
1629 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1630 $new_show = <STDIN>;
1631 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1632 $use_special_folder_color = "true";
1633 } else {
1634 $use_special_folder_color = "false";
1635 }
1636 return $use_special_folder_color;
911ad01c 1637}
1638
911ad01c 1639# Auto expunge
2f287147 1640sub command29 {
eaace00e 1641 print "The way that IMAP handles deleting messages is as follows. You\n";
1642 print "mark the message as deleted, and then to 'really' delete it, you\n";
1643 print "expunge it. This option asks if you want to just have messages\n";
1644 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1645 print "messages too.\n";
1646 print "\n";
1647
1648 if ( lc($auto_expunge) eq "true" ) {
1649 $default_value = "y";
1650 } else {
1651 $default_value = "n";
1652 }
1653 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1654 $new_show = <STDIN>;
1655 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1656 $auto_expunge = "true";
1657 } else {
1658 $auto_expunge = "false";
1659 }
1660 return $auto_expunge;
911ad01c 1661}
1662
1663# Default sub of inbox
2f287147 1664sub command210 {
eaace00e 1665 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1666 print "This can cause some confusion in folder creation for users when\n";
1667 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1668 print "and get permission errors. This option asks if you want folders\n";
1669 print "to be subfolders of INBOX by default.\n";
1670 print "\n";
1671
1672 if ( lc($default_sub_of_inbox) eq "true" ) {
1673 $default_value = "y";
1674 } else {
1675 $default_value = "n";
1676 }
1677 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1678 $new_show = <STDIN>;
1679 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1680 $default_sub_of_inbox = "true";
1681 } else {
1682 $default_sub_of_inbox = "false";
1683 }
1684 return $default_sub_of_inbox;
911ad01c 1685}
1686
1687# Show contain subfolder option
2f287147 1688sub command211 {
eaace00e 1689 print "Some IMAP servers (UW) make it so that there are two types of\n";
1690 print "folders. Those that contain messages, and those that contain\n";
1691 print "subfolders. If this is the case for your server, set this to\n";
1692 print "true, and it will ask the user whether the folder they are\n";
1693 print "creating contains subfolders or messages.\n";
1694 print "\n";
1695
1696 if ( lc($show_contain_subfolders_option) eq "true" ) {
1697 $default_value = "y";
1698 } else {
1699 $default_value = "n";
1700 }
1701 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1702 $new_show = <STDIN>;
1703 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1704 $show_contain_subfolders_option = "true";
1705 } else {
1706 $show_contain_subfolders_option = "false";
1707 }
1708 return $show_contain_subfolders_option;
911ad01c 1709}
1710
24fc5dd2 1711# Default Unseen Notify
1712sub command212 {
eaace00e 1713 print "This option specifies where the users will receive notification\n";
1714 print "about unseen messages by default. This is of course an option that\n";
1715 print "can be changed on a user level.\n";
1716 print " 1 = No notification\n";
1717 print " 2 = Only on the INBOX\n";
1718 print " 3 = On all folders\n";
1719 print "\n";
1720
1721 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1722 $new_show = <STDIN>;
1723 if ( $new_show =~ /^[1|2|3]\n/i ) {
1724 $default_unseen_notify = $new_show;
1725 }
1726 $default_unseen_notify =~ s/[\r|\n]//g;
1727 return $default_unseen_notify;
24fc5dd2 1728}
1729
1730# Default Unseen Type
1731sub command213 {
eaace00e 1732 print "Here you can define the default way that unseen messages will be displayed\n";
1733 print "to the user in the folder listing on the left side.\n";
1734 print " 1 = Only unseen messages (4)\n";
1735 print " 2 = Unseen and Total messages (4/27)\n";
1736 print "\n";
1737
1738 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1739 $new_show = <STDIN>;
1740 if ( $new_show =~ /^[1|2]\n/i ) {
1741 $default_unseen_type = $new_show;
1742 }
1743 $default_unseen_type =~ s/[\r|\n]//g;
1744 return $default_unseen_type;
24fc5dd2 1745}
1746
f7bfc9de 1747# Auto create special folders
1748sub command214 {
eaace00e 1749 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1750 print "automatically print for you when a user logs in? If the user\n";
1751 print "accidentally deletes their special folders, this option will\n";
1752 print "automatically create it again for them.\n";
1753 print "\n";
1754
1755 if ( lc($auto_create_special) eq "true" ) {
1756 $default_value = "y";
1757 } else {
1758 $default_value = "n";
1759 }
1760 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1761 $new_show = <STDIN>;
1762 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1763 $auto_create_special = "true";
1764 } else {
1765 $auto_create_special = "false";
1766 }
1767 return $auto_create_special;
f7bfc9de 1768}
1769
2eec12b5 1770# Automatically delete folders
4e85a37f 1771sub command215 {
d04165f3 1772 if ( $imap_server_type eq "uw" ) {
1773 print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
1774 print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
98468fba 1775 print "If this is not the correct value for your server,\n";
1776 print "please use option D on the Main Menu to configure your server correctly.\n\n";
2eec12b5 1777 print "Press any key to continue...\n";
1778 $new_delete = <STDIN>;
1779 $delete_folder = "true";
1780 } else {
d04165f3 1781 if ( $imap_server_type eq "courier" ) {
1782 print "Courier (or Courier-IMAP) IMAP servers may not support ";
1783 print "subfolders of Trash. \n";
1784 print "Specifically, if Courier is set to always move messages to Trash, \n";
1785 print "Trash will be treated by Courier as a special folder that does not \n";
1786 print "allow subfolders. \n\n";
1787 print "Please verify your Courier configuration, and test folder deletion \n";
1788 print "when changing this setting.\n\n";
1789 }
1790
1791 print "Are subfolders of the Trash supported by your IMAP server?\n";
1792 print "If so, should deleted folders be sent to Trash?\n";
1793 print "If not, say no (deleted folders should not be sent to Trash)\n\n";
1794 # reversal of logic.
1795 # question was: Should folders be automatically deleted instead of sent to trash..
1796 # we've changed the question to make it more clear,
1797 # and are here handling that to avoid changing the answers..
2eec12b5 1798 if ( lc($delete_folder) eq "true" ) {
2eec12b5 1799 $default_value = "n";
d04165f3 1800 } else {
1801 $default_value = "y";
2eec12b5 1802 }
d04165f3 1803 print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
2eec12b5 1804 $new_delete = <STDIN>;
1805 if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2eec12b5 1806 $delete_folder = "false";
d04165f3 1807 } else {
1808 $delete_folder = "true";
2eec12b5 1809 }
eaace00e 1810 }
1811 return $delete_folder;
1812}
24fc5dd2 1813
ca85aabe 1814#noselect fix
1815sub command216 {
1816 print "Some IMAP server allow subfolders to exist even if the parent\n";
1817 print "folders do not. This fixes some problems with the folder list\n";
1818 print "when this is the case, causing the /NoSelect folders to be displayed\n";
1819 print "\n";
1820
1821 if ( lc($noselect_fix_enable) eq "true" ) {
1822 $default_value = "y";
1823 } else {
1824 $default_value = "n";
1825 }
1826 print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
1827 $noselect_fix_enable = <STDIN>;
1828 if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1829 $noselect_fix_enable = "true";
1830 } else {
1831 $noselect_fix_enable = "false";
1832 }
1833 return $noselect_fix_enable;
1834}
ccfb2029 1835############# GENERAL OPTIONS #####################
1836
1837# Default Charset
1838sub command31 {
eaace00e 1839 print "This option controls what character set is used when sending\n";
1840 print "mail and when sending HTML to the browser. Do not set this\n";
1841 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1842 print "to use KOI8-R, since this implementation is faster than most\n";
1843 print "of the alternatives\n";
1844 print "\n";
1845
1846 print "[$WHT$default_charset$NRM]: $WHT";
1847 $new_default_charset = <STDIN>;
1848 if ( $new_default_charset eq "\n" ) {
1849 $new_default_charset = $default_charset;
1850 } else {
1851 $new_default_charset =~ s/[\r|\n]//g;
1852 }
1853 return $new_default_charset;
ccfb2029 1854}
1855
ccfb2029 1856# Data directory
3392dc86 1857sub command33a {
e6566358 1858 print "Specify the location for your data directory.\n";
1859 print "The path name can be absolute or relative (to the config directory).\n";
1860 print "It doesn't matter. Here are two examples:\n";
1861 print " Absolute: /var/spool/data/\n";
1862 print " Relative: ../data/\n";
8bd9e0dd 1863 print "Relative paths to directories outside of the SquirrelMail distribution\n";
e6566358 1864 print "will be converted to their absolute path equivalents in config.php.\n\n";
1865 print "Note: There are potential security risks with having a writable directory\n";
1866 print "under the web server's root directory (ex: /home/httpd/html).\n";
1867 print "For this reason, it is recommended to put the data directory\n";
2eec12b5 1868 print "in an alternate location of your choice. \n";
1869 print "\n";
1870
eaace00e 1871 print "[$WHT$data_dir$NRM]: $WHT";
1872 $new_data_dir = <STDIN>;
1873 if ( $new_data_dir eq "\n" ) {
1874 $new_data_dir = $data_dir;
1875 } else {
1876 $new_data_dir =~ s/[\r|\n]//g;
1877 }
1878 if ( $new_data_dir =~ /^\s*$/ ) {
1879 $new_data_dir = "";
1880 } else {
1881 $new_data_dir =~ s/\/*$//g;
1882 $new_data_dir =~ s/$/\//g;
1883 }
1884 return $new_data_dir;
ccfb2029 1885}
1886
1887# Attachment directory
3392dc86 1888sub command33b {
eaace00e 1889 print "Path to directory used for storing attachments while a mail is\n";
e6566358 1890 print "being sent. The path name can be absolute or relative (to the config directory).\n";
1891 print "It doesn't matter. Here are two examples:\n";
1892 print " Absolute: /var/spool/attach/\n";
1893 print " Relative: ../attach/\n";
1894 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1895 print "will be converted to their absolute path equivalents in config.php.\n\n";
1896 print "Note: There are a few security considerations regarding this\n";
eaace00e 1897 print "directory:\n";
1898 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1899 print " impossible for a random person with access to the webserver\n";
1900 print " to list files in this directory. Confidential data might\n";
1901 print " be laying around in there.\n";
e6566358 1902 print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
1903 print " may be possible, and more secure (e.g. root:apache)\n";
eaace00e 1904 print " 2. Since the webserver is not able to list the files in the\n";
1905 print " content is also impossible for the webserver to delete files\n";
1906 print " lying around there for too long.\n";
1907 print " 3. It should probably be another directory than the data\n";
1908 print " directory specified in option 3.\n";
1909 print "\n";
1910
1911 print "[$WHT$attachment_dir$NRM]: $WHT";
1912 $new_attachment_dir = <STDIN>;
1913 if ( $new_attachment_dir eq "\n" ) {
1914 $new_attachment_dir = $attachment_dir;
1915 } else {
1916 $new_attachment_dir =~ s/[\r|\n]//g;
1917 }
1918 if ( $new_attachment_dir =~ /^\s*$/ ) {
1919 $new_attachment_dir = "";
1920 } else {
1921 $new_attachment_dir =~ s/\/*$//g;
1922 $new_attachment_dir =~ s/$/\//g;
1923 }
1924 return $new_attachment_dir;
ccfb2029 1925}
1926
3392dc86 1927sub command33c {
eaace00e 1928 print "The directory hash level setting allows you to configure the level\n";
1929 print "of hashing that Squirremail employs in your data and attachment\n";
1930 print "directories. This value must be an integer ranging from 0 to 4.\n";
1931 print "When this value is set to 0, Squirrelmail will simply store all\n";
1932 print "files as normal in the data and attachment directories. However,\n";
1933 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1934 print "used to organize the files in this directory. In short, the crc32\n";
1935 print "value for a username will be computed. Then, up to the first 4\n";
1936 print "digits of the hash, as set by this configuration value, will be\n";
1937 print "used to directory hash the files for that user in the data and\n";
1938 print "attachment directory. This allows for better performance on\n";
1939 print "servers with larger numbers of users.\n";
1940 print "\n";
1941
1942 print "[$WHT$dir_hash_level$NRM]: $WHT";
1943 $new_dir_hash_level = <STDIN>;
1944 if ( $new_dir_hash_level eq "\n" ) {
1945 $new_dir_hash_level = $dir_hash_level;
1946 } else {
1947 $new_dir_hash_level =~ s/[\r|\n]//g;
1948 }
1949 if ( ( int($new_dir_hash_level) < 0 )
1950 || ( int($new_dir_hash_level) > 4 )
1951 || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
1952 print "Invalid Directory Hash Level.\n";
1953 print "Value must be an integer ranging from 0 to 4\n";
1954 print "Hit enter to continue.\n";
1955 $enter_key = <STDIN>;
1956
1957 $new_dir_hash_level = $dir_hash_level;
1958 }
1959
1960 return $new_dir_hash_level;
3392dc86 1961}
ccfb2029 1962
1963sub command35 {
eaace00e 1964 print "This is the default size (in pixels) of the left folder list.\n";
1965 print "Default is 200, but you can set it to whatever you wish. This\n";
1966 print "is a user preference, so this will only show up as their default.\n";
1967 print "\n";
1968 print "[$WHT$default_left_size$NRM]: $WHT";
1969 $new_default_left_size = <STDIN>;
1970 if ( $new_default_left_size eq "\n" ) {
1971 $new_default_left_size = $default_left_size;
1972 } else {
1973 $new_default_left_size =~ s/[\r|\n]//g;
1974 }
1975 return $new_default_left_size;
ccfb2029 1976}
1977
985f7c88 1978sub command36 {
eaace00e 1979 print "Some IMAP servers only have lowercase letters in the usernames\n";
1980 print "but they still allow people with uppercase to log in. This\n";
1981 print "causes a problem with the user's preference files. This option\n";
1982 print "transparently changes all usernames to lowercase.";
1983 print "\n";
1984
1985 if ( lc($force_username_lowercase) eq "true" ) {
1986 $default_value = "y";
1987 } else {
1988 $default_value = "n";
1989 }
1990 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1991 $new_show = <STDIN>;
1992 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1993 return "true";
1994 }
1995 return "false";
985f7c88 1996}
1997
0d15cd19 1998sub command37 {
eaace00e 1999 print "";
2000 print "\n";
985f7c88 2001
eaace00e 2002 if ( lc($default_use_priority) eq "true" ) {
2003 $default_value = "y";
2004 } else {
2005 $default_value = "n";
2006 }
2007
2008 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
2009 $new_show = <STDIN>;
2010 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2011 return "true";
2012 }
2013 return "false";
826b7f71 2014}
2015
eaace00e 2016sub command38 {
2017 print "";
2018 print "\n";
2019
2020 if ( lc($default_hide_attribution) eq "true" ) {
2021 $default_value = "y";
2022 } else {
2023 $default_value = "n";
2024 }
2025
2026 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
2027 $new_show = <STDIN>;
2028 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2029 return "true";
2030 }
2031 return "false";
2032}
826b7f71 2033
8c21da0c 2034sub command39 {
eaace00e 2035 print "";
2036 print "\n";
2037
2038 if ( lc($default_use_mdn) eq "true" ) {
2039 $default_value = "y";
2040 } else {
2041 $default_value = "n";
2042 }
2043
2044 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
2045 $new_show = <STDIN>;
2046 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2047 return "true";
2048 }
2049 return "false";
8c21da0c 2050}
2051
8a7d0669 2052sub command310 {
2eec12b5 2053 print "This allows you to prevent the editing of the user's name and ";
2054 print "email address. This is mainly useful when used with the ";
8a7d0669 2055 print "retrieveuserdata plugin\n";
2056 print "\n";
eaace00e 2057
2058 if ( lc($edit_identity) eq "true" ) {
8a7d0669 2059 $default_value = "y";
2060 } else {
2061 $default_value = "n";
2062 }
2eec12b5 2063 print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
8a7d0669 2064 $new_edit = <STDIN>;
eaace00e 2065 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
8a7d0669 2066 $edit_identity = "true";
2eec12b5 2067 $edit_name = "true";
8a7d0669 2068 } else {
2069 $edit_identity = "false";
2eec12b5 2070 $edit_name = command311();
8a7d0669 2071 }
2072 return $edit_identity;
2073}
2074
2075sub command311 {
2eec12b5 2076 print "As a follow-up, this option allows you to choose if the user ";
2077 print "can edit their full name even when you don't want them to ";
2078 print "change their username\n";
8a7d0669 2079 print "\n";
2080
eaace00e 2081 if ( lc($edit_name) eq "true" ) {
8a7d0669 2082 $default_value = "y";
2083 } else {
2084 $default_value = "n";
2085 }
2086 print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
2087 $new_edit = <STDIN>;
eaace00e 2088 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
8a7d0669 2089 $edit_name = "true";
2090 } else {
2091 $edit_name = "false";
2092 }
2093 return $edit_name;
2094}
8c21da0c 2095
7c612fdd 2096sub command312 {
2097 print "This option allows you to choose if users can use thread sorting\n";
2098 print "Your IMAP server must support the THREAD command for this to work\n";
aa0da530 2099 print "PHP versions later than 4.0.3 recommended\n";
7c612fdd 2100 print "\n";
2101
2102 if ( lc($allow_thread_sort) eq "true" ) {
2103 $default_value = "y";
2104 } else {
2105 $default_value = "n";
2106 }
2107 print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2108 $allow_thread_sort = <STDIN>;
2109 if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2110 $allow_thread_sort = "true";
2111 } else {
2112 $allow_thread_sort = "false";
2113 }
2114 return $allow_thread_sort;
2115}
2116
aa0da530 2117sub command313 {
2118 print "This option allows you to choose if SM uses server-side sorting\n";
2119 print "Your IMAP server must support the SORT command for this to work\n";
2120 print "\n";
2121
2122 if ( lc($allow_server_sort) eq "true" ) {
2123 $default_value = "y";
2124 } else {
2125 $default_value = "n";
2126 }
2127 print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2128 $allow_server_sort = <STDIN>;
2129 if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2130 $allow_server_sort = "true";
2131 } else {
2132 $allow_server_sort = "false";
2133 }
2134 return $allow_server_sort;
2135}
2136
65ffb3ce 2137sub command314 {
2138 print "This option allows you to choose if SM uses charset search\n";
2139 print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2140 print "\n";
2141
2142 if ( lc($allow_charset_search) eq "true" ) {
2143 $default_value = "y";
2144 } else {
2145 $default_value = "n";
2146 }
2147 print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
2148 $allow_charset_search = <STDIN>;
2149 if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2150 $allow_charset_search = "true";
2151 } else {
2152 $allow_charset_search = "false";
2153 }
2154 return $allow_charset_search;
2155}
2156
3c7ee482 2157sub command315 {
a2a7ac04 2158 ## OBSOLETE - UID support is now always enabled
2159 return "true";
3c7ee482 2160 print "This option allows you to enable unique identifier (UID) support.\n";
2161 print "\n";
2162
2163 if ( lc($uid_support) eq "true" ) {
2164 $default_value = "y";
2165 } else {
2166 $default_value = "n";
2167 }
2168 print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
2169 $uid_support = <STDIN>;
2170 if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2171 $uid_support = "true";
2172 } else {
2173 $uid_support = "false";
2174 }
2175 return $uid_support;
2176}
2177
6c499577 2178sub command316 {
2179 print "This option allows you to change the name of the PHP session used\n";
2180 print "by SquirrelMail. Unless you know what you are doing, you probably\n";
2181 print "don't need or want to change this from the default of SQMSESSID.\n";
2182 print "[$WHT$session_name$NRM]: $WHT";
2183 $new_session_name = <STDIN>;
2184 chomp($new_session_name);
6614128e 2185 if ( $new_session_name eq "" ) {
6c499577 2186 $new_session_name = $session_name;
2187 }
2188 return $new_session_name;
2189}
2190
2191
65ffb3ce 2192
ccfb2029 2193sub command41 {
2eec12b5 2194 print "\nDefine the themes that you wish to use. If you have added ";
2195 print "a theme of your own, just follow the instructions (?) about how to add ";
eaace00e 2196 print "them. You can also change the default theme.\n";
2197 print "[theme] command (?=help) > ";
2198 $input = <STDIN>;
2199 $input =~ s/[\r|\n]//g;
2200 while ( $input ne "d" ) {
2201 if ( $input =~ /^\s*l\s*/i ) {
2202 $count = 0;
2203 while ( $count <= $#theme_name ) {
2204 if ( $count == $theme_default ) {
2205 print " *";
2206 } else {
2207 print " ";
2208 }
2eec12b5 2209 if ( $count < 10 ) {
2210 print " ";
2211 }
eaace00e 2212 $name = $theme_name[$count];
2eec12b5 2213 $num_spaces = 35 - length($name);
eaace00e 2214 for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
2215 $name = $name . " ";
2216 }
2217
2218 print " $count. $name";
2219 print "($theme_path[$count])\n";
2220
2221 $count++;
ccfb2029 2222 }
eaace00e 2223 } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
2224 $old_def = $theme_default;
2225 $theme_default = $input;
2226 $theme_default =~ s/^\s*m\s*//;
2227 if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
2228 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
2229 $theme_default = $old_def;
ccfb2029 2230 }
eaace00e 2231 } elsif ( $input =~ /^\s*\+/ ) {
2232 print "What is the name of this theme: ";
2233 $name = <STDIN>;
2234 $name =~ s/[\r|\n]//g;
2235 $theme_name[ $#theme_name + 1 ] = $name;
2236 print "Be sure to put ../themes/ before the filename.\n";
2237 print "What file is this stored in (ex: ../themes/default_theme.php): ";
2238 $name = <STDIN>;
2239 $name =~ s/[\r|\n]//g;
2240 $theme_path[ $#theme_path + 1 ] = $name;
2241 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2242 if ( $input =~ /[0-9]+\s*$/ ) {
2243 $rem_num = $input;
2244 $rem_num =~ s/^\s*-\s*//g;
2245 $rem_num =~ s/\s*$//;
2246 } else {
2247 $rem_num = $#theme_name;
ccfb2029 2248 }
eaace00e 2249 if ( $rem_num == $theme_default ) {
2250 print "You cannot remove the default theme!\n";
2251 } else {
2252 $count = 0;
2253 @new_theme_name = ();
2254 @new_theme_path = ();
2255 while ( $count <= $#theme_name ) {
2256 if ( $count != $rem_num ) {
2257 @new_theme_name = ( @new_theme_name, $theme_name[$count] );
2258 @new_theme_path = ( @new_theme_path, $theme_path[$count] );
2259 }
2260 $count++;
2261 }
2262 @theme_name = @new_theme_name;
2263 @theme_path = @new_theme_path;
2264 if ( $theme_default > $rem_num ) {
2265 $theme_default--;
2266 }
8442ac08 2267 }
eaace00e 2268 } elsif ( $input =~ /^\s*t\s*/i ) {
2269 print "\nStarting detection...\n\n";
2270
2271 opendir( DIR, "../themes" );
2272 @files = grep { /\.php$/i } readdir(DIR);
2273 $cnt = 0;
2274 while ( $cnt <= $#files ) {
2275 $filename = "../themes/" . $files[$cnt];
2276 if ( $filename ne "../themes/index.php" ) {
2277 $found = 0;
2278 for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
2279 if ( $theme_path[$x] eq $filename ) {
2280 $found = 1;
2281 }
2282 }
2283 if ( $found != 1 ) {
2284 print "** Found theme: $filename\n";
2285 print " What is its name? ";
2286 $nm = <STDIN>;
2287 $nm =~ s/[\n|\r]//g;
2288 $theme_name[ $#theme_name + 1 ] = $nm;
2289 $theme_path[ $#theme_path + 1 ] = $filename;
2290 }
2291 }
2292 $cnt++;
8442ac08 2293 }
eaace00e 2294 print "\n";
2295 for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
2296 $filename = $theme_path[$cnt];
2297 if ( !( -e $filename ) ) {
2298 print " Removing $filename (file not found)\n";
2299 $offset = 0;
2300 @new_theme_name = ();
2301 @new_theme_path = ();
2302 for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
2303 if ( $theme_path[$x] eq $filename ) {
2304 $offset = 1;
2305 }
2306 if ( $offset == 1 ) {
2307 $new_theme_name[$x] = $theme_name[ $x + 1 ];
2308 $new_theme_path[$x] = $theme_path[ $x + 1 ];
2309 } else {
2310 $new_theme_name[$x] = $theme_name[$x];
2311 $new_theme_path[$x] = $theme_path[$x];
2312 }
2313 }
2314 @theme_name = @new_theme_name;
2315 @theme_path = @new_theme_path;
2316 }
2317 }
2318 print "\nDetection complete!\n\n";
2319
2320 closedir DIR;
2321 } elsif ( $input =~ /^\s*\?\s*/ ) {
2322 print ".-------------------------.\n";
2323 print "| t (detect themes) |\n";
2324 print "| + (add theme) |\n";
2325 print "| - N (remove theme) |\n";
2326 print "| m N (mark default) |\n";
2327 print "| l (list themes) |\n";
2328 print "| d (done) |\n";
2329 print "`-------------------------'\n";
2330 }
2331 print "[theme] command (?=help) > ";
2332 $input = <STDIN>;
2333 $input =~ s/[\r|\n]//g;
2334 }
2335}
ccfb2029 2336
6f3bfa54 2337# Theme - CSS file
2338sub command42 {
eaace00e 2339 print "You may specify a cascading style-sheet (CSS) file to be included\n";
2340 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
2341 print "for specifying a site-wide font. If you're not familiar with CSS\n";
2342 print "files, leave this blank.\n";
2343 print "\n";
2344 print "To clear out an existing value, just type a space for the input.\n";
2345 print "\n";
25be56ab 2346 print "Please be aware of the following: \n";
2347 print " - Relative URLs are relative to the config dir\n";
2348 print " to use the themes directory, use ../themes/css/newdefault.css\n";
2349 print " - To specify a css file defined outside the SquirrelMail source tree\n";
2350 print " use the absolute URL the webserver would use to include the file\n";
2351 print " e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
8bd9e0dd 2352 print "\n";
eaace00e 2353 print "[$WHT$theme_css$NRM]: $WHT";
2354 $new_theme_css = <STDIN>;
6f3bfa54 2355
eaace00e 2356 if ( $new_theme_css eq "\n" ) {
2357 $new_theme_css = $theme_css;
2358 } else {
2359 $new_theme_css =~ s/[\r|\n]//g;
2360 }
2361 $new_theme_css =~ s/^\s*//;
2362 return $new_theme_css;
2363}
6f3bfa54 2364
1e0628fb 2365sub command61 {
eaace00e 2366 print "You can now define different LDAP servers.\n";
2367 print "[ldap] command (?=help) > ";
2368 $input = <STDIN>;
2369 $input =~ s/[\r|\n]//g;
2370 while ( $input ne "d" ) {
2371 if ( $input =~ /^\s*l\s*/i ) {
2372 $count = 0;
2373 while ( $count <= $#ldap_host ) {
2374 print "$count. $ldap_host[$count]\n";
2375 print " base: $ldap_base[$count]\n";
2376 if ( $ldap_charset[$count] ) {
2377 print " charset: $ldap_charset[$count]\n";
2378 }
2379 if ( $ldap_port[$count] ) {
2380 print " port: $ldap_port[$count]\n";
2381 }
2382 if ( $ldap_name[$count] ) {
2383 print " name: $ldap_name[$count]\n";
2384 }
2385 if ( $ldap_maxrows[$count] ) {
2386 print " maxrows: $ldap_maxrows[$count]\n";
2387 }
2388 print "\n";
2389 $count++;
a93b12ba 2390 }
eaace00e 2391 } elsif ( $input =~ /^\s*\+/ ) {
2392 $sub = $#ldap_host + 1;
2393
2394 print "First, we need to have the hostname or the IP address where\n";
2395 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
2396 print "hostname: ";
2397 $name = <STDIN>;
2398 $name =~ s/[\r|\n]//g;
2399 $ldap_host[$sub] = $name;
2400
2401 print "\n";
2402
2403 print "Next, we need the server root (base dn). For this, an empty\n";
2404 print "string is allowed.\n";
2405 print "Example: ou=member_directory,o=netcenter.com\n";
2406 print "base: ";
2407 $name = <STDIN>;
2408 $name =~ s/[\r|\n]//g;
2409 $ldap_base[$sub] = $name;
2410
2411 print "\n";
2412
2413 print "This is the TCP/IP port number for the LDAP server. Default\n";
2414 print "port is 389. This is optional. Press ENTER for default.\n";
2415 print "port: ";
2416 $name = <STDIN>;
2417 $name =~ s/[\r|\n]//g;
2418 $ldap_port[$sub] = $name;
2419
2420 print "\n";
2421
2422 print "This is the charset for the server. Default is utf-8. This\n";
2423 print "is also optional. Press ENTER for default.\n";
2424 print "charset: ";
2425 $name = <STDIN>;
2426 $name =~ s/[\r|\n]//g;
2427 $ldap_charset[$sub] = $name;
2428
2429 print "\n";
2430
2431 print "This is the name for the server, used to tag the results of\n";
2432 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
2433 print "name: ";
2434 $name = <STDIN>;
2435 $name =~ s/[\r|\n]//g;
2436 $ldap_name[$sub] = $name;
2437
2438 print "\n";
2439
2440 print "You can specify the maximum number of rows in the search result.\n";
2441 print "Default is unlimited. Press ENTER for default.\n";
2442 print "maxrows: ";
2443 $name = <STDIN>;
2444 $name =~ s/[\r|\n]//g;
2445 $ldap_maxrows[$sub] = $name;
2446
a93b12ba 2447 print "\n";
eaace00e 2448
2449 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2450 if ( $input =~ /[0-9]+\s*$/ ) {
2451 $rem_num = $input;
2452 $rem_num =~ s/^\s*-\s*//g;
2453 $rem_num =~ s/\s*$//;
2454 } else {
2455 $rem_num = $#ldap_host;
2456 }
2457 $count = 0;
2458 @new_ldap_host = ();
2459 @new_ldap_base = ();
2460 @new_ldap_port = ();
2461 @new_ldap_name = ();
2462 @new_ldap_charset = ();
2463 @new_ldap_maxrows = ();
2464
2465 while ( $count <= $#ldap_host ) {
2466 if ( $count != $rem_num ) {
2467 @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
2468 @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
2469 @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
2470 @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
2471 @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
2472 @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
2473 }
2474 $count++;
1e0628fb 2475 }
eaace00e 2476 @ldap_host = @new_ldap_host;
2477 @ldap_base = @new_ldap_base;
2478 @ldap_port = @new_ldap_port;
2479 @ldap_name = @new_ldap_name;
2480 @ldap_charset = @new_ldap_charset;
2481 @ldap_maxrows = @new_ldap_maxrows;
2482 } elsif ( $input =~ /^\s*\?\s*/ ) {
2483 print ".-------------------------.\n";
2484 print "| + (add host) |\n";
2485 print "| - N (remove host) |\n";
2486 print "| l (list hosts) |\n";
2487 print "| d (done) |\n";
2488 print "`-------------------------'\n";
2489 }
2490 print "[ldap] command (?=help) > ";
2491 $input = <STDIN>;
2492 $input =~ s/[\r|\n]//g;
2493 }
2494}
1e0628fb 2495
3806fa52 2496sub command62 {
eaace00e 2497 print "Some of our developers have come up with very good javascript interface\n";
2498 print "for searching through address books, however, our original goals said\n";
2499 print "that we would be 100% HTML. In order to make it possible to use their\n";
2500 print "interface, and yet stick with our goals, we have also written a plain\n";
2501 print "HTML version of the search. Here, you can choose which version to use.\n";
2502 print "\n";
2503 print "This is just the default value. It is also a user option that each\n";
2504 print "user can configure individually\n";
2505 print "\n";
2506
2507 if ( lc($default_use_javascript_addr_book) eq "true" ) {
2508 $default_value = "y";
2509 } else {
2510 $default_use_javascript_addr_book = "false";
2511 $default_value = "n";
2512 }
2513 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
2514 $new_show = <STDIN>;
2515 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2516 $default_use_javascript_addr_book = "true";
2517 } else {
2518 $default_use_javascript_addr_book = "false";
2519 }
2520 return $default_use_javascript_addr_book;
3806fa52 2521}
1e0628fb 2522
497203d4 2523sub command91 {
eaace00e 2524 print "If you want to store your users address book details in a database then\n";
2525 print "you need to set this DSN to a valid value. The format for this is:\n";
2526 print "mysql://user:pass\@hostname/dbname\n";
2527 print "Where mysql can be one of the databases PHP supports, the most common\n";
2528 print "of these are mysql, msql and pgsql\n";
2529 print "If the DSN is left empty (hit space and then return) the database\n";
2530 print "related code for address books will not be used\n";
2531 print "\n";
2532
2533 if ( $addrbook_dsn eq "" ) {
2534 $default_value = "Disabled";
2535 } else {
2536 $default_value = $addrbook_dsn;
2537 }
2538 print "[$WHT$addrbook_dsn$NRM]: $WHT";
2539 $new_dsn = <STDIN>;
2540 if ( $new_dsn eq "\n" ) {
2541 $new_dsn = "";
2542 } else {
2543 $new_dsn =~ s/[\r|\n]//g;
2544 $new_dsn =~ s/^\s+$//g;
2545 }
2546 return $new_dsn;
497203d4 2547}
ccfb2029 2548
4f40a59d 2549sub command92 {
eaace00e 2550 print "This is the name of the table you want to store the address book\n";
2551 print "data in, it defaults to 'address'\n";
2552 print "\n";
2553 print "[$WHT$addrbook_table$NRM]: $WHT";
2554 $new_table = <STDIN>;
2555 if ( $new_table eq "\n" ) {
2556 $new_table = $addrbook_table;
2557 } else {
2558 $new_table =~ s/[\r|\n]//g;
2559 }
2560 return $new_table;
4f40a59d 2561}
2562
3499f99f 2563sub command93 {
2564 print "If you want to store your users preferences in a database then\n";
2565 print "you need to set this DSN to a valid value. The format for this is:\n";
2566 print "mysql://user:pass\@hostname/dbname\n";
2567 print "Where mysql can be one of the databases PHP supports, the most common\n";
2568 print "of these are mysql, msql and pgsql\n";
2569 print "If the DSN is left empty (hit space and then return) the database\n";
2570 print "related code for address books will not be used\n";
2571 print "\n";
2572
eaace00e 2573 if ( $prefs_dsn eq "" ) {
3499f99f 2574 $default_value = "Disabled";
2575 } else {
2576 $default_value = $prefs_dsn;
2577 }
2578 print "[$WHT$prefs_dsn$NRM]: $WHT";
2579 $new_dsn = <STDIN>;
eaace00e 2580 if ( $new_dsn eq "\n" ) {
3499f99f 2581 $new_dsn = "";
2582 } else {
2583 $new_dsn =~ s/[\r|\n]//g;
2584 $new_dsn =~ s/^\s+$//g;
2585 }
2586 return $new_dsn;
2587}
2588
2589sub command94 {
2590 print "This is the name of the table you want to store the preferences\n";
99a6c222 2591 print "data in, it defaults to 'userprefs'\n";
3499f99f 2592 print "\n";
2593 print "[$WHT$prefs_table$NRM]: $WHT";
2594 $new_table = <STDIN>;
eaace00e 2595 if ( $new_table eq "\n" ) {
3499f99f 2596 $new_table = $prefs_table;
2597 } else {
2598 $new_table =~ s/[\r|\n]//g;
2599 }
2600 return $new_table;
eaace00e 2601}
3499f99f 2602
99a6c222 2603sub command95 {
2604 print "This is the name of the field in which you want to store the\n";
2605 print "username of the person the prefs are for. It default to 'user'\n";
2606 print "which clashes with a reserved keyword in PostgreSQL so this\n";
2607 print "will need to be changed for that database at least\n";
2608 print "\n";
2609 print "[$WHT$prefs_user_field$NRM]: $WHT";
2610 $new_field = <STDIN>;
2611 if ( $new_field eq "\n" ) {
2612 $new_field = $prefs_user_field;
2613 } else {
2614 $new_field =~ s/[\r|\n]//g;
2615 }
2616 return $new_field;
2617}
2618
2619sub command96 {
2620 print "This is the name of the field in which you want to store the\n";
2621 print "preferences keyword. It defaults to 'prefkey'\n";
2622 print "\n";
2623 print "[$WHT$prefs_key_field$NRM]: $WHT";
2624 $new_field = <STDIN>;
2625 if ( $new_field eq "\n" ) {
2626 $new_field = $prefs_key_field;
2627 } else {
2628 $new_field =~ s/[\r|\n]//g;
2629 }
2630 return $new_field;
2631}
2632
2633sub command97 {
2634 print "This is the name of the field in which you want to store the\n";
2635 print "preferences value. It defaults to 'prefval'\n";
2636 print "\n";
2637 print "[$WHT$prefs_val_field$NRM]: $WHT";
2638 $new_field = <STDIN>;
2639 if ( $new_field eq "\n" ) {
2640 $new_field = $prefs_val_field;
2641 } else {
2642 $new_field =~ s/[\r|\n]//g;
2643 }
2644 return $new_field;
2645}
2646
ccfb2029 2647sub save_data {
ebd13f55 2648 $tab = " ";
eaace00e 2649 if ( open( CF, ">config.php" ) ) {
ebd13f55 2650 print CF "<?php\n";
2651 print CF "\n";
eaace00e 2652
ebd13f55 2653 print CF "/**\n";
2654 print CF " * SquirrelMail Configuration File\n";
2655 print CF " * Created using the configure script, conf.pl\n";
2656 print CF " */\n";
2657 print CF "\n";
93c06fa2 2658 print CF "global \$version;\n";
2659
ebd13f55 2660 if ($print_config_version) {
eaace00e 2661 print CF "\$config_version = '$print_config_version';\n";
ebd13f55 2662 }
254ded61 2663 # integer
2664 print CF "\$config_use_color = $config_use_color;\n";
ebd13f55 2665 print CF "\n";
254ded61 2666
2667 # string
d756b071 2668 print CF "\$org_name = \"$org_name\";\n";
254ded61 2669 # string
8bd9e0dd 2670 print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
b6e0c3b6 2671 $org_logo_width |= 0;
2672 $org_logo_height |= 0;
254ded61 2673 # string
80519ece 2674 print CF "\$org_logo_width = '$org_logo_width';\n";
254ded61 2675 # string
2676 print CF "\$org_logo_height = '$org_logo_height';\n";
2677 # string that can contain variables.
12947430 2678 print CF "\$org_title = \"$org_title\";\n";
254ded61 2679 # string
8bd9e0dd 2680 print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
254ded61 2681 # string
3d043efc 2682 print CF "\$frame_top = '$frame_top';\n";
ebd13f55 2683 print CF "\n";
eaace00e 2684
0ae4c1f2 2685 print CF "\$provider_uri = '$provider_uri';\n";
2686 print CF "\n";
2687
2688 print CF "\$provider_name = '$provider_name';\n";
2689 print CF "\n";
2690
254ded61 2691 # string that can contain variables
2692 print CF "\$motd = \"$motd\";\n";
ebd13f55 2693 print CF "\n";
254ded61 2694
2695 # string
ebd13f55 2696 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
2697 print CF "\n";
eaace00e 2698
254ded61 2699 # string
ebd13f55 2700 print CF "\$domain = '$domain';\n";
254ded61 2701 # string
ebd13f55 2702 print CF "\$imapServerAddress = '$imapServerAddress';\n";
254ded61 2703 # integer
2704 print CF "\$imapPort = $imapPort;\n";
2705 # boolean
2706 print CF "\$useSendmail = $useSendmail;\n";
2707 # string
ebd13f55 2708 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
254ded61 2709 # integer
2710 print CF "\$smtpPort = $smtpPort;\n";
2711 # string
ebd13f55 2712 print CF "\$sendmail_path = '$sendmail_path';\n";
254ded61 2713 # boolean
47a29326 2714# print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
254ded61 2715 # boolean
2716 print CF "\$pop_before_smtp = $pop_before_smtp;\n";
2717 # string
ebd13f55 2718 print CF "\$imap_server_type = '$imap_server_type';\n";
254ded61 2719 # boolean
374726c9 2720 print CF "\$invert_time = $invert_time;\n";
254ded61 2721 # string
ebd13f55 2722 print CF "\$optional_delimiter = '$optional_delimiter';\n";
2723 print CF "\n";
eaace00e 2724
254ded61 2725 # string
ebd13f55 2726 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
254ded61 2727 # string
ebd13f55 2728 print CF "\$trash_folder = '$trash_folder';\n";
254ded61 2729 # string
ebd13f55 2730 print CF "\$sent_folder = '$sent_folder';\n";
254ded61 2731 # string
ebd13f55 2732 print CF "\$draft_folder = '$draft_folder';\n";
254ded61 2733 # boolean
2734 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
2735 # boolean
2736 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
2737 # boolean
2738 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
2739 # boolean
2740 print CF "\$show_prefix_option = $show_prefix_option;\n";
2741 # boolean
2742 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
2743 # boolean
2744 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
2745 # boolean
2746 print CF "\$auto_expunge = $auto_expunge;\n";
2747 # boolean
2748 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
2749 # boolean
2750 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
2751 # integer
2752 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
2753 # integer
2754 print CF "\$default_unseen_type = $default_unseen_type;\n";
2755 # boolean
2756 print CF "\$auto_create_special = $auto_create_special;\n";
2757 # boolean
2758 print CF "\$delete_folder = $delete_folder;\n";
ca85aabe 2759 # boolean
2760 print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
2761
ebd13f55 2762 print CF "\n";
eaace00e 2763
254ded61 2764 # string
ebd13f55 2765 print CF "\$default_charset = '$default_charset';\n";
254ded61 2766 # string
8bd9e0dd 2767 print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
254ded61 2768 # string that can contain a variable
8bd9e0dd 2769 print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
254ded61 2770 # integer
2771 print CF "\$dir_hash_level = $dir_hash_level;\n";
2772 # string
80519ece 2773 print CF "\$default_left_size = '$default_left_size';\n";
254ded61 2774 # boolean
2775 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
2776 # boolean
2777 print CF "\$default_use_priority = $default_use_priority;\n";
2778 # boolean
2779 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
2780 # boolean
2781 print CF "\$default_use_mdn = $default_use_mdn;\n";
2782 # boolean
2783 print CF "\$edit_identity = $edit_identity;\n";
2784 # boolean
2785 print CF "\$edit_name = $edit_name;\n";
2786 # boolean
2787 print CF "\$allow_thread_sort = $allow_thread_sort;\n";
2788 # boolean
2789 print CF "\$allow_server_sort = $allow_server_sort;\n";
65ffb3ce 2790 # boolean
3c7ee482 2791 print CF "\$allow_charset_search = $allow_charset_search;\n";
ebd13f55 2792 print CF "\n";
254ded61 2793
2794 # all plugins are strings
eaace00e 2795 for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
2796 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
ebd13f55 2797 }
2798 print CF "\n";
eaace00e 2799
254ded61 2800 # strings
8bd9e0dd 2801 print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
a73af766 2802 if ( $theme_default eq '' ) { $theme_default = '0'; }
57c6fabc 2803 print CF "\$theme_default = $theme_default;\n";
2804
eaace00e 2805 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
8bd9e0dd 2806 print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
eaace00e 2807 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
ebd13f55 2808 }
2809 print CF "\n";
eaace00e 2810
2811 if ( $default_use_javascript_addr_book ne "true" ) {
2812 $default_use_javascript_addr_book = "false";
2813 }
254ded61 2814
2815 # boolean
ebd13f55 2816 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
eaace00e 2817 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
2818 print CF "\$ldap_server[$count] = array(\n";
254ded61 2819 # string
eaace00e 2820 print CF " 'host' => '$ldap_host[$count]',\n";
254ded61 2821 # string
eaace00e 2822 print CF " 'base' => '$ldap_base[$count]'";
2823 if ( $ldap_name[$count] ) {
2824 print CF ",\n";
254ded61 2825 # string
eaace00e 2826 print CF " 'name' => '$ldap_name[$count]'";
2827 }
2828 if ( $ldap_port[$count] ) {
2829 print CF ",\n";
254ded61 2830 # integer
2831 print CF " 'port' => $ldap_port[$count]";
eaace00e 2832 }
2833 if ( $ldap_charset[$count] ) {
2834 print CF ",\n";
254ded61 2835 # string
eaace00e 2836 print CF " 'charset' => '$ldap_charset[$count]'";
2837 }
2838 if ( $ldap_maxrows[$count] ) {
2839 print CF ",\n";
254ded61 2840 # integer
2841 print CF " 'maxrows' => $ldap_maxrows[$count]";
eaace00e 2842 }
2843 print CF "\n";
2844 print CF ");\n";
2845 print CF "\n";
ebd13f55 2846 }
b622e1b8 2847
254ded61 2848 # string
4f40a59d 2849 print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
254ded61 2850 # string
4f40a59d 2851 print CF "\$addrbook_table = '$addrbook_table';\n\n";
254ded61 2852 # string
3499f99f 2853 print CF "\$prefs_dsn = '$prefs_dsn';\n";
254ded61 2854 # string
99a6c222 2855 print CF "\$prefs_table = '$prefs_table';\n";
254ded61 2856 # string
99a6c222 2857 print CF "\$prefs_user_field = '$prefs_user_field';\n";
254ded61 2858 # string
99a6c222 2859 print CF "\$prefs_key_field = '$prefs_key_field';\n";
254ded61 2860 # string
99a6c222 2861 print CF "\$prefs_val_field = '$prefs_val_field';\n";
52ed2f88 2862 # boolean
3d01b823 2863 print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
47a29326 2864
2865 # string
3d01b823 2866 print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
2867 print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
47a29326 2868 # boolean
3d01b823 2869 print CF "\$use_imap_tls = $use_imap_tls;\n";
2870 print CF "\$use_smtp_tls = $use_smtp_tls;\n";
2871
6c499577 2872 print CF "\$session_name = '$session_name';\n";
2873
3d01b823 2874 print CF "\n";
4a809164 2875 print CF "\@include SM_PATH . 'config/config_local.php';\n";
3d01b823 2876
2877 print CF "\n/**\n";
2878 print CF " * Make sure there are no characters after the PHP closing\n";
2879 print CF " * tag below (including newline characters and whitespace).\n";
2880 print CF " * Otherwise, that character will cause the headers to be\n";
2881 print CF " * sent and regular output to begin, which will majorly screw\n";
2882 print CF " * things up when we try to send more headers later.\n";
2883 print CF " */\n";
2884 print CF "?>";
2885
2886 close CF;
ebd13f55 2887
3d01b823 2888 print "Data saved in config.php\n";
ebd13f55 2889 } else {
2890 print "Error saving config.php: $!\n";
2891 }
911ad01c 2892}
a93b12ba 2893
2894sub set_defaults {
f8c17cdd 2895 clear_screen();
eaace00e 2896 print $WHT. "SquirrelMail Configuration : " . $NRM;
2897 if ( $config == 1 ) { print "Read: config.php"; }
2898 elsif ( $config == 2 ) { print "Read: config_default.php"; }
2899 print "\n";
2900 print "---------------------------------------------------------\n";
2901
2902 print "While we have been building SquirrelMail, we have discovered some\n";
2903 print "preferences that work better with some servers that don't work so\n";
2904 print "well with others. If you select your IMAP server, this option will\n";
2905 print "set some pre-defined settings for that server.\n";
2906 print "\n";
2907 print "Please note that you will still need to go through and make sure\n";
2908 print "everything is correct. This does not change everything. There are\n";
2909 print "only a few settings that this will change.\n";
2910 print "\n";
2911
2912 $continue = 0;
2913 while ( $continue != 1 ) {
2914 print "Please select your IMAP server:\n";
2915 print " cyrus = Cyrus IMAP server\n";
2916 print " uw = University of Washington's IMAP server\n";
2917 print " exchange = Microsoft Exchange IMAP server\n";
2918 print " courier = Courier IMAP server\n";
cfe486a7 2919 print " macosx = Mac OS X Mailserver\n";
063ed2b1 2920 print " mercury32 = Mercury/32\n";
eaace00e 2921 print " quit = Do not change anything\n";
2922 print "Command >> ";
2923 $server = <STDIN>;
2924 $server =~ s/[\r|\n]//g;
2925
2926 print "\n";
2927 if ( $server eq "cyrus" ) {
2928 $imap_server_type = "cyrus";
2929 $default_folder_prefix = "";
2930 $trash_folder = "INBOX.Trash";
2931 $sent_folder = "INBOX.Sent";
2932 $draft_folder = "INBOX.Drafts";
2933 $show_prefix_option = false;
2934 $default_sub_of_inbox = true;
2935 $show_contain_subfolders_option = false;
2936 $optional_delimiter = ".";
2937 $disp_default_folder_prefix = "<none>";
b79b84c2 2938 $force_username_lowercase = false;
eaace00e 2939
2940 $continue = 1;
2941 } elsif ( $server eq "uw" ) {
2942 $imap_server_type = "uw";
2943 $default_folder_prefix = "mail/";
2944 $trash_folder = "Trash";
2945 $sent_folder = "Sent";
2946 $draft_folder = "Drafts";
2947 $show_prefix_option = true;
2948 $default_sub_of_inbox = false;
2949 $show_contain_subfolders_option = true;
2950 $optional_delimiter = "/";
2951 $disp_default_folder_prefix = $default_folder_prefix;
2eec12b5 2952 $delete_folder = true;
b79b84c2 2953 $force_username_lowercase = true;
2eec12b5 2954
eaace00e 2955 $continue = 1;
2956 } elsif ( $server eq "exchange" ) {
2957 $imap_server_type = "exchange";
2958 $default_folder_prefix = "";
2959 $default_sub_of_inbox = true;
2960 $trash_folder = "INBOX/Deleted Items";
2961 $sent_folder = "INBOX/Sent Items";
2962 $drafts_folder = "INBOX/Drafts";
2963 $show_prefix_option = false;
2964 $show_contain_subfolders_option = false;
2965 $optional_delimiter = "detect";
2966 $disp_default_folder_prefix = "<none>";
b79b84c2 2967 $force_username_lowercase = true;
eaace00e 2968
2969 $continue = 1;
2970 } elsif ( $server eq "courier" ) {
2971 $imap_server_type = "courier";
2972 $default_folder_prefix = "INBOX.";
2973 $trash_folder = "Trash";
2974 $sent_folder = "Sent";
2975 $draft_folder = "Drafts";
2976 $show_prefix_option = false;
2977 $default_sub_of_inbox = false;
2978 $show_contain_subfolders_option = false;
2979 $optional_delimiter = ".";
2980 $disp_default_folder_prefix = $default_folder_prefix;
2eec12b5 2981 $delete_folder = true;
b79b84c2 2982 $force_username_lowercase = false;
2eec12b5 2983
cfe486a7 2984 $continue = 1;
2985 } elsif ( $server eq "macosx" ) {
2986 $imap_server_type = "macosx";
2987 $default_folder_prefix = "INBOX/";
2988 $trash_folder = "Trash";
2989 $sent_folder = "Sent";
2990 $draft_folder = "Drafts";
2991 $show_prefix_option = false;
2992 $default_sub_of_inbox = true;
2993 $show_contain_subfolders_option = false;
2994 $optional_delimiter = "detect";
2995 $allow_charset_search = false;
2996 $disp_default_folder_prefix = $default_folder_prefix;
eaace00e 2997
063ed2b1 2998 $continue = 1;
2999 } elsif ( $server eq "mercury32" ) {
3000 $imap_server_type = "mercury32";
3001 $default_folder_prefix = "";
3002 $trash_folder = "INBOX.Trash";
3003 $sent_folder = "INBOX.Sent";
3004 $draft_folder = "INBOX.Drafts";
3005 $show_prefix_option = false;
3006 $default_sub_of_inbox = true;
3007 $show_contain_subfolders_option = true;
3008 $optional_delimiter = "detect";
3009 $delete_folder = true;
3010 $force_username_lowercase = true;
3011
eaace00e 3012 $continue = 1;
3013 } elsif ( $server eq "quit" ) {
3014 $continue = 1;
3015 } else {
3016 $disp_default_folder_prefix = $default_folder_prefix;
3017 print "Unrecognized server: $server\n";
3018 print "\n";
3019 }
3020
3021 print " imap_server_type = $imap_server_type\n";
3022 print " default_folder_prefix = $disp_default_folder_prefix\n";
3023 print " trash_folder = $trash_folder\n";
3024 print " sent_folder = $sent_folder\n";
3025 print " draft_folder = $draft_folder\n";
3026 print " show_prefix_option = $show_prefix_option\n";
3027 print " default_sub_of_inbox = $default_sub_of_inbox\n";
3028 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3029 print " optional_delimiter = $optional_delimiter\n";
2eec12b5 3030 print " delete_folder = $delete_folder\n";
b79b84c2 3031 print " force_username_lowercase = $force_username_lowercase\n";
eaace00e 3032 }
b79b84c2 3033 print "\nPress enter to continue...";
eaace00e 3034 $tmp = <STDIN>;
a93b12ba 3035}
8bd9e0dd 3036
8bd9e0dd 3037# This subroutine corrects relative paths to ensure they
3038# will work within the SM space. If the path falls within
3039# the SM directory tree, the SM_PATH variable will be
3040# prepended to the path, if not, then the path will be
e6566358 3041# converted to an absolute path, e.g.
2222aed0 3042# '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
a2a74376 3043# '../../someplace/data' --> '/absolute/path/someplace/data'
2222aed0 3044# 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
3045# '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3046# 'http://whatever/' --> 'http://whatever'
b72da239 3047# $some_var/path --> "$some_var/path"
8bd9e0dd 3048sub change_to_SM_path() {
3049 my ($old_path) = @_;
3050 my $new_path = '';
3051 my @rel_path;
3052 my @abs_path;
3053 my $subdir;
3054
3055 # If the path is absolute, don't bother.
3056 return "\'" . $old_path . "\'" if ( $old_path eq '');
a28a56da 3057 return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ );
d3fb3870 3058 return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:\// );
25be56ab 3059 return $old_path if ( $old_path =~ /^\'(\/|http)/ );
d3fb3870 3060 return $old_path if ( $old_path =~ /^\'\w:\// );
b72da239 3061 return $old_path if ( $old_path =~ /^SM_PATH/);
3062
3063 if ( $old_path =~ /^\$/ ) {
3064 # check if it's a single var, or a $var/path combination
3065 # if it's $var/path, enclose in ""
3066 if ( $old_path =~ /\// ) {
3067 return '"'.$old_path.'"';
3068 }
3069 return $old_path;
3070 }
93c06fa2 3071
25be56ab 3072 # Remove remaining '
3073 $old_path =~ s/\'//g;
3074
8bd9e0dd 3075 # For relative paths, split on '../'
3076 @rel_path = split(/\.\.\//, $old_path);
3077
3078 if ( $#rel_path > 1 ) {
3079 # more than two levels away. Make it absolute.
a2a74376 3080 @abs_path = split(/\//, $dir);
3081
3082 # Lop off the relative pieces of the absolute path..
3083 for ( $i = 0; $i <= $#rel_path; $i++ ) {
3084 pop @abs_path;
3085 shift @rel_path;
3086 }
3087 push @abs_path, @rel_path;
1df76076 3088 $new_path = "\'" . join('/', @abs_path) . "\'";
8bd9e0dd 3089 } elsif ( $#rel_path > 0 ) {
3090 # it's within the SM tree, prepend SM_PATH
3091 $new_path = $old_path;
3092 $new_path =~ s/^\.\.\//SM_PATH . \'/;
25be56ab 3093 $new_path .= "\'";
8bd9e0dd 3094 } else {
3095 # Last, it's a relative path without any leading '.'
e6566358 3096 # Prepend SM_PATH and config, since the paths are
3097 # relative to the config directory
3098 $new_path = "SM_PATH . \'config/" . $old_path . "\'";
8bd9e0dd 3099 }
8bd9e0dd 3100 return $new_path;
3101}
3102
e6566358 3103
3104# Change SM_PATH to admin-friendly version, e.g.:
3105# SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
3106# SM_PATH . 'config/some.php' --> 'some.php'
3107# '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3108# 'http://whatever/' --> 'http://whatever'
8bd9e0dd 3109sub change_to_rel_path() {
3110 my ($old_path) = @_;
e6566358 3111 my $new_path = $old_path;
8bd9e0dd 3112
3113 if ( $old_path =~ /^SM_PATH/ ) {
8bd9e0dd 3114 $new_path =~ s/^SM_PATH . \'/\.\.\//;
b72da239 3115 $new_path =~ s/\.\.\/config\///;
8bd9e0dd 3116 }
3117
3118 return $new_path;
3119}
b47821fb 3120
3121sub detect_auth_support {
3122# Attempts to auto-detect if a specific auth mechanism is supported.
3123# Called by 'command112a' and 'command112b'
3124# ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3125
3126 # Misc setup
3127 use IO::Socket;
3128 my $service = shift;
3129 my $host = shift;
3130 my $mech = shift;
3131 # Sanity checks
3132 if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3133 # Error - wrong # of args
3134 print "BAD ARGS!\n";
3135 return undef;
3136 }
3137
3138 if ($service eq 'SMTP') {
3139 $cmd = "AUTH $mech\n";
3140 $logout = "QUIT\n";
3141 } elsif ($service eq 'IMAP') {
3142 $cmd = "A01 AUTHENTICATE $mech\n";
3143 $logout = "C01 LOGOUT\n";
3144 } else {
3145 # unknown service - whoops.
3146 return undef;
3147 }
3148
3149 # Get this show on the road
3150 my $sock=IO::Socket::INET->new($host);
3151 if (!defined($sock)) {
3152 # Connect failed
3153 return undef;
3154 }
3155 my $discard = <$sock>; # Server greeting/banner - who cares..
fe0b18b3 3156
3157 if ($service eq 'SMTP') {
3158 # Say hello first..
3159 print $sock "helo $domain\n";
3160 $discard = <$sock>; # Yeah yeah, you're happy to see me..
3161 }
b47821fb 3162 print $sock $cmd;
3163
3164 my $response = <$sock>;
fe0b18b3 3165 chomp($response);
b47821fb 3166 if (!defined($response)) {
3167 return undef;
3168 }
3169
3170 # So at this point, we have a response, and it is (hopefully) valid.
3171 if ($service eq 'SMTP') {
3172 if (($response =~ /^535/) or ($response =~/^502/)) {
3173 # Not supported
3174 close $sock;
3175 return 'NO';
fe0b18b3 3176 } elsif ($response =~ /^503/) {
3177 #Something went wrong
3178 return undef;
b47821fb 3179 }
3180 } elsif ($service eq 'IMAP') {
3181 if ($response =~ /^A01/) {
3182 # Not supported
3183 close $sock;
3184 return 'NO';
3185 }
3186 } else {
3187 # Unknown service - this shouldn't be able to happen.
3188 close $sock;
3189 return undef;
3190 }
3191
3192 # If it gets here, the mech is supported
3193 print $sock "*\n"; # Attempt to cancel authentication
3194 print $sock $logout; # Try to log out, but we don't really care if this fails
3195 close $sock;
3196 return 'YES';
3197}
f8c17cdd 3198
3199sub clear_screen() {
3200 if ( $^O =~ /^mswin/i) {
3201 system "cls";
3202 } else {
3203 system "clear";
3204 }
3205}