3066133c0ac95b4fe9ae13a539e3f9a069f133be
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. Auto Forward : $WHT$auto_forward$NRM\n";
177 print "3. Data Directory : $WHT$data_dir$NRM\n";
178 print "4. Attachment Directory : $WHT$attachment_dir$NRM\n";
179 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
181 print "R Return to Main Menu\n";
182 } elsif ($menu == 5) {
183 print $WHT."Themes\n".$NRM;
184 print "1. Change Themes\n";
185 for ($count = 0; $count <= $#theme_name; $count++) {
186 print " > $theme_name[$count]\n";
189 print "R Return to Main Menu\n";
190 } elsif ($menu == 6) {
191 print $WHT."Address Books (LDAP)\n".$NRM;
192 print "1. Change Servers\n";
193 for ($count = 0; $count <= $#ldap_host; $count++) {
194 print " > $ldap_host[$count]\n";
196 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
198 print "R Return to Main Menu\n";
199 } elsif ($menu == 7) {
200 print $WHT."Message of the Day (MOTD)\n".$NRM;
203 print "1 Edit the MOTD\n";
205 print "R Return to Main Menu\n";
207 print "S Save data\n";
211 print "Command >> ".$WHT;
213 $command =~ s/[\n|\r]//g;
216 # Read the commands they entered.
217 if (($command eq "R") || ($command eq "r")) {
219 } elsif (($command eq "s") || ($command eq "S")) {
221 print "Data saved in config.php\n";
222 print "Press any key to continue...";
225 } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
226 print "You have not saved your data.\n";
227 print "Save? (y/n) [".$WHT."y".$NRM."]: ";
229 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
232 } elsif (($command eq "d") || ($command eq "D")) {
237 if (($command > 0) && ($command < 8)) {
240 } elsif ($menu == 1) {
241 if ($command == 1) { $org_name = command1
(); }
242 elsif ($command == 2) { $org_logo = command2
(); }
243 elsif ($command == 3) { $org_title = command3
(); }
244 } elsif ($menu == 2) {
245 if ($command == 1) { $domain = command11
(); }
246 elsif ($command == 2) { $imapServerAddress = command12
(); }
247 elsif ($command == 3) { $imapPort = command13
(); }
248 elsif ($command == 4) { $useSendmail = command14
(); }
249 elsif ($command == 5) { $sendmail_path = command15
(); }
250 elsif ($command == 6) { $smtpServerAddress = command16
(); }
251 elsif ($command == 7) { $smtpPort = command17
(); }
252 elsif ($command == 8) { $imap_server_type = command18
(); }
253 } elsif ($menu == 3) {
254 if ($command == 1) { $default_folder_prefix = command21
(); }
255 elsif ($command == 2) { $show_prefix_option = command22
(); }
256 elsif ($command == 3) { $trash_folder = command23
(); }
257 elsif ($command == 4) { $sent_folder = command24
(); }
258 elsif ($command == 5) { $default_move_to_trash = command25
(); }
259 elsif ($command == 6) { $default_move_to_sent = command26
(); }
260 elsif ($command == 7) { $list_special_folders_first = command27
(); }
261 elsif ($command == 8) { $use_special_folder_color = command28
(); }
262 elsif ($command == 9) { $auto_expunge = command29
(); }
263 elsif ($command == 10){ $default_sub_of_inbox = command210
(); }
264 elsif ($command == 11){ $show_contain_subfolders_option = command211
(); }
265 } elsif ($menu == 4) {
266 if ($command == 1) { $default_charset = command31
(); }
267 elsif ($command == 2) { $auto_forward = command32
(); }
268 elsif ($command == 3) { $data_dir = command33
(); }
269 elsif ($command == 4) { $attachment_dir = command34
(); }
270 elsif ($command == 5) { $default_left_size = command35
(); }
271 } elsif ($menu == 5) {
275 } elsif ($menu == 6) {
276 if ($command == 1) { command61
(); }
277 elsif ($command == 2) { command62
(); }
278 } elsif ($menu == 7) {
279 if ($command == 1) { $motd = command71
(); }
284 ####################################################################################
288 print "We have tried to make the name SquirrelMail as transparent as\n";
289 print "possible. If you set up an organization name, most places where\n";
290 print "SquirrelMail would take credit will be credited to your organization.\n";
292 print "[$WHT$org_name$NRM]: $WHT";
293 $new_org_name = <STDIN
>;
294 if ($new_org_name eq "\n") {
295 $new_org_name = $org_name;
297 $new_org_name =~ s/[\r|\n]//g;
299 return $new_org_name;
305 print "Your organization's logo is an image that will be displayed at\n";
306 print "different times throughout SquirrelMail. This is asking for the\n";
307 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
308 print "(../images/logo.jpg) path to your logo.\n";
310 print "[$WHT$org_logo$NRM]: $WHT";
311 $new_org_logo = <STDIN
>;
312 if ($new_org_logo eq "\n") {
313 $new_org_logo = $org_logo;
315 $new_org_logo =~ s/[\r|\n]//g;
317 return $new_org_logo;
322 print "A title is what is displayed at the top of the browser window in\n";
323 print "the titlebar. Usually this will end up looking something like:\n";
324 print "\"Netscape: $org_title\"\n";
326 print "[$WHT$org_title$NRM]: $WHT";
327 $new_org_title = <STDIN
>;
328 if ($new_org_title eq "\n") {
329 $new_org_title = $org_title;
331 $new_org_title =~ s/[\r|\n]//g;
333 return $new_org_title;
336 ####################################################################################
340 print "The domain name is the suffix at the end of all email messages. If\n";
341 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
342 print "would be myorg.com.\n";
344 print "[$WHT$domain$NRM]: $WHT";
345 $new_domain = <STDIN
>;
346 if ($new_domain eq "\n") {
347 $new_domain = $domain;
349 $new_domain =~ s/[\r|\n]//g;
356 print "This is the address where your IMAP server resides.\n";
357 print "[$WHT$imapServerAddress$NRM]: $WHT";
358 $new_imapServerAddress = <STDIN
>;
359 if ($new_imapServerAddress eq "\n") {
360 $new_imapServerAddress = $imapServerAddress;
362 $new_imapServerAddress =~ s/[\r|\n]//g;
364 return $new_imapServerAddress;
369 print "This is the port that your IMAP server is on. Usually this is 143.\n";
370 print "[$WHT$imapPort$NRM]: $WHT";
371 $new_imapPort = <STDIN
>;
372 if ($new_imapPort eq "\n") {
373 $new_imapPort = $imapPort;
375 $new_imapPort =~ s/[\r|\n]//g;
377 return $new_imapPort;
382 print "You now need to choose the method that you will use for sending\n";
383 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
384 print "or use sendmail directly.\n";
385 if ($useSendmail eq "true") {
386 $default_value = "y";
388 $default_value = "n";
391 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
392 $use_sendmail = <STDIN
>;
393 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
394 $useSendmail = "true";
396 $useSendmail = "false";
403 if ($sendmail_path[0] !~ /./) {
404 $sendmail_path = "/usr/sbin/sendmail";
406 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
407 print "[$WHT$sendmail_path$NRM]: $WHT";
408 $new_sendmail_path = <STDIN
>;
409 if ($new_sendmail_path eq "\n") {
410 $new_sendmail_path = $sendmail_path;
412 $new_sendmail_path =~ s/[\r|\n]//g;
414 return $new_sendmail_path;
419 print "This is the location of your SMTP server.\n";
420 print "[$WHT$smtpServerAddress$NRM]: $WHT";
421 $new_smtpServerAddress = <STDIN
>;
422 if ($new_smtpServerAddress eq "\n") {
423 $new_smtpServerAddress = $smtpServerAddress;
425 $new_smtpServerAddress =~ s/[\r|\n]//g;
427 return $new_smtpServerAddress;
432 print "This is the port to connect to for SMTP. Usually 25.\n";
433 print "[$WHT$smtpPort$NRM]: $WHT";
434 $new_smtpPort = <STDIN
>;
435 if ($new_smtpPort eq "\n") {
436 $new_smtpPort = $smtpPort;
438 $new_smtpPort =~ s/[\r|\n]//g;
440 return $new_smtpPort;
444 print "Eash IMAP server has its own quirks. As much as we tried to stick\n";
445 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
446 print "the same principles. We have made some work-arounds for some of\n";
447 print "these servers. If you would like to use them, please select your\n";
448 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
449 print "set this to \"other\", and none will be used.\n";
450 print " cyrus = Cyrus IMAP server\n";
451 print " uw = University of Washington's IMAP server\n";
452 print " exchange = Microsoft Exchange IMAP server\n";
453 print " courier = Courier IMAP server\n";
454 print "[$WHT$imap_server_type$NRM]: $WHT";
455 $new_imap_server_type = <STDIN
>;
456 if ($new_imap_server_type eq "\n") {
457 $new_imap_server_type = $imap_server_type;
459 $new_imap_server_type =~ s/[\r|\n]//g;
461 return $new_imap_server_type;
466 print "\nYou can now create the welcome message that is displayed\n";
467 print "every time a user logs on. You can use HTML or just plain\n";
468 print "text.\n\n(Type @ on a blank line to exit)\n";
474 $line =~ s/[\r|\n]//g;
476 $line =~ s/ /\ \ /g;
477 $line =~ s/\t/\ \ \ \ /g;
479 $line =~ s/\"/\\\"/g;
481 $new_motd = $new_motd . $line;
483 } while ($line ne "@");
487 ################# FOLDERS ###################
489 # default_folder_prefix
491 print "Some IMAP servers (UW, for example) store mail and folders in\n";
492 print "your user space in a separate subdirectory. This is where you\n";
493 print "specify what that directory is.\n";
495 print "EXAMPLE: mail/";
497 print "NOTE: If you use Cyrus, or some server that would not use this\n";
498 print " option, you must set this to 'none'.\n";
500 print "[$WHT$default_folder_prefix$NRM]: $WHT";
501 $new_default_folder_prefix = <STDIN
>;
502 if ($new_default_folder_prefix eq "\n") {
503 $new_default_folder_prefix = $default_folder_prefix;
505 $new_default_folder_prefix =~ s/[\r|\n]//g;
507 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
508 $new_default_folder_prefix = "";
510 $new_default_folder_prefix =~ s/\/*$//g
;
511 $new_default_folder_prefix =~ s/$/\//g
;
513 return $new_default_folder_prefix;
518 print "It is possible to set up the default folder prefix as a user\n";
519 print "specific option, where each user can specify what their mail\n";
520 print "folder is. If you set this to false, they will never see the\n";
521 print "option, but if it is true, this option will appear in the\n";
522 print "'options' section.\n";
524 print "NOTE: You set the default folder prefix in option '1' of this\n";
525 print " section. That will be the default if the user doesn't\n";
526 print " specify anything different.\n";
529 if ($show_prefix_option eq "true") {
530 $default_value = "y";
532 $default_value = "n";
535 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
537 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
538 $show_prefix_option = "true";
540 $show_prefix_option = "false";
542 return $show_prefix_option;
547 print "You can now specify where the default trash folder is located.\n";
548 print "On servers where you do not want this, you can set it to anything\n";
549 print "and set option 7 to false.\n";
551 print "This is relative to where the rest of your email is kept. You do\n";
552 print "not need to worry about their mail directory. If this folder\n";
553 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
554 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
557 print "[$WHT$trash_folder$NRM]: $WHT";
558 $new_trash_folder = <STDIN
>;
559 if ($new_trash_folder eq "\n") {
560 $new_trash_folder = $trash_folder;
562 $new_trash_folder =~ s/[\r|\n]//g;
564 return $new_trash_folder;
569 print "This is where messages that are sent will be stored. SquirrelMail\n";
570 print "by default puts a copy of all outgoing messages in this folder.\n";
572 print "This is relative to where the rest of your email is kept. You do\n";
573 print "not need to worry about their mail directory. If this folder\n";
574 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
575 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
578 print "[$WHT$sent_folder$NRM]: $WHT";
579 $new_sent_folder = <STDIN
>;
580 if ($new_sent_folder eq "\n") {
581 $new_sent_folder = $sent_folder;
583 $new_sent_folder =~ s/[\r|\n]//g;
585 return $new_sent_folder;
588 # default move to trash
590 print "By default, should messages get moved to the trash folder? You\n";
591 print "can specify the default trash folder in option 3. If this is set\n";
592 print "to false, messages will get deleted immediately without moving\n";
593 print "to the trash folder.\n";
595 print "Trash folder is currently: $trash_folder\n";
598 if ($default_move_to_trash eq "true") {
599 $default_value = "y";
601 $default_value = "n";
603 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
605 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
606 $default_move_to_trash = "true";
608 $default_move_to_trash = "false";
610 return $default_move_to_trash;
613 # default move to sent
615 print "By default, should messages get moved to the sent folder? You\n";
616 print "can specify the default sent folder in option 4. If this is set\n";
617 print "to false, messages will get deleted immediately without moving\n";
618 print "to the sent folder.\n";
620 print "Trash folder is currently: $sent_folder\n";
623 if ($default_move_to_sent eq "true") {
624 $default_value = "y";
626 $default_value = "n";
628 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
630 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
631 $default_move_to_sent = "true";
633 $default_move_to_sent = "false";
635 return $default_move_to_sent;
638 # List special folders first
640 print "SquirrelMail has what we call 'special folders' that are not\n";
641 print "manipulated and viewed like normal folders. Some examples of\n";
642 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
643 print "Simply asks if you want these folders listed first in the folder\n";
647 if ($list_special_folders_first eq "true") {
648 $default_value = "y";
650 $default_value = "n";
653 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
655 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
656 $list_special_folders_first = "true";
658 $list_special_folders_first = "false";
660 return $list_special_folders_first;
663 # Show special folders color
665 print "SquirrelMail has what we call 'special folders' that are not\n";
666 print "manipulated and viewed like normal folders. Some examples of\n";
667 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
668 print "wants to know if we should display special folders in a\n";
669 print "color than the other folders.\n";
672 if ($use_special_folder_color eq "true") {
673 $default_value = "y";
675 $default_value = "n";
678 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
680 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
681 $use_special_folder_color = "true";
683 $use_special_folder_color = "false";
685 return $use_special_folder_color;
690 print "The way that IMAP handles deleting messages is as follows. You\n";
691 print "mark the message as deleted, and then to 'really' delete it, you\n";
692 print "expunge it. This option asks if you want to just have messages\n";
693 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
694 print "messages too.\n";
697 if ($auto_expunge eq "true") {
698 $default_value = "y";
700 $default_value = "n";
702 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
704 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
705 $auto_expunge = "true";
707 $auto_expunge = "false";
709 return $auto_expunge;
712 # Default sub of inbox
714 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
715 print "This can cause some confusion in folder creation for users when\n";
716 print "they try to create folders and don't put it as a subfolder of INBOX\n";
717 print "and get permission errors. This option asks if you want folders\n";
718 print "to be subfolders of INBOX by default.\n";
721 if ($default_sub_of_inbox eq "true") {
722 $default_value = "y";
724 $default_value = "n";
726 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
728 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
729 $default_sub_of_inbox = "true";
731 $default_sub_of_inbox = "false";
733 return $default_sub_of_inbox;
736 # Show contain subfolder option
738 print "Some IMAP servers (UW) make it so that there are two types of\n";
739 print "folders. Those that contain messages, and those that contain\n";
740 print "subfolders. If this is the case for your server, set this to\n";
741 print "true, and it will ask the user whether the folder they are\n";
742 print "creating contains subfolders or messages.\n";
745 if ($show_contain_subfolders_option eq "true") {
746 $default_value = "y";
748 $default_value = "n";
750 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
752 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
753 $show_contain_subfolders_option = "true";
755 $show_contain_subfolders_option = "false";
757 return $show_contain_subfolders_option;
760 ############# GENERAL OPTIONS #####################
764 print "This option controls what character set is used when sending\n";
765 print "mail and when sending HTML to the browser. Do not set this\n";
766 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
767 print "to use KOI8-R, since this implementation is faster than most\n";
768 print "of the alternatives\n";
771 print "[$WHT$default_charset$NRM]: $WHT";
772 $new_default_charset = <STDIN
>;
773 if ($new_default_charset eq "\n") {
774 $new_default_charset = $default_charset;
776 $new_default_charset =~ s/[\r|\n]//g;
778 return $new_default_charset;
783 print "There are some places that we will automatically forward the user\n";
784 print "rather than display pointless messages like 'Message sent!' or\n";
785 print "stuff like that. Use this or not?\n";
787 print "NOTE: This is not working currently as we are trying to find a\n";
788 print " better way to handle this. This option really doesn't do\n";
792 if ($auto_forward eq "true") {
793 $default_value = "y";
795 $default_value = "n";
797 print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT";
799 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
800 $auto_forward = "true";
802 $auto_forward = "false";
804 return $auto_forward;
809 print "It is a possible security hole to have a writable directory\n";
810 print "under the web server's root directory (ex: /home/httpd/html).\n";
811 print "For this reason, it is possible to put the data directory\n";
812 print "anywhere you would like. The path name can be absolute or\n";
813 print "relative (to the config directory). It doesn't matter. Here\n";
814 print "are two examples:\n";
815 print " Absolute: /usr/local/squirrelmail/data/\n";
816 print " Relative: ../data/\n";
819 print "[$WHT$data_dir$NRM]: $WHT";
820 $new_data_dir = <STDIN
>;
821 if ($new_data_dir eq "\n") {
822 $new_data_dir = $data_dir;
824 $new_data_dir =~ s/[\r|\n]//g;
826 if ($new_data_dir =~ /^\s*$/) {
829 $new_data_dir =~ s/\/*$//g
;
830 $new_data_dir =~ s/$/\//g
;
832 return $new_data_dir;
835 # Attachment directory
837 print "Path to directory used for storing attachments while a mail is\n";
838 print "being sent. There are a few security considerations regarding this\n";
839 print "directory:\n";
840 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
841 print " impossible for a random person with access to the webserver\n";
842 print " to list files in this directory. Confidential data might\n";
843 print " be laying around in there.\n";
844 print " 2. Since the webserver is not able to list the files in the\n";
845 print " content is also impossible for the webserver to delete files\n";
846 print " lying around there for too long.\n";
847 print " 3. It should probably be another directory than the data\n";
848 print " directory specified in option 3.\n";
851 print "[$WHT$attachment_dir$NRM]: $WHT";
852 $new_attachment_dir = <STDIN
>;
853 if ($new_attachment_dir eq "\n") {
854 $new_attachment_dir = $attachment_dir;
856 $new_attachment_dir =~ s/[\r|\n]//g;
858 if ($new_attachment_dir =~ /^\s*$/) {
859 $new_attachment_dir = "";
861 $new_attachment_dir =~ s/\/*$//g
;
862 $new_attachment_dir =~ s/$/\//g
;
864 return $new_attachment_dir;
869 print "This is the default size (in pixels) of the left folder list.\n";
870 print "Default is 200, but you can set it to whatever you wish. This\n";
871 print "is a user preference, so this will only show up as their default.\n";
873 print "[$WHT$default_left_size$NRM]: $WHT";
874 $new_default_left_size = <STDIN
>;
875 if ($new_default_left_size eq "\n") {
876 $new_default_left_size = $default_left_size;
878 $new_default_left_size =~ s/[\r|\n]//g;
880 return $new_default_left_size;
885 print "\nNow we will define the themes that you wish to use. If you have added\n";
886 print "a theme of your own, just follow the instructions (?) about how to add\n";
887 print "them. You can also change the default theme.\n";
888 print "[theme] command (?=help) > ";
890 $input =~ s/[\r|\n]//g;
891 while ($input ne "d") {
892 if ($input =~ /^\s*l\s*/i) {
894 while ($count <= $#theme_name) {
895 if ($count == $theme_default) {
900 $name = $theme_name[$count];
901 $num_spaces = 25 - length($name);
902 for ($i = 0; $i < $num_spaces;$i++) {
906 print " $count. $name";
907 print "($theme_path[$count])\n";
911 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
912 $old_def = $theme_default;
913 $theme_default = $input;
914 $theme_default =~ s/^\s*m\s*//;
915 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
916 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
917 $theme_default = $old_def;
919 } elsif ($input =~ /^\s*\+/) {
920 print "What is the name of this theme: ";
922 $name =~ s/[\r|\n]//g;
923 $theme_name[$#theme_name+1] = $name;
924 print "Be sure to put ../config/ before the filename.\n";
925 print "What file is this stored in (ex: ../config/default_theme.php): ";
927 $name =~ s/[\r|\n]//g;
928 $theme_path[$#theme_path+1] = $name;
929 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
930 if ($input =~ /[0-9]+\s*$/) {
932 $rem_num =~ s/^\s*-\s*//g;
933 $rem_num =~ s/\s*$//;
935 $rem_num = $#theme_name;
937 if ($rem_num == $theme_default) {
938 print "You cannot remove the default theme!\n";
941 @new_theme_name = ();
942 @new_theme_path = ();
943 while ($count <= $#theme_name) {
944 if ($count != $rem_num) {
945 @new_theme_name = (@new_theme_name, $theme_name[$count]);
946 @new_theme_path = (@new_theme_path, $theme_path[$count]);
950 @theme_name = @new_theme_name;
951 @theme_path = @new_theme_path;
952 if ($theme_default > $rem_num) {
956 } elsif ($input =~ /^\s*\?\s*/) {
957 print ".-------------------------.\n";
958 print "| + (add theme) |\n";
959 print "| - N (remove theme) |\n";
960 print "| m N (mark default) |\n";
961 print "| l (list themes) |\n";
962 print "| d (done) |\n";
963 print "`-------------------------'\n";
965 print "[theme] command (?=help) > ";
967 $input =~ s/[\r|\n]//g;
973 print "You can now define different LDAP servers.\n";
974 print "[ldap] command (?=help) > ";
976 $input =~ s/[\r|\n]//g;
977 while ($input ne "d") {
978 if ($input =~ /^\s*l\s*/i) {
980 while ($count <= $#ldap_host) {
981 print "$count. $ldap_host[$count]\n";
982 print " base: $ldap_base[$count]\n";
983 if ($ldap_charset[$count]) {
984 print " charset: $ldap_charset[$count]\n";
986 if ($ldap_port[$count]) {
987 print " port: $ldap_port[$count]\n";
989 if ($ldap_name[$count]) {
990 print " name: $ldap_name[$count]\n";
992 if ($ldap_maxrows[$count]) {
993 print " maxrows: $ldap_maxrows[$count]\n";
998 } elsif ($input =~ /^\s*\+/) {
999 $sub = $#ldap_host + 1;
1001 print "First, we need to have the hostname or the IP address where\n";
1002 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1005 $name =~ s/[\r|\n]//g;
1006 $ldap_host[$sub] = $name;
1010 print "Next, we need the server root (base dn). For this, an empty\n";
1011 print "string is allowed.\n";
1012 print "Example: ou=member_directory,o=netcenter.com\n";
1015 $name =~ s/[\r|\n]//g;
1016 $ldap_base[$sub] = $name;
1020 print "This is the TCP/IP port number for the LDAP server. Default\n";
1021 print "port is 389. This is optional. Press ENTER for default.\n";
1024 $name =~ s/[\r|\n]//g;
1025 $ldap_port[$sub] = $name;
1029 print "This is the charset for the server. Default is utf-8. This\n";
1030 print "is also optional. Press ENTER for default.\n";
1033 $name =~ s/[\r|\n]//g;
1034 $ldap_charset[$sub] = $name;
1038 print "This is the name for the server, used to tag the results of\n";
1039 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1042 $name =~ s/[\r|\n]//g;
1043 $ldap_name[$sub] = $name;
1047 print "You can specify the maximum number of rows in the search result.\n";
1048 print "Default is unlimited. Press ENTER for default.\n";
1051 $name =~ s/[\r|\n]//g;
1052 $ldap_maxrows[$sub] = $name;
1056 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1057 if ($input =~ /[0-9]+\s*$/) {
1059 $rem_num =~ s/^\s*-\s*//g;
1060 $rem_num =~ s/\s*$//;
1062 $rem_num = $#ldap_host;
1065 @new_ldap_host = ();
1066 @new_ldap_base = ();
1067 @new_ldap_port = ();
1068 @new_ldap_name = ();
1069 @new_ldap_charset = ();
1070 @new_ldap_maxrows = ();
1071 while ($count <= $#ldap_host) {
1072 if ($count != $rem_num) {
1073 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1074 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1075 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1076 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1077 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1078 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1082 @ldap_host = @new_ldap_host;
1083 @ldap_base = @new_ldap_base;
1084 @ldap_port = @new_ldap_port;
1085 @ldap_name = @new_ldap_name;
1086 @ldap_charset = @new_ldap_charset;
1087 @ldap_maxrows = @new_ldap_maxrows;
1088 } elsif ($input =~ /^\s*\?\s*/) {
1089 print ".-------------------------.\n";
1090 print "| + (add host) |\n";
1091 print "| - N (remove host) |\n";
1092 print "| l (list hosts) |\n";
1093 print "| d (done) |\n";
1094 print "`-------------------------'\n";
1096 print "[ldap] command (?=help) > ";
1098 $input =~ s/[\r|\n]//g;
1103 print "Some of our developers have come up with very good javascript interface\n";
1104 print "for searching through address books, however, our original goals said\n";
1105 print "that we would be 100% HTML. In order to make it possible to use their\n";
1106 print "interface, and yet stick with our goals, we have also written a plain\n";
1107 print "HTML version of the search. Here, you can choose which version to use.\n";
1109 print "This is just the default value. It is also a user option that each\n";
1110 print "user can configure individually\n";
1113 if ($default_use_javascript_addr_book eq "true") {
1114 $default_value = "y";
1116 $default_use_javascript_addr_book = "false";
1117 $default_value = "n";
1119 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1120 $new_show = <STDIN
>;
1121 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1122 $default_use_javascript_addr_book = "true";
1124 $default_use_javascript_addr_book = "false";
1126 return $default_use_javascript_addr_book;
1131 open (FILE
, ">config.php");
1133 print FILE
"<?php\n\t/** SquirrelMail configuration\n";
1134 print FILE
"\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1136 print FILE
"\t\$org_name = \"$org_name\";\n";
1137 print FILE
"\t\$org_logo = \"$org_logo\";\n";
1138 print FILE
"\t\$org_title = \"$org_title\";\n";
1142 print FILE
"\t\$domain = \"$domain\";\n";
1143 print FILE
"\t\$imapServerAddress = \"$imapServerAddress\";\n";
1144 print FILE
"\t\$imapPort = $imapPort;\n";
1145 print FILE
"\t\$useSendmail = $useSendmail;\n";
1146 print FILE
"\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1147 print FILE
"\t\$smtpPort = $smtpPort;\n";
1148 print FILE
"\t\$sendmailPath = \"$sendmail_path\";\n";
1149 print FILE
"\t\$imap_server_type = \"$imap_server_type\";\n";
1153 print FILE
"\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1154 print FILE
"\t\$trash_folder = \"$trash_folder\";\n";
1155 print FILE
"\t\$sent_folder = \"$sent_folder\";\n";
1156 print FILE
"\t\$default_move_to_trash = $default_move_to_trash;\n";
1157 print FILE
"\t\$default_move_to_sent = $default_move_to_sent;\n";
1158 print FILE
"\t\$show_prefix_option = $show_prefix_option;\n";
1159 print FILE
"\t\$list_special_folders_first = $list_special_folders_first;\n";
1160 print FILE
"\t\$use_special_folder_color = $use_special_folder_color;\n";
1161 print FILE
"\t\$auto_expunge = $auto_expunge;\n";
1162 print FILE
"\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1163 print FILE
"\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1166 print FILE
"\t\$default_charset = \"$default_charset\";\n";
1167 print FILE
"\t\$auto_forward = $auto_forward;\n";
1168 print FILE
"\t\$data_dir = \"$data_dir\";\n";
1169 print FILE
"\t\$attachment_dir = \"$attachment_dir\";\n";
1170 print FILE
"\t\$default_left_size = $default_left_size;\n";
1174 for ($count=0; $count <= $#theme_name; $count++) {
1175 print FILE
"\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1176 print FILE
"\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1181 if ($default_use_javascript_addr_book ne "true") {
1182 $default_use_javascript_addr_book = "false";
1184 print FILE
"\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1185 for ($count=0; $count <= $#ldap_host; $count++) {
1186 print FILE
"\t\$ldap_server[$count] = Array(\n";
1187 print FILE
"\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1188 print FILE
"\t\t\t\"base\" => \"$ldap_base[$count]\"";
1189 if ($ldap_name[$count]) {
1190 print FILE
",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1192 if ($ldap_port[$count]) {
1193 print FILE
",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1195 if ($ldap_charset[$count]) {
1196 print FILE
",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1198 if ($ldap_maxrows[$count]) {
1199 print FILE
",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1201 print FILE
");\n\n";
1205 print FILE
"\t\$motd = \"$motd\";\n";
1213 print "While we have been building SquirrelMail, we have discovered some\n";
1214 print "preferences that work better with some servers that don't work so\n";
1215 print "well with others. If you select your IMAP server, this option will\n";
1216 print "set some pre-defined settings for that server.\n";
1218 print "Please note that you will still need to go through and make sure\n";
1219 print "everything is correct. This does not change everything. There are\n";
1220 print "only a few settings that this will change.\n";
1224 while ($continue != 1) {
1225 print "Please select your IMAP server:\n";
1226 print " cyrus = Cyrus IMAP server\n";
1227 print " uw = University of Washington's IMAP server\n";
1228 print " exchange = Microsoft Exchange IMAP server\n";
1229 print " courier = Courier IMAP server\n";
1230 print " quit = Do not change anything\n";
1231 print "Command >> ";
1233 $server =~ s/[\r|\n]//g;
1236 if ($server eq "cyrus") {
1237 $default_folder_prefix = "INBOX";
1238 $trash_folder = "INBOX.Trash";
1239 $sent_folder = "INBOX.Sent";
1240 $show_prefix_option = false
;
1241 $default_sub_of_inbox = true
;
1242 $show_contain_subfolders_option = false
;
1243 $imap_server_type = "cyrus";
1245 print " default_folder_prefix = INBOX\n";
1246 print " trash_folder = INBOX.Trash\n";
1247 print " sent_folder = INBOX.Sent\n";
1248 print " show_prefix_option = false\n";
1249 print " default_sub_of_inbox = true\n";
1250 print "show_contain_subfolders_option = false\n";
1251 print " imap_server_type = cyrus\n";
1254 } elsif ($server eq "uw") {
1255 $default_folder_prefix = "mail/";
1256 $trash_folder = "Trash";
1257 $sent_folder = "Sent";
1258 $show_prefix_option = true
;
1259 $default_sub_of_inbox = false
;
1260 $show_contain_subfolders_option = true
;
1261 $imap_server_type = "uw";
1263 print " default_folder_prefix = mail/\n";
1264 print " trash_folder = Trash\n";
1265 print " sent_folder = Sent\n";
1266 print " show_prefix_option = true\n";
1267 print " default_sub_of_inbox = false\n";
1268 print "show_contain_subfolders_option = true\n";
1269 print " imap_server_type = uw\n";
1272 } elsif ($server eq "exchange") {
1273 $default_folder_prefix = "INBOX/";
1274 $default_sub_of_inbox = true
;
1275 $trash_folder = "INBOX/Deleted Items";
1276 $sent_folder = "INBOX/Sent Items";
1277 $show_prefix_option = false
;
1278 $show_contain_subfolders_option = false
;
1280 $imap_server_type = "exchange";
1283 } elsif ($server eq "courier") {
1284 $imap_server_type = "courier";
1287 } elsif ($server eq "quit") {
1290 print "Unrecognized server: $server\n";
1294 print "\nPress any key to continue...";