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