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