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