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