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