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