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