3 # Written March 26, 2000
4 # Luke Ehresman (lehresma@css.tayloru.edu)
6 # A simple configure script to configure squirrelmail
7 ############################################################
11 ############################################################
12 # First, lets read in the data already in there...
13 ############################################################
14 if ( -e
"config.php") {
16 open (FILE
, "config.php");
17 } elsif (-e
"config_default.php") {
19 open (FILE
, "config_default.php");
21 print "No configuration file found. Please get config_default.php or\n";
22 print "config.php before running this again. This program needs a\n";
23 print "default config file to get default values.\n";
27 # Reads and parses the current configuration file (either
28 # config.php or config_default.php).
30 while ($line = <FILE
>) {
31 if ($line =~ /^\s+\$/) {
35 if ($var =~ /^([a-z]|[A-Z])/) {
36 @options = split(/\s*=\s*/, $var);
37 $options[1] =~ s/[\n|\r]//g;
38 $options[1] =~ s/^"//g;
39 $options[1] =~ s/;.*$//g;
40 $options[1] =~ s/"$//g;
42 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
44 $sub =~ s/\]\["PATH"\]//;
45 $sub = substr ($sub, @sub-1, 1);
46 $theme_path[$sub] = $options[1];
47 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
49 $sub =~ s/\]\["NAME"\]//;
50 $sub = substr ($sub, @sub-1, 1);
51 $theme_name[$sub] = $options[1];
52 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
54 $sub = substr ($sub, length($sub)-2, 1);
56 while (($tmp = <FILE
>) && ($continue != 1)) {
57 if ($tmp =~ /\);\s*$/) {
61 if ($tmp =~ /^\s*"host"/i) {
62 $tmp =~ s/^\s*"host"\s*=>\s*"//i;
66 } elsif ($tmp =~ /^\s*"base"/i) {
67 $tmp =~ s/^\s*"base"\s*=>\s*"//i;
72 } elsif ($tmp =~ /^\s*"charset"/i) {
73 $tmp =~ s/^\s*"charset"\s*=>\s*"//i;
77 } elsif ($tmp =~ /^\s*"port"/i) {
78 $tmp =~ s/^\s*"port"\s*=>\s*"//i;
82 } elsif ($tmp =~ /^\s*"maxrows"/i) {
83 $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i;
87 } elsif ($tmp =~ /^\s*"name"/i) {
88 $tmp =~ s/^\s*"name"\s*=>\s*"//i;
94 $ldap_host[$sub] = $host;
95 $ldap_base[$sub] = $base;
96 $ldap_name[$sub] = $name;
97 $ldap_port[$sub] = $port;
98 $ldap_maxrows[$sub] = $maxrows;
99 $ldap_charset[$sub] = $charset;
101 ${$options[0]} = $options[1];
106 if ($useSendmail ne "true") {
107 $useSendmail = "false";
109 if (!$sendmail_path) {
110 $sendmail_path = "/usr/sbin/sendmail";
113 #####################################################################################
115 while (($command ne "q") && ($command ne "Q")) {
118 print $WHT."SquirrelMail Configuration : ".$NRM;
119 if ($config == 1) { print "Read: config.php"; }
120 elsif ($config == 2) { print "Read: config_default.php"; }
123 print $WHT."Main Menu --\n".$NRM;
124 print "1. Organization Preferences\n";
125 print "2. Server Settings\n";
126 print "3. Folder Defaults\n";
127 print "4. General Options\n";
129 print "6. Address Books (LDAP)\n";
130 print "7. Message of the Day (MOTD)\n";
132 print "D. Set pre-defined settings for specific IMAP servers\n";
134 } elsif ($menu == 1) {
135 print $WHT."Organization Preferences\n".$NRM;
136 print "1. Organization Name : $WHT$org_name$NRM\n";
137 print "2. Organization Logo : $WHT$org_logo$NRM\n";
138 print "3. Organization Title : $WHT$org_title$NRM\n";
140 print "R Return to Main Menu\n";
141 } elsif ($menu == 2) {
142 print $WHT."Server Settings\n".$NRM;
143 print "1. Domain : $WHT$domain$NRM\n";
144 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
145 print "3. IMAP Port : $WHT$imapPort$NRM\n";
146 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
147 if ($useSendmail eq "true") {
148 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
150 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
151 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
153 print "8. Server : $WHT$imap_server_type$NRM\n";
155 print "R Return to Main Menu\n";
156 } elsif ($menu == 3) {
157 print $WHT."Folder Defaults\n".$NRM;
158 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
159 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
160 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
161 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
162 print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
163 print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
164 print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
165 print "8. Auto Expunge : $WHT$auto_expunge$NRM\n";
166 print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
167 print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
169 print "R Return to Main Menu\n";
170 } elsif ($menu == 4) {
171 print $WHT."General Options\n".$NRM;
172 print "1. Default Charset : $WHT$default_charset$NRM\n";
173 print "2. Auto Forward : $WHT$auto_forward$NRM\n";
174 print "3. Data Directory : $WHT$data_dir$NRM\n";
175 print "4. Attachment Directory : $WHT$attachment_dir$NRM\n";
176 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
178 print "R Return to Main Menu\n";
179 } elsif ($menu == 5) {
180 print $WHT."Themes\n".$NRM;
181 print "1. Change Themes\n";
182 for ($count = 0; $count <= $#theme_name; $count++) {
183 print " > $theme_name[$count]\n";
186 print "R Return to Main Menu\n";
187 } elsif ($menu == 6) {
188 print $WHT."Address Books (LDAP)\n".$NRM;
189 print "1. Change Servers\n";
190 for ($count = 0; $count <= $#ldap_host; $count++) {
191 print " > $ldap_host[$count]\n";
194 print "R Return to Main Menu\n";
195 } elsif ($menu == 7) {
196 print $WHT."Message of the Day (MOTD)\n".$NRM;
199 print "1 Edit the MOTD\n";
201 print "R Return to Main Menu\n";
203 print "S Save data\n";
207 print "Command >> ".$WHT;
209 $command =~ s/[\n|\r]//g;
212 # Read the commands they entered.
213 if (($command eq "R") || ($command eq "r")) {
215 } elsif (($command eq "s") || ($command eq "S")) {
217 print "Data saved in config.php\n";
218 print "Press any key to continue...";
221 } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
222 print "You have not saved your data.\n";
223 print "Save? (y/n) [".$WHT."y".$NRM."]: ";
225 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
228 } elsif (($command eq "d") || ($command eq "D")) {
233 if (($command > 0) && ($command < 8)) {
236 } elsif ($menu == 1) {
237 if ($command == 1) { $org_name = command1
(); }
238 elsif ($command == 2) { $org_logo = command2
(); }
239 elsif ($command == 3) { $org_title = command3
(); }
240 } elsif ($menu == 2) {
241 if ($command == 1) { $domain = command11
(); }
242 elsif ($command == 2) { $imapServerAddress = command12
(); }
243 elsif ($command == 3) { $imapPort = command13
(); }
244 elsif ($command == 4) { $useSendmail = command14
(); }
245 elsif ($command == 5) { $sendmail_path = command15
(); }
246 elsif ($command == 6) { $smtpServerAddress = command16
(); }
247 elsif ($command == 7) { $smtpPort = command17
(); }
248 elsif ($command == 8) { $imap_server_type = command18
(); }
249 } elsif ($menu == 3) {
250 if ($command == 1) { $default_folder_prefix = command21
(); }
251 elsif ($command == 2) { $show_prefix_option = command22
(); }
252 elsif ($command == 3) { $trash_folder = command23
(); }
253 elsif ($command == 4) { $sent_folder = command24
(); }
254 elsif ($command == 5) { $list_special_folders_first = command25
(); }
255 elsif ($command == 6) { $use_special_folder_color = command26
(); }
256 elsif ($command == 7) { $default_move_to_trash = command27
(); }
257 elsif ($command == 8) { $auto_expunge = command28
(); }
258 elsif ($command == 9) { $default_sub_of_inbox = command29
(); }
259 elsif ($command == 10){ $show_contain_subfolders_option = command210
(); }
260 } elsif ($menu == 4) {
261 if ($command == 1) { $default_charset = command31
(); }
262 elsif ($command == 2) { $auto_forward = command32
(); }
263 elsif ($command == 3) { $data_dir = command33
(); }
264 elsif ($command == 4) { $attachment_dir = command34
(); }
265 elsif ($command == 5) { $default_left_size = command35
(); }
266 } elsif ($menu == 5) {
270 } elsif ($menu == 6) {
271 if ($command == 1) { command61
(); }
272 } elsif ($menu == 7) {
273 if ($command == 1) { $motd = command71
(); $motd =~ s/"/\\"/g;}
278 ####################################################################################
282 print "We have tried to make the name SquirrelMail as transparent as\n";
283 print "possible. If you set up an organization name, most places where\n";
284 print "SquirrelMail would take credit will be credited to your organization.\n";
286 print "[$WHT$org_name$NRM]: $WHT";
287 $new_org_name = <STDIN
>;
288 if ($new_org_name eq "\n") {
289 $new_org_name = $org_name;
291 $new_org_name =~ s/[\r|\n]//g;
293 return $new_org_name;
299 print "Your organization's logo is an image that will be displayed at\n";
300 print "different times throughout SquirrelMail. This is asking for the\n";
301 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
302 print "(../images/logo.jpg) path to your logo.\n";
304 print "[$WHT$org_logo$NRM]: $WHT";
305 $new_org_logo = <STDIN
>;
306 if ($new_org_logo eq "\n") {
307 $new_org_logo = $org_logo;
309 $new_org_logo =~ s/[\r|\n]//g;
311 return $new_org_logo;
316 print "A title is what is displayed at the top of the browser window in\n";
317 print "the titlebar. Usually this will end up looking something like:\n";
318 print "\"Netscape: $org_title\"\n";
320 print "[$WHT$org_title$NRM]: $WHT";
321 $new_org_title = <STDIN
>;
322 if ($new_org_title eq "\n") {
323 $new_org_title = $org_title;
325 $new_org_title =~ s/[\r|\n]//g;
327 return $new_org_title;
330 ####################################################################################
334 print "The domain name is the suffix at the end of all email messages. If\n";
335 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
336 print "would be myorg.com.\n";
338 print "[$WHT$domain$NRM]: $WHT";
339 $new_domain = <STDIN
>;
340 if ($new_domain eq "\n") {
341 $new_domain = $domain;
343 $new_domain =~ s/[\r|\n]//g;
350 print "This is the address where your IMAP server resides.\n";
351 print "[$WHT$imapServerAddress$NRM]: $WHT";
352 $new_imapServerAddress = <STDIN
>;
353 if ($new_imapServerAddress eq "\n") {
354 $new_imapServerAddress = $imapServerAddress;
356 $new_imapServerAddress =~ s/[\r|\n]//g;
358 return $new_imapServerAddress;
363 print "This is the port that your IMAP server is on. Usually this is 143.\n";
364 print "[$WHT$imapPort$NRM]: $WHT";
365 $new_imapPort = <STDIN
>;
366 if ($new_imapPort eq "\n") {
367 $new_imapPort = $imapPort;
369 $new_imapPort =~ s/[\r|\n]//g;
371 return $new_imapPort;
376 print "You now need to choose the method that you will use for sending\n";
377 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
378 print "or use sendmail directly.\n";
379 if ($useSendmail eq "true") {
380 $default_value = "y";
382 $default_value = "n";
385 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
386 $use_sendmail = <STDIN
>;
387 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
388 $useSendmail = "true";
390 $useSendmail = "false";
397 if ($sendmail_path[0] !~ /./) {
398 $sendmail_path = "/usr/sbin/sendmail";
400 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
401 print "[$WHT$sendmail_path$NRM]: $WHT";
402 $new_sendmail_path = <STDIN
>;
403 if ($new_sendmail_path eq "\n") {
404 $new_sendmail_path = $sendmail_path;
406 $new_sendmail_path =~ s/[\r|\n]//g;
408 return $new_sendmail_path;
413 print "This is the location of your SMTP server.\n";
414 print "[$WHT$smtpServerAddress$NRM]: $WHT";
415 $new_smtpServerAddress = <STDIN
>;
416 if ($new_smtpServerAddress eq "\n") {
417 $new_smtpServerAddress = $smtpServerAddress;
419 $new_smtpServerAddress =~ s/[\r|\n]//g;
421 return $new_smtpServerAddress;
426 print "This is the port to connect to for SMTP. Usually 25.\n";
427 print "[$WHT$smtpPort$NRM]: $WHT";
428 $new_smtpPort = <STDIN
>;
429 if ($new_smtpPort eq "\n") {
430 $new_smtpPort = $smtpPort;
432 $new_smtpPort =~ s/[\r|\n]//g;
434 return $new_smtpPort;
438 print "Eash IMAP server has its own quirks. As much as we tried to stick\n";
439 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
440 print "the same principles. We have made some work-arounds for some of\n";
441 print "these servers. If you would like to use them, please select your\n";
442 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
443 print "set this to \"other\", and none will be used.\n";
444 print " cyrus = Cyrus IMAP server\n";
445 print " uw = University of Washington's IMAP server\n";
446 print " exchange = Microsoft Exchange IMAP server\n";
447 print " courier = Courier IMAP server\n";
448 print "[$WHT$imap_server_type$NRM]: $WHT";
449 $new_imap_server_type = <STDIN
>;
450 if ($new_imap_server_type eq "\n") {
451 $new_imap_server_type = $imap_server_type;
453 $new_imap_server_type =~ s/[\r|\n]//g;
455 return $new_imap_server_type;
460 print "\nYou can now create the welcome message that is displayed\n";
461 print "every time a user logs on. You can use HTML or just plain\n";
462 print "text.\n\n(Type @ on a blank line to exit)\n";
466 $line =~ s/[\r|\n]//g;
467 $line =~ s/ /\ \ /g;
469 $new_motd = $new_motd . $line;
471 } while ($line ne "@");
475 ################# FOLDERS ###################
477 # default_folder_prefix
479 print "Some IMAP servers (UW, for example) store mail and folders in\n";
480 print "your user space in a separate subdirectory. This is where you\n";
481 print "specify what that directory is.\n";
483 print "EXAMPLE: mail/";
485 print "NOTE: If you use Cyrus, or some server that would not use this\n";
486 print " option, you must set this to 'none'.\n";
488 print "[$WHT$default_folder_prefix$NRM]: $WHT";
489 $new_default_folder_prefix = <STDIN
>;
490 if ($new_default_folder_prefix eq "\n") {
491 $new_default_folder_prefix = $default_folder_prefix;
493 $new_default_folder_prefix =~ s/[\r|\n]//g;
495 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
496 $new_default_folder_prefix = "";
498 $new_default_folder_prefix =~ s/\/*$//g
;
499 $new_default_folder_prefix =~ s/$/\//g
;
501 return $new_default_folder_prefix;
506 print "It is possible to set up the default folder prefix as a user\n";
507 print "specific option, where each user can specify what their mail\n";
508 print "folder is. If you set this to false, they will never see the\n";
509 print "option, but if it is true, this option will appear in the\n";
510 print "'options' section.\n";
512 print "NOTE: You set the default folder prefix in option '1' of this\n";
513 print " section. That will be the default if the user doesn't\n";
514 print " specify anything different.\n";
517 if ($show_prefix_option eq "true") {
518 $default_value = "y";
520 $default_value = "n";
523 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
525 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
526 $show_prefix_option = "true";
528 $show_prefix_option = "false";
530 return $show_prefix_option;
535 print "You can now specify where the default trash folder is located.\n";
536 print "On servers where you do not want this, you can set it to anything\n";
537 print "and set option 7 to false.\n";
539 print "This is relative to where the rest of your email is kept. You do\n";
540 print "not need to worry about their mail directory. If this folder\n";
541 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
542 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
545 print "[$WHT$trash_folder$NRM]: $WHT";
546 $new_trash_folder = <STDIN
>;
547 if ($new_trash_folder eq "\n") {
548 $new_trash_folder = $trash_folder;
550 $new_trash_folder =~ s/[\r|\n]//g;
552 return $new_trash_folder;
557 print "This is where messages that are sent will be stored. SquirrelMail\n";
558 print "by default puts a copy of all outgoing messages in this folder.\n";
560 print "This is relative to where the rest of your email is kept. You do\n";
561 print "not need to worry about their mail directory. If this folder\n";
562 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
563 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
566 print "[$WHT$sent_folder$NRM]: $WHT";
567 $new_sent_folder = <STDIN
>;
568 if ($new_sent_folder eq "\n") {
569 $new_sent_folder = $sent_folder;
571 $new_sent_folder =~ s/[\r|\n]//g;
573 return $new_sent_folder;
576 # List special folders first
578 print "SquirrelMail has what we call 'special folders' that are not\n";
579 print "manipulated and viewed like normal folders. Some examples of\n";
580 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
581 print "Simply asks if you want these folders listed first in the folder\n";
585 if ($list_special_folders_first eq "true") {
586 $default_value = "y";
588 $default_value = "n";
591 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
593 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
594 $list_special_folders_first = "true";
596 $list_special_folders_first = "false";
598 return $list_special_folders_first;
601 # Show special folders color
603 print "SquirrelMail has what we call 'special folders' that are not\n";
604 print "manipulated and viewed like normal folders. Some examples of\n";
605 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
606 print "wants to know if we should display special folders in a\n";
607 print "color than the other folders.\n";
610 if ($use_special_folder_color eq "true") {
611 $default_value = "y";
613 $default_value = "n";
616 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
618 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
619 $use_special_folder_color = "true";
621 $use_special_folder_color = "false";
623 return $use_special_folder_color;
626 # default move to trash
628 print "By default, should messages get moved to the trash folder? You\n";
629 print "can specify the default trash folder in option 3. If this is set\n";
630 print "to false, messages will get deleted immediately without moving\n";
631 print "to the trash folder.\n";
633 print "Trash folder is currently: $trash_folder\n";
636 if ($default_move_to_trash eq "true") {
637 $default_value = "y";
639 $default_value = "n";
641 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
643 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
644 $default_move_to_trash = "true";
646 $default_move_to_trash = "false";
648 return $default_move_to_trash;
653 print "The way that IMAP handles deleting messages is as follows. You\n";
654 print "mark the message as deleted, and then to 'really' delete it, you\n";
655 print "expunge it. This option asks if you want to just have messages\n";
656 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
657 print "messages too.\n";
660 if ($auto_expunge eq "true") {
661 $default_value = "y";
663 $default_value = "n";
665 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
667 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
668 $auto_expunge = "true";
670 $auto_expunge = "false";
672 return $auto_expunge;
675 # Default sub of inbox
677 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
678 print "This can cause some confusion in folder creation for users when\n";
679 print "they try to create folders and don't put it as a subfolder of INBOX\n";
680 print "and get permission errors. This option asks if you want folders\n";
681 print "to be subfolders of INBOX by default.\n";
684 if ($default_sub_of_inbox eq "true") {
685 $default_value = "y";
687 $default_value = "n";
689 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
691 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
692 $default_sub_of_inbox = "true";
694 $default_sub_of_inbox = "false";
696 return $default_sub_of_inbox;
699 # Show contain subfolder option
701 print "Some IMAP servers (UW) make it so that there are two types of\n";
702 print "folders. Those that contain messages, and those that contain\n";
703 print "subfolders. If this is the case for your server, set this to\n";
704 print "true, and it will ask the user whether the folder they are\n";
705 print "creating contains subfolders or messages.\n";
708 if ($show_contain_subfolders_option eq "true") {
709 $default_value = "y";
711 $default_value = "n";
713 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
715 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
716 $show_contain_subfolders_option = "true";
718 $show_contain_subfolders_option = "false";
720 return $show_contain_subfolders_option;
723 ############# GENERAL OPTIONS #####################
727 print "This option controls what character set is used when sending\n";
728 print "mail and when sending HTML to the browser. Do not set this\n";
729 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
730 print "to use KOI8-R, since this implementation is faster than most\n";
731 print "of the alternatives\n";
734 print "[$WHT$default_charset$NRM]: $WHT";
735 $new_default_charset = <STDIN
>;
736 if ($new_default_charset eq "\n") {
737 $new_default_charset = $default_charset;
739 $new_default_charset =~ s/[\r|\n]//g;
741 return $new_default_charset;
746 print "There are some places that we will automatically forward the user\n";
747 print "rather than display pointless messages like 'Message sent!' or\n";
748 print "stuff like that. Use this or not?\n";
750 print "NOTE: This is not working currently as we are trying to find a\n";
751 print " better way to handle this. This option really doesn't do\n";
755 if ($auto_forward eq "true") {
756 $default_value = "y";
758 $default_value = "n";
760 print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT";
762 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
763 $auto_forward = "true";
765 $auto_forward = "false";
767 return $auto_forward;
772 print "It is a possible security hole to have a writable directory\n";
773 print "under the web server's root directory (ex: /home/httpd/html).\n";
774 print "For this reason, it is possible to put the data directory\n";
775 print "anywhere you would like. The path name can be absolute or\n";
776 print "relative (to the config directory). It doesn't matter. Here\n";
777 print "are two examples:\n";
778 print " Absolute: /usr/local/squirrelmail/data/\n";
779 print " Relative: ../data/\n";
782 print "[$WHT$data_dir$NRM]: $WHT";
783 $new_data_dir = <STDIN
>;
784 if ($new_data_dir eq "\n") {
785 $new_data_dir = $data_dir;
787 $new_data_dir =~ s/[\r|\n]//g;
789 if ($new_data_dir =~ /^\s*$/) {
792 $new_data_dir =~ s/\/*$//g
;
793 $new_data_dir =~ s/$/\//g
;
795 return $new_data_dir;
798 # Attachment directory
800 print "Path to directory used for storing attachments while a mail is\n";
801 print "being sent. There are a few security considerations regarding this\n";
802 print "directory:\n";
803 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
804 print " impossible for a random person with access to the webserver\n";
805 print " to list files in this directory. Confidential data might\n";
806 print " be laying around in there.\n";
807 print " 2. Since the webserver is not able to list the files in the\n";
808 print " content is also impossible for the webserver to delete files\n";
809 print " lying around there for too long.\n";
810 print " 3. It should probably be another directory than the data\n";
811 print " directory specified in option 3.\n";
814 print "[$WHT$attachment_dir$NRM]: $WHT";
815 $new_attachment_dir = <STDIN
>;
816 if ($new_attachment_dir eq "\n") {
817 $new_attachment_dir = $attachment_dir;
819 $new_attachment_dir =~ s/[\r|\n]//g;
821 if ($new_attachment_dir =~ /^\s*$/) {
822 $new_attachment_dir = "";
824 $new_attachment_dir =~ s/\/*$//g
;
825 $new_attachment_dir =~ s/$/\//g
;
827 return $new_attachment_dir;
832 print "This is the default size (in pixels) of the left folder list.\n";
833 print "Default is 200, but you can set it to whatever you wish. This\n";
834 print "is a user preference, so this will only show up as their default.\n";
836 print "[$WHT$default_left_size$NRM]: $WHT";
837 $new_default_left_size = <STDIN
>;
838 if ($new_default_left_size eq "\n") {
839 $new_default_left_size = $default_left_size;
841 $new_default_left_size =~ s/[\r|\n]//g;
843 return $new_default_left_size;
848 print "\nNow we will define the themes that you wish to use. If you have added\n";
849 print "a theme of your own, just follow the instructions (?) about how to add\n";
850 print "them. You can also change the default theme.\n";
851 print "[theme] command (?=help) > ";
853 $input =~ s/[\r|\n]//g;
854 while ($input ne "d") {
855 if ($input =~ /^\s*l\s*/i) {
857 while ($count <= $#theme_name) {
858 if ($count == $theme_default) {
863 $name = $theme_name[$count];
864 $num_spaces = 25 - length($name);
865 for ($i = 0; $i < $num_spaces;$i++) {
869 print " $count. $name";
870 print "($theme_path[$count])\n";
874 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
875 $old_def = $theme_default;
876 $theme_default = $input;
877 $theme_default =~ s/^\s*m\s*//;
878 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
879 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
880 $theme_default = $old_def;
882 } elsif ($input =~ /^\s*\+/) {
883 print "What is the name of this theme: ";
885 $name =~ s/[\r|\n]//g;
886 $theme_name[$#theme_name+1] = $name;
887 print "Be sure to put ../config/ before the filename.\n";
888 print "What file is this stored in (ex: ../config/default_theme.php): ";
890 $name =~ s/[\r|\n]//g;
891 $theme_path[$#theme_path+1] = $name;
892 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
893 if ($input =~ /[0-9]+\s*$/) {
895 $rem_num =~ s/^\s*-\s*//g;
896 $rem_num =~ s/\s*$//;
898 $rem_num = $#theme_name;
900 if ($rem_num == $theme_default) {
901 print "You cannot remove the default theme!\n";
904 @new_theme_name = ();
905 @new_theme_path = ();
906 while ($count <= $#theme_name) {
907 if ($count != $rem_num) {
908 @new_theme_name = (@new_theme_name, $theme_name[$count]);
909 @new_theme_path = (@new_theme_path, $theme_path[$count]);
913 @theme_name = @new_theme_name;
914 @theme_path = @new_theme_path;
915 if ($theme_default > $rem_num) {
919 } elsif ($input =~ /^\s*\?\s*/) {
920 print ".-------------------------.\n";
921 print "| + (add theme) |\n";
922 print "| - N (remove theme) |\n";
923 print "| m N (mark default) |\n";
924 print "| l (list themes) |\n";
925 print "| d (done) |\n";
926 print "`-------------------------'\n";
928 print "[theme] command (?=help) > ";
930 $input =~ s/[\r|\n]//g;
936 print "You can now define different LDAP servers.\n";
937 print "[ldap] command (?=help) > ";
939 $input =~ s/[\r|\n]//g;
940 while ($input ne "d") {
941 if ($input =~ /^\s*l\s*/i) {
943 while ($count <= $#ldap_host) {
944 print "$count. $ldap_host[$count]\n";
945 print " base: $ldap_base[$count]\n";
946 if ($ldap_charset[$count]) {
947 print " charset: $ldap_charset[$count]\n";
949 if ($ldap_port[$count]) {
950 print " port: $ldap_port[$count]\n";
952 if ($ldap_name[$count]) {
953 print " name: $ldap_name[$count]\n";
955 if ($ldap_maxrows[$count]) {
956 print " maxrows: $ldap_maxrows[$count]\n";
961 } elsif ($input =~ /^\s*\+/) {
962 $sub = $#ldap_host + 1;
964 print "First, we need to have the hostname or the IP address where\n";
965 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
968 $name =~ s/[\r|\n]//g;
969 $ldap_host[$sub] = $name;
973 print "Next, we need the server root (base dn). For this, an empty\n";
974 print "string is allowed.\n";
975 print "Example: ou=member_directory,o=netcenter.com\n";
978 $name =~ s/[\r|\n]//g;
979 $ldap_base[$sub] = $name;
983 print "This is the TCP/IP port number for the LDAP server. Default\n";
984 print "port is 389. This is optional. Press ENTER for default.\n";
987 $name =~ s/[\r|\n]//g;
988 $ldap_port[$sub] = $name;
992 print "This is the charset for the server. Default is utf-8. This\n";
993 print "is also optional. Press ENTER for default.\n";
996 $name =~ s/[\r|\n]//g;
997 $ldap_charset[$sub] = $name;
1001 print "This is the name for the server, used to tag the results of\n";
1002 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1005 $name =~ s/[\r|\n]//g;
1006 $ldap_name[$sub] = $name;
1010 print "You can specify the maximum number of rows in the search result.\n";
1011 print "Default is unlimited. Press ENTER for default.\n";
1014 $name =~ s/[\r|\n]//g;
1015 $ldap_maxrows[$sub] = $name;
1019 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1020 if ($input =~ /[0-9]+\s*$/) {
1022 $rem_num =~ s/^\s*-\s*//g;
1023 $rem_num =~ s/\s*$//;
1025 $rem_num = $#ldap_host;
1028 @new_ldap_host = ();
1029 @new_ldap_base = ();
1030 @new_ldap_port = ();
1031 @new_ldap_name = ();
1032 @new_ldap_charset = ();
1033 @new_ldap_maxrows = ();
1034 while ($count <= $#ldap_host) {
1035 if ($count != $rem_num) {
1036 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1037 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1038 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1039 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1040 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1041 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1045 @ldap_host = @new_ldap_host;
1046 @ldap_base = @new_ldap_base;
1047 @ldap_port = @new_ldap_port;
1048 @ldap_name = @new_ldap_name;
1049 @ldap_charset = @new_ldap_charset;
1050 @ldap_maxrows = @new_ldap_maxrows;
1051 } elsif ($input =~ /^\s*\?\s*/) {
1052 print ".-------------------------.\n";
1053 print "| + (add host) |\n";
1054 print "| - N (remove host) |\n";
1055 print "| l (list hosts) |\n";
1056 print "| d (done) |\n";
1057 print "`-------------------------'\n";
1059 print "[ldap] command (?=help) > ";
1061 $input =~ s/[\r|\n]//g;
1068 open (FILE
, ">config.php");
1070 print FILE
"<?\n\t/** SquirrelMail configuration\n";
1071 print FILE
"\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1073 print FILE
"\t\$org_name = \"$org_name\";\n";
1074 print FILE
"\t\$org_logo = \"$org_logo\";\n";
1075 print FILE
"\t\$org_title = \"$org_title\";\n";
1079 print FILE
"\t\$domain = \"$domain\";\n";
1080 print FILE
"\t\$imapServerAddress = \"$imapServerAddress\";\n";
1081 print FILE
"\t\$imapPort = $imapPort;\n";
1082 print FILE
"\t\$useSendmail = $useSendmail;\n";
1083 print FILE
"\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1084 print FILE
"\t\$smtpPort = $smtpPort;\n";
1085 print FILE
"\t\$sendmailPath = \"$sendmail_path\";\n";
1086 print FILE
"\t\$imap_server_type = \"$imap_server_type\";\n";
1090 print FILE
"\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1091 print FILE
"\t\$trash_folder = \"$trash_folder\";\n";
1092 print FILE
"\t\$sent_folder = \"$sent_folder\";\n";
1093 print FILE
"\t\$show_prefix_option = $show_prefix_option;\n";
1094 print FILE
"\t\$list_special_folders_first = $list_special_folders_first;\n";
1095 print FILE
"\t\$use_special_folder_color = $use_special_folder_color;\n";
1096 print FILE
"\t\$default_move_to_trash = $default_move_to_trash;\n";
1097 print FILE
"\t\$auto_expunge = $auto_expunge;\n";
1098 print FILE
"\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1099 print FILE
"\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1102 print FILE
"\t\$default_charset = \"$default_charset\";\n";
1103 print FILE
"\t\$auto_forward = $auto_forward;\n";
1104 print FILE
"\t\$data_dir = \"$data_dir\";\n";
1105 print FILE
"\t\$attachment_dir = \"$attachment_dir\";\n";
1106 print FILE
"\t\$default_left_size = $default_left_size;\n";
1110 for ($count=0; $count <= $#theme_name; $count++) {
1111 print FILE
"\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1112 print FILE
"\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1117 for ($count=0; $count <= $#ldap_host; $count++) {
1118 print FILE
"\t\$ldap_server[$count] = Array(\n";
1119 print FILE
"\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1120 print FILE
"\t\t\t\"base\" => \"$ldap_base[$count]\"";
1121 if ($ldap_name[$count]) {
1122 print FILE
",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1124 if ($ldap_port[$count]) {
1125 print FILE
",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1127 if ($ldap_charset[$count]) {
1128 print FILE
",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1130 if ($ldap_maxrows[$count]) {
1131 print FILE
",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1133 print FILE
");\n\n";
1136 print FILE
"\t\$motd = \"$motd\";\n";
1144 print "While we have been building SquirrelMail, we have discovered some\n";
1145 print "preferences that work better with some servers that don't work so\n";
1146 print "well with others. If you select your IMAP server, this option will\n";
1147 print "set some pre-defined settings for that server.\n";
1149 print "Please note that you will still need to go through and make sure\n";
1150 print "everything is correct. This does not change everything. There are\n";
1151 print "only a few settings that thils will change.\n";
1155 while ($continue != 1) {
1156 print "Please select your IMAP server:\n";
1157 print " cyrus = Cyrus IMAP server\n";
1158 print " uw = University of Washington's IMAP server\n";
1159 print " exchange = Microsoft Exchange IMAP server\n";
1160 print " courier = Courier IMAP server\n";
1161 print " quit = Do not change anything\n";
1162 print "Command >> ";
1164 $server =~ s/[\r|\n]//g;
1166 if ($server eq "cyrus") {
1167 $default_folder_prefix = "";
1168 $trash_folder = "INBOX.Trash";
1169 $sent_folder = "INBOX.Sent";
1170 $show_prefix_option = false
;
1171 $default_sub_of_inbox = true
;
1172 $show_contain_subfolders_option = false
;
1173 $imap_server_type = "cyrus";
1176 } elsif ($server eq "uw") {
1177 $default_folder_prefix = "mail/";
1178 $trash_folder = "Trash";
1179 $sent_folder = "Sent";
1180 $show_prefix_option = true
;
1181 $default_sub_of_inbox = false
;
1182 $show_contain_subfolders_option = true
;
1183 $imap_server_type = "uw";
1186 } elsif ($server eq "exchange") {
1187 $default_folder_prefix = "INBOX/";
1188 $default_sub_of_inbox = true
;
1189 $trash_folder = "INBOX/Deleted Items";
1190 $sent_folder = "INBOX/Sent Items";
1191 $show_prefix_option = false
;
1192 $show_contain_subfolders_option = false
;
1194 $imap_server_type = "exchange";
1197 } elsif ($server eq "courier") {
1198 $imap_server_type = "courier";
1201 } elsif ($server eq "quit") {
1204 print "Unrecognized server: $server\n";