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