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