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