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