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