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