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+\$/) {
35 if ($var =~ /^([a-z]|[A-Z])/) {
36 @options = split(/\s*EQUALS\s*/, $var);
37 $options[1] =~ s/[\n|\r]//g;
38 $options[1] =~ s/\";$//;
39 $options[1] =~ s/;$//;
40 $options[1] =~ s/^"//;
42 # $options[1] =~ s/"$//;
45 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
47 $sub =~ s/\]\["PATH"\]//;
48 $sub = substr ($sub, @sub-1, 1);
49 $theme_path[$sub] = $options[1];
50 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
52 $sub =~ s/\]\["NAME"\]//;
53 $sub = substr ($sub, @sub-1, 1);
54 $theme_name[$sub] = $options[1];
55 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
57 $sub = substr ($sub, length($sub)-2, 1);
59 while (($tmp = <FILE
>) && ($continue != 1)) {
60 if ($tmp =~ /\);\s*$/) {
64 if ($tmp =~ /^\s*"host"/i) {
65 $tmp =~ s/^\s*"host"\s*=>\s*"//i;
69 } elsif ($tmp =~ /^\s*"base"/i) {
70 $tmp =~ s/^\s*"base"\s*=>\s*"//i;
74 } elsif ($tmp =~ /^\s*"charset"/i) {
75 $tmp =~ s/^\s*"charset"\s*=>\s*"//i;
79 } elsif ($tmp =~ /^\s*"port"/i) {
80 $tmp =~ s/^\s*"port"\s*=>\s*"//i;
84 } elsif ($tmp =~ /^\s*"maxrows"/i) {
85 $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i;
89 } elsif ($tmp =~ /^\s*"name"/i) {
90 $tmp =~ s/^\s*"name"\s*=>\s*"//i;
96 $ldap_host[$sub] = $host;
97 $ldap_base[$sub] = $base;
98 $ldap_name[$sub] = $name;
99 $ldap_port[$sub] = $port;
100 $ldap_maxrows[$sub] = $maxrows;
101 $ldap_charset[$sub] = $charset;
103 ${$options[0]} = $options[1];
108 if ($useSendmail ne "true") {
109 $useSendmail = "false";
111 if (!$sendmail_path) {
112 $sendmail_path = "/usr/sbin/sendmail";
115 #####################################################################################
117 while (($command ne "q") && ($command ne "Q")) {
120 print $WHT."SquirrelMail Configuration : ".$NRM;
121 if ($config == 1) { print "Read: config.php"; }
122 elsif ($config == 2) { print "Read: config_default.php"; }
125 print $WHT."Main Menu --\n".$NRM;
126 print "1. Organization Preferences\n";
127 print "2. Server Settings\n";
128 print "3. Folder Defaults\n";
129 print "4. General Options\n";
131 print "6. Address Books (LDAP)\n";
132 print "7. Message of the Day (MOTD)\n";
134 print "D. Set pre-defined settings for specific IMAP servers\n";
136 } elsif ($menu == 1) {
137 print $WHT."Organization Preferences\n".$NRM;
138 print "1. Organization Name : $WHT$org_name$NRM\n";
139 print "2. Organization Logo : $WHT$org_logo$NRM\n";
140 print "3. Organization Title : $WHT$org_title$NRM\n";
142 print "R Return to Main Menu\n";
143 } elsif ($menu == 2) {
144 print $WHT."Server Settings\n".$NRM;
145 print "1. Domain : $WHT$domain$NRM\n";
146 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
147 print "3. IMAP Port : $WHT$imapPort$NRM\n";
148 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
149 if ($useSendmail eq "true") {
150 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
152 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
153 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
155 print "8. Server : $WHT$imap_server_type$NRM\n";
157 print "R Return to Main Menu\n";
158 } elsif ($menu == 3) {
159 print $WHT."Folder Defaults\n".$NRM;
160 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
161 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
162 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
163 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
164 print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
165 print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
166 print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
167 print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
168 print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
169 print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
170 print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
172 print "R Return to Main Menu\n";
173 } elsif ($menu == 4) {
174 print $WHT."General Options\n".$NRM;
175 print "1. Default Charset : $WHT$default_charset$NRM\n";
176 print "2. Data Directory : $WHT$data_dir$NRM\n";
177 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
178 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
180 print "R Return to Main Menu\n";
181 } elsif ($menu == 5) {
182 print $WHT."Themes\n".$NRM;
183 print "1. Change Themes\n";
184 for ($count = 0; $count <= $#theme_name; $count++) {
185 print " > $theme_name[$count]\n";
188 print "R Return to Main Menu\n";
189 } elsif ($menu == 6) {
190 print $WHT."Address Books (LDAP)\n".$NRM;
191 print "1. Change Servers\n";
192 for ($count = 0; $count <= $#ldap_host; $count++) {
193 print " > $ldap_host[$count]\n";
195 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
197 print "R Return to Main Menu\n";
198 } elsif ($menu == 7) {
199 print $WHT."Message of the Day (MOTD)\n".$NRM;
202 print "1 Edit the MOTD\n";
204 print "R Return to Main Menu\n";
206 print "S Save data\n";
210 print "Command >> ".$WHT;
212 $command =~ s/[\n|\r]//g;
215 # Read the commands they entered.
216 if (($command eq "R") || ($command eq "r")) {
218 } elsif (($command eq "s") || ($command eq "S")) {
220 print "Data saved in config.php\n";
221 print "Press any key to continue...";
224 } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
225 print "You have not saved your data.\n";
226 print "Save? (y/n) [".$WHT."y".$NRM."]: ";
228 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
231 } elsif (($command eq "d") || ($command eq "D")) {
236 if (($command > 0) && ($command < 8)) {
239 } elsif ($menu == 1) {
240 if ($command == 1) { $org_name = command1
(); }
241 elsif ($command == 2) { $org_logo = command2
(); }
242 elsif ($command == 3) { $org_title = command3
(); }
243 } elsif ($menu == 2) {
244 if ($command == 1) { $domain = command11
(); }
245 elsif ($command == 2) { $imapServerAddress = command12
(); }
246 elsif ($command == 3) { $imapPort = command13
(); }
247 elsif ($command == 4) { $useSendmail = command14
(); }
248 elsif ($command == 5) { $sendmail_path = command15
(); }
249 elsif ($command == 6) { $smtpServerAddress = command16
(); }
250 elsif ($command == 7) { $smtpPort = command17
(); }
251 elsif ($command == 8) { $imap_server_type = command18
(); }
252 } elsif ($menu == 3) {
253 if ($command == 1) { $default_folder_prefix = command21
(); }
254 elsif ($command == 2) { $show_prefix_option = command22
(); }
255 elsif ($command == 3) { $trash_folder = command23
(); }
256 elsif ($command == 4) { $sent_folder = command24
(); }
257 elsif ($command == 5) { $default_move_to_trash = command25
(); }
258 elsif ($command == 6) { $default_move_to_sent = command26
(); }
259 elsif ($command == 7) { $list_special_folders_first = command27
(); }
260 elsif ($command == 8) { $use_special_folder_color = command28
(); }
261 elsif ($command == 9) { $auto_expunge = command29
(); }
262 elsif ($command == 10){ $default_sub_of_inbox = command210
(); }
263 elsif ($command == 11){ $show_contain_subfolders_option = command211
(); }
264 } elsif ($menu == 4) {
265 if ($command == 1) { $default_charset = command31
(); }
266 elsif ($command == 2) { $data_dir = command33
(); }
267 elsif ($command == 3) { $attachment_dir = command34
(); }
268 elsif ($command == 4) { $default_left_size = command35
(); }
269 } elsif ($menu == 5) {
273 } elsif ($menu == 6) {
274 if ($command == 1) { command61
(); }
275 elsif ($command == 2) { command62
(); }
276 } elsif ($menu == 7) {
277 if ($command == 1) { $motd = command71
(); }
282 ####################################################################################
286 print "We have tried to make the name SquirrelMail as transparent as\n";
287 print "possible. If you set up an organization name, most places where\n";
288 print "SquirrelMail would take credit will be credited to your organization.\n";
290 print "[$WHT$org_name$NRM]: $WHT";
291 $new_org_name = <STDIN
>;
292 if ($new_org_name eq "\n") {
293 $new_org_name = $org_name;
295 $new_org_name =~ s/[\r|\n]//g;
297 return $new_org_name;
303 print "Your organization's logo is an image that will be displayed at\n";
304 print "different times throughout SquirrelMail. This is asking for the\n";
305 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
306 print "(../images/logo.jpg) path to your logo.\n";
308 print "[$WHT$org_logo$NRM]: $WHT";
309 $new_org_logo = <STDIN
>;
310 if ($new_org_logo eq "\n") {
311 $new_org_logo = $org_logo;
313 $new_org_logo =~ s/[\r|\n]//g;
315 return $new_org_logo;
320 print "A title is what is displayed at the top of the browser window in\n";
321 print "the titlebar. Usually this will end up looking something like:\n";
322 print "\"Netscape: $org_title\"\n";
324 print "[$WHT$org_title$NRM]: $WHT";
325 $new_org_title = <STDIN
>;
326 if ($new_org_title eq "\n") {
327 $new_org_title = $org_title;
329 $new_org_title =~ s/[\r|\n]//g;
331 return $new_org_title;
334 ####################################################################################
338 print "The domain name is the suffix at the end of all email messages. If\n";
339 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
340 print "would be myorg.com.\n";
342 print "[$WHT$domain$NRM]: $WHT";
343 $new_domain = <STDIN
>;
344 if ($new_domain eq "\n") {
345 $new_domain = $domain;
347 $new_domain =~ s/[\r|\n]//g;
354 print "This is the address where your IMAP server resides.\n";
355 print "[$WHT$imapServerAddress$NRM]: $WHT";
356 $new_imapServerAddress = <STDIN
>;
357 if ($new_imapServerAddress eq "\n") {
358 $new_imapServerAddress = $imapServerAddress;
360 $new_imapServerAddress =~ s/[\r|\n]//g;
362 return $new_imapServerAddress;
367 print "This is the port that your IMAP server is on. Usually this is 143.\n";
368 print "[$WHT$imapPort$NRM]: $WHT";
369 $new_imapPort = <STDIN
>;
370 if ($new_imapPort eq "\n") {
371 $new_imapPort = $imapPort;
373 $new_imapPort =~ s/[\r|\n]//g;
375 return $new_imapPort;
380 print "You now need to choose the method that you will use for sending\n";
381 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
382 print "or use sendmail directly.\n";
383 if ($useSendmail eq "true") {
384 $default_value = "y";
386 $default_value = "n";
389 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
390 $use_sendmail = <STDIN
>;
391 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
392 $useSendmail = "true";
394 $useSendmail = "false";
401 if ($sendmail_path[0] !~ /./) {
402 $sendmail_path = "/usr/sbin/sendmail";
404 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
405 print "[$WHT$sendmail_path$NRM]: $WHT";
406 $new_sendmail_path = <STDIN
>;
407 if ($new_sendmail_path eq "\n") {
408 $new_sendmail_path = $sendmail_path;
410 $new_sendmail_path =~ s/[\r|\n]//g;
412 return $new_sendmail_path;
417 print "This is the location of your SMTP server.\n";
418 print "[$WHT$smtpServerAddress$NRM]: $WHT";
419 $new_smtpServerAddress = <STDIN
>;
420 if ($new_smtpServerAddress eq "\n") {
421 $new_smtpServerAddress = $smtpServerAddress;
423 $new_smtpServerAddress =~ s/[\r|\n]//g;
425 return $new_smtpServerAddress;
430 print "This is the port to connect to for SMTP. Usually 25.\n";
431 print "[$WHT$smtpPort$NRM]: $WHT";
432 $new_smtpPort = <STDIN
>;
433 if ($new_smtpPort eq "\n") {
434 $new_smtpPort = $smtpPort;
436 $new_smtpPort =~ s/[\r|\n]//g;
438 return $new_smtpPort;
442 print "Eash IMAP server has its own quirks. As much as we tried to stick\n";
443 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
444 print "the same principles. We have made some work-arounds for some of\n";
445 print "these servers. If you would like to use them, please select your\n";
446 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
447 print "set this to \"other\", and none will be used.\n";
448 print " cyrus = Cyrus IMAP server\n";
449 print " uw = University of Washington's IMAP server\n";
450 print " exchange = Microsoft Exchange IMAP server\n";
451 print " courier = Courier IMAP server\n";
452 print "[$WHT$imap_server_type$NRM]: $WHT";
453 $new_imap_server_type = <STDIN
>;
454 if ($new_imap_server_type eq "\n") {
455 $new_imap_server_type = $imap_server_type;
457 $new_imap_server_type =~ s/[\r|\n]//g;
459 return $new_imap_server_type;
464 print "\nYou can now create the welcome message that is displayed\n";
465 print "every time a user logs on. You can use HTML or just plain\n";
466 print "text.\n\n(Type @ on a blank line to exit)\n";
472 $line =~ s/[\r|\n]//g;
474 $line =~ s/ /\ \ /g;
475 $line =~ s/\t/\ \ \ \ /g;
477 $line =~ s/\"/\\\"/g;
479 $new_motd = $new_motd . $line;
481 } while ($line ne "@");
485 ################# FOLDERS ###################
487 # default_folder_prefix
489 print "Some IMAP servers (UW, for example) store mail and folders in\n";
490 print "your user space in a separate subdirectory. This is where you\n";
491 print "specify what that directory is.\n";
493 print "EXAMPLE: mail/";
495 print "NOTE: If you use Cyrus, or some server that would not use this\n";
496 print " option, you must set this to 'none'.\n";
498 print "[$WHT$default_folder_prefix$NRM]: $WHT";
499 $new_default_folder_prefix = <STDIN
>;
500 if ($new_default_folder_prefix eq "\n") {
501 $new_default_folder_prefix = $default_folder_prefix;
503 $new_default_folder_prefix =~ s/[\r|\n]//g;
505 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
506 $new_default_folder_prefix = "";
508 $new_default_folder_prefix =~ s/\/*$//g
;
509 $new_default_folder_prefix =~ s/$/\//g
;
511 return $new_default_folder_prefix;
516 print "It is possible to set up the default folder prefix as a user\n";
517 print "specific option, where each user can specify what their mail\n";
518 print "folder is. If you set this to false, they will never see the\n";
519 print "option, but if it is true, this option will appear in the\n";
520 print "'options' section.\n";
522 print "NOTE: You set the default folder prefix in option '1' of this\n";
523 print " section. That will be the default if the user doesn't\n";
524 print " specify anything different.\n";
527 if ($show_prefix_option eq "true") {
528 $default_value = "y";
530 $default_value = "n";
533 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
535 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
536 $show_prefix_option = "true";
538 $show_prefix_option = "false";
540 return $show_prefix_option;
545 print "You can now specify where the default trash folder is located.\n";
546 print "On servers where you do not want this, you can set it to anything\n";
547 print "and set option 7 to false.\n";
549 print "This is relative to where the rest of your email is kept. You do\n";
550 print "not need to worry about their mail directory. If this folder\n";
551 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
552 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
555 print "[$WHT$trash_folder$NRM]: $WHT";
556 $new_trash_folder = <STDIN
>;
557 if ($new_trash_folder eq "\n") {
558 $new_trash_folder = $trash_folder;
560 $new_trash_folder =~ s/[\r|\n]//g;
562 return $new_trash_folder;
567 print "This is where messages that are sent will be stored. SquirrelMail\n";
568 print "by default puts a copy of all outgoing messages in this folder.\n";
570 print "This is relative to where the rest of your email is kept. You do\n";
571 print "not need to worry about their mail directory. If this folder\n";
572 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
573 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
576 print "[$WHT$sent_folder$NRM]: $WHT";
577 $new_sent_folder = <STDIN
>;
578 if ($new_sent_folder eq "\n") {
579 $new_sent_folder = $sent_folder;
581 $new_sent_folder =~ s/[\r|\n]//g;
583 return $new_sent_folder;
586 # default move to trash
588 print "By default, should messages get moved to the trash folder? You\n";
589 print "can specify the default trash folder in option 3. If this is set\n";
590 print "to false, messages will get deleted immediately without moving\n";
591 print "to the trash folder.\n";
593 print "Trash folder is currently: $trash_folder\n";
596 if ($default_move_to_trash eq "true") {
597 $default_value = "y";
599 $default_value = "n";
601 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
603 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
604 $default_move_to_trash = "true";
606 $default_move_to_trash = "false";
608 return $default_move_to_trash;
611 # default move to sent
613 print "By default, should messages get moved to the sent folder? You\n";
614 print "can specify the default sent folder in option 4. If this is set\n";
615 print "to false, messages will get sent an no copy will be made.\n";
617 print "Trash folder is currently: $sent_folder\n";
620 if ($default_move_to_sent eq "true") {
621 $default_value = "y";
623 $default_value = "n";
625 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
627 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
628 $default_move_to_sent = "true";
630 $default_move_to_sent = "false";
632 return $default_move_to_sent;
635 # List special folders first
637 print "SquirrelMail has what we call 'special folders' that are not\n";
638 print "manipulated and viewed like normal folders. Some examples of\n";
639 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
640 print "Simply asks if you want these folders listed first in the folder\n";
644 if ($list_special_folders_first eq "true") {
645 $default_value = "y";
647 $default_value = "n";
650 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
652 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
653 $list_special_folders_first = "true";
655 $list_special_folders_first = "false";
657 return $list_special_folders_first;
660 # Show special folders color
662 print "SquirrelMail has what we call 'special folders' that are not\n";
663 print "manipulated and viewed like normal folders. Some examples of\n";
664 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
665 print "wants to know if we should display special folders in a\n";
666 print "color than the other folders.\n";
669 if ($use_special_folder_color eq "true") {
670 $default_value = "y";
672 $default_value = "n";
675 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
677 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
678 $use_special_folder_color = "true";
680 $use_special_folder_color = "false";
682 return $use_special_folder_color;
687 print "The way that IMAP handles deleting messages is as follows. You\n";
688 print "mark the message as deleted, and then to 'really' delete it, you\n";
689 print "expunge it. This option asks if you want to just have messages\n";
690 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
691 print "messages too.\n";
694 if ($auto_expunge eq "true") {
695 $default_value = "y";
697 $default_value = "n";
699 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
701 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
702 $auto_expunge = "true";
704 $auto_expunge = "false";
706 return $auto_expunge;
709 # Default sub of inbox
711 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
712 print "This can cause some confusion in folder creation for users when\n";
713 print "they try to create folders and don't put it as a subfolder of INBOX\n";
714 print "and get permission errors. This option asks if you want folders\n";
715 print "to be subfolders of INBOX by default.\n";
718 if ($default_sub_of_inbox eq "true") {
719 $default_value = "y";
721 $default_value = "n";
723 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
725 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
726 $default_sub_of_inbox = "true";
728 $default_sub_of_inbox = "false";
730 return $default_sub_of_inbox;
733 # Show contain subfolder option
735 print "Some IMAP servers (UW) make it so that there are two types of\n";
736 print "folders. Those that contain messages, and those that contain\n";
737 print "subfolders. If this is the case for your server, set this to\n";
738 print "true, and it will ask the user whether the folder they are\n";
739 print "creating contains subfolders or messages.\n";
742 if ($show_contain_subfolders_option eq "true") {
743 $default_value = "y";
745 $default_value = "n";
747 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
749 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
750 $show_contain_subfolders_option = "true";
752 $show_contain_subfolders_option = "false";
754 return $show_contain_subfolders_option;
757 ############# GENERAL OPTIONS #####################
761 print "This option controls what character set is used when sending\n";
762 print "mail and when sending HTML to the browser. Do not set this\n";
763 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
764 print "to use KOI8-R, since this implementation is faster than most\n";
765 print "of the alternatives\n";
768 print "[$WHT$default_charset$NRM]: $WHT";
769 $new_default_charset = <STDIN
>;
770 if ($new_default_charset eq "\n") {
771 $new_default_charset = $default_charset;
773 $new_default_charset =~ s/[\r|\n]//g;
775 return $new_default_charset;
780 print "It is a possible security hole to have a writable directory\n";
781 print "under the web server's root directory (ex: /home/httpd/html).\n";
782 print "For this reason, it is possible to put the data directory\n";
783 print "anywhere you would like. The path name can be absolute or\n";
784 print "relative (to the config directory). It doesn't matter. Here\n";
785 print "are two examples:\n";
786 print " Absolute: /usr/local/squirrelmail/data/\n";
787 print " Relative: ../data/\n";
790 print "[$WHT$data_dir$NRM]: $WHT";
791 $new_data_dir = <STDIN
>;
792 if ($new_data_dir eq "\n") {
793 $new_data_dir = $data_dir;
795 $new_data_dir =~ s/[\r|\n]//g;
797 if ($new_data_dir =~ /^\s*$/) {
800 $new_data_dir =~ s/\/*$//g
;
801 $new_data_dir =~ s/$/\//g
;
803 return $new_data_dir;
806 # Attachment directory
808 print "Path to directory used for storing attachments while a mail is\n";
809 print "being sent. There are a few security considerations regarding this\n";
810 print "directory:\n";
811 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
812 print " impossible for a random person with access to the webserver\n";
813 print " to list files in this directory. Confidential data might\n";
814 print " be laying around in there.\n";
815 print " 2. Since the webserver is not able to list the files in the\n";
816 print " content is also impossible for the webserver to delete files\n";
817 print " lying around there for too long.\n";
818 print " 3. It should probably be another directory than the data\n";
819 print " directory specified in option 3.\n";
822 print "[$WHT$attachment_dir$NRM]: $WHT";
823 $new_attachment_dir = <STDIN
>;
824 if ($new_attachment_dir eq "\n") {
825 $new_attachment_dir = $attachment_dir;
827 $new_attachment_dir =~ s/[\r|\n]//g;
829 if ($new_attachment_dir =~ /^\s*$/) {
830 $new_attachment_dir = "";
832 $new_attachment_dir =~ s/\/*$//g
;
833 $new_attachment_dir =~ s/$/\//g
;
835 return $new_attachment_dir;
840 print "This is the default size (in pixels) of the left folder list.\n";
841 print "Default is 200, but you can set it to whatever you wish. This\n";
842 print "is a user preference, so this will only show up as their default.\n";
844 print "[$WHT$default_left_size$NRM]: $WHT";
845 $new_default_left_size = <STDIN
>;
846 if ($new_default_left_size eq "\n") {
847 $new_default_left_size = $default_left_size;
849 $new_default_left_size =~ s/[\r|\n]//g;
851 return $new_default_left_size;
856 print "\nNow we will define the themes that you wish to use. If you have added\n";
857 print "a theme of your own, just follow the instructions (?) about how to add\n";
858 print "them. You can also change the default theme.\n";
859 print "[theme] command (?=help) > ";
861 $input =~ s/[\r|\n]//g;
862 while ($input ne "d") {
863 if ($input =~ /^\s*l\s*/i) {
865 while ($count <= $#theme_name) {
866 if ($count == $theme_default) {
871 $name = $theme_name[$count];
872 $num_spaces = 25 - length($name);
873 for ($i = 0; $i < $num_spaces;$i++) {
877 print " $count. $name";
878 print "($theme_path[$count])\n";
882 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
883 $old_def = $theme_default;
884 $theme_default = $input;
885 $theme_default =~ s/^\s*m\s*//;
886 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
887 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
888 $theme_default = $old_def;
890 } elsif ($input =~ /^\s*\+/) {
891 print "What is the name of this theme: ";
893 $name =~ s/[\r|\n]//g;
894 $theme_name[$#theme_name+1] = $name;
895 print "Be sure to put ../config/ before the filename.\n";
896 print "What file is this stored in (ex: ../config/default_theme.php): ";
898 $name =~ s/[\r|\n]//g;
899 $theme_path[$#theme_path+1] = $name;
900 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
901 if ($input =~ /[0-9]+\s*$/) {
903 $rem_num =~ s/^\s*-\s*//g;
904 $rem_num =~ s/\s*$//;
906 $rem_num = $#theme_name;
908 if ($rem_num == $theme_default) {
909 print "You cannot remove the default theme!\n";
912 @new_theme_name = ();
913 @new_theme_path = ();
914 while ($count <= $#theme_name) {
915 if ($count != $rem_num) {
916 @new_theme_name = (@new_theme_name, $theme_name[$count]);
917 @new_theme_path = (@new_theme_path, $theme_path[$count]);
921 @theme_name = @new_theme_name;
922 @theme_path = @new_theme_path;
923 if ($theme_default > $rem_num) {
927 } elsif ($input =~ /^\s*\?\s*/) {
928 print ".-------------------------.\n";
929 print "| + (add theme) |\n";
930 print "| - N (remove theme) |\n";
931 print "| m N (mark default) |\n";
932 print "| l (list themes) |\n";
933 print "| d (done) |\n";
934 print "`-------------------------'\n";
936 print "[theme] command (?=help) > ";
938 $input =~ s/[\r|\n]//g;
944 print "You can now define different LDAP servers.\n";
945 print "[ldap] command (?=help) > ";
947 $input =~ s/[\r|\n]//g;
948 while ($input ne "d") {
949 if ($input =~ /^\s*l\s*/i) {
951 while ($count <= $#ldap_host) {
952 print "$count. $ldap_host[$count]\n";
953 print " base: $ldap_base[$count]\n";
954 if ($ldap_charset[$count]) {
955 print " charset: $ldap_charset[$count]\n";
957 if ($ldap_port[$count]) {
958 print " port: $ldap_port[$count]\n";
960 if ($ldap_name[$count]) {
961 print " name: $ldap_name[$count]\n";
963 if ($ldap_maxrows[$count]) {
964 print " maxrows: $ldap_maxrows[$count]\n";
969 } elsif ($input =~ /^\s*\+/) {
970 $sub = $#ldap_host + 1;
972 print "First, we need to have the hostname or the IP address where\n";
973 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
976 $name =~ s/[\r|\n]//g;
977 $ldap_host[$sub] = $name;
981 print "Next, we need the server root (base dn). For this, an empty\n";
982 print "string is allowed.\n";
983 print "Example: ou=member_directory,o=netcenter.com\n";
986 $name =~ s/[\r|\n]//g;
987 $ldap_base[$sub] = $name;
991 print "This is the TCP/IP port number for the LDAP server. Default\n";
992 print "port is 389. This is optional. Press ENTER for default.\n";
995 $name =~ s/[\r|\n]//g;
996 $ldap_port[$sub] = $name;
1000 print "This is the charset for the server. Default is utf-8. This\n";
1001 print "is also optional. Press ENTER for default.\n";
1004 $name =~ s/[\r|\n]//g;
1005 $ldap_charset[$sub] = $name;
1009 print "This is the name for the server, used to tag the results of\n";
1010 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1013 $name =~ s/[\r|\n]//g;
1014 $ldap_name[$sub] = $name;
1018 print "You can specify the maximum number of rows in the search result.\n";
1019 print "Default is unlimited. Press ENTER for default.\n";
1022 $name =~ s/[\r|\n]//g;
1023 $ldap_maxrows[$sub] = $name;
1027 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1028 if ($input =~ /[0-9]+\s*$/) {
1030 $rem_num =~ s/^\s*-\s*//g;
1031 $rem_num =~ s/\s*$//;
1033 $rem_num = $#ldap_host;
1036 @new_ldap_host = ();
1037 @new_ldap_base = ();
1038 @new_ldap_port = ();
1039 @new_ldap_name = ();
1040 @new_ldap_charset = ();
1041 @new_ldap_maxrows = ();
1042 while ($count <= $#ldap_host) {
1043 if ($count != $rem_num) {
1044 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1045 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1046 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1047 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1048 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1049 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1053 @ldap_host = @new_ldap_host;
1054 @ldap_base = @new_ldap_base;
1055 @ldap_port = @new_ldap_port;
1056 @ldap_name = @new_ldap_name;
1057 @ldap_charset = @new_ldap_charset;
1058 @ldap_maxrows = @new_ldap_maxrows;
1059 } elsif ($input =~ /^\s*\?\s*/) {
1060 print ".-------------------------.\n";
1061 print "| + (add host) |\n";
1062 print "| - N (remove host) |\n";
1063 print "| l (list hosts) |\n";
1064 print "| d (done) |\n";
1065 print "`-------------------------'\n";
1067 print "[ldap] command (?=help) > ";
1069 $input =~ s/[\r|\n]//g;
1074 print "Some of our developers have come up with very good javascript interface\n";
1075 print "for searching through address books, however, our original goals said\n";
1076 print "that we would be 100% HTML. In order to make it possible to use their\n";
1077 print "interface, and yet stick with our goals, we have also written a plain\n";
1078 print "HTML version of the search. Here, you can choose which version to use.\n";
1080 print "This is just the default value. It is also a user option that each\n";
1081 print "user can configure individually\n";
1084 if ($default_use_javascript_addr_book eq "true") {
1085 $default_value = "y";
1087 $default_use_javascript_addr_book = "false";
1088 $default_value = "n";
1090 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1091 $new_show = <STDIN
>;
1092 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1093 $default_use_javascript_addr_book = "true";
1095 $default_use_javascript_addr_book = "false";
1097 return $default_use_javascript_addr_book;
1102 open (FILE
, ">config.php");
1104 print FILE
"<?php\n\t/** SquirrelMail configuration\n";
1105 print FILE
"\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1107 print FILE
"\t\$org_name = \"$org_name\";\n";
1108 print FILE
"\t\$org_logo = \"$org_logo\";\n";
1109 print FILE
"\t\$org_title = \"$org_title\";\n";
1113 print FILE
"\t\$domain = \"$domain\";\n";
1114 print FILE
"\t\$imapServerAddress = \"$imapServerAddress\";\n";
1115 print FILE
"\t\$imapPort = $imapPort;\n";
1116 print FILE
"\t\$useSendmail = $useSendmail;\n";
1117 print FILE
"\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1118 print FILE
"\t\$smtpPort = $smtpPort;\n";
1119 print FILE
"\t\$sendmailPath = \"$sendmail_path\";\n";
1120 print FILE
"\t\$imap_server_type = \"$imap_server_type\";\n";
1124 print FILE
"\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1125 print FILE
"\t\$trash_folder = \"$trash_folder\";\n";
1126 print FILE
"\t\$sent_folder = \"$sent_folder\";\n";
1127 print FILE
"\t\$default_move_to_trash = $default_move_to_trash;\n";
1128 print FILE
"\t\$default_move_to_sent = $default_move_to_sent;\n";
1129 print FILE
"\t\$show_prefix_option = $show_prefix_option;\n";
1130 print FILE
"\t\$list_special_folders_first = $list_special_folders_first;\n";
1131 print FILE
"\t\$use_special_folder_color = $use_special_folder_color;\n";
1132 print FILE
"\t\$auto_expunge = $auto_expunge;\n";
1133 print FILE
"\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1134 print FILE
"\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1137 print FILE
"\t\$default_charset = \"$default_charset\";\n";
1138 print FILE
"\t\$data_dir = \"$data_dir\";\n";
1139 print FILE
"\t\$attachment_dir = \"$attachment_dir\";\n";
1140 print FILE
"\t\$default_left_size = $default_left_size;\n";
1144 for ($count=0; $count <= $#theme_name; $count++) {
1145 print FILE
"\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1146 print FILE
"\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1151 if ($default_use_javascript_addr_book ne "true") {
1152 $default_use_javascript_addr_book = "false";
1154 print FILE
"\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1155 for ($count=0; $count <= $#ldap_host; $count++) {
1156 print FILE
"\t\$ldap_server[$count] = Array(\n";
1157 print FILE
"\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1158 print FILE
"\t\t\t\"base\" => \"$ldap_base[$count]\"";
1159 if ($ldap_name[$count]) {
1160 print FILE
",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1162 if ($ldap_port[$count]) {
1163 print FILE
",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1165 if ($ldap_charset[$count]) {
1166 print FILE
",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1168 if ($ldap_maxrows[$count]) {
1169 print FILE
",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1171 print FILE
");\n\n";
1175 print FILE
"\t\$motd = \"$motd\";\n";
1183 print "While we have been building SquirrelMail, we have discovered some\n";
1184 print "preferences that work better with some servers that don't work so\n";
1185 print "well with others. If you select your IMAP server, this option will\n";
1186 print "set some pre-defined settings for that server.\n";
1188 print "Please note that you will still need to go through and make sure\n";
1189 print "everything is correct. This does not change everything. There are\n";
1190 print "only a few settings that this will change.\n";
1194 while ($continue != 1) {
1195 print "Please select your IMAP server:\n";
1196 print " cyrus = Cyrus IMAP server\n";
1197 print " uw = University of Washington's IMAP server\n";
1198 print " exchange = Microsoft Exchange IMAP server\n";
1199 print " courier = Courier IMAP server\n";
1200 print " quit = Do not change anything\n";
1201 print "Command >> ";
1203 $server =~ s/[\r|\n]//g;
1206 if ($server eq "cyrus") {
1207 $default_folder_prefix = "INBOX";
1208 $trash_folder = "INBOX.Trash";
1209 $sent_folder = "INBOX.Sent";
1210 $show_prefix_option = false
;
1211 $default_sub_of_inbox = true
;
1212 $show_contain_subfolders_option = false
;
1213 $imap_server_type = "cyrus";
1215 print " default_folder_prefix = INBOX\n";
1216 print " trash_folder = INBOX.Trash\n";
1217 print " sent_folder = INBOX.Sent\n";
1218 print " show_prefix_option = false\n";
1219 print " default_sub_of_inbox = true\n";
1220 print "show_contain_subfolders_option = false\n";
1221 print " imap_server_type = cyrus\n";
1224 } elsif ($server eq "uw") {
1225 $default_folder_prefix = "mail/";
1226 $trash_folder = "Trash";
1227 $sent_folder = "Sent";
1228 $show_prefix_option = true
;
1229 $default_sub_of_inbox = false
;
1230 $show_contain_subfolders_option = true
;
1231 $imap_server_type = "uw";
1233 print " default_folder_prefix = mail/\n";
1234 print " trash_folder = Trash\n";
1235 print " sent_folder = Sent\n";
1236 print " show_prefix_option = true\n";
1237 print " default_sub_of_inbox = false\n";
1238 print "show_contain_subfolders_option = true\n";
1239 print " imap_server_type = uw\n";
1242 } elsif ($server eq "exchange") {
1243 $default_folder_prefix = "INBOX/";
1244 $default_sub_of_inbox = true
;
1245 $trash_folder = "INBOX/Deleted Items";
1246 $sent_folder = "INBOX/Sent Items";
1247 $show_prefix_option = false
;
1248 $show_contain_subfolders_option = false
;
1250 $imap_server_type = "exchange";
1253 } elsif ($server eq "courier") {
1254 $imap_server_type = "courier";
1257 } elsif ($server eq "quit") {
1260 print "Unrecognized server: $server\n";
1264 print "\nPress any key to continue...";