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