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