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