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