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