3 # Luke Ehresman (luke@squirrelmail.org)
5 # A simple configure script to configure squirrelmail
6 ############################################################
10 ############################################################
11 # First, lets read in the data already in there...
12 ############################################################
13 if ( -e
"config.php") {
15 open (FILE
, "config.php");
16 } elsif (-e
"config_default.php") {
18 open (FILE
, "config_default.php");
20 print "No configuration file found. Please get config_default.php or\n";
21 print "config.php before running this again. This program needs a\n";
22 print "default config file to get default values.\n";
26 # Reads and parses the current configuration file (either
27 # config.php or config_default.php).
29 while ($line = <FILE
>) {
30 if ($line =~ /^\s+\$/) {
34 if ($var =~ /^([a-z]|[A-Z])/) {
35 @options = split(/\s*=\s*/, $var);
36 $options[1] =~ s/[\n|\r]//g;
37 $options[1] =~ s/^"//g;
38 $options[1] =~ s/;\s*$//g;
39 $options[1] =~ s/"$//g;
41 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
43 $sub =~ s/\]\["PATH"\]//;
44 $sub = substr ($sub, @sub-1, 1);
45 $theme_path[$sub] = $options[1];
46 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
48 $sub =~ s/\]\["NAME"\]//;
49 $sub = substr ($sub, @sub-1, 1);
50 $theme_name[$sub] = $options[1];
51 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
53 $sub = substr ($sub, length($sub)-2, 1);
55 while (($tmp = <FILE
>) && ($continue != 1)) {
56 if ($tmp =~ /\);\s*$/) {
60 if ($tmp =~ /^\s*"host"/i) {
61 $tmp =~ s/^\s*"host"\s*=>\s*"//i;
65 } elsif ($tmp =~ /^\s*"base"/i) {
66 $tmp =~ s/^\s*"base"\s*=>\s*"//i;
70 } elsif ($tmp =~ /^\s*"charset"/i) {
71 $tmp =~ s/^\s*"charset"\s*=>\s*"//i;
75 } elsif ($tmp =~ /^\s*"port"/i) {
76 $tmp =~ s/^\s*"port"\s*=>\s*"//i;
80 } elsif ($tmp =~ /^\s*"maxrows"/i) {
81 $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i;
85 } elsif ($tmp =~ /^\s*"name"/i) {
86 $tmp =~ s/^\s*"name"\s*=>\s*"//i;
92 $ldap_host[$sub] = $host;
93 $ldap_base[$sub] = $base;
94 $ldap_name[$sub] = $name;
95 $ldap_port[$sub] = $port;
96 $ldap_maxrows[$sub] = $maxrows;
97 $ldap_charset[$sub] = $charset;
99 ${$options[0]} = $options[1];
104 if ($useSendmail ne "true") {
105 $useSendmail = "false";
107 if (!$sendmail_path) {
108 $sendmail_path = "/usr/sbin/sendmail";
111 #####################################################################################
113 while (($command ne "q") && ($command ne "Q")) {
116 print $WHT."SquirrelMail Configuration : ".$NRM;
117 if ($config == 1) { print "Read: config.php"; }
118 elsif ($config == 2) { print "Read: config_default.php"; }
121 print $WHT."Main Menu --\n".$NRM;
122 print "1. Organization Preferences\n";
123 print "2. Server Settings\n";
124 print "3. Folder Defaults\n";
125 print "4. General Options\n";
127 print "6. Address Books (LDAP)\n";
128 print "7. Message of the Day (MOTD)\n";
130 print "D. Set pre-defined settings for specific IMAP servers\n";
132 } elsif ($menu == 1) {
133 print $WHT."Organization Preferences\n".$NRM;
134 print "1. Organization Name : $WHT$org_name$NRM\n";
135 print "2. Organization Logo : $WHT$org_logo$NRM\n";
136 print "3. Organization Title : $WHT$org_title$NRM\n";
138 print "R Return to Main Menu\n";
139 } elsif ($menu == 2) {
140 print $WHT."Server Settings\n".$NRM;
141 print "1. Domain : $WHT$domain$NRM\n";
142 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
143 print "3. IMAP Port : $WHT$imapPort$NRM\n";
144 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
145 if ($useSendmail eq "true") {
146 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
148 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
149 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
151 print "8. Server : $WHT$imap_server_type$NRM\n";
153 print "R Return to Main Menu\n";
154 } elsif ($menu == 3) {
155 print $WHT."Folder Defaults\n".$NRM;
156 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
157 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
158 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
159 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
160 print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
161 print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
162 print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
163 print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
164 print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
165 print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
166 print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
168 print "R Return to Main Menu\n";
169 } elsif ($menu == 4) {
170 print $WHT."General Options\n".$NRM;
171 print "1. Default Charset : $WHT$default_charset$NRM\n";
172 print "2. Auto Forward : $WHT$auto_forward$NRM\n";
173 print "3. Data Directory : $WHT$data_dir$NRM\n";
174 print "4. Attachment Directory : $WHT$attachment_dir$NRM\n";
175 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
177 print "R Return to Main Menu\n";
178 } elsif ($menu == 5) {
179 print $WHT."Themes\n".$NRM;
180 print "1. Change Themes\n";
181 for ($count = 0; $count <= $#theme_name; $count++) {
182 print " > $theme_name[$count]\n";
185 print "R Return to Main Menu\n";
186 } elsif ($menu == 6) {
187 print $WHT."Address Books (LDAP)\n".$NRM;
188 print "1. Change Servers\n";
189 for ($count = 0; $count <= $#ldap_host; $count++) {
190 print " > $ldap_host[$count]\n";
192 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\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) { $default_move_to_trash = command25
(); }
255 elsif ($command == 6) { $default_move_to_sent = command26
(); }
256 elsif ($command == 7) { $list_special_folders_first = command27
(); }
257 elsif ($command == 8) { $use_special_folder_color = command28
(); }
258 elsif ($command == 9) { $auto_expunge = command29
(); }
259 elsif ($command == 10){ $default_sub_of_inbox = command210
(); }
260 elsif ($command == 11){ $show_contain_subfolders_option = command211
(); }
261 } elsif ($menu == 4) {
262 if ($command == 1) { $default_charset = command31
(); }
263 elsif ($command == 2) { $auto_forward = command32
(); }
264 elsif ($command == 3) { $data_dir = command33
(); }
265 elsif ($command == 4) { $attachment_dir = command34
(); }
266 elsif ($command == 5) { $default_left_size = command35
(); }
267 } elsif ($menu == 5) {
271 } elsif ($menu == 6) {
272 if ($command == 1) { command61
(); }
273 elsif ($command == 2) { command62
(); }
274 } elsif ($menu == 7) {
275 if ($command == 1) { $motd = command71
(); }
280 ####################################################################################
284 print "We have tried to make the name SquirrelMail as transparent as\n";
285 print "possible. If you set up an organization name, most places where\n";
286 print "SquirrelMail would take credit will be credited to your organization.\n";
288 print "[$WHT$org_name$NRM]: $WHT";
289 $new_org_name = <STDIN
>;
290 if ($new_org_name eq "\n") {
291 $new_org_name = $org_name;
293 $new_org_name =~ s/[\r|\n]//g;
295 return $new_org_name;
301 print "Your organization's logo is an image that will be displayed at\n";
302 print "different times throughout SquirrelMail. This is asking for the\n";
303 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
304 print "(../images/logo.jpg) path to your logo.\n";
306 print "[$WHT$org_logo$NRM]: $WHT";
307 $new_org_logo = <STDIN
>;
308 if ($new_org_logo eq "\n") {
309 $new_org_logo = $org_logo;
311 $new_org_logo =~ s/[\r|\n]//g;
313 return $new_org_logo;
318 print "A title is what is displayed at the top of the browser window in\n";
319 print "the titlebar. Usually this will end up looking something like:\n";
320 print "\"Netscape: $org_title\"\n";
322 print "[$WHT$org_title$NRM]: $WHT";
323 $new_org_title = <STDIN
>;
324 if ($new_org_title eq "\n") {
325 $new_org_title = $org_title;
327 $new_org_title =~ s/[\r|\n]//g;
329 return $new_org_title;
332 ####################################################################################
336 print "The domain name is the suffix at the end of all email messages. If\n";
337 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
338 print "would be myorg.com.\n";
340 print "[$WHT$domain$NRM]: $WHT";
341 $new_domain = <STDIN
>;
342 if ($new_domain eq "\n") {
343 $new_domain = $domain;
345 $new_domain =~ s/[\r|\n]//g;
352 print "This is the address where your IMAP server resides.\n";
353 print "[$WHT$imapServerAddress$NRM]: $WHT";
354 $new_imapServerAddress = <STDIN
>;
355 if ($new_imapServerAddress eq "\n") {
356 $new_imapServerAddress = $imapServerAddress;
358 $new_imapServerAddress =~ s/[\r|\n]//g;
360 return $new_imapServerAddress;
365 print "This is the port that your IMAP server is on. Usually this is 143.\n";
366 print "[$WHT$imapPort$NRM]: $WHT";
367 $new_imapPort = <STDIN
>;
368 if ($new_imapPort eq "\n") {
369 $new_imapPort = $imapPort;
371 $new_imapPort =~ s/[\r|\n]//g;
373 return $new_imapPort;
378 print "You now need to choose the method that you will use for sending\n";
379 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
380 print "or use sendmail directly.\n";
381 if ($useSendmail eq "true") {
382 $default_value = "y";
384 $default_value = "n";
387 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
388 $use_sendmail = <STDIN
>;
389 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
390 $useSendmail = "true";
392 $useSendmail = "false";
399 if ($sendmail_path[0] !~ /./) {
400 $sendmail_path = "/usr/sbin/sendmail";
402 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
403 print "[$WHT$sendmail_path$NRM]: $WHT";
404 $new_sendmail_path = <STDIN
>;
405 if ($new_sendmail_path eq "\n") {
406 $new_sendmail_path = $sendmail_path;
408 $new_sendmail_path =~ s/[\r|\n]//g;
410 return $new_sendmail_path;
415 print "This is the location of your SMTP server.\n";
416 print "[$WHT$smtpServerAddress$NRM]: $WHT";
417 $new_smtpServerAddress = <STDIN
>;
418 if ($new_smtpServerAddress eq "\n") {
419 $new_smtpServerAddress = $smtpServerAddress;
421 $new_smtpServerAddress =~ s/[\r|\n]//g;
423 return $new_smtpServerAddress;
428 print "This is the port to connect to for SMTP. Usually 25.\n";
429 print "[$WHT$smtpPort$NRM]: $WHT";
430 $new_smtpPort = <STDIN
>;
431 if ($new_smtpPort eq "\n") {
432 $new_smtpPort = $smtpPort;
434 $new_smtpPort =~ s/[\r|\n]//g;
436 return $new_smtpPort;
440 print "Eash IMAP server has its own quirks. As much as we tried to stick\n";
441 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
442 print "the same principles. We have made some work-arounds for some of\n";
443 print "these servers. If you would like to use them, please select your\n";
444 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
445 print "set this to \"other\", and none will be used.\n";
446 print " cyrus = Cyrus IMAP server\n";
447 print " uw = University of Washington's IMAP server\n";
448 print " exchange = Microsoft Exchange IMAP server\n";
449 print " courier = Courier IMAP server\n";
450 print "[$WHT$imap_server_type$NRM]: $WHT";
451 $new_imap_server_type = <STDIN
>;
452 if ($new_imap_server_type eq "\n") {
453 $new_imap_server_type = $imap_server_type;
455 $new_imap_server_type =~ s/[\r|\n]//g;
457 return $new_imap_server_type;
462 print "\nYou can now create the welcome message that is displayed\n";
463 print "every time a user logs on. You can use HTML or just plain\n";
464 print "text.\n\n(Type @ on a blank line to exit)\n";
469 $line =~ s/[\r|\n]//g;
471 $line =~ s/ /\ \ /g;
472 $line =~ s/\t/\ \ \ \ /g;
476 $new_motd = $new_motd . $line;
478 } while ($line ne "@");
482 ################# FOLDERS ###################
484 # default_folder_prefix
486 print "Some IMAP servers (UW, for example) store mail and folders in\n";
487 print "your user space in a separate subdirectory. This is where you\n";
488 print "specify what that directory is.\n";
490 print "EXAMPLE: mail/";
492 print "NOTE: If you use Cyrus, or some server that would not use this\n";
493 print " option, you must set this to 'none'.\n";
495 print "[$WHT$default_folder_prefix$NRM]: $WHT";
496 $new_default_folder_prefix = <STDIN
>;
497 if ($new_default_folder_prefix eq "\n") {
498 $new_default_folder_prefix = $default_folder_prefix;
500 $new_default_folder_prefix =~ s/[\r|\n]//g;
502 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
503 $new_default_folder_prefix = "";
505 $new_default_folder_prefix =~ s/\/*$//g
;
506 $new_default_folder_prefix =~ s/$/\//g
;
508 return $new_default_folder_prefix;
513 print "It is possible to set up the default folder prefix as a user\n";
514 print "specific option, where each user can specify what their mail\n";
515 print "folder is. If you set this to false, they will never see the\n";
516 print "option, but if it is true, this option will appear in the\n";
517 print "'options' section.\n";
519 print "NOTE: You set the default folder prefix in option '1' of this\n";
520 print " section. That will be the default if the user doesn't\n";
521 print " specify anything different.\n";
524 if ($show_prefix_option eq "true") {
525 $default_value = "y";
527 $default_value = "n";
530 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
532 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
533 $show_prefix_option = "true";
535 $show_prefix_option = "false";
537 return $show_prefix_option;
542 print "You can now specify where the default trash folder is located.\n";
543 print "On servers where you do not want this, you can set it to anything\n";
544 print "and set option 7 to false.\n";
546 print "This is relative to where the rest of your email is kept. You do\n";
547 print "not need to worry about their mail directory. If this folder\n";
548 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
549 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
552 print "[$WHT$trash_folder$NRM]: $WHT";
553 $new_trash_folder = <STDIN
>;
554 if ($new_trash_folder eq "\n") {
555 $new_trash_folder = $trash_folder;
557 $new_trash_folder =~ s/[\r|\n]//g;
559 return $new_trash_folder;
564 print "This is where messages that are sent will be stored. SquirrelMail\n";
565 print "by default puts a copy of all outgoing messages in this folder.\n";
567 print "This is relative to where the rest of your email is kept. You do\n";
568 print "not need to worry about their mail directory. If this folder\n";
569 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
570 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
573 print "[$WHT$sent_folder$NRM]: $WHT";
574 $new_sent_folder = <STDIN
>;
575 if ($new_sent_folder eq "\n") {
576 $new_sent_folder = $sent_folder;
578 $new_sent_folder =~ s/[\r|\n]//g;
580 return $new_sent_folder;
583 # default move to trash
585 print "By default, should messages get moved to the trash folder? You\n";
586 print "can specify the default trash folder in option 3. If this is set\n";
587 print "to false, messages will get deleted immediately without moving\n";
588 print "to the trash folder.\n";
590 print "Trash folder is currently: $trash_folder\n";
593 if ($default_move_to_trash eq "true") {
594 $default_value = "y";
596 $default_value = "n";
598 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
600 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
601 $default_move_to_trash = "true";
603 $default_move_to_trash = "false";
605 return $default_move_to_trash;
608 # default move to sent
610 print "By default, should messages get moved to the sent folder? You\n";
611 print "can specify the default sent folder in option 4. If this is set\n";
612 print "to false, messages will get deleted immediately without moving\n";
613 print "to the sent folder.\n";
615 print "Trash folder is currently: $sent_folder\n";
618 if ($default_move_to_sent eq "true") {
619 $default_value = "y";
621 $default_value = "n";
623 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
625 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
626 $default_move_to_sent = "true";
628 $default_move_to_sent = "false";
630 return $default_move_to_sent;
633 # List special folders first
635 print "SquirrelMail has what we call 'special folders' that are not\n";
636 print "manipulated and viewed like normal folders. Some examples of\n";
637 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
638 print "Simply asks if you want these folders listed first in the folder\n";
642 if ($list_special_folders_first eq "true") {
643 $default_value = "y";
645 $default_value = "n";
648 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
650 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
651 $list_special_folders_first = "true";
653 $list_special_folders_first = "false";
655 return $list_special_folders_first;
658 # Show special folders color
660 print "SquirrelMail has what we call 'special folders' that are not\n";
661 print "manipulated and viewed like normal folders. Some examples of\n";
662 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
663 print "wants to know if we should display special folders in a\n";
664 print "color than the other folders.\n";
667 if ($use_special_folder_color eq "true") {
668 $default_value = "y";
670 $default_value = "n";
673 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
675 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
676 $use_special_folder_color = "true";
678 $use_special_folder_color = "false";
680 return $use_special_folder_color;
685 print "The way that IMAP handles deleting messages is as follows. You\n";
686 print "mark the message as deleted, and then to 'really' delete it, you\n";
687 print "expunge it. This option asks if you want to just have messages\n";
688 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
689 print "messages too.\n";
692 if ($auto_expunge eq "true") {
693 $default_value = "y";
695 $default_value = "n";
697 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
699 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
700 $auto_expunge = "true";
702 $auto_expunge = "false";
704 return $auto_expunge;
707 # Default sub of inbox
709 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
710 print "This can cause some confusion in folder creation for users when\n";
711 print "they try to create folders and don't put it as a subfolder of INBOX\n";
712 print "and get permission errors. This option asks if you want folders\n";
713 print "to be subfolders of INBOX by default.\n";
716 if ($default_sub_of_inbox eq "true") {
717 $default_value = "y";
719 $default_value = "n";
721 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
723 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
724 $default_sub_of_inbox = "true";
726 $default_sub_of_inbox = "false";
728 return $default_sub_of_inbox;
731 # Show contain subfolder option
733 print "Some IMAP servers (UW) make it so that there are two types of\n";
734 print "folders. Those that contain messages, and those that contain\n";
735 print "subfolders. If this is the case for your server, set this to\n";
736 print "true, and it will ask the user whether the folder they are\n";
737 print "creating contains subfolders or messages.\n";
740 if ($show_contain_subfolders_option eq "true") {
741 $default_value = "y";
743 $default_value = "n";
745 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
747 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
748 $show_contain_subfolders_option = "true";
750 $show_contain_subfolders_option = "false";
752 return $show_contain_subfolders_option;
755 ############# GENERAL OPTIONS #####################
759 print "This option controls what character set is used when sending\n";
760 print "mail and when sending HTML to the browser. Do not set this\n";
761 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
762 print "to use KOI8-R, since this implementation is faster than most\n";
763 print "of the alternatives\n";
766 print "[$WHT$default_charset$NRM]: $WHT";
767 $new_default_charset = <STDIN
>;
768 if ($new_default_charset eq "\n") {
769 $new_default_charset = $default_charset;
771 $new_default_charset =~ s/[\r|\n]//g;
773 return $new_default_charset;
778 print "There are some places that we will automatically forward the user\n";
779 print "rather than display pointless messages like 'Message sent!' or\n";
780 print "stuff like that. Use this or not?\n";
782 print "NOTE: This is not working currently as we are trying to find a\n";
783 print " better way to handle this. This option really doesn't do\n";
787 if ($auto_forward eq "true") {
788 $default_value = "y";
790 $default_value = "n";
792 print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT";
794 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
795 $auto_forward = "true";
797 $auto_forward = "false";
799 return $auto_forward;
804 print "It is a possible security hole to have a writable directory\n";
805 print "under the web server's root directory (ex: /home/httpd/html).\n";
806 print "For this reason, it is possible to put the data directory\n";
807 print "anywhere you would like. The path name can be absolute or\n";
808 print "relative (to the config directory). It doesn't matter. Here\n";
809 print "are two examples:\n";
810 print " Absolute: /usr/local/squirrelmail/data/\n";
811 print " Relative: ../data/\n";
814 print "[$WHT$data_dir$NRM]: $WHT";
815 $new_data_dir = <STDIN
>;
816 if ($new_data_dir eq "\n") {
817 $new_data_dir = $data_dir;
819 $new_data_dir =~ s/[\r|\n]//g;
821 if ($new_data_dir =~ /^\s*$/) {
824 $new_data_dir =~ s/\/*$//g
;
825 $new_data_dir =~ s/$/\//g
;
827 return $new_data_dir;
830 # Attachment directory
832 print "Path to directory used for storing attachments while a mail is\n";
833 print "being sent. There are a few security considerations regarding this\n";
834 print "directory:\n";
835 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
836 print " impossible for a random person with access to the webserver\n";
837 print " to list files in this directory. Confidential data might\n";
838 print " be laying around in there.\n";
839 print " 2. Since the webserver is not able to list the files in the\n";
840 print " content is also impossible for the webserver to delete files\n";
841 print " lying around there for too long.\n";
842 print " 3. It should probably be another directory than the data\n";
843 print " directory specified in option 3.\n";
846 print "[$WHT$attachment_dir$NRM]: $WHT";
847 $new_attachment_dir = <STDIN
>;
848 if ($new_attachment_dir eq "\n") {
849 $new_attachment_dir = $attachment_dir;
851 $new_attachment_dir =~ s/[\r|\n]//g;
853 if ($new_attachment_dir =~ /^\s*$/) {
854 $new_attachment_dir = "";
856 $new_attachment_dir =~ s/\/*$//g
;
857 $new_attachment_dir =~ s/$/\//g
;
859 return $new_attachment_dir;
864 print "This is the default size (in pixels) of the left folder list.\n";
865 print "Default is 200, but you can set it to whatever you wish. This\n";
866 print "is a user preference, so this will only show up as their default.\n";
868 print "[$WHT$default_left_size$NRM]: $WHT";
869 $new_default_left_size = <STDIN
>;
870 if ($new_default_left_size eq "\n") {
871 $new_default_left_size = $default_left_size;
873 $new_default_left_size =~ s/[\r|\n]//g;
875 return $new_default_left_size;
880 print "\nNow we will define the themes that you wish to use. If you have added\n";
881 print "a theme of your own, just follow the instructions (?) about how to add\n";
882 print "them. You can also change the default theme.\n";
883 print "[theme] command (?=help) > ";
885 $input =~ s/[\r|\n]//g;
886 while ($input ne "d") {
887 if ($input =~ /^\s*l\s*/i) {
889 while ($count <= $#theme_name) {
890 if ($count == $theme_default) {
895 $name = $theme_name[$count];
896 $num_spaces = 25 - length($name);
897 for ($i = 0; $i < $num_spaces;$i++) {
901 print " $count. $name";
902 print "($theme_path[$count])\n";
906 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
907 $old_def = $theme_default;
908 $theme_default = $input;
909 $theme_default =~ s/^\s*m\s*//;
910 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
911 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
912 $theme_default = $old_def;
914 } elsif ($input =~ /^\s*\+/) {
915 print "What is the name of this theme: ";
917 $name =~ s/[\r|\n]//g;
918 $theme_name[$#theme_name+1] = $name;
919 print "Be sure to put ../config/ before the filename.\n";
920 print "What file is this stored in (ex: ../config/default_theme.php): ";
922 $name =~ s/[\r|\n]//g;
923 $theme_path[$#theme_path+1] = $name;
924 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
925 if ($input =~ /[0-9]+\s*$/) {
927 $rem_num =~ s/^\s*-\s*//g;
928 $rem_num =~ s/\s*$//;
930 $rem_num = $#theme_name;
932 if ($rem_num == $theme_default) {
933 print "You cannot remove the default theme!\n";
936 @new_theme_name = ();
937 @new_theme_path = ();
938 while ($count <= $#theme_name) {
939 if ($count != $rem_num) {
940 @new_theme_name = (@new_theme_name, $theme_name[$count]);
941 @new_theme_path = (@new_theme_path, $theme_path[$count]);
945 @theme_name = @new_theme_name;
946 @theme_path = @new_theme_path;
947 if ($theme_default > $rem_num) {
951 } elsif ($input =~ /^\s*\?\s*/) {
952 print ".-------------------------.\n";
953 print "| + (add theme) |\n";
954 print "| - N (remove theme) |\n";
955 print "| m N (mark default) |\n";
956 print "| l (list themes) |\n";
957 print "| d (done) |\n";
958 print "`-------------------------'\n";
960 print "[theme] command (?=help) > ";
962 $input =~ s/[\r|\n]//g;
968 print "You can now define different LDAP servers.\n";
969 print "[ldap] command (?=help) > ";
971 $input =~ s/[\r|\n]//g;
972 while ($input ne "d") {
973 if ($input =~ /^\s*l\s*/i) {
975 while ($count <= $#ldap_host) {
976 print "$count. $ldap_host[$count]\n";
977 print " base: $ldap_base[$count]\n";
978 if ($ldap_charset[$count]) {
979 print " charset: $ldap_charset[$count]\n";
981 if ($ldap_port[$count]) {
982 print " port: $ldap_port[$count]\n";
984 if ($ldap_name[$count]) {
985 print " name: $ldap_name[$count]\n";
987 if ($ldap_maxrows[$count]) {
988 print " maxrows: $ldap_maxrows[$count]\n";
993 } elsif ($input =~ /^\s*\+/) {
994 $sub = $#ldap_host + 1;
996 print "First, we need to have the hostname or the IP address where\n";
997 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1000 $name =~ s/[\r|\n]//g;
1001 $ldap_host[$sub] = $name;
1005 print "Next, we need the server root (base dn). For this, an empty\n";
1006 print "string is allowed.\n";
1007 print "Example: ou=member_directory,o=netcenter.com\n";
1010 $name =~ s/[\r|\n]//g;
1011 $ldap_base[$sub] = $name;
1015 print "This is the TCP/IP port number for the LDAP server. Default\n";
1016 print "port is 389. This is optional. Press ENTER for default.\n";
1019 $name =~ s/[\r|\n]//g;
1020 $ldap_port[$sub] = $name;
1024 print "This is the charset for the server. Default is utf-8. This\n";
1025 print "is also optional. Press ENTER for default.\n";
1028 $name =~ s/[\r|\n]//g;
1029 $ldap_charset[$sub] = $name;
1033 print "This is the name for the server, used to tag the results of\n";
1034 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1037 $name =~ s/[\r|\n]//g;
1038 $ldap_name[$sub] = $name;
1042 print "You can specify the maximum number of rows in the search result.\n";
1043 print "Default is unlimited. Press ENTER for default.\n";
1046 $name =~ s/[\r|\n]//g;
1047 $ldap_maxrows[$sub] = $name;
1051 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1052 if ($input =~ /[0-9]+\s*$/) {
1054 $rem_num =~ s/^\s*-\s*//g;
1055 $rem_num =~ s/\s*$//;
1057 $rem_num = $#ldap_host;
1060 @new_ldap_host = ();
1061 @new_ldap_base = ();
1062 @new_ldap_port = ();
1063 @new_ldap_name = ();
1064 @new_ldap_charset = ();
1065 @new_ldap_maxrows = ();
1066 while ($count <= $#ldap_host) {
1067 if ($count != $rem_num) {
1068 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1069 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1070 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1071 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1072 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1073 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1077 @ldap_host = @new_ldap_host;
1078 @ldap_base = @new_ldap_base;
1079 @ldap_port = @new_ldap_port;
1080 @ldap_name = @new_ldap_name;
1081 @ldap_charset = @new_ldap_charset;
1082 @ldap_maxrows = @new_ldap_maxrows;
1083 } elsif ($input =~ /^\s*\?\s*/) {
1084 print ".-------------------------.\n";
1085 print "| + (add host) |\n";
1086 print "| - N (remove host) |\n";
1087 print "| l (list hosts) |\n";
1088 print "| d (done) |\n";
1089 print "`-------------------------'\n";
1091 print "[ldap] command (?=help) > ";
1093 $input =~ s/[\r|\n]//g;
1098 print "Some of our developers have come up with very good javascript interface\n";
1099 print "for searching through address books, however, our original goals said\n";
1100 print "that we would be 100% HTML. In order to make it possible to use their\n";
1101 print "interface, and yet stick with our goals, we have also written a plain\n";
1102 print "HTML version of the search. Here, you can choose which version to use.\n";
1104 print "This is just the default value. It is also a user option that each\n";
1105 print "user can configure individually\n";
1108 if ($default_use_javascript_addr_book eq "true") {
1109 $default_value = "y";
1111 $default_use_javascript_addr_book = "false";
1112 $default_value = "n";
1114 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1115 $new_show = <STDIN
>;
1116 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1117 $default_use_javascript_addr_book = "true";
1119 $default_use_javascript_addr_book = "false";
1121 return $default_use_javascript_addr_book;
1126 open (FILE
, ">config.php");
1128 print FILE
"<?php\n\t/** SquirrelMail configuration\n";
1129 print FILE
"\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1131 print FILE
"\t\$org_name = \"$org_name\";\n";
1132 print FILE
"\t\$org_logo = \"$org_logo\";\n";
1133 print FILE
"\t\$org_title = \"$org_title\";\n";
1137 print FILE
"\t\$domain = \"$domain\";\n";
1138 print FILE
"\t\$imapServerAddress = \"$imapServerAddress\";\n";
1139 print FILE
"\t\$imapPort = $imapPort;\n";
1140 print FILE
"\t\$useSendmail = $useSendmail;\n";
1141 print FILE
"\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1142 print FILE
"\t\$smtpPort = $smtpPort;\n";
1143 print FILE
"\t\$sendmailPath = \"$sendmail_path\";\n";
1144 print FILE
"\t\$imap_server_type = \"$imap_server_type\";\n";
1148 print FILE
"\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1149 print FILE
"\t\$trash_folder = \"$trash_folder\";\n";
1150 print FILE
"\t\$sent_folder = \"$sent_folder\";\n";
1151 print FILE
"\t\$default_move_to_trash = $default_move_to_trash;\n";
1152 print FILE
"\t\$default_move_to_sent = $default_move_to_sent;\n";
1153 print FILE
"\t\$show_prefix_option = $show_prefix_option;\n";
1154 print FILE
"\t\$list_special_folders_first = $list_special_folders_first;\n";
1155 print FILE
"\t\$use_special_folder_color = $use_special_folder_color;\n";
1156 print FILE
"\t\$auto_expunge = $auto_expunge;\n";
1157 print FILE
"\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1158 print FILE
"\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1161 print FILE
"\t\$default_charset = \"$default_charset\";\n";
1162 print FILE
"\t\$auto_forward = $auto_forward;\n";
1163 print FILE
"\t\$data_dir = \"$data_dir\";\n";
1164 print FILE
"\t\$attachment_dir = \"$attachment_dir\";\n";
1165 print FILE
"\t\$default_left_size = $default_left_size;\n";
1169 for ($count=0; $count <= $#theme_name; $count++) {
1170 print FILE
"\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1171 print FILE
"\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1176 if ($default_use_javascript_addr_book ne "true") {
1177 $default_use_javascript_addr_book = "false";
1179 print FILE
"\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1180 for ($count=0; $count <= $#ldap_host; $count++) {
1181 print FILE
"\t\$ldap_server[$count] = Array(\n";
1182 print FILE
"\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1183 print FILE
"\t\t\t\"base\" => \"$ldap_base[$count]\"";
1184 if ($ldap_name[$count]) {
1185 print FILE
",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1187 if ($ldap_port[$count]) {
1188 print FILE
",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1190 if ($ldap_charset[$count]) {
1191 print FILE
",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1193 if ($ldap_maxrows[$count]) {
1194 print FILE
",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1196 print FILE
");\n\n";
1200 print FILE
"\t\$motd = \"$motd\";\n";
1208 print "While we have been building SquirrelMail, we have discovered some\n";
1209 print "preferences that work better with some servers that don't work so\n";
1210 print "well with others. If you select your IMAP server, this option will\n";
1211 print "set some pre-defined settings for that server.\n";
1213 print "Please note that you will still need to go through and make sure\n";
1214 print "everything is correct. This does not change everything. There are\n";
1215 print "only a few settings that thils will change.\n";
1219 while ($continue != 1) {
1220 print "Please select your IMAP server:\n";
1221 print " cyrus = Cyrus IMAP server\n";
1222 print " uw = University of Washington's IMAP server\n";
1223 print " exchange = Microsoft Exchange IMAP server\n";
1224 print " courier = Courier IMAP server\n";
1225 print " quit = Do not change anything\n";
1226 print "Command >> ";
1228 $server =~ s/[\r|\n]//g;
1231 if ($server eq "cyrus") {
1232 $default_folder_prefix = "INBOX";
1233 $trash_folder = "INBOX.Trash";
1234 $sent_folder = "INBOX.Sent";
1235 $show_prefix_option = false
;
1236 $default_sub_of_inbox = true
;
1237 $show_contain_subfolders_option = false
;
1238 $imap_server_type = "cyrus";
1240 print " default_folder_prefix = INBOX\n";
1241 print " trash_folder = INBOX.Trash\n";
1242 print " sent_folder = INBOX.Sent\n";
1243 print " show_prefix_optin = false\n";
1244 print " default_sub_of_inbox = true\n";
1245 print "show_contain_subfolders_option = false\n";
1246 print " imap_server_type = cyrus\n";
1249 } elsif ($server eq "uw") {
1250 $default_folder_prefix = "mail/";
1251 $trash_folder = "Trash";
1252 $sent_folder = "Sent";
1253 $show_prefix_option = true
;
1254 $default_sub_of_inbox = false
;
1255 $show_contain_subfolders_option = true
;
1256 $imap_server_type = "uw";
1258 print " default_folder_prefix = mail/\n";
1259 print " trash_folder = Trash\n";
1260 print " sent_folder = Sent\n";
1261 print " show_prefix_option = true\n";
1262 print " default_sub_of_inbox = false\n";
1263 print "show_contain_subfolders_option = true\n";
1264 print " imap_server_type = uw\n";
1267 } elsif ($server eq "exchange") {
1268 $default_folder_prefix = "INBOX/";
1269 $default_sub_of_inbox = true
;
1270 $trash_folder = "INBOX/Deleted Items";
1271 $sent_folder = "INBOX/Sent Items";
1272 $show_prefix_option = false
;
1273 $show_contain_subfolders_option = false
;
1275 $imap_server_type = "exchange";
1278 } elsif ($server eq "courier") {
1279 $imap_server_type = "courier";
1282 } elsif ($server eq "quit") {
1285 print "Unrecognized server: $server\n";
1289 print "\nPress any key to continue...";