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