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