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