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