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