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