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