3b3fa9a7382e75a01bfe60ce282bc1af0b028d6d
[squirrelmail.git] / config / conf.pl
1 #!/usr/bin/env perl
2 # conf.pl
3 #
4 # Copyright (c) 1999-2003 The SquirrelMail Project Team
5 # Licensed under the GNU GPL. For full terms see COPYING.
6 #
7 # A simple configure script to configure SquirrelMail
8 #
9 # $Id$
10 ############################################################
11 $conf_pl_version = "1.4.0";
12
13 ############################################################
14 # Check what directory we're supposed to be running in, and
15 # change there if necessary. File::Basename has been in
16 # Perl since at least 5.003_7, and nobody sane runs anything
17 # before that, but just in case.
18 ############################################################
19 my $dir;
20 if ( eval q{require "File/Basename.pm"} ) {
21 $dir = File::Basename::dirname($0);
22 chdir($dir);
23 }
24
25 ############################################################
26 # Some people try to run this as a CGI. That's wrong!
27 ############################################################
28 if ( defined( $ENV{'PATH_INFO'} )
29 || defined( $ENV{'QUERY_STRING'} )
30 || defined( $ENV{'REQUEST_METHOD'} ) ) {
31 print "Content-Type: text/html\n\n";
32 print "You must run this script from the command line.";
33 exit;
34 }
35
36 ############################################################
37 # If we got here, use Cwd to get the full directory path
38 # (the Basename stuff above will sometimes return '.' as
39 # the base directory, which is not helpful here).
40 ############################################################
41 use Cwd;
42 $dir = cwd();
43
44
45 ############################################################
46 # First, lets read in the data already in there...
47 ############################################################
48 if ( -e "config.php" ) {
49 open( FILE, "config.php" );
50 while ( $line = <FILE> ) {
51 $line =~ s/^\s+//;
52 $line =~ s/^\$//;
53 $var = $line;
54
55 $var =~ s/=/EQUALS/;
56 if ( $var =~ /^([a-z]|[A-Z])/ ) {
57 @o = split ( /\s*EQUALS\s*/, $var );
58 if ( $o[0] eq "config_version" ) {
59 $o[1] =~ s/[\n|\r]//g;
60 $o[1] =~ s/[\'|\"];\s*$//;
61 $o[1] =~ s/;$//;
62 $o[1] =~ s/^[\'|\"]//;
63
64 $config_version = $o[1];
65 close(FILE);
66 }
67 }
68 }
69 close(FILE);
70
71 if ( $config_version ne $conf_pl_version ) {
72 clear_screen();
73 print $WHT. "WARNING:\n" . $NRM;
74 print " The file \"config/config.php\" was found, but it is for\n";
75 print " an older version of SquirrelMail. It is possible to still\n";
76 print " read the defaults from this file but be warned that many\n";
77 print " preferences change between versions. It is recommended that\n";
78 print " you start with a clean config.php for each upgrade that you\n";
79 print " do. To do this, just move config/config.php out of the way.\n";
80 print "\n";
81 print "Continue loading with the old config.php [y/N]? ";
82 $ctu = <STDIN>;
83
84 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
85 exit;
86 }
87
88 print "\nDo you want me to stop warning you [y/N]? ";
89 $ctu = <STDIN>;
90 if ( $ctu =~ /^y\n/i ) {
91 $print_config_version = $conf_pl_version;
92 } else {
93 $print_config_version = $config_version;
94 }
95 } else {
96 $print_config_version = $config_version;
97 }
98
99 $config = 1;
100 open( FILE, "config.php" );
101 } elsif ( -e "config_default.php" ) {
102 open( FILE, "config_default.php" );
103 while ( $line = <FILE> ) {
104 $line =~ s/^\s+//;
105 $line =~ s/^\$//;
106 $var = $line;
107
108 $var =~ s/=/EQUALS/;
109 if ( $var =~ /^([a-z]|[A-Z])/ ) {
110 @o = split ( /\s*EQUALS\s*/, $var );
111 if ( $o[0] eq "config_version" ) {
112 $o[1] =~ s/[\n|\r]//g;
113 $o[1] =~ s/[\'|\"];\s*$//;
114 $o[1] =~ s/;$//;
115 $o[1] =~ s/^[\'|\"]//;
116
117 $config_version = $o[1];
118 close(FILE);
119 }
120 }
121 }
122 close(FILE);
123
124 if ( $config_version ne $conf_pl_version ) {
125 clear_screen();
126 print $WHT. "WARNING:\n" . $NRM;
127 print " You are trying to use a 'config_default.php' from an older\n";
128 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
129 print " should get the 'config_default.php' that matches the version\n";
130 print " of SquirrelMail that you are running. You can get this from\n";
131 print " the SquirrelMail web page by going to the following URL:\n";
132 print " http://www.squirrelmail.org.\n";
133 print "\n";
134 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
135 $ctu = <STDIN>;
136
137 if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
138 exit;
139 }
140
141 print "\nDo you want me to stop warning you [y/N]? ";
142 $ctu = <STDIN>;
143 if ( $ctu =~ /^y\n/i ) {
144 $print_config_version = $conf_pl_version;
145 } else {
146 $print_config_version = $config_version;
147 }
148 } else {
149 $print_config_version = $config_version;
150 }
151 $config = 2;
152 open( FILE, "config_default.php" );
153 } else {
154 print "No configuration file found. Please get config_default.php\n";
155 print "or config.php before running this again. This program needs\n";
156 print "a default config file to get default values.\n";
157 exit;
158 }
159
160 # Read and parse the current configuration file
161 # (either config.php or config_default.php).
162 while ( $line = <FILE> ) {
163 $line =~ s/^\s+//;
164 $line =~ s/^\$//;
165 $var = $line;
166
167 $var =~ s/=/EQUALS/;
168 if ( $var =~ /^([a-z]|[A-Z])/ ) {
169 @options = split ( /\s*EQUALS\s*/, $var );
170 $options[1] =~ s/[\n|\r]//g;
171 $options[1] =~ s/[\'|\"];\s*$//;
172 $options[1] =~ s/;$//;
173 $options[1] =~ s/^[\'|\"]//;
174
175 if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
176 $sub = $options[0];
177 $sub =~ s/\]\[['|"]PATH['|"]\]//;
178 $sub =~ s/.*\[//;
179 if ( -e "../themes" ) {
180 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
181 }
182 $theme_path[$sub] = &change_to_rel_path($options[1]);
183 } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
184 $sub = $options[0];
185 $sub =~ s/\]\[['|"]NAME['|"]\]//;
186 $sub =~ s/.*\[//;
187 $theme_name[$sub] = $options[1];
188 } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
189 $sub = $options[0];
190 $sub =~ s/\]//;
191 $sub =~ s/^plugins\[//;
192 $plugins[$sub] = $options[1];
193 } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
194 $sub = $options[0];
195 $sub =~ s/\]//;
196 $sub =~ s/^ldap_server\[//;
197 $continue = 0;
198 while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
199 if ( $tmp =~ /\);\s*$/ ) {
200 $continue = 1;
201 }
202
203 if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) {
204 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
205 $tmp =~ s/[\'|\"],?\s*$//;
206 $tmp =~ s/[\'|\"]\);\s*$//;
207 $host = $tmp;
208 } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) {
209 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
210 $tmp =~ s/[\'|\"],?\s*$//;
211 $tmp =~ s/[\'|\"]\);\s*$//;
212 $base = $tmp;
213 } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) {
214 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
215 $tmp =~ s/[\'|\"],?\s*$//;
216 $tmp =~ s/[\'|\"]\);\s*$//;
217 $charset = $tmp;
218 } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
219 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
220 $tmp =~ s/[\'|\"]?,?\s*$//;
221 $tmp =~ s/[\'|\"]?\);\s*$//;
222 $port = $tmp;
223 } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
224 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
225 $tmp =~ s/[\'|\"]?,?\s*$//;
226 $tmp =~ s/[\'|\"]?\);\s*$//;
227 $maxrows = $tmp;
228 } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
229 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
230 $tmp =~ s/[\'|\"],?\s*$//;
231 $tmp =~ s/[\'|\"]\);\s*$//;
232 $name = $tmp;
233 }
234 }
235 $ldap_host[$sub] = $host;
236 $ldap_base[$sub] = $base;
237 $ldap_name[$sub] = $name;
238 $ldap_port[$sub] = $port;
239 $ldap_maxrows[$sub] = $maxrows;
240 $ldap_charset[$sub] = $charset;
241 } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
242 ${ $options[0] } = &change_to_rel_path($options[1]);
243 } else {
244 ${ $options[0] } = $options[1];
245 }
246 }
247 }
248 close FILE;
249 if ( lc($useSendmail) ne "true" ) {
250 $useSendmail = "false";
251 }
252 if ( !$sendmail_path ) {
253 $sendmail_path = "/usr/sbin/sendmail";
254 }
255 if ( !$pop_before_smtp ) {
256 $pop_before_smtp = "false";
257 }
258 if ( !$default_unseen_notify ) {
259 $default_unseen_notify = 2;
260 }
261 if ( !$default_unseen_type ) {
262 $default_unseen_type = 1;
263 }
264 if ( !$config_use_color ) {
265 $config_use_color = 0;
266 }
267 if ( !$invert_time ) {
268 $invert_time = "false";
269 }
270 if ( !$force_username_lowercase ) {
271 $force_username_lowercase = "false";
272 }
273 if ( !$optional_delimiter ) {
274 $optional_delimiter = "detect";
275 }
276 if ( !$auto_create_special ) {
277 $auto_create_special = "false";
278 }
279 if ( !$default_use_priority ) {
280 $default_use_priority = "true";
281 }
282 if ( !$hide_sm_attributions ) {
283 $hide_sm_attributions = "false";
284 }
285 if ( !$default_use_mdn ) {
286 $default_use_mdn = "true";
287 }
288 if ( !$delete_folder ) {
289 $delete_folder = "false";
290 }
291 if ( !$noselect_fix_enable ) {
292 $noselect_fix_enable = "false";
293 }
294 if ( !$frame_top ) {
295 $frame_top = "_top";
296 }
297
298 if ( !$provider_uri ) {
299 $provider_uri = "http://www.squirrelmail.org/";
300 }
301
302 if ( !$provider_name ) {
303 $provider_name = "SquirrelMail";
304 }
305
306 if ( !$edit_identity ) {
307 $edit_identity = "true";
308 }
309 if ( !$edit_name ) {
310 $edit_name = "true";
311 }
312 if ( !$allow_thread_sort ) {
313 $allow_thread_sort = 'false';
314 }
315 if ( !$allow_server_sort ) {
316 $allow_server_sort = 'false';
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 = 'login';
348 }
349
350 if (!$session_name ) {
351 $session_name = 'SQMSESSID';
352 }
353
354 if (!$show_alternative_names ) {
355 $show_alternative_names = 'false';
356 }
357
358 if (!$available_languages ) {
359 $available_languages = 'all';
360 }
361
362 if (!$agresive_decoding ) {
363 $agresive_decoding = 'false';
364 }
365
366 if (!$advanced_tree ) {
367 $advanced_tree = 'false';
368 }
369
370 if (!$oldway ) {
371 $oldway = 'false';
372 }
373
374 if (!$use_php_recode ) {
375 $use_php_recode = 'false';
376 }
377
378 if (!$use_php_iconv ) {
379 $use_php_iconv = 'false';
380 }
381
382 if ( $ARGV[0] eq '--install-plugin' ) {
383 print "Activating plugin " . $ARGV[1] . "\n";
384 push @plugins, $ARGV[1];
385 save_data();
386 exit(0);
387 } elsif ( $ARGV[0] eq '--remove-plugin' ) {
388 print "Removing plugin " . $ARGV[1] . "\n";
389 foreach $plugin (@plugins) {
390 if ( $plugin ne $ARGV[1] ) {
391 push @newplugins, $plugin;
392 }
393 }
394 @plugins = @newplugins;
395 save_data();
396 exit(0);
397 }
398
399 #####################################################################################
400 if ( $config_use_color == 1 ) {
401 $WHT = "\x1B[37;1m";
402 $NRM = "\x1B[0m";
403 } else {
404 $WHT = "";
405 $NRM = "";
406 $config_use_color = 2;
407 }
408
409 while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
410 clear_screen();
411 print $WHT. "SquirrelMail Configuration : " . $NRM;
412 if ( $config == 1 ) { print "Read: config.php"; }
413 elsif ( $config == 2 ) { print "Read: config_default.php"; }
414 print " ($print_config_version)\n";
415 print "---------------------------------------------------------\n";
416
417 if ( $menu == 0 ) {
418 print $WHT. "Main Menu --\n" . $NRM;
419 print "1. Organization Preferences\n";
420 print "2. Server Settings\n";
421 print "3. Folder Defaults\n";
422 print "4. General Options\n";
423 print "5. Themes\n";
424 print "6. Address Books (LDAP)\n";
425 print "7. Message of the Day (MOTD)\n";
426 print "8. Plugins\n";
427 print "9. Database\n";
428 print "10. Language settings\n";
429 print "11. Tweaks\n";
430 print "\n";
431 print "D. Set pre-defined settings for specific IMAP servers\n";
432 print "\n";
433 } elsif ( $menu == 1 ) {
434 print $WHT. "Organization Preferences\n" . $NRM;
435 print "1. Organization Name : $WHT$org_name$NRM\n";
436 print "2. Organization Logo : $WHT$org_logo$NRM\n";
437 print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
438 print "4. Organization Title : $WHT$org_title$NRM\n";
439 print "5. Signout Page : $WHT$signout_page$NRM\n";
440 print "6. Top Frame : $WHT$frame_top$NRM\n";
441 print "7. Provider link : $WHT$provider_uri$NRM\n";
442 print "8. Provider name : $WHT$provider_name$NRM\n";
443
444 print "\n";
445 print "R Return to Main Menu\n";
446 } elsif ( $menu == 2 ) {
447 print $WHT. "Server Settings\n\n" . $NRM;
448 print $WHT . "General" . $NRM . "\n";
449 print "-------\n";
450 print "1. Domain : $WHT$domain$NRM\n";
451 print "2. Invert Time : $WHT$invert_time$NRM\n";
452 print "3. Sendmail or SMTP : $WHT";
453 if ( lc($useSendmail) eq "true" ) {
454 print "Sendmail";
455 } else {
456 print "SMTP";
457 }
458 print "$NRM\n";
459 print "\n";
460
461 if ( $show_imap_settings ) {
462 print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
463 print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
464 print "5. IMAP Port : $WHT$imapPort$NRM\n";
465 print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
466 print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n";
467 print "8. Server software : $WHT$imap_server_type$NRM\n";
468 print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
469 print "\n";
470 } elsif ( $show_smtp_settings ) {
471 if ( lc($useSendmail) eq "true" ) {
472 print $WHT . "Sendmail" . $NRM . "\n--------\n";
473 print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
474 print "\n";
475 } else {
476 print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
477 print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
478 print "5. SMTP Port : $WHT$smtpPort$NRM\n";
479 print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
480 print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n";
481 print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n";
482 print "\n";
483 }
484 }
485
486 if ($show_imap_settings == 0) {
487 print "A. Update IMAP Settings : ";
488 print "$WHT$imapServerAddress$NRM:";
489 print "$WHT$imapPort$NRM ";
490 print "($WHT$imap_server_type$NRM)\n";
491 }
492 if ($show_smtp_settings == 0) {
493 if ( lc($useSendmail) eq "true" ) {
494 print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
495 } else {
496 print "B. Update SMTP Settings : ";
497 print "$WHT$smtpServerAddress$NRM:";
498 print "$WHT$smtpPort$NRM\n";
499 }
500 }
501 if ( $show_smtp_settings || $show_imap_settings )
502 {
503 print "H. Hide " .
504 ($show_imap_settings ? "IMAP Server" :
505 (lc($useSendmail) eq "true") ? "Sendmail" : "SMTP") . " Settings\n";
506 }
507
508 print "\n";
509 print "R Return to Main Menu\n";
510 } elsif ( $menu == 3 ) {
511 print $WHT. "Folder Defaults\n" . $NRM;
512 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
513 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
514 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
515 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
516 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
517 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
518 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
519 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
520 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
521 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
522 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
523 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
524 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
525 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
526 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
527 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
528 print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
529 print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
530 print "\n";
531 print "R Return to Main Menu\n";
532 } elsif ( $menu == 4 ) {
533 print $WHT. "General Options\n" . $NRM;
534 print "1. Data Directory : $WHT$data_dir$NRM\n";
535 print "2. Attachment Directory : $WHT$attachment_dir$NRM\n";
536 print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
537 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
538 print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
539 print "6. Allow use of priority : $WHT$default_use_priority$NRM\n";
540 print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
541 print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
542 print "9. Allow editing of identity : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
543 print "10. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
544 print "11. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
545 print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
546 print "13. PHP session name : $WHT$session_name$NRM\n";
547 print "\n";
548 print "R Return to Main Menu\n";
549 } elsif ( $menu == 5 ) {
550 print $WHT. "Themes\n" . $NRM;
551 print "1. Change Themes\n";
552 for ( $count = 0 ; $count <= $#theme_name/2 ; $count++ ) {
553 $temp_name = $theme_name[$count*2];
554 printf " %s%*s %s\n", $temp_name,
555 40 - length($temp_name), " ",
556 $theme_name[($count*2)+1];
557 }
558 print "2. CSS File : $WHT$theme_css$NRM\n";
559 print "\n";
560 print "R Return to Main Menu\n";
561 } elsif ( $menu == 6 ) {
562 print $WHT. "Address Books (LDAP)\n" . $NRM;
563 print "1. Change Servers\n";
564 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
565 print " > $ldap_host[$count]\n";
566 }
567 print
568 "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
569 print "\n";
570 print "R Return to Main Menu\n";
571 } elsif ( $menu == 7 ) {
572 print $WHT. "Message of the Day (MOTD)\n" . $NRM;
573 print "\n$motd\n";
574 print "\n";
575 print "1 Edit the MOTD\n";
576 print "\n";
577 print "R Return to Main Menu\n";
578 } elsif ( $menu == 8 ) {
579 print $WHT. "Plugins\n" . $NRM;
580 print " Installed Plugins\n";
581 $num = 0;
582 for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
583 $num = $count + 1;
584 print " $num. $plugins[$count]\n";
585 }
586 print "\n Available Plugins:\n";
587 opendir( DIR, "../plugins" );
588 @files = readdir(DIR);
589 $pos = 0;
590 @unused_plugins = ();
591 for ( $i = 0 ; $i <= $#files ; $i++ ) {
592 if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
593 $match = 0;
594 for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
595 if ( $plugins[$k] eq $files[$i] ) {
596 $match = 1;
597 }
598 }
599 if ( $match == 0 ) {
600 $unused_plugins[$pos] = $files[$i];
601 $pos++;
602 }
603 }
604 }
605
606 for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
607 $num = $num + 1;
608 print " $num. $unused_plugins[$i]\n";
609 }
610 closedir DIR;
611
612 print "\n";
613 print "R Return to Main Menu\n";
614 } elsif ( $menu == 9 ) {
615 print $WHT. "Database\n" . $NRM;
616 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
617 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
618 print "\n";
619 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
620 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
621 print "5. Field for username : $WHT$prefs_user_field$NRM\n";
622 print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
623 print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
624 print "\n";
625 print "R Return to Main Menu\n";
626 } elsif ( $menu == 10 ) {
627 print $WHT. "Language settings\n" . $NRM;
628 print "1. Default Language : $WHT$squirrelmail_default_language$NRM\n";
629 print "2. Default Charset : $WHT$default_charset$NRM\n";
630 print "3. Show alternative language names : $WHT$show_alternative_names$NRM\n";
631 print "4. Available languages : $WHT$available_languages$NRM\n";
632 print "5. Use agresive decoding : $WHT$agresive_decoding$NRM\n";
633 print "\n";
634 print "R Return to Main Menu\n";
635 } elsif ( $menu == 11 ) {
636 print $WHT. "Interface tweaks\n" . $NRM;
637 print "1. Advanced tree : $WHT$advanced_tree$NRM\n";
638 print "2. Oldway : $WHT$oldway$NRM\n";
639 print "\n";
640 print $WHT. "PHP tweaks\n" . $NRM;
641 print "3. Use php recode functions : $WHT$use_php_recode$NRM\n";
642 print "4. Use php iconv functions : $WHT$use_php_iconv$NRM\n";
643 print "\n";
644 print "R Return to Main Menu\n";
645 }
646 if ( $config_use_color == 1 ) {
647 print "C. Turn color off\n";
648 } else {
649 print "C. Turn color on\n";
650 }
651 print "S Save data\n";
652 print "Q Quit\n";
653
654 print "\n";
655 print "Command >> " . $WHT;
656 $command = <STDIN>;
657 $command =~ s/[\n|\r]//g;
658 $command =~ tr/A-Z/a-z/;
659 print "$NRM\n";
660
661 # Read the commands they entered.
662 if ( $command eq "r" ) {
663 $menu = 0;
664 } elsif ( $command eq "s" ) {
665 save_data();
666 print "Press enter to continue...";
667 $tmp = <STDIN>;
668 $saved = 1;
669 } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
670 print "You have not saved your data.\n";
671 print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
672 $save = <STDIN>;
673 if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
674 save_data();
675 }
676 } elsif ( $command eq "c" ) {
677 if ( $config_use_color == 1 ) {
678 $config_use_color = 2;
679 $WHT = "";
680 $NRM = "";
681 } else {
682 $config_use_color = 1;
683 $WHT = "\x1B[37;1m";
684 $NRM = "\x1B[0m";
685 }
686 } elsif ( $command eq "d" && $menu == 0 ) {
687 set_defaults();
688 } else {
689 $saved = 0;
690 if ( $menu == 0 ) {
691 if ( ( $command > 0 ) && ( $command < 12 ) ) {
692 $menu = $command;
693 }
694 } elsif ( $menu == 1 ) {
695 if ( $command == 1 ) { $org_name = command1(); }
696 elsif ( $command == 2 ) { $org_logo = command2(); }
697 elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); }
698 elsif ( $command == 4 ) { $org_title = command3(); }
699 elsif ( $command == 5 ) { $signout_page = command4(); }
700 elsif ( $command == 6 ) { $frame_top = command6(); }
701 elsif ( $command == 7 ) { $provider_uri = command7(); }
702 elsif ( $command == 8 ) { $provider_name = command8(); }
703
704 } elsif ( $menu == 2 ) {
705 if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
706 elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
707 elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
708 elsif ( $command <= 3 ) {
709 if ( $command == 1 ) { $domain = command11(); }
710 elsif ( $command == 2 ) { $invert_time = command110(); }
711 elsif ( $command == 3 ) { $useSendmail = command14(); }
712 $show_imap_settings = 0; $show_smtp_settings = 0;
713 } elsif ( $show_imap_settings ) {
714 if ( $command == 4 ) { $imapServerAddress = command12(); }
715 elsif ( $command == 5 ) { $imapPort = command13(); }
716 elsif ( $command == 6 ) { $imap_auth_mech = command112a(); }
717 elsif ( $command == 7 ) { $use_imap_tls = command113("IMAP",$use_imap_tls); }
718 elsif ( $command == 8 ) { $imap_server_type = command19(); }
719 elsif ( $command == 9 ) { $optional_delimiter = command111(); }
720 } elsif ( $show_smtp_settings && lc($useSendmail) eq "true" ) {
721 if ( $command == 4 ) { $sendmail_path = command15(); }
722 } elsif ( $show_smtp_settings ) {
723 if ( $command == 4 ) { $smtpServerAddress = command16(); }
724 elsif ( $command == 5 ) { $smtpPort = command17(); }
725 elsif ( $command == 6 ) { $pop_before_smtp = command18a(); }
726 elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); }
727 elsif ( $command == 8 ) { $use_smtp_tls = command113("SMTP",$use_smtp_tls); }
728 }
729 } elsif ( $menu == 3 ) {
730 if ( $command == 1 ) { $default_folder_prefix = command21(); }
731 elsif ( $command == 2 ) { $show_prefix_option = command22(); }
732 elsif ( $command == 3 ) { $trash_folder = command23a(); }
733 elsif ( $command == 4 ) { $sent_folder = command23b(); }
734 elsif ( $command == 5 ) { $draft_folder = command23c(); }
735 elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
736 elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
737 elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
738 elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
739 elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
740 elsif ( $command == 11 ) { $auto_expunge = command29(); }
741 elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
742 elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
743 elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
744 elsif ( $command == 15 ) { $default_unseen_type = command213(); }
745 elsif ( $command == 16 ) { $auto_create_special = command214(); }
746 elsif ( $command == 17 ) { $delete_folder = command215(); }
747 elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
748 } elsif ( $menu == 4 ) {
749 if ( $command == 1 ) { $data_dir = command33a(); }
750 elsif ( $command == 2 ) { $attachment_dir = command33b(); }
751 elsif ( $command == 3 ) { $dir_hash_level = command33c(); }
752 elsif ( $command == 4 ) { $default_left_size = command35(); }
753 elsif ( $command == 5 ) { $force_username_lowercase = command36(); }
754 elsif ( $command == 6 ) { $default_use_priority = command37(); }
755 elsif ( $command == 7 ) { $hide_sm_attributions = command38(); }
756 elsif ( $command == 8 ) { $default_use_mdn = command39(); }
757 elsif ( $command == 9 ) { $edit_identity = command310(); }
758 elsif ( $command == 10 ) { $allow_thread_sort = command312(); }
759 elsif ( $command == 11 ) { $allow_server_sort = command313(); }
760 elsif ( $command == 12 ) { $allow_charset_search = command314(); }
761 elsif ( $command == 13 ) { $session_name = command316(); }
762 } elsif ( $menu == 5 ) {
763 if ( $command == 1 ) { command41(); }
764 elsif ( $command == 2 ) { $theme_css = command42(); }
765 } elsif ( $menu == 6 ) {
766 if ( $command == 1 ) { command61(); }
767 elsif ( $command == 2 ) { command62(); }
768 } elsif ( $menu == 7 ) {
769 if ( $command == 1 ) { $motd = command71(); }
770 } elsif ( $menu == 8 ) {
771 if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
772 } elsif ( $menu == 9 ) {
773 if ( $command == 1 ) { $addrbook_dsn = command91(); }
774 elsif ( $command == 2 ) { $addrbook_table = command92(); }
775 elsif ( $command == 3 ) { $prefs_dsn = command93(); }
776 elsif ( $command == 4 ) { $prefs_table = command94(); }
777 elsif ( $command == 5 ) { $prefs_user_field = command95(); }
778 elsif ( $command == 6 ) { $prefs_key_field = command96(); }
779 elsif ( $command == 7 ) { $prefs_val_field = command97(); }
780 } elsif ( $menu == 10 ) {
781 if ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
782 elsif ( $command == 2 ) { $default_charset = commandA2(); }
783 elsif ( $command == 3 ) { $show_alternative_names = commandA3(); }
784 elsif ( $command == 4 ) { $available_languages = commandA4(); }
785 elsif ( $command == 5 ) { $agresive_decoding = commandA5(); }
786 } elsif ( $menu == 11 ) {
787 if ( $command == 1 ) { $advanced_tree = commandB1(); }
788 elsif ( $command == 2 ) { $oldway = commandB2(); }
789 elsif ( $command == 3 ) { $use_php_recode = commandB3(); }
790 elsif ( $command == 4 ) { $use_php_iconv = commandB4(); }
791 }
792 }
793 }
794
795 ####################################################################################
796
797 # org_name
798 sub command1 {
799 print "We have tried to make the name SquirrelMail as transparent as\n";
800 print "possible. If you set up an organization name, most places where\n";
801 print "SquirrelMail would take credit will be credited to your organization.\n";
802 print "\n";
803 print "If your Organization Name includes a '\$', please precede it with a \\. \n";
804 print "Other '\$' will be considered the beginning of a variable that\n";
805 print "must be defined before the \$org_name is printed.\n";
806 print "\$version, for example, is included by default, and will print the\n";
807 print "string representing the current SquirrelMail version.\n";
808 print "\n";
809 print "[$WHT$org_name$NRM]: $WHT";
810 $new_org_name = <STDIN>;
811 if ( $new_org_name eq "\n" ) {
812 $new_org_name = $org_name;
813 } else {
814 $new_org_name =~ s/[\r|\n]//g;
815 $new_org_name =~ s/\"/&quot;/g;
816 }
817 return $new_org_name;
818 }
819
820 # org_logo
821 sub command2 {
822 print "Your organization's logo is an image that will be displayed at\n";
823 print "different times throughout SquirrelMail. ";
824 print "\n";
825 print "Please be aware of the following: \n";
826 print " - Relative URLs are relative to the config dir\n";
827 print " to use the default logo, use ../images/sm_logo.png\n";
828 print " - To specify a logo defined outside the SquirrelMail source tree\n";
829 print " use the absolute URL the webserver would use to include the file\n";
830 print " e.g. http://some.host.com/images/mylogo.gif or /images/mylogo.jpg\n";
831 print "\n";
832 print "[$WHT$org_logo$NRM]: $WHT";
833 $new_org_logo = <STDIN>;
834 if ( $new_org_logo eq "\n" ) {
835 $new_org_logo = $org_logo;
836 } else {
837 $new_org_logo =~ s/[\r|\n]//g;
838 }
839 return $new_org_logo;
840 }
841
842 # org_logo_width
843 sub command2a {
844 print "Your organization's logo is an image that will be displayed at\n";
845 print "different times throughout SquirrelMail. Width\n";
846 print "and Height of your logo image. Use '0' to disable.\n";
847 print "\n";
848 print "Width: [$WHT$org_logo_width$NRM]: $WHT";
849 $new_org_logo_width = <STDIN>;
850 $new_org_logo_width =~ tr/0-9//cd; # only want digits!
851 if ( $new_org_logo_width eq '' ) {
852 $new_org_logo_width = $org_logo_width;
853 }
854 if ( $new_org_logo_width > 0 ) {
855 print "Height: [$WHT$org_logo_height$NRM]: $WHT";
856 $new_org_logo_height = <STDIN>;
857 $new_org_logo_height =~ tr/0-9//cd; # only want digits!
858 if( $new_org_logo_height eq '' ) {
859 $new_org_logo_height = $org_logo_height;
860 }
861 } else {
862 $new_org_logo_height = 0;
863 }
864 return ($new_org_logo_width, $new_org_logo_height);
865 }
866
867 # org_title
868 sub command3 {
869 print "A title is what is displayed at the top of the browser window in\n";
870 print "the titlebar. Usually this will end up looking something like:\n";
871 print "\"Netscape: $org_title\"\n";
872 print "\n";
873 print "If your Organization Title includes a '\$', please precede it with a \\. \n";
874 print "Other '\$' will be considered the beginning of a variable that\n";
875 print "must be defined before the \$org_title is printed.\n";
876 print "\$version, for example, is included by default, and will print the\n";
877 print "string representing the current SquirrelMail version.\n";
878 print "\n";
879 print "[$WHT$org_title$NRM]: $WHT";
880 $new_org_title = <STDIN>;
881 if ( $new_org_title eq "\n" ) {
882 $new_org_title = $org_title;
883 } else {
884 $new_org_title =~ s/[\r|\n]//g;
885 $new_org_title =~ s/\"/\'/g;
886 }
887 return $new_org_title;
888 }
889
890 # signout_page
891 sub command4 {
892 print "When users click the Sign Out button they will be logged out and\n";
893 print "then sent to signout_page. If signout_page is left empty,\n";
894 print "(hit space and then return) they will be taken, as normal,\n";
895 print "to the default and rather sparse SquirrelMail signout page.\n";
896 print "\n";
897 print "[$WHT$signout_page$NRM]: $WHT";
898 $new_signout_page = <STDIN>;
899 if ( $new_signout_page eq "\n" ) {
900 $new_signout_page = $signout_page;
901 } else {
902 $new_signout_page =~ s/[\r|\n]//g;
903 $new_signout_page =~ s/^\s+$//g;
904 }
905 return $new_signout_page;
906 }
907
908 # Default top frame
909 sub command6 {
910 print "SquirrelMail defaults to using the whole of the browser window.\n";
911 print "This allows you to keep it within a specified frame. The default\n";
912 print "is '_top'\n";
913 print "\n";
914 print "[$WHT$frame_top$NRM]: $WHT";
915 $new_frame_top = <STDIN>;
916 if ( $new_frame_top eq "\n" ) {
917 $new_frame_top = '_top';
918 } else {
919 $new_frame_top =~ s/[\r|\n]//g;
920 $new_frame_top =~ s/^\s+$//g;
921 }
922 return $new_frame_top;
923 }
924
925 # Default link to provider
926 sub command7 {
927 print "Here you can set the link on the right of the page.\n";
928 print "The default is 'http://www.squirrelmail.org/'\n";
929 print "\n";
930 print "[$WHT$provider_uri$NRM]: $WHT";
931 $new_provider_uri = <STDIN>;
932 if ( $new_provider_uri eq "\n" ) {
933 $new_provider_uri = 'http://www.squirrelmail.org/';
934 } else {
935 $new_provider_uri =~ s/[\r|\n]//g;
936 $new_provider_uri =~ s/^\s+$//g;
937 }
938 return $new_provider_uri;
939 }
940
941 sub command8 {
942 print "Here you can set the name of the link on the right of the page.\n";
943 print "The default is 'SquirrelMail/'\n";
944 print "\n";
945 print "[$WHT$provider_name$NRM]: $WHT";
946 $new_provider_name = <STDIN>;
947 if ( $new_provider_name eq "\n" ) {
948 $new_provider_name = 'SquirrelMail';
949 } else {
950 $new_provider_name =~ s/[\r|\n]//g;
951 $new_provider_name =~ s/^\s+$//g;
952 }
953 return $new_provider_name;
954 }
955
956 ####################################################################################
957
958 # domain
959 sub command11 {
960 print "The domain name is the suffix at the end of all email addresses. If\n";
961 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
962 print "would be myorg.com.\n";
963 print "\n";
964 print "[$WHT$domain$NRM]: $WHT";
965 $new_domain = <STDIN>;
966 if ( $new_domain eq "\n" ) {
967 $new_domain = $domain;
968 } else {
969 $new_domain =~ s/[\r|\n]//g;
970 }
971 return $new_domain;
972 }
973
974 # imapServerAddress
975 sub command12 {
976 print "This is the hostname where your IMAP server can be contacted.\n";
977 print "[$WHT$imapServerAddress$NRM]: $WHT";
978 $new_imapServerAddress = <STDIN>;
979 if ( $new_imapServerAddress eq "\n" ) {
980 $new_imapServerAddress = $imapServerAddress;
981 } else {
982 $new_imapServerAddress =~ s/[\r|\n]//g;
983 }
984 return $new_imapServerAddress;
985 }
986
987 # imapPort
988 sub command13 {
989 print "This is the port that your IMAP server is on. Usually this is 143.\n";
990 print "[$WHT$imapPort$NRM]: $WHT";
991 $new_imapPort = <STDIN>;
992 if ( $new_imapPort eq "\n" ) {
993 $new_imapPort = $imapPort;
994 } else {
995 $new_imapPort =~ s/[\r|\n]//g;
996 }
997 return $new_imapPort;
998 }
999
1000 # useSendmail
1001 sub command14 {
1002 print "You now need to choose the method that you will use for sending\n";
1003 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
1004 print "or use sendmail directly.\n";
1005 if ( lc($useSendmail) eq "true" ) {
1006 $default_value = "1";
1007 } else {
1008 $default_value = "2";
1009 }
1010 print "\n";
1011 print " 1. Sendmail\n";
1012 print " 2. SMTP\n";
1013 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
1014 $use_sendmail = <STDIN>;
1015 if ( ( $use_sendmail =~ /^1\n/i )
1016 || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
1017 $useSendmail = "true";
1018 } else {
1019 $useSendmail = "false";
1020 }
1021 return $useSendmail;
1022 }
1023
1024 # sendmail_path
1025 sub command15 {
1026 if ( $sendmail_path[0] !~ /./ ) {
1027 $sendmail_path = "/usr/sbin/sendmail";
1028 }
1029 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
1030 print "[$WHT$sendmail_path$NRM]: $WHT";
1031 $new_sendmail_path = <STDIN>;
1032 if ( $new_sendmail_path eq "\n" ) {
1033 $new_sendmail_path = $sendmail_path;
1034 } else {
1035 $new_sendmail_path =~ s/[\r|\n]//g;
1036 }
1037 return $new_sendmail_path;
1038 }
1039
1040 # smtpServerAddress
1041 sub command16 {
1042 print "This is the hostname of your SMTP server.\n";
1043 print "[$WHT$smtpServerAddress$NRM]: $WHT";
1044 $new_smtpServerAddress = <STDIN>;
1045 if ( $new_smtpServerAddress eq "\n" ) {
1046 $new_smtpServerAddress = $smtpServerAddress;
1047 } else {
1048 $new_smtpServerAddress =~ s/[\r|\n]//g;
1049 }
1050 return $new_smtpServerAddress;
1051 }
1052
1053 # smtpPort
1054 sub command17 {
1055 print "This is the port to connect to for SMTP. Usually 25.\n";
1056 print "[$WHT$smtpPort$NRM]: $WHT";
1057 $new_smtpPort = <STDIN>;
1058 if ( $new_smtpPort eq "\n" ) {
1059 $new_smtpPort = $smtpPort;
1060 } else {
1061 $new_smtpPort =~ s/[\r|\n]//g;
1062 }
1063 return $new_smtpPort;
1064 }
1065
1066 # authenticated server
1067 sub command18 {
1068 return;
1069 # This sub disabled by tassium - it has been replaced with smtp_auth_mech
1070 print "Do you wish to use an authenticated SMTP server? Your server must\n";
1071 print "support this in order for SquirrelMail to work with it. We implemented\n";
1072 print "it according to RFC 2554.\n";
1073
1074 $YesNo = 'n';
1075 $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" );
1076
1077 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
1078
1079 $new_use_authenticated_smtp = <STDIN>;
1080 $new_use_authenticated_smtp =~ tr/yn//cd;
1081 return "true" if ( $new_use_authenticated_smtp eq "y" );
1082 return "false" if ( $new_use_authenticated_smtp eq "n" );
1083 return $use_authenticated_smtp;
1084 }
1085
1086 # pop before SMTP
1087 sub command18a {
1088 print "Do you wish to use POP3 before SMTP? Your server must\n";
1089 print "support this in order for SquirrelMail to work with it.\n";
1090
1091 $YesNo = 'n';
1092 $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
1093
1094 print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
1095
1096 $new_pop_before_smtp = <STDIN>;
1097 $new_pop_before_smtp =~ tr/yn//cd;
1098 return "true" if ( $new_pop_before_smtp eq "y" );
1099 return "false" if ( $new_pop_before_smtp eq "n" );
1100 return $pop_before_smtp;
1101 }
1102
1103 # imap_server_type
1104 sub command19 {
1105 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
1106 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
1107 print "the same principles. We have made some work-arounds for some of\n";
1108 print "these servers. If you would like to use them, please select your\n";
1109 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
1110 print "set this to \"other\", and none will be used.\n";
1111 print " cyrus = Cyrus IMAP server\n";
1112 print " uw = University of Washington's IMAP server\n";
1113 print " exchange = Microsoft Exchange IMAP server\n";
1114 print " courier = Courier IMAP server\n";
1115 print " macosx = Mac OS X Mailserver\n";
1116 print " other = Not one of the above servers\n";
1117 print "[$WHT$imap_server_type$NRM]: $WHT";
1118 $new_imap_server_type = <STDIN>;
1119
1120 if ( $new_imap_server_type eq "\n" ) {
1121 $new_imap_server_type = $imap_server_type;
1122 } else {
1123 $new_imap_server_type =~ s/[\r|\n]//g;
1124 }
1125 return $new_imap_server_type;
1126 }
1127
1128 # invert_time
1129 sub command110 {
1130 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
1131 print "on some machines). Typically this happens if the system doesn't support\n";
1132 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
1133 print "This most often occurs on Solaris 7 machines in the United States.\n";
1134 print "By default, this is off. It should be kept off unless problems surface\n";
1135 print "about the time that messages are sent.\n";
1136 print " no = Do NOT fix time -- almost always correct\n";
1137 print " yes = Fix the time for this system\n";
1138
1139 $YesNo = 'n';
1140 $YesNo = 'y' if ( lc($invert_time) eq "true" );
1141
1142 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
1143
1144 $new_invert_time = <STDIN>;
1145 $new_invert_time =~ tr/yn//cd;
1146 return "true" if ( $new_invert_time eq "y" );
1147 return "false" if ( $new_invert_time eq "n" );
1148 return $invert_time;
1149 }
1150
1151 sub command111 {
1152 print "This is the delimiter that your IMAP server uses to distinguish between\n";
1153 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
1154 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
1155 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
1156 print "but if you are sure you know what delimiter your server uses, you can\n";
1157 print "specify it here.\n";
1158 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
1159 print "[$WHT$optional_delimiter$NRM]: $WHT";
1160 $new_optional_delimiter = <STDIN>;
1161
1162 if ( $new_optional_delimiter eq "\n" ) {
1163 $new_optional_delimiter = $optional_delimiter;
1164 } else {
1165 $new_optional_delimiter =~ s/[\r|\n]//g;
1166 }
1167 return $new_optional_delimiter;
1168 }
1169 # IMAP authentication type
1170 # Possible values: login, plain, cram-md5, digest-md5
1171 # Now offers to detect supported mechs, assuming server & port are set correctly
1172
1173 sub command112a {
1174 if ($use_imap_tls =~ /^true\b/i) {
1175 print "Auto-detection of login methods is unavailable when using TLS.\n";
1176 } else {
1177 print "If you have already set the hostname and port number, I can try to\n";
1178 print "detect the mechanisms your IMAP server supports.\n";
1179 print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n";
1180 print "for \"login\" or \"plain\" without knowing a username and password.\n";
1181 print "Auto-detecting is optional - you can safely say \"n\" here.\n";
1182 print "\nTry to detect supported mechanisms? [y/N]: ";
1183 $inval=<STDIN>;
1184 chomp($inval);
1185 if ($inval =~ /^y\b/i) {
1186 # Yes, let's try to detect.
1187 print "Trying to detect IMAP capabilities...\n";
1188 my $host = $imapServerAddress . ':'. $imapPort;
1189 print "CRAM-MD5:\t";
1190 my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
1191 if (defined($tmp)) {
1192 if ($tmp eq 'YES') {
1193 print "$WHT SUPPORTED$NRM\n";
1194 } else {
1195 print "$WHT NOT SUPPORTED$NRM\n";
1196 }
1197 } else {
1198 print $WHT . " ERROR DETECTING$NRM\n";
1199 }
1200
1201 print "DIGEST-MD5:\t";
1202 $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
1203 if (defined($tmp)) {
1204 if ($tmp eq 'YES') {
1205 print "$WHT SUPPORTED$NRM\n";
1206 } else {
1207 print "$WHT NOT SUPPORTED$NRM\n";
1208 }
1209 } else {
1210 print $WHT . " ERROR DETECTING$NRM\n";
1211 }
1212
1213 }
1214 }
1215 print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
1216 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1217 print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
1218 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
1219 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1220 print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
1221 print "If you don't understand or are unsure, you probably want \"login\"\n\n";
1222 print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
1223 $inval=<STDIN>;
1224 chomp($inval);
1225 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
1226 return lc($inval);
1227 } else {
1228 # user entered garbage or default value so nothing needs to be set
1229 return $imap_auth_mech;
1230 }
1231 }
1232
1233
1234 # SMTP authentication type
1235 # Possible choices: none, plain, cram-md5, digest-md5
1236 sub command112b {
1237 if ($use_smtp_tls =~ /^true\b/i) {
1238 print "Auto-detection of login methods is unavailable when using TLS.\n";
1239 } else {
1240 print "If you have already set the hostname and port number, I can try to\n";
1241 print "automatically detect some of the mechanisms your SMTP server supports.\n";
1242 print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
1243 print "\nTry to detect auth mechanisms? [y/N]: ";
1244 $inval=<STDIN>;
1245 chomp($inval);
1246 if ($inval =~ /^y\b/i) {
1247 # Yes, let's try to detect.
1248 print "Trying to detect supported methods (SMTP)...\n";
1249
1250 # Special case!
1251 # Check none by trying to relay to junk@microsoft.com
1252 $host = $smtpServerAddress . ':' . $smtpPort;
1253 use IO::Socket;
1254 my $sock = IO::Socket::INET->new($host);
1255 print "Testing none:\t\t$WHT";
1256 if (!defined($sock)) {
1257 print " ERROR TESTING\n";
1258 close $sock;
1259 } else {
1260 print $sock "mail from: tester\@squirrelmail.org\n";
1261 $got = <$sock>; # Discard
1262 print $sock "rcpt to: junk\@microsoft.com\n";
1263 $got = <$sock>; # This is the important line
1264 if ($got =~ /^250\b/) { # SMTP will relay without auth
1265 print "SUPPORTED$NRM\n";
1266 } else {
1267 print "NOT SUPPORTED$NRM\n";
1268 }
1269 print $sock "rset\n";
1270 print $sock "quit\n";
1271 close $sock;
1272 }
1273 # Try login (SquirrelMail default)
1274 print "Testing login:\t\t";
1275 $tmp=detect_auth_support('SMTP',$host,'LOGIN');
1276 if (defined($tmp)) {
1277 if ($tmp eq 'YES') {
1278 print $WHT . "SUPPORTED$NRM\n";
1279 } else {
1280 print $WHT . "NOT SUPPORTED$NRM\n";
1281 }
1282 } else {
1283 print $WHT . "ERROR DETECTING$NRM\n";
1284 }
1285
1286 # Try CRAM-MD5
1287 print "Testing CRAM-MD5:\t";
1288 $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5');
1289 if (defined($tmp)) {
1290 if ($tmp eq 'YES') {
1291 print $WHT . "SUPPORTED$NRM\n";
1292 } else {
1293 print $WHT . "NOT SUPPORTED$NRM\n";
1294 }
1295 } else {
1296 print $WHT . "ERROR DETECTING$NRM\n";
1297 }
1298
1299
1300 print "Testing DIGEST-MD5:\t";
1301 $tmp=detect_auth_support('SMTP',$host,'DIGEST-MD5');
1302 if (defined($tmp)) {
1303 if ($tmp eq 'YES') {
1304 print $WHT . "SUPPORTED$NRM\n";
1305 } else {
1306 print $WHT . "NOT SUPPORTED$NRM\n";
1307 }
1308 } else {
1309 print $WHT . "ERROR DETECTING$NRM\n";
1310 }
1311 }
1312 }
1313 print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
1314 print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
1315 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1316 print $WHT . "plain" . $NRM . " - SASL PLAIN. You already know it if you need this.\n";
1317 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1318 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1319 print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
1320 print "If you don't understand or are unsure, you probably want \"none\"\n\n";
1321 print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
1322 $inval=<STDIN>;
1323 chomp($inval);
1324 if ($inval =~ /^none\b/i) {
1325 # SMTP doesn't necessarily require logins
1326 return "none";
1327 }
1328 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
1329 ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
1330 return lc($inval);
1331 } else {
1332 # user entered garbage, or default value so nothing needs to be set
1333 return $smtp_auth_mech;
1334 }
1335 }
1336
1337 # TLS
1338 # This sub is reused for IMAP and SMTP
1339 # Args: service name, default value
1340 sub command113 {
1341 my($default_val,$service,$inval);
1342 $service=$_[0];
1343 $default_val=$_[1];
1344 print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
1345 print "If you're familiar with SSL, you get the idea.\n";
1346 print "To use this feature, your " . $service . " server must offer TLS\n";
1347 print "capability, plus PHP 4.3.x with OpenSSL support.\n";
1348 print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
1349 print "If it is remote, you may wish to seriously consider enabling this.\n";
1350 print "Enable TLS (y/n) [$WHT";
1351 if ($default_val eq "true") {
1352 print "y";
1353 } else {
1354 print "n";
1355 }
1356 print "$NRM]: $WHT";
1357 $inval=<STDIN>;
1358 $inval =~ tr/yn//cd;
1359 return "true" if ( $inval eq "y" );
1360 return "false" if ( $inval eq "n" );
1361 return $default_val;
1362
1363
1364 }
1365
1366
1367 # MOTD
1368 sub command71 {
1369 print "\nYou can now create the welcome message that is displayed\n";
1370 print "every time a user logs on. You can use HTML or just plain\n";
1371 print
1372 "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1373
1374 $new_motd = "";
1375 do {
1376 print "] ";
1377 $line = <STDIN>;
1378 $line =~ s/[\r|\n]//g;
1379 if ( $line ne "@" ) {
1380 $line =~ s/ /\&nbsp;\&nbsp;/g;
1381 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
1382 $line =~ s/$/ /;
1383 $line =~ s/\"/&quot;/g;
1384
1385 $new_motd = $new_motd . $line;
1386 }
1387 } while ( $line ne "@" );
1388 return $new_motd;
1389 }
1390
1391 ################# PLUGINS ###################
1392
1393 sub command81 {
1394 $command =~ s/[\s|\n|\r]*//g;
1395 if ( $command > 0 ) {
1396 $command = $command - 1;
1397 if ( $command <= $#plugins ) {
1398 @newplugins = ();
1399 $ct = 0;
1400 while ( $ct <= $#plugins ) {
1401 if ( $ct != $command ) {
1402 @newplugins = ( @newplugins, $plugins[$ct] );
1403 }
1404 $ct++;
1405 }
1406 @plugins = @newplugins;
1407 } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
1408 $num = $command - $#plugins - 1;
1409 @newplugins = @plugins;
1410 $ct = 0;
1411 while ( $ct <= $#unused_plugins ) {
1412 if ( $ct == $num ) {
1413 @newplugins = ( @newplugins, $unused_plugins[$ct] );
1414 }
1415 $ct++;
1416 }
1417 @plugins = @newplugins;
1418 }
1419 }
1420 return @plugins;
1421 }
1422
1423 ################# FOLDERS ###################
1424
1425 # default_folder_prefix
1426 sub command21 {
1427 print "Some IMAP servers (UW, for example) store mail and folders in\n";
1428 print "your user space in a separate subdirectory. This is where you\n";
1429 print "specify what that directory is.\n";
1430 print "\n";
1431 print "EXAMPLE: mail/";
1432 print "\n";
1433 print "NOTE: If you use Cyrus, or some server that would not use this\n";
1434 print " option, you must set this to 'none'.\n";
1435 print "\n";
1436 print "[$WHT$default_folder_prefix$NRM]: $WHT";
1437 $new_default_folder_prefix = <STDIN>;
1438
1439 if ( $new_default_folder_prefix eq "\n" ) {
1440 $new_default_folder_prefix = $default_folder_prefix;
1441 } else {
1442 $new_default_folder_prefix =~ s/[\r\n]//g;
1443 }
1444 if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
1445 $new_default_folder_prefix = "";
1446 } else {
1447 # add the trailing delimiter only if we know what the server is.
1448 if (($imap_server_type eq 'cyrus' and
1449 $optional_delimiter eq 'detect') or
1450 ($imap_server_type eq 'courier' and
1451 $optional_delimiter eq 'detect')) {
1452 $new_default_folder_prefix =~ s/\.*$/\./;
1453 } elsif ($imap_server_type eq 'uw' and
1454 $optional_delimiter eq 'detect') {
1455 $new_default_folder_prefix =~ s/\/*$/\//;
1456 }
1457 }
1458 return $new_default_folder_prefix;
1459 }
1460
1461 # Show Folder Prefix
1462 sub command22 {
1463 print "It is possible to set up the default folder prefix as a user\n";
1464 print "specific option, where each user can specify what their mail\n";
1465 print "folder is. If you set this to false, they will never see the\n";
1466 print "option, but if it is true, this option will appear in the\n";
1467 print "'options' section.\n";
1468 print "\n";
1469 print "NOTE: You set the default folder prefix in option '1' of this\n";
1470 print " section. That will be the default if the user doesn't\n";
1471 print " specify anything different.\n";
1472 print "\n";
1473
1474 if ( lc($show_prefix_option) eq "true" ) {
1475 $default_value = "y";
1476 } else {
1477 $default_value = "n";
1478 }
1479 print "\n";
1480 print "Show option (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 $show_prefix_option = "true";
1484 } else {
1485 $show_prefix_option = "false";
1486 }
1487 return $show_prefix_option;
1488 }
1489
1490 # Trash Folder
1491 sub command23a {
1492 print "You can now specify where the default trash folder is located.\n";
1493 print "On servers where you do not want this, you can set it to anything\n";
1494 print "and set option 6 to false.\n";
1495 print "\n";
1496 print "This is relative to where the rest of your email is kept. You do\n";
1497 print "not need to worry about their mail directory. If this folder\n";
1498 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1499 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1500 print "\n";
1501
1502 print "[$WHT$trash_folder$NRM]: $WHT";
1503 $new_trash_folder = <STDIN>;
1504 if ( $new_trash_folder eq "\n" ) {
1505 $new_trash_folder = $trash_folder;
1506 } else {
1507 $new_trash_folder =~ s/[\r|\n]//g;
1508 }
1509 return $new_trash_folder;
1510 }
1511
1512 # Sent Folder
1513 sub command23b {
1514 print "This is where messages that are sent will be stored. SquirrelMail\n";
1515 print "by default puts a copy of all outgoing messages in this folder.\n";
1516 print "\n";
1517 print "This is relative to where the rest of your email is kept. You do\n";
1518 print "not need to worry about their mail directory. If this folder\n";
1519 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1520 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1521 print "\n";
1522
1523 print "[$WHT$sent_folder$NRM]: $WHT";
1524 $new_sent_folder = <STDIN>;
1525 if ( $new_sent_folder eq "\n" ) {
1526 $new_sent_folder = $sent_folder;
1527 } else {
1528 $new_sent_folder =~ s/[\r|\n]//g;
1529 }
1530 return $new_sent_folder;
1531 }
1532
1533 # Draft Folder
1534 sub command23c {
1535 print "You can now specify where the default draft folder is located.\n";
1536 print "On servers where you do not want this, you can set it to anything\n";
1537 print "and set option 9 to false.\n";
1538 print "\n";
1539 print "This is relative to where the rest of your email is kept. You do\n";
1540 print "not need to worry about their mail directory. If this folder\n";
1541 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1542 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1543 print "\n";
1544
1545 print "[$WHT$draft_folder$NRM]: $WHT";
1546 $new_draft_folder = <STDIN>;
1547 if ( $new_draft_folder eq "\n" ) {
1548 $new_draft_folder = $draft_folder;
1549 } else {
1550 $new_draft_folder =~ s/[\r|\n]//g;
1551 }
1552 return $new_draft_folder;
1553 }
1554
1555 # default move to trash
1556 sub command24a {
1557 print "By default, should messages get moved to the trash folder? You\n";
1558 print "can specify the default trash folder in option 3. If this is set\n";
1559 print "to false, messages will get deleted immediately without moving\n";
1560 print "to the trash folder.\n";
1561 print "\n";
1562 print "Trash folder is currently: $trash_folder\n";
1563 print "\n";
1564
1565 if ( lc($default_move_to_trash) eq "true" ) {
1566 $default_value = "y";
1567 } else {
1568 $default_value = "n";
1569 }
1570 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1571 $new_show = <STDIN>;
1572 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1573 $default_move_to_trash = "true";
1574 } else {
1575 $default_move_to_trash = "false";
1576 }
1577 return $default_move_to_trash;
1578 }
1579
1580 # default move to sent
1581 sub command24b {
1582 print "By default, should messages get moved to the sent folder? You\n";
1583 print "can specify the default sent folder in option 4. If this is set\n";
1584 print "to false, messages will get sent and no copy will be made.\n";
1585 print "\n";
1586 print "Sent folder is currently: $sent_folder\n";
1587 print "\n";
1588
1589 if ( lc($default_move_to_sent) eq "true" ) {
1590 $default_value = "y";
1591 } else {
1592 $default_value = "n";
1593 }
1594 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1595 $new_show = <STDIN>;
1596 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1597 $default_move_to_sent = "true";
1598 } else {
1599 $default_move_to_sent = "false";
1600 }
1601 return $default_move_to_sent;
1602 }
1603
1604 # default save as draft
1605 sub command24c {
1606 print "By default, should the save to draft option be shown? You can\n";
1607 print "specify the default drafts folder in option 5. If this is set\n";
1608 print "to false, users will not be shown the save to draft option.\n";
1609 print "\n";
1610 print "Drafts folder is currently: $draft_folder\n";
1611 print "\n";
1612
1613 if ( lc($default_move_to_draft) eq "true" ) {
1614 $default_value = "y";
1615 } else {
1616 $default_value = "n";
1617 }
1618 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1619 $new_show = <STDIN>;
1620 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1621 $default_save_as_draft = "true";
1622 } else {
1623 $default_save_as_draft = "false";
1624 }
1625 return $default_save_as_draft;
1626 }
1627
1628 # List special folders first
1629 sub command27 {
1630 print "SquirrelMail has what we call 'special folders' that are not\n";
1631 print "manipulated and viewed like normal folders. Some examples of\n";
1632 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1633 print "Simply asks if you want these folders listed first in the folder\n";
1634 print "listing.\n";
1635 print "\n";
1636
1637 if ( lc($list_special_folders_first) eq "true" ) {
1638 $default_value = "y";
1639 } else {
1640 $default_value = "n";
1641 }
1642 print "\n";
1643 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1644 $new_show = <STDIN>;
1645 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1646 $list_special_folders_first = "true";
1647 } else {
1648 $list_special_folders_first = "false";
1649 }
1650 return $list_special_folders_first;
1651 }
1652
1653 # Show special folders color
1654 sub command28 {
1655 print "SquirrelMail has what we call 'special folders' that are not\n";
1656 print "manipulated and viewed like normal folders. Some examples of\n";
1657 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1658 print "wants to know if we should display special folders in a\n";
1659 print "color than the other folders.\n";
1660 print "\n";
1661
1662 if ( lc($use_special_folder_color) eq "true" ) {
1663 $default_value = "y";
1664 } else {
1665 $default_value = "n";
1666 }
1667 print "\n";
1668 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1669 $new_show = <STDIN>;
1670 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1671 $use_special_folder_color = "true";
1672 } else {
1673 $use_special_folder_color = "false";
1674 }
1675 return $use_special_folder_color;
1676 }
1677
1678 # Auto expunge
1679 sub command29 {
1680 print "The way that IMAP handles deleting messages is as follows. You\n";
1681 print "mark the message as deleted, and then to 'really' delete it, you\n";
1682 print "expunge it. This option asks if you want to just have messages\n";
1683 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1684 print "messages too.\n";
1685 print "\n";
1686
1687 if ( lc($auto_expunge) eq "true" ) {
1688 $default_value = "y";
1689 } else {
1690 $default_value = "n";
1691 }
1692 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1693 $new_show = <STDIN>;
1694 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1695 $auto_expunge = "true";
1696 } else {
1697 $auto_expunge = "false";
1698 }
1699 return $auto_expunge;
1700 }
1701
1702 # Default sub of inbox
1703 sub command210 {
1704 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1705 print "This can cause some confusion in folder creation for users when\n";
1706 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1707 print "and get permission errors. This option asks if you want folders\n";
1708 print "to be subfolders of INBOX by default.\n";
1709 print "\n";
1710
1711 if ( lc($default_sub_of_inbox) eq "true" ) {
1712 $default_value = "y";
1713 } else {
1714 $default_value = "n";
1715 }
1716 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1717 $new_show = <STDIN>;
1718 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1719 $default_sub_of_inbox = "true";
1720 } else {
1721 $default_sub_of_inbox = "false";
1722 }
1723 return $default_sub_of_inbox;
1724 }
1725
1726 # Show contain subfolder option
1727 sub command211 {
1728 print "Some IMAP servers (UW) make it so that there are two types of\n";
1729 print "folders. Those that contain messages, and those that contain\n";
1730 print "subfolders. If this is the case for your server, set this to\n";
1731 print "true, and it will ask the user whether the folder they are\n";
1732 print "creating contains subfolders or messages.\n";
1733 print "\n";
1734
1735 if ( lc($show_contain_subfolders_option) eq "true" ) {
1736 $default_value = "y";
1737 } else {
1738 $default_value = "n";
1739 }
1740 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1741 $new_show = <STDIN>;
1742 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1743 $show_contain_subfolders_option = "true";
1744 } else {
1745 $show_contain_subfolders_option = "false";
1746 }
1747 return $show_contain_subfolders_option;
1748 }
1749
1750 # Default Unseen Notify
1751 sub command212 {
1752 print "This option specifies where the users will receive notification\n";
1753 print "about unseen messages by default. This is of course an option that\n";
1754 print "can be changed on a user level.\n";
1755 print " 1 = No notification\n";
1756 print " 2 = Only on the INBOX\n";
1757 print " 3 = On all folders\n";
1758 print "\n";
1759
1760 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1761 $new_show = <STDIN>;
1762 if ( $new_show =~ /^[1|2|3]\n/i ) {
1763 $default_unseen_notify = $new_show;
1764 }
1765 $default_unseen_notify =~ s/[\r|\n]//g;
1766 return $default_unseen_notify;
1767 }
1768
1769 # Default Unseen Type
1770 sub command213 {
1771 print "Here you can define the default way that unseen messages will be displayed\n";
1772 print "to the user in the folder listing on the left side.\n";
1773 print " 1 = Only unseen messages (4)\n";
1774 print " 2 = Unseen and Total messages (4/27)\n";
1775 print "\n";
1776
1777 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1778 $new_show = <STDIN>;
1779 if ( $new_show =~ /^[1|2]\n/i ) {
1780 $default_unseen_type = $new_show;
1781 }
1782 $default_unseen_type =~ s/[\r|\n]//g;
1783 return $default_unseen_type;
1784 }
1785
1786 # Auto create special folders
1787 sub command214 {
1788 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1789 print "automatically print for you when a user logs in? If the user\n";
1790 print "accidentally deletes their special folders, this option will\n";
1791 print "automatically create it again for them.\n";
1792 print "\n";
1793
1794 if ( lc($auto_create_special) eq "true" ) {
1795 $default_value = "y";
1796 } else {
1797 $default_value = "n";
1798 }
1799 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1800 $new_show = <STDIN>;
1801 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1802 $auto_create_special = "true";
1803 } else {
1804 $auto_create_special = "false";
1805 }
1806 return $auto_create_special;
1807 }
1808
1809 # Automatically delete folders
1810 sub command215 {
1811 if ( $imap_server_type eq "uw" ) {
1812 print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
1813 print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
1814 print "If this is not the correct value for your server,\n";
1815 print "please use option D on the Main Menu to configure your server correctly.\n\n";
1816 print "Press any key to continue...\n";
1817 $new_delete = <STDIN>;
1818 $delete_folder = "true";
1819 } else {
1820 if ( $imap_server_type eq "courier" ) {
1821 print "Courier (or Courier-IMAP) IMAP servers may not support ";
1822 print "subfolders of Trash. \n";
1823 print "Specifically, if Courier is set to always move messages to Trash, \n";
1824 print "Trash will be treated by Courier as a special folder that does not \n";
1825 print "allow subfolders. \n\n";
1826 print "Please verify your Courier configuration, and test folder deletion \n";
1827 print "when changing this setting.\n\n";
1828 }
1829
1830 print "Are subfolders of the Trash supported by your IMAP server?\n";
1831 print "If so, should deleted folders be sent to Trash?\n";
1832 print "If not, say no (deleted folders should not be sent to Trash)\n\n";
1833 # reversal of logic.
1834 # question was: Should folders be automatically deleted instead of sent to trash..
1835 # we've changed the question to make it more clear,
1836 # and are here handling that to avoid changing the answers..
1837 if ( lc($delete_folder) eq "true" ) {
1838 $default_value = "n";
1839 } else {
1840 $default_value = "y";
1841 }
1842 print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
1843 $new_delete = <STDIN>;
1844 if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1845 $delete_folder = "false";
1846 } else {
1847 $delete_folder = "true";
1848 }
1849 }
1850 return $delete_folder;
1851 }
1852
1853 #noselect fix
1854 sub command216 {
1855 print "Some IMAP server allow subfolders to exist even if the parent\n";
1856 print "folders do not. This fixes some problems with the folder list\n";
1857 print "when this is the case, causing the /NoSelect folders to be displayed\n";
1858 print "\n";
1859
1860 if ( lc($noselect_fix_enable) eq "true" ) {
1861 $default_value = "y";
1862 } else {
1863 $default_value = "n";
1864 }
1865 print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
1866 $noselect_fix_enable = <STDIN>;
1867 if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1868 $noselect_fix_enable = "true";
1869 } else {
1870 $noselect_fix_enable = "false";
1871 }
1872 return $noselect_fix_enable;
1873 }
1874 ############# GENERAL OPTIONS #####################
1875
1876 # Data directory
1877 sub command33a {
1878 print "Specify the location for your data directory.\n";
1879 print "The path name can be absolute or relative (to the config directory).\n";
1880 print "It doesn't matter. Here are two examples:\n";
1881 print " Absolute: /var/spool/data/\n";
1882 print " Relative: ../data/\n";
1883 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1884 print "will be converted to their absolute path equivalents in config.php.\n\n";
1885 print "Note: There are potential security risks with having a writable directory\n";
1886 print "under the web server's root directory (ex: /home/httpd/html).\n";
1887 print "For this reason, it is recommended to put the data directory\n";
1888 print "in an alternate location of your choice. \n";
1889 print "\n";
1890
1891 print "[$WHT$data_dir$NRM]: $WHT";
1892 $new_data_dir = <STDIN>;
1893 if ( $new_data_dir eq "\n" ) {
1894 $new_data_dir = $data_dir;
1895 } else {
1896 $new_data_dir =~ s/[\r|\n]//g;
1897 }
1898 if ( $new_data_dir =~ /^\s*$/ ) {
1899 $new_data_dir = "";
1900 } else {
1901 $new_data_dir =~ s/\/*$//g;
1902 $new_data_dir =~ s/$/\//g;
1903 }
1904 return $new_data_dir;
1905 }
1906
1907 # Attachment directory
1908 sub command33b {
1909 print "Path to directory used for storing attachments while a mail is\n";
1910 print "being sent. The path name can be absolute or relative (to the config directory).\n";
1911 print "It doesn't matter. Here are two examples:\n";
1912 print " Absolute: /var/spool/attach/\n";
1913 print " Relative: ../attach/\n";
1914 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1915 print "will be converted to their absolute path equivalents in config.php.\n\n";
1916 print "Note: There are a few security considerations regarding this\n";
1917 print "directory:\n";
1918 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1919 print " impossible for a random person with access to the webserver\n";
1920 print " to list files in this directory. Confidential data might\n";
1921 print " be laying around in there.\n";
1922 print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
1923 print " may be possible, and more secure (e.g. root:apache)\n";
1924 print " 2. Since the webserver is not able to list the files in the\n";
1925 print " content is also impossible for the webserver to delete files\n";
1926 print " lying around there for too long.\n";
1927 print " 3. It should probably be another directory than the data\n";
1928 print " directory specified in option 3.\n";
1929 print "\n";
1930
1931 print "[$WHT$attachment_dir$NRM]: $WHT";
1932 $new_attachment_dir = <STDIN>;
1933 if ( $new_attachment_dir eq "\n" ) {
1934 $new_attachment_dir = $attachment_dir;
1935 } else {
1936 $new_attachment_dir =~ s/[\r|\n]//g;
1937 }
1938 if ( $new_attachment_dir =~ /^\s*$/ ) {
1939 $new_attachment_dir = "";
1940 } else {
1941 $new_attachment_dir =~ s/\/*$//g;
1942 $new_attachment_dir =~ s/$/\//g;
1943 }
1944 return $new_attachment_dir;
1945 }
1946
1947 sub command33c {
1948 print "The directory hash level setting allows you to configure the level\n";
1949 print "of hashing that Squirremail employs in your data and attachment\n";
1950 print "directories. This value must be an integer ranging from 0 to 4.\n";
1951 print "When this value is set to 0, Squirrelmail will simply store all\n";
1952 print "files as normal in the data and attachment directories. However,\n";
1953 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1954 print "used to organize the files in this directory. In short, the crc32\n";
1955 print "value for a username will be computed. Then, up to the first 4\n";
1956 print "digits of the hash, as set by this configuration value, will be\n";
1957 print "used to directory hash the files for that user in the data and\n";
1958 print "attachment directory. This allows for better performance on\n";
1959 print "servers with larger numbers of users.\n";
1960 print "\n";
1961
1962 print "[$WHT$dir_hash_level$NRM]: $WHT";
1963 $new_dir_hash_level = <STDIN>;
1964 if ( $new_dir_hash_level eq "\n" ) {
1965 $new_dir_hash_level = $dir_hash_level;
1966 } else {
1967 $new_dir_hash_level =~ s/[\r|\n]//g;
1968 }
1969 if ( ( int($new_dir_hash_level) < 0 )
1970 || ( int($new_dir_hash_level) > 4 )
1971 || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
1972 print "Invalid Directory Hash Level.\n";
1973 print "Value must be an integer ranging from 0 to 4\n";
1974 print "Hit enter to continue.\n";
1975 $enter_key = <STDIN>;
1976
1977 $new_dir_hash_level = $dir_hash_level;
1978 }
1979
1980 return $new_dir_hash_level;
1981 }
1982
1983 sub command35 {
1984 print "This is the default size (in pixels) of the left folder list.\n";
1985 print "Default is 200, but you can set it to whatever you wish. This\n";
1986 print "is a user preference, so this will only show up as their default.\n";
1987 print "\n";
1988 print "[$WHT$default_left_size$NRM]: $WHT";
1989 $new_default_left_size = <STDIN>;
1990 if ( $new_default_left_size eq "\n" ) {
1991 $new_default_left_size = $default_left_size;
1992 } else {
1993 $new_default_left_size =~ s/[\r|\n]//g;
1994 }
1995 return $new_default_left_size;
1996 }
1997
1998 sub command36 {
1999 print "Some IMAP servers only have lowercase letters in the usernames\n";
2000 print "but they still allow people with uppercase to log in. This\n";
2001 print "causes a problem with the user's preference files. This option\n";
2002 print "transparently changes all usernames to lowercase.";
2003 print "\n";
2004
2005 if ( lc($force_username_lowercase) eq "true" ) {
2006 $default_value = "y";
2007 } else {
2008 $default_value = "n";
2009 }
2010 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
2011 $new_show = <STDIN>;
2012 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2013 return "true";
2014 }
2015 return "false";
2016 }
2017
2018 sub command37 {
2019 print "";
2020 print "\n";
2021
2022 if ( lc($default_use_priority) eq "true" ) {
2023 $default_value = "y";
2024 } else {
2025 $default_value = "n";
2026 }
2027
2028 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
2029 $new_show = <STDIN>;
2030 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2031 return "true";
2032 }
2033 return "false";
2034 }
2035
2036 sub command38 {
2037 print "";
2038 print "\n";
2039
2040 if ( lc($default_hide_attribution) eq "true" ) {
2041 $default_value = "y";
2042 } else {
2043 $default_value = "n";
2044 }
2045
2046 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
2047 $new_show = <STDIN>;
2048 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2049 return "true";
2050 }
2051 return "false";
2052 }
2053
2054 sub command39 {
2055 print "";
2056 print "\n";
2057
2058 if ( lc($default_use_mdn) eq "true" ) {
2059 $default_value = "y";
2060 } else {
2061 $default_value = "n";
2062 }
2063
2064 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
2065 $new_show = <STDIN>;
2066 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2067 return "true";
2068 }
2069 return "false";
2070 }
2071
2072 sub command310 {
2073 print "This allows you to prevent the editing of the user's name and ";
2074 print "email address. This is mainly useful when used with the ";
2075 print "retrieveuserdata plugin\n";
2076 print "\n";
2077
2078 if ( lc($edit_identity) eq "true" ) {
2079 $default_value = "y";
2080 } else {
2081 $default_value = "n";
2082 }
2083 print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
2084 $new_edit = <STDIN>;
2085 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2086 $edit_identity = "true";
2087 $edit_name = "true";
2088 } else {
2089 $edit_identity = "false";
2090 $edit_name = command311();
2091 }
2092 return $edit_identity;
2093 }
2094
2095 sub command311 {
2096 print "As a follow-up, this option allows you to choose if the user ";
2097 print "can edit their full name even when you don't want them to ";
2098 print "change their username\n";
2099 print "\n";
2100
2101 if ( lc($edit_name) eq "true" ) {
2102 $default_value = "y";
2103 } else {
2104 $default_value = "n";
2105 }
2106 print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
2107 $new_edit = <STDIN>;
2108 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2109 $edit_name = "true";
2110 } else {
2111 $edit_name = "false";
2112 }
2113 return $edit_name;
2114 }
2115
2116 sub command312 {
2117 print "This option allows you to choose if users can use thread sorting\n";
2118 print "Your IMAP server must support the THREAD command for this to work\n";
2119 print "PHP versions later than 4.0.3 recommended\n";
2120 print "\n";
2121
2122 if ( lc($allow_thread_sort) eq "true" ) {
2123 $default_value = "y";
2124 } else {
2125 $default_value = "n";
2126 }
2127 print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2128 $allow_thread_sort = <STDIN>;
2129 if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2130 $allow_thread_sort = "true";
2131 } else {
2132 $allow_thread_sort = "false";
2133 }
2134 return $allow_thread_sort;
2135 }
2136
2137 sub command313 {
2138 print "This option allows you to choose if SM uses server-side sorting\n";
2139 print "Your IMAP server must support the SORT command for this to work\n";
2140 print "\n";
2141
2142 if ( lc($allow_server_sort) eq "true" ) {
2143 $default_value = "y";
2144 } else {
2145 $default_value = "n";
2146 }
2147 print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2148 $allow_server_sort = <STDIN>;
2149 if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2150 $allow_server_sort = "true";
2151 } else {
2152 $allow_server_sort = "false";
2153 }
2154 return $allow_server_sort;
2155 }
2156
2157 sub command314 {
2158 print "This option allows you to choose if SM uses charset search\n";
2159 print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2160 print "\n";
2161
2162 if ( lc($allow_charset_search) eq "true" ) {
2163 $default_value = "y";
2164 } else {
2165 $default_value = "n";
2166 }
2167 print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
2168 $allow_charset_search = <STDIN>;
2169 if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2170 $allow_charset_search = "true";
2171 } else {
2172 $allow_charset_search = "false";
2173 }
2174 return $allow_charset_search;
2175 }
2176
2177 sub command315 {
2178 ## OBSOLETE - UID support is now always enabled
2179 return "true";
2180 print "This option allows you to enable unique identifier (UID) support.\n";
2181 print "\n";
2182
2183 if ( lc($uid_support) eq "true" ) {
2184 $default_value = "y";
2185 } else {
2186 $default_value = "n";
2187 }
2188 print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
2189 $uid_support = <STDIN>;
2190 if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2191 $uid_support = "true";
2192 } else {
2193 $uid_support = "false";
2194 }
2195 return $uid_support;
2196 }
2197
2198 sub command316 {
2199 print "This option allows you to change the name of the PHP session used\n";
2200 print "by SquirrelMail. Unless you know what you are doing, you probably\n";
2201 print "don't need or want to change this from the default of SQMSESSID.\n";
2202 print "[$WHT$session_name$NRM]: $WHT";
2203 $new_session_name = <STDIN>;
2204 chomp($new_session_name);
2205 if ( $new_session_name eq "" ) {
2206 $new_session_name = $session_name;
2207 }
2208 return $new_session_name;
2209 }
2210
2211
2212
2213 sub command41 {
2214 print "\nDefine the themes that you wish to use. If you have added ";
2215 print "a theme of your own, just follow the instructions (?) about how to add ";
2216 print "them. You can also change the default theme.\n";
2217 print "[theme] command (?=help) > ";
2218 $input = <STDIN>;
2219 $input =~ s/[\r|\n]//g;
2220 while ( $input ne "d" ) {
2221 if ( $input =~ /^\s*l\s*/i ) {
2222 $count = 0;
2223 while ( $count <= $#theme_name ) {
2224 if ( $count == $theme_default ) {
2225 print " *";
2226 } else {
2227 print " ";
2228 }
2229 if ( $count < 10 ) {
2230 print " ";
2231 }
2232 $name = $theme_name[$count];
2233 $num_spaces = 35 - length($name);
2234 for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
2235 $name = $name . " ";
2236 }
2237
2238 print " $count. $name";
2239 print "($theme_path[$count])\n";
2240
2241 $count++;
2242 }
2243 } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
2244 $old_def = $theme_default;
2245 $theme_default = $input;
2246 $theme_default =~ s/^\s*m\s*//;
2247 if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
2248 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
2249 $theme_default = $old_def;
2250 }
2251 } elsif ( $input =~ /^\s*\+/ ) {
2252 print "What is the name of this theme: ";
2253 $name = <STDIN>;
2254 $name =~ s/[\r|\n]//g;
2255 $theme_name[ $#theme_name + 1 ] = $name;
2256 print "Be sure to put ../themes/ before the filename.\n";
2257 print "What file is this stored in (ex: ../themes/default_theme.php): ";
2258 $name = <STDIN>;
2259 $name =~ s/[\r|\n]//g;
2260 $theme_path[ $#theme_path + 1 ] = $name;
2261 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2262 if ( $input =~ /[0-9]+\s*$/ ) {
2263 $rem_num = $input;
2264 $rem_num =~ s/^\s*-\s*//g;
2265 $rem_num =~ s/\s*$//;
2266 } else {
2267 $rem_num = $#theme_name;
2268 }
2269 if ( $rem_num == $theme_default ) {
2270 print "You cannot remove the default theme!\n";
2271 } else {
2272 $count = 0;
2273 @new_theme_name = ();
2274 @new_theme_path = ();
2275 while ( $count <= $#theme_name ) {
2276 if ( $count != $rem_num ) {
2277 @new_theme_name = ( @new_theme_name, $theme_name[$count] );
2278 @new_theme_path = ( @new_theme_path, $theme_path[$count] );
2279 }
2280 $count++;
2281 }
2282 @theme_name = @new_theme_name;
2283 @theme_path = @new_theme_path;
2284 if ( $theme_default > $rem_num ) {
2285 $theme_default--;
2286 }
2287 }
2288 } elsif ( $input =~ /^\s*t\s*/i ) {
2289 print "\nStarting detection...\n\n";
2290
2291 opendir( DIR, "../themes" );
2292 @files = grep { /\.php$/i } readdir(DIR);
2293 $cnt = 0;
2294 while ( $cnt <= $#files ) {
2295 $filename = "../themes/" . $files[$cnt];
2296 if ( $filename ne "../themes/index.php" ) {
2297 $found = 0;
2298 for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
2299 if ( $theme_path[$x] eq $filename ) {
2300 $found = 1;
2301 }
2302 }
2303 if ( $found != 1 ) {
2304 print "** Found theme: $filename\n";
2305 print " What is its name? ";
2306 $nm = <STDIN>;
2307 $nm =~ s/[\n|\r]//g;
2308 $theme_name[ $#theme_name + 1 ] = $nm;
2309 $theme_path[ $#theme_path + 1 ] = $filename;
2310 }
2311 }
2312 $cnt++;
2313 }
2314 print "\n";
2315 for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
2316 $filename = $theme_path[$cnt];
2317 if ( !( -e $filename ) ) {
2318 print " Removing $filename (file not found)\n";
2319 $offset = 0;
2320 @new_theme_name = ();
2321 @new_theme_path = ();
2322 for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
2323 if ( $theme_path[$x] eq $filename ) {
2324 $offset = 1;
2325 }
2326 if ( $offset == 1 ) {
2327 $new_theme_name[$x] = $theme_name[ $x + 1 ];
2328 $new_theme_path[$x] = $theme_path[ $x + 1 ];
2329 } else {
2330 $new_theme_name[$x] = $theme_name[$x];
2331 $new_theme_path[$x] = $theme_path[$x];
2332 }
2333 }
2334 @theme_name = @new_theme_name;
2335 @theme_path = @new_theme_path;
2336 }
2337 }
2338 print "\nDetection complete!\n\n";
2339
2340 closedir DIR;
2341 } elsif ( $input =~ /^\s*\?\s*/ ) {
2342 print ".-------------------------.\n";
2343 print "| t (detect themes) |\n";
2344 print "| + (add theme) |\n";
2345 print "| - N (remove theme) |\n";
2346 print "| m N (mark default) |\n";
2347 print "| l (list themes) |\n";
2348 print "| d (done) |\n";
2349 print "`-------------------------'\n";
2350 }
2351 print "[theme] command (?=help) > ";
2352 $input = <STDIN>;
2353 $input =~ s/[\r|\n]//g;
2354 }
2355 }
2356
2357 # Theme - CSS file
2358 sub command42 {
2359 print "You may specify a cascading style-sheet (CSS) file to be included\n";
2360 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
2361 print "for specifying a site-wide font. If you're not familiar with CSS\n";
2362 print "files, leave this blank.\n";
2363 print "\n";
2364 print "To clear out an existing value, just type a space for the input.\n";
2365 print "\n";
2366 print "Please be aware of the following: \n";
2367 print " - Relative URLs are relative to the config dir\n";
2368 print " to use the themes directory, use ../themes/css/newdefault.css\n";
2369 print " - To specify a css file defined outside the SquirrelMail source tree\n";
2370 print " use the absolute URL the webserver would use to include the file\n";
2371 print " e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
2372 print "\n";
2373 print "[$WHT$theme_css$NRM]: $WHT";
2374 $new_theme_css = <STDIN>;
2375
2376 if ( $new_theme_css eq "\n" ) {
2377 $new_theme_css = $theme_css;
2378 } else {
2379 $new_theme_css =~ s/[\r|\n]//g;
2380 }
2381 $new_theme_css =~ s/^\s*//;
2382 return $new_theme_css;
2383 }
2384
2385 sub command61 {
2386 print "You can now define different LDAP servers.\n";
2387 print "[ldap] command (?=help) > ";
2388 $input = <STDIN>;
2389 $input =~ s/[\r|\n]//g;
2390 while ( $input ne "d" ) {
2391 if ( $input =~ /^\s*l\s*/i ) {
2392 $count = 0;
2393 while ( $count <= $#ldap_host ) {
2394 print "$count. $ldap_host[$count]\n";
2395 print " base: $ldap_base[$count]\n";
2396 if ( $ldap_charset[$count] ) {
2397 print " charset: $ldap_charset[$count]\n";
2398 }
2399 if ( $ldap_port[$count] ) {
2400 print " port: $ldap_port[$count]\n";
2401 }
2402 if ( $ldap_name[$count] ) {
2403 print " name: $ldap_name[$count]\n";
2404 }
2405 if ( $ldap_maxrows[$count] ) {
2406 print " maxrows: $ldap_maxrows[$count]\n";
2407 }
2408 print "\n";
2409 $count++;
2410 }
2411 } elsif ( $input =~ /^\s*\+/ ) {
2412 $sub = $#ldap_host + 1;
2413
2414 print "First, we need to have the hostname or the IP address where\n";
2415 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
2416 print "hostname: ";
2417 $name = <STDIN>;
2418 $name =~ s/[\r|\n]//g;
2419 $ldap_host[$sub] = $name;
2420
2421 print "\n";
2422
2423 print "Next, we need the server root (base dn). For this, an empty\n";
2424 print "string is allowed.\n";
2425 print "Example: ou=member_directory,o=netcenter.com\n";
2426 print "base: ";
2427 $name = <STDIN>;
2428 $name =~ s/[\r|\n]//g;
2429 $ldap_base[$sub] = $name;
2430
2431 print "\n";
2432
2433 print "This is the TCP/IP port number for the LDAP server. Default\n";
2434 print "port is 389. This is optional. Press ENTER for default.\n";
2435 print "port: ";
2436 $name = <STDIN>;
2437 $name =~ s/[\r|\n]//g;
2438 $ldap_port[$sub] = $name;
2439
2440 print "\n";
2441
2442 print "This is the charset for the server. Default is utf-8. This\n";
2443 print "is also optional. Press ENTER for default.\n";
2444 print "charset: ";
2445 $name = <STDIN>;
2446 $name =~ s/[\r|\n]//g;
2447 $ldap_charset[$sub] = $name;
2448
2449 print "\n";
2450
2451 print "This is the name for the server, used to tag the results of\n";
2452 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
2453 print "name: ";
2454 $name = <STDIN>;
2455 $name =~ s/[\r|\n]//g;
2456 $ldap_name[$sub] = $name;
2457
2458 print "\n";
2459
2460 print "You can specify the maximum number of rows in the search result.\n";
2461 print "Default is unlimited. Press ENTER for default.\n";
2462 print "maxrows: ";
2463 $name = <STDIN>;
2464 $name =~ s/[\r|\n]//g;
2465 $ldap_maxrows[$sub] = $name;
2466
2467 print "\n";
2468
2469 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2470 if ( $input =~ /[0-9]+\s*$/ ) {
2471 $rem_num = $input;
2472 $rem_num =~ s/^\s*-\s*//g;
2473 $rem_num =~ s/\s*$//;
2474 } else {
2475 $rem_num = $#ldap_host;
2476 }
2477 $count = 0;
2478 @new_ldap_host = ();
2479 @new_ldap_base = ();
2480 @new_ldap_port = ();
2481 @new_ldap_name = ();
2482 @new_ldap_charset = ();
2483 @new_ldap_maxrows = ();
2484
2485 while ( $count <= $#ldap_host ) {
2486 if ( $count != $rem_num ) {
2487 @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
2488 @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
2489 @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
2490 @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
2491 @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
2492 @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
2493 }
2494 $count++;
2495 }
2496 @ldap_host = @new_ldap_host;
2497 @ldap_base = @new_ldap_base;
2498 @ldap_port = @new_ldap_port;
2499 @ldap_name = @new_ldap_name;
2500 @ldap_charset = @new_ldap_charset;
2501 @ldap_maxrows = @new_ldap_maxrows;
2502 } elsif ( $input =~ /^\s*\?\s*/ ) {
2503 print ".-------------------------.\n";
2504 print "| + (add host) |\n";
2505 print "| - N (remove host) |\n";
2506 print "| l (list hosts) |\n";
2507 print "| d (done) |\n";
2508 print "`-------------------------'\n";
2509 }
2510 print "[ldap] command (?=help) > ";
2511 $input = <STDIN>;
2512 $input =~ s/[\r|\n]//g;
2513 }
2514 }
2515
2516 sub command62 {
2517 print "Some of our developers have come up with very good javascript interface\n";
2518 print "for searching through address books, however, our original goals said\n";
2519 print "that we would be 100% HTML. In order to make it possible to use their\n";
2520 print "interface, and yet stick with our goals, we have also written a plain\n";
2521 print "HTML version of the search. Here, you can choose which version to use.\n";
2522 print "\n";
2523 print "This is just the default value. It is also a user option that each\n";
2524 print "user can configure individually\n";
2525 print "\n";
2526
2527 if ( lc($default_use_javascript_addr_book) eq "true" ) {
2528 $default_value = "y";
2529 } else {
2530 $default_use_javascript_addr_book = "false";
2531 $default_value = "n";
2532 }
2533 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
2534 $new_show = <STDIN>;
2535 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2536 $default_use_javascript_addr_book = "true";
2537 } else {
2538 $default_use_javascript_addr_book = "false";
2539 }
2540 return $default_use_javascript_addr_book;
2541 }
2542
2543 sub command91 {
2544 print "If you want to store your users address book details in a database then\n";
2545 print "you need to set this DSN to a valid value. The format for this is:\n";
2546 print "mysql://user:pass\@hostname/dbname\n";
2547 print "Where mysql can be one of the databases PHP supports, the most common\n";
2548 print "of these are mysql, msql and pgsql\n";
2549 print "If the DSN is left empty (hit space and then return) the database\n";
2550 print "related code for address books will not be used\n";
2551 print "\n";
2552
2553 if ( $addrbook_dsn eq "" ) {
2554 $default_value = "Disabled";
2555 } else {
2556 $default_value = $addrbook_dsn;
2557 }
2558 print "[$WHT$addrbook_dsn$NRM]: $WHT";
2559 $new_dsn = <STDIN>;
2560 if ( $new_dsn eq "\n" ) {
2561 $new_dsn = "";
2562 } else {
2563 $new_dsn =~ s/[\r|\n]//g;
2564 $new_dsn =~ s/^\s+$//g;
2565 }
2566 return $new_dsn;
2567 }
2568
2569 sub command92 {
2570 print "This is the name of the table you want to store the address book\n";
2571 print "data in, it defaults to 'address'\n";
2572 print "\n";
2573 print "[$WHT$addrbook_table$NRM]: $WHT";
2574 $new_table = <STDIN>;
2575 if ( $new_table eq "\n" ) {
2576 $new_table = $addrbook_table;
2577 } else {
2578 $new_table =~ s/[\r|\n]//g;
2579 }
2580 return $new_table;
2581 }
2582
2583 sub command93 {
2584 print "If you want to store your users preferences in a database then\n";
2585 print "you need to set this DSN to a valid value. The format for this is:\n";
2586 print "mysql://user:pass\@hostname/dbname\n";
2587 print "Where mysql can be one of the databases PHP supports, the most common\n";
2588 print "of these are mysql, msql and pgsql\n";
2589 print "If the DSN is left empty (hit space and then return) the database\n";
2590 print "related code for address books will not be used\n";
2591 print "\n";
2592
2593 if ( $prefs_dsn eq "" ) {
2594 $default_value = "Disabled";
2595 } else {
2596 $default_value = $prefs_dsn;
2597 }
2598 print "[$WHT$prefs_dsn$NRM]: $WHT";
2599 $new_dsn = <STDIN>;
2600 if ( $new_dsn eq "\n" ) {
2601 $new_dsn = "";
2602 } else {
2603 $new_dsn =~ s/[\r|\n]//g;
2604 $new_dsn =~ s/^\s+$//g;
2605 }
2606 return $new_dsn;
2607 }
2608
2609 sub command94 {
2610 print "This is the name of the table you want to store the preferences\n";
2611 print "data in, it defaults to 'userprefs'\n";
2612 print "\n";
2613 print "[$WHT$prefs_table$NRM]: $WHT";
2614 $new_table = <STDIN>;
2615 if ( $new_table eq "\n" ) {
2616 $new_table = $prefs_table;
2617 } else {
2618 $new_table =~ s/[\r|\n]//g;
2619 }
2620 return $new_table;
2621 }
2622
2623 sub command95 {
2624 print "This is the name of the field in which you want to store the\n";
2625 print "username of the person the prefs are for. It default to 'user'\n";
2626 print "which clashes with a reserved keyword in PostgreSQL so this\n";
2627 print "will need to be changed for that database at least\n";
2628 print "\n";
2629 print "[$WHT$prefs_user_field$NRM]: $WHT";
2630 $new_field = <STDIN>;
2631 if ( $new_field eq "\n" ) {
2632 $new_field = $prefs_user_field;
2633 } else {
2634 $new_field =~ s/[\r|\n]//g;
2635 }
2636 return $new_field;
2637 }
2638
2639 sub command96 {
2640 print "This is the name of the field in which you want to store the\n";
2641 print "preferences keyword. It defaults to 'prefkey'\n";
2642 print "\n";
2643 print "[$WHT$prefs_key_field$NRM]: $WHT";
2644 $new_field = <STDIN>;
2645 if ( $new_field eq "\n" ) {
2646 $new_field = $prefs_key_field;
2647 } else {
2648 $new_field =~ s/[\r|\n]//g;
2649 }
2650 return $new_field;
2651 }
2652
2653 sub command97 {
2654 print "This is the name of the field in which you want to store the\n";
2655 print "preferences value. It defaults to 'prefval'\n";
2656 print "\n";
2657 print "[$WHT$prefs_val_field$NRM]: $WHT";
2658 $new_field = <STDIN>;
2659 if ( $new_field eq "\n" ) {
2660 $new_field = $prefs_val_field;
2661 } else {
2662 $new_field =~ s/[\r|\n]//g;
2663 }
2664 return $new_field;
2665 }
2666
2667 # Default language
2668 sub commandA1 {
2669 print "SquirrelMail attempts to set the language in many ways. If it\n";
2670 print "can not figure it out in another way, it will default to this\n";
2671 print "language. Please use the code for the desired language.\n";
2672 print "\n";
2673 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
2674 $new_squirrelmail_default_language = <STDIN>;
2675 if ( $new_squirrelmail_default_language eq "\n" ) {
2676 $new_squirrelmail_default_language = $squirrelmail_default_language;
2677 } else {
2678 $new_squirrelmail_default_language =~ s/[\r|\n]//g;
2679 $new_squirrelmail_default_language =~ s/^\s+$//g;
2680 }
2681 return $new_squirrelmail_default_language;
2682 }
2683 # Default Charset
2684 sub commandA2 {
2685 # print "This option controls what character set is used when sending\n";
2686 # print "mail and when sending HTML to the browser. Do not set this\n";
2687 # print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
2688 # print "to use KOI8-R, since this implementation is faster than most\n";
2689 # print "of the alternatives\n";
2690 print "This option is obsolate. Default charset depends on language\n";
2691 print "you have selected in \"Default language\" option.\n";
2692 print "\n";
2693
2694 print "[$WHT$default_charset$NRM]: $WHT";
2695 $new_default_charset = <STDIN>;
2696 if ( $new_default_charset eq "\n" ) {
2697 $new_default_charset = $default_charset;
2698 } else {
2699 $new_default_charset =~ s/[\r|\n]//g;
2700 }
2701 return $new_default_charset;
2702 }
2703 # Alternative language names
2704 sub commandA3 {
2705 print "Enable this option if you want to see localized language names in\n";
2706 print "language selection box. Note, that if don't limit list of available\n";
2707 print "languages, this option can trigger installation of foreign language\n";
2708 print "support modules in some browsers.\n";
2709 print "\n";
2710
2711 if ( lc($show_alternative_names) eq "true" ) {
2712 $default_value = "y";
2713 } else {
2714 $default_value = "n";
2715 }
2716 print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
2717 $show_alternative_names = <STDIN>;
2718 if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2719 $show_alternative_names = "true";
2720 } else {
2721 $show_alternative_names = "false";
2722 }
2723 return $show_alternative_names;
2724 }
2725 # Available languages
2726 sub commandA4 {
2727 print "This option allows to limit number of languages available in\n";
2728 print "language selection box. You can enter as code of every language that\n";
2729 print "you want to enable. Language codes should be separated by space. If you\n";
2730 print "enter name unsupported by SquirrelMail, it will be ignored. If you enter\n";
2731 print "special key \'all\' - all languages available in SquirrelMail will be\n";
2732 print "listed. If you enter special key \'none\' - user won't be able to change";
2733 print "language and interface will use language set it \"Default language\" option.\n";
2734 print "\n";
2735 print "Valid language names are:\n";
2736 print " ar (Arabic), bg_BG (Bulgarian), ca_ES (Catalan), cy_GB (Welsh)\n";
2737 print " cs_CZ (Chech), da_DK (Danish), de_DE (German), el_GR (Greek),\n";
2738 print " en_US (English), es_ES (Spanish), et_EE (Estonian), fi_FI (Finnish),\n";
2739 print " fo_FO (Faroese), fr_FR (French), he_IL (Hebrew), hr_HR (Croatian),\n";
2740 print " hu_HU (Hungarian), id_ID (Indonesian), is_IS (Icelandic), it_IT (Italian),\n";
2741 print " ja_JP (Japanese), ko_KR (Korean), lt_LT (Lithuanian), ms_MY (Malay),\n";
2742 print " nl_NL (Dutch), nn_NO (Norwegian (Nynorsk)), no_NO (Norwegian (Bokmal)),\n";
2743 print " pl_PL (Polish), pt_BR (Portuguese (Brazil)), pt_PT (Portuguese (Portugal)),\n";
2744 print " ro_RO (Romanian), ru_RU (Russian), sk_SK (Slovak), sl_SI (Slovenian),\n";
2745 print " sr_YU (Serbian), sv_SE (Swedish), th_TH (Thai), tr_TR (Turkish),\n";
2746 print " zh_CN (Chinese Simplified), zh_TW (Chinese Traditional).\n";
2747 print "\n";
2748 print "[$WHT$available_languages$NRM]: $WHT";
2749 $new_available_languages = <STDIN>;
2750 if ( $new_available_languages eq "\n" ) {
2751 $new_available_languages = $available_languages;
2752 } else {
2753 $new_available_languages =~ s/[\r|\n]//g;
2754 $new_available_languages =~ s/^\s+$//g;
2755 }
2756 return $new_available_languages;
2757 }
2758 # Agresive decoding
2759 sub commandA5 {
2760 print "Enable this option if you want to use CPU and memory intensive decoding\n";
2761 print "functions. This option allows reading multibyte charset, that are used\n";
2762 print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
2763 print "even when you have disabled use of recode in Tweaks section.\n";
2764 print "\n";
2765
2766 if ( lc($agresive_decoding) eq "true" ) {
2767 $default_value = "y";
2768 } else {
2769 $default_value = "n";
2770 }
2771 print "Use agresive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
2772 $agresive_decoding = <STDIN>;
2773 if ( ( $agresive_decoding =~ /^y\n/i ) || ( ( $agresive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2774 $agresive_decoding = "true";
2775 } else {
2776 $agresive_decoding = "false";
2777 }
2778 return $agresive_decoding;
2779 }
2780
2781 # Advanced tree
2782 sub commandB1 {
2783 print "Enable this option if you want to use DHTML based folder listing.\n";
2784 print "Code is experimental, works only with some browsers and there might\n";
2785 print "be some glitches.\n";
2786 print "\n";
2787
2788 if ( lc($advanced_tree) eq "true" ) {
2789 $default_value = "y";
2790 } else {
2791 $default_value = "n";
2792 }
2793 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2794 $advanced_tree = <STDIN>;
2795 if ( ( $advanced_tree =~ /^y\n/i ) || ( ( $advanced_tree =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2796 $advanced_tree = "true";
2797 } else {
2798 $advanced_tree = "false";
2799 }
2800 return $advanced_tree;
2801 }
2802 # Oldway
2803 sub commandB2 {
2804 print "Setting $oldway to false causes left_main.php to use the new\n";
2805 print "experimental way of getting the mailbox-tree.\n";
2806 print "\n";
2807
2808 if ( lc($oldway) eq "true" ) {
2809 $default_value = "y";
2810 } else {
2811 $default_value = "n";
2812 }
2813 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2814 $oldway = <STDIN>;
2815 if ( ( $oldway =~ /^y\n/i ) || ( ( $oldway =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2816 $oldway = "true";
2817 } else {
2818 $oldway = "false";
2819 }
2820 return $oldway;
2821 }
2822 # php recode
2823 sub commandB3 {
2824 print "Enable this option if you want to use php recode functions to read\n";
2825 print "emails written in charset that differs from the one that is set in\n";
2826 print "translation selected by user. Code is experimental, it might cause\n";
2827 print "errors, if email contains charset unsupported by recode or if your\n";
2828 print "php does not have recode support.\n";
2829 print "\n";
2830
2831 if ( lc($use_php_recode) eq "true" ) {
2832 $default_value = "y";
2833 } else {
2834 $default_value = "n";
2835 }
2836 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2837 $use_php_recode = <STDIN>;
2838 if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2839 $use_php_recode = "true";
2840 } else {
2841 $use_php_recode = "false";
2842 }
2843 return $use_php_recode;
2844 }
2845 # php iconv
2846 sub commandB4 {
2847 print "Enable this option if you want to use php iconv functions to read\n";
2848 print "emails written in charset that differs from the one that is set in\n";
2849 print "translation selected by user. Code is experimental, it works only\n";
2850 print "with translations that use utf-8 charset. Code might cause errors,\n";
2851 print "if email contains charset unsupported by iconv or if your php does\n";
2852 print "not have iconv support.\n";
2853 print "\n";
2854
2855 if ( lc($use_php_iconv) eq "true" ) {
2856 $default_value = "y";
2857 } else {
2858 $default_value = "n";
2859 }
2860 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2861 $use_php_iconv = <STDIN>;
2862 if ( ( $use_php_iconv =~ /^y\n/i ) || ( ( $use_php_iconv =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2863 $use_php_iconv = "true";
2864 } else {
2865 $use_php_iconv = "false";
2866 }
2867 return $use_php_iconv;
2868 }
2869
2870
2871 sub save_data {
2872 $tab = " ";
2873 if ( open( CF, ">config.php" ) ) {
2874 print CF "<?php\n";
2875 print CF "\n";
2876
2877 print CF "/**\n";
2878 print CF " * SquirrelMail Configuration File\n";
2879 print CF " * Created using the configure script, conf.pl\n";
2880 print CF " */\n";
2881 print CF "\n";
2882 print CF "global \$version;\n";
2883
2884 if ($print_config_version) {
2885 print CF "\$config_version = '$print_config_version';\n";
2886 }
2887 # integer
2888 print CF "\$config_use_color = $config_use_color;\n";
2889 print CF "\n";
2890
2891 # string
2892 print CF "\$org_name = \"$org_name\";\n";
2893 # string
2894 print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
2895 $org_logo_width |= 0;
2896 $org_logo_height |= 0;
2897 # string
2898 print CF "\$org_logo_width = '$org_logo_width';\n";
2899 # string
2900 print CF "\$org_logo_height = '$org_logo_height';\n";
2901 # string that can contain variables.
2902 print CF "\$org_title = \"$org_title\";\n";
2903 # string
2904 print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
2905 # string
2906 print CF "\$frame_top = '$frame_top';\n";
2907 print CF "\n";
2908
2909 print CF "\$provider_uri = '$provider_uri';\n";
2910 print CF "\n";
2911
2912 print CF "\$provider_name = '$provider_name';\n";
2913 print CF "\n";
2914
2915 # string that can contain variables
2916 print CF "\$motd = \"$motd\";\n";
2917 print CF "\n";
2918
2919 # string
2920 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
2921 # string
2922 print CF "\$default_charset = '$default_charset';\n";
2923 # boolean
2924 print CF "\$show_alternative_names = '$show_alternative_names';\n";
2925 # string
2926 print CF "\$available_languages = '$available_languages';\n";
2927 # boolean
2928 print CF "\$agresive_decoding = '$agresive_decoding';\n";
2929 print CF "\n";
2930
2931 # string
2932 print CF "\$domain = '$domain';\n";
2933 # string
2934 print CF "\$imapServerAddress = '$imapServerAddress';\n";
2935 # integer
2936 print CF "\$imapPort = $imapPort;\n";
2937 # boolean
2938 print CF "\$useSendmail = $useSendmail;\n";
2939 # string
2940 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
2941 # integer
2942 print CF "\$smtpPort = $smtpPort;\n";
2943 # string
2944 print CF "\$sendmail_path = '$sendmail_path';\n";
2945 # boolean
2946 # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
2947 # boolean
2948 print CF "\$pop_before_smtp = $pop_before_smtp;\n";
2949 # string
2950 print CF "\$imap_server_type = '$imap_server_type';\n";
2951 # boolean
2952 print CF "\$invert_time = $invert_time;\n";
2953 # string
2954 print CF "\$optional_delimiter = '$optional_delimiter';\n";
2955 print CF "\n";
2956
2957 # string
2958 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
2959 # string
2960 print CF "\$trash_folder = '$trash_folder';\n";
2961 # string
2962 print CF "\$sent_folder = '$sent_folder';\n";
2963 # string
2964 print CF "\$draft_folder = '$draft_folder';\n";
2965 # boolean
2966 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
2967 # boolean
2968 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
2969 # boolean
2970 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
2971 # boolean
2972 print CF "\$show_prefix_option = $show_prefix_option;\n";
2973 # boolean
2974 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
2975 # boolean
2976 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
2977 # boolean
2978 print CF "\$auto_expunge = $auto_expunge;\n";
2979 # boolean
2980 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
2981 # boolean
2982 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
2983 # integer
2984 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
2985 # integer
2986 print CF "\$default_unseen_type = $default_unseen_type;\n";
2987 # boolean
2988 print CF "\$auto_create_special = $auto_create_special;\n";
2989 # boolean
2990 print CF "\$delete_folder = $delete_folder;\n";
2991 # boolean
2992 print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
2993
2994 print CF "\n";
2995
2996 # string
2997 print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
2998 # string that can contain a variable
2999 print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
3000 # integer
3001 print CF "\$dir_hash_level = $dir_hash_level;\n";
3002 # string
3003 print CF "\$default_left_size = '$default_left_size';\n";
3004 # boolean
3005 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
3006 # boolean
3007 print CF "\$default_use_priority = $default_use_priority;\n";
3008 # boolean
3009 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
3010 # boolean
3011 print CF "\$default_use_mdn = $default_use_mdn;\n";
3012 # boolean
3013 print CF "\$edit_identity = $edit_identity;\n";
3014 # boolean
3015 print CF "\$edit_name = $edit_name;\n";
3016 # boolean
3017 print CF "\$allow_thread_sort = $allow_thread_sort;\n";
3018 # boolean
3019 print CF "\$allow_server_sort = $allow_server_sort;\n";
3020 # boolean
3021 print CF "\$allow_charset_search = $allow_charset_search;\n";
3022 print CF "\n";
3023
3024 # all plugins are strings
3025 for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
3026 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
3027 }
3028 print CF "\n";
3029
3030 # strings
3031 print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
3032 if ( $theme_default eq '' ) { $theme_default = '0'; }
3033 print CF "\$theme_default = $theme_default;\n";
3034
3035 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
3036 print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
3037 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
3038 }
3039 print CF "\n";
3040
3041 if ( $default_use_javascript_addr_book ne "true" ) {
3042 $default_use_javascript_addr_book = "false";
3043 }
3044
3045 # boolean
3046 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
3047 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
3048 print CF "\$ldap_server[$count] = array(\n";
3049 # string
3050 print CF " 'host' => '$ldap_host[$count]',\n";
3051 # string
3052 print CF " 'base' => '$ldap_base[$count]'";
3053 if ( $ldap_name[$count] ) {
3054 print CF ",\n";
3055 # string
3056 print CF " 'name' => '$ldap_name[$count]'";
3057 }
3058 if ( $ldap_port[$count] ) {
3059 print CF ",\n";
3060 # integer
3061 print CF " 'port' => $ldap_port[$count]";
3062 }
3063 if ( $ldap_charset[$count] ) {
3064 print CF ",\n";
3065 # string
3066 print CF " 'charset' => '$ldap_charset[$count]'";
3067 }
3068 if ( $ldap_maxrows[$count] ) {
3069 print CF ",\n";
3070 # integer
3071 print CF " 'maxrows' => $ldap_maxrows[$count]";
3072 }
3073 print CF "\n";
3074 print CF ");\n";
3075 print CF "\n";
3076 }
3077
3078 # string
3079 print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
3080 # string
3081 print CF "\$addrbook_table = '$addrbook_table';\n\n";
3082 # string
3083 print CF "\$prefs_dsn = '$prefs_dsn';\n";
3084 # string
3085 print CF "\$prefs_table = '$prefs_table';\n";
3086 # string
3087 print CF "\$prefs_user_field = '$prefs_user_field';\n";
3088 # string
3089 print CF "\$prefs_key_field = '$prefs_key_field';\n";
3090 # string
3091 print CF "\$prefs_val_field = '$prefs_val_field';\n";
3092 # boolean
3093 print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
3094
3095 # string
3096 print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
3097 print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
3098 # boolean
3099 print CF "\$use_imap_tls = $use_imap_tls;\n";
3100 print CF "\$use_smtp_tls = $use_smtp_tls;\n";
3101
3102 print CF "\$session_name = '$session_name';\n";
3103
3104 print CF "\n";
3105
3106 # boolean
3107 print CF "\$advanced_tree = '$advanced_tree';\n";
3108 print CF "\n";
3109 # boolean
3110 print CF "\$oldway = '$oldway';\n";
3111 print CF "\n";
3112 # boolean
3113 print CF "\$use_php_recode = '$use_php_recode';\n";
3114 print CF "\n";
3115 # boolean
3116 print CF "\$use_php_iconv = '$use_php_iconv';\n";
3117 print CF "\n";
3118
3119 print CF "\@include SM_PATH . 'config/config_local.php';\n";
3120
3121 print CF "\n/**\n";
3122 print CF " * Make sure there are no characters after the PHP closing\n";
3123 print CF " * tag below (including newline characters and whitespace).\n";
3124 print CF " * Otherwise, that character will cause the headers to be\n";
3125 print CF " * sent and regular output to begin, which will majorly screw\n";
3126 print CF " * things up when we try to send more headers later.\n";
3127 print CF " */\n";
3128 print CF "?>";
3129
3130 close CF;
3131
3132 print "Data saved in config.php\n";
3133 } else {
3134 print "Error saving config.php: $!\n";
3135 }
3136 }
3137
3138 sub set_defaults {
3139 clear_screen();
3140 print $WHT. "SquirrelMail Configuration : " . $NRM;
3141 if ( $config == 1 ) { print "Read: config.php"; }
3142 elsif ( $config == 2 ) { print "Read: config_default.php"; }
3143 print "\n";
3144 print "---------------------------------------------------------\n";
3145
3146 print "While we have been building SquirrelMail, we have discovered some\n";
3147 print "preferences that work better with some servers that don't work so\n";
3148 print "well with others. If you select your IMAP server, this option will\n";
3149 print "set some pre-defined settings for that server.\n";
3150 print "\n";
3151 print "Please note that you will still need to go through and make sure\n";
3152 print "everything is correct. This does not change everything. There are\n";
3153 print "only a few settings that this will change.\n";
3154 print "\n";
3155
3156 $continue = 0;
3157 while ( $continue != 1 ) {
3158 print "Please select your IMAP server:\n";
3159 print " cyrus = Cyrus IMAP server\n";
3160 print " uw = University of Washington's IMAP server\n";
3161 print " exchange = Microsoft Exchange IMAP server\n";
3162 print " courier = Courier IMAP server\n";
3163 print " macosx = Mac OS X Mailserver\n";
3164 print " mercury32 = Mercury/32\n";
3165 print " quit = Do not change anything\n";
3166 print "Command >> ";
3167 $server = <STDIN>;
3168 $server =~ s/[\r|\n]//g;
3169
3170 print "\n";
3171 if ( $server eq "cyrus" ) {
3172 $imap_server_type = "cyrus";
3173 $default_folder_prefix = "";
3174 $trash_folder = "INBOX.Trash";
3175 $sent_folder = "INBOX.Sent";
3176 $draft_folder = "INBOX.Drafts";
3177 $show_prefix_option = false;
3178 $default_sub_of_inbox = true;
3179 $show_contain_subfolders_option = false;
3180 $optional_delimiter = ".";
3181 $disp_default_folder_prefix = "<none>";
3182 $force_username_lowercase = false;
3183
3184 $continue = 1;
3185 } elsif ( $server eq "uw" ) {
3186 $imap_server_type = "uw";
3187 $default_folder_prefix = "mail/";
3188 $trash_folder = "Trash";
3189 $sent_folder = "Sent";
3190 $draft_folder = "Drafts";
3191 $show_prefix_option = true;
3192 $default_sub_of_inbox = false;
3193 $show_contain_subfolders_option = true;
3194 $optional_delimiter = "/";
3195 $disp_default_folder_prefix = $default_folder_prefix;
3196 $delete_folder = true;
3197 $force_username_lowercase = true;
3198
3199 $continue = 1;
3200 } elsif ( $server eq "exchange" ) {
3201 $imap_server_type = "exchange";
3202 $default_folder_prefix = "";
3203 $default_sub_of_inbox = true;
3204 $trash_folder = "INBOX/Deleted Items";
3205 $sent_folder = "INBOX/Sent Items";
3206 $drafts_folder = "INBOX/Drafts";
3207 $show_prefix_option = false;
3208 $show_contain_subfolders_option = false;
3209 $optional_delimiter = "detect";
3210 $disp_default_folder_prefix = "<none>";
3211 $force_username_lowercase = true;
3212
3213 $continue = 1;
3214 } elsif ( $server eq "courier" ) {
3215 $imap_server_type = "courier";
3216 $default_folder_prefix = "INBOX.";
3217 $trash_folder = "Trash";
3218 $sent_folder = "Sent";
3219 $draft_folder = "Drafts";
3220 $show_prefix_option = false;
3221 $default_sub_of_inbox = false;
3222 $show_contain_subfolders_option = false;
3223 $optional_delimiter = ".";
3224 $disp_default_folder_prefix = $default_folder_prefix;
3225 $delete_folder = true;
3226 $force_username_lowercase = false;
3227
3228 $continue = 1;
3229 } elsif ( $server eq "macosx" ) {
3230 $imap_server_type = "macosx";
3231 $default_folder_prefix = "INBOX/";
3232 $trash_folder = "Trash";
3233 $sent_folder = "Sent";
3234 $draft_folder = "Drafts";
3235 $show_prefix_option = false;
3236 $default_sub_of_inbox = true;
3237 $show_contain_subfolders_option = false;
3238 $optional_delimiter = "detect";
3239 $allow_charset_search = false;
3240 $disp_default_folder_prefix = $default_folder_prefix;
3241
3242 $continue = 1;
3243 } elsif ( $server eq "mercury32" ) {
3244 $imap_server_type = "mercury32";
3245 $default_folder_prefix = "";
3246 $trash_folder = "INBOX.Trash";
3247 $sent_folder = "INBOX.Sent";
3248 $draft_folder = "INBOX.Drafts";
3249 $show_prefix_option = false;
3250 $default_sub_of_inbox = true;
3251 $show_contain_subfolders_option = true;
3252 $optional_delimiter = "detect";
3253 $delete_folder = true;
3254 $force_username_lowercase = true;
3255
3256 $continue = 1;
3257 } elsif ( $server eq "quit" ) {
3258 $continue = 1;
3259 } else {
3260 $disp_default_folder_prefix = $default_folder_prefix;
3261 print "Unrecognized server: $server\n";
3262 print "\n";
3263 }
3264
3265 print " imap_server_type = $imap_server_type\n";
3266 print " default_folder_prefix = $disp_default_folder_prefix\n";
3267 print " trash_folder = $trash_folder\n";
3268 print " sent_folder = $sent_folder\n";
3269 print " draft_folder = $draft_folder\n";
3270 print " show_prefix_option = $show_prefix_option\n";
3271 print " default_sub_of_inbox = $default_sub_of_inbox\n";
3272 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3273 print " optional_delimiter = $optional_delimiter\n";
3274 print " delete_folder = $delete_folder\n";
3275 print " force_username_lowercase = $force_username_lowercase\n";
3276 }
3277 print "\nPress enter to continue...";
3278 $tmp = <STDIN>;
3279 }
3280
3281 # This subroutine corrects relative paths to ensure they
3282 # will work within the SM space. If the path falls within
3283 # the SM directory tree, the SM_PATH variable will be
3284 # prepended to the path, if not, then the path will be
3285 # converted to an absolute path, e.g.
3286 # '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
3287 # '../../someplace/data' --> '/absolute/path/someplace/data'
3288 # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
3289 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3290 # 'http://whatever/' --> 'http://whatever'
3291 # $some_var/path --> "$some_var/path"
3292 sub change_to_SM_path() {
3293 my ($old_path) = @_;
3294 my $new_path = '';
3295 my @rel_path;
3296 my @abs_path;
3297 my $subdir;
3298
3299 # If the path is absolute, don't bother.
3300 return "\'" . $old_path . "\'" if ( $old_path eq '');
3301 return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ );
3302 return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:\// );
3303 return $old_path if ( $old_path =~ /^\'(\/|http)/ );
3304 return $old_path if ( $old_path =~ /^\'\w:\// );
3305 return $old_path if ( $old_path =~ /^SM_PATH/);
3306
3307 if ( $old_path =~ /^\$/ ) {
3308 # check if it's a single var, or a $var/path combination
3309 # if it's $var/path, enclose in ""
3310 if ( $old_path =~ /\// ) {
3311 return '"'.$old_path.'"';
3312 }
3313 return $old_path;
3314 }
3315
3316 # Remove remaining '
3317 $old_path =~ s/\'//g;
3318
3319 # For relative paths, split on '../'
3320 @rel_path = split(/\.\.\//, $old_path);
3321
3322 if ( $#rel_path > 1 ) {
3323 # more than two levels away. Make it absolute.
3324 @abs_path = split(/\//, $dir);
3325
3326 # Lop off the relative pieces of the absolute path..
3327 for ( $i = 0; $i <= $#rel_path; $i++ ) {
3328 pop @abs_path;
3329 shift @rel_path;
3330 }
3331 push @abs_path, @rel_path;
3332 $new_path = "\'" . join('/', @abs_path) . "\'";
3333 } elsif ( $#rel_path > 0 ) {
3334 # it's within the SM tree, prepend SM_PATH
3335 $new_path = $old_path;
3336 $new_path =~ s/^\.\.\//SM_PATH . \'/;
3337 $new_path .= "\'";
3338 } else {
3339 # Last, it's a relative path without any leading '.'
3340 # Prepend SM_PATH and config, since the paths are
3341 # relative to the config directory
3342 $new_path = "SM_PATH . \'config/" . $old_path . "\'";
3343 }
3344 return $new_path;
3345 }
3346
3347
3348 # Change SM_PATH to admin-friendly version, e.g.:
3349 # SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
3350 # SM_PATH . 'config/some.php' --> 'some.php'
3351 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3352 # 'http://whatever/' --> 'http://whatever'
3353 sub change_to_rel_path() {
3354 my ($old_path) = @_;
3355 my $new_path = $old_path;
3356
3357 if ( $old_path =~ /^SM_PATH/ ) {
3358 $new_path =~ s/^SM_PATH . \'/\.\.\//;
3359 $new_path =~ s/\.\.\/config\///;
3360 }
3361
3362 return $new_path;
3363 }
3364
3365 sub detect_auth_support {
3366 # Attempts to auto-detect if a specific auth mechanism is supported.
3367 # Called by 'command112a' and 'command112b'
3368 # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3369
3370 # Misc setup
3371 use IO::Socket;
3372 my $service = shift;
3373 my $host = shift;
3374 my $mech = shift;
3375 # Sanity checks
3376 if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3377 # Error - wrong # of args
3378 print "BAD ARGS!\n";
3379 return undef;
3380 }
3381
3382 if ($service eq 'SMTP') {
3383 $cmd = "AUTH $mech\n";
3384 $logout = "QUIT\n";
3385 } elsif ($service eq 'IMAP') {
3386 $cmd = "A01 AUTHENTICATE $mech\n";
3387 $logout = "C01 LOGOUT\n";
3388 } else {
3389 # unknown service - whoops.
3390 return undef;
3391 }
3392
3393 # Get this show on the road
3394 my $sock=IO::Socket::INET->new($host);
3395 if (!defined($sock)) {
3396 # Connect failed
3397 return undef;
3398 }
3399 my $discard = <$sock>; # Server greeting/banner - who cares..
3400
3401 if ($service eq 'SMTP') {
3402 # Say hello first..
3403 print $sock "helo $domain\n";
3404 $discard = <$sock>; # Yeah yeah, you're happy to see me..
3405 }
3406 print $sock $cmd;
3407
3408 my $response = <$sock>;
3409 chomp($response);
3410 if (!defined($response)) {
3411 return undef;
3412 }
3413
3414 # So at this point, we have a response, and it is (hopefully) valid.
3415 if ($service eq 'SMTP') {
3416 if (($response =~ /^535/) or ($response =~/^502/)) {
3417 # Not supported
3418 close $sock;
3419 return 'NO';
3420 } elsif ($response =~ /^503/) {
3421 #Something went wrong
3422 return undef;
3423 }
3424 } elsif ($service eq 'IMAP') {
3425 if ($response =~ /^A01/) {
3426 # Not supported
3427 close $sock;
3428 return 'NO';
3429 }
3430 } else {
3431 # Unknown service - this shouldn't be able to happen.
3432 close $sock;
3433 return undef;
3434 }
3435
3436 # If it gets here, the mech is supported
3437 print $sock "*\n"; # Attempt to cancel authentication
3438 print $sock $logout; # Try to log out, but we don't really care if this fails
3439 close $sock;
3440 return 'YES';
3441 }
3442
3443 sub clear_screen() {
3444 if ( $^O =~ /^mswin/i) {
3445 system "cls";
3446 } else {
3447 system "clear";
3448 }
3449 }