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