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