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/\";\s*$//;
39 $options[1] =~ s/;$//;
40 $options[1] =~ s/^"//;
42 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
44 $sub =~ s/\]\["PATH"\]//;
46 $theme_path[$sub] = $options[1];
47 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
49 $sub =~ s/\]\["NAME"\]//;
51 $theme_name[$sub] = $options[1];
52 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
55 $sub =~ s/^plugins\[//;
56 $plugins[$sub] = $options[1];
57 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
60 $sub =~ s/^ldap_server\[//;
62 while (($tmp = <FILE
>) && ($continue != 1)) {
63 if ($tmp =~ /\);\s*$/) {
67 if ($tmp =~ /^\s*"host"/i) {
68 $tmp =~ s/^\s*"host"\s*=>\s*"//i;
72 } elsif ($tmp =~ /^\s*"base"/i) {
73 $tmp =~ s/^\s*"base"\s*=>\s*"//i;
77 } elsif ($tmp =~ /^\s*"charset"/i) {
78 $tmp =~ s/^\s*"charset"\s*=>\s*"//i;
82 } elsif ($tmp =~ /^\s*"port"/i) {
83 $tmp =~ s/^\s*"port"\s*=>\s*"//i;
87 } elsif ($tmp =~ /^\s*"maxrows"/i) {
88 $tmp =~ s/^\s*"maxrows"\s*=>\s*"//i;
92 } elsif ($tmp =~ /^\s*"name"/i) {
93 $tmp =~ s/^\s*"name"\s*=>\s*"//i;
99 $ldap_host[$sub] = $host;
100 $ldap_base[$sub] = $base;
101 $ldap_name[$sub] = $name;
102 $ldap_port[$sub] = $port;
103 $ldap_maxrows[$sub] = $maxrows;
104 $ldap_charset[$sub] = $charset;
106 ${$options[0]} = $options[1];
111 if ($useSendmail ne "true") {
112 $useSendmail = "false";
114 if (!$sendmail_path) {
115 $sendmail_path = "/usr/sbin/sendmail";
117 if (!$default_unseen_notify) {
118 $default_unseen_notify = 2;
120 if (!$default_unseen_type) {
121 $default_unseen_type = 1;
124 #####################################################################################
126 while (($command ne "q") && ($command ne "Q")) {
129 print $WHT."SquirrelMail Configuration : ".$NRM;
130 if ($config == 1) { print "Read: config.php"; }
131 elsif ($config == 2) { print "Read: config_default.php"; }
134 print $WHT."Main Menu --\n".$NRM;
135 print "1. Organization Preferences\n";
136 print "2. Server Settings\n";
137 print "3. Folder Defaults\n";
138 print "4. General Options\n";
140 print "6. Address Books (LDAP)\n";
141 print "7. Message of the Day (MOTD)\n";
142 print "8. Plugins\n";
144 print "D. Set pre-defined settings for specific IMAP servers\n";
146 } elsif ($menu == 1) {
147 print $WHT."Organization Preferences\n".$NRM;
148 print "1. Organization Name : $WHT$org_name$NRM\n";
149 print "2. Organization Logo : $WHT$org_logo$NRM\n";
150 print "3. Organization Title : $WHT$org_title$NRM\n";
152 print "R Return to Main Menu\n";
153 } elsif ($menu == 2) {
154 print $WHT."Server Settings\n".$NRM;
155 print "1. Domain : $WHT$domain$NRM\n";
156 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
157 print "3. IMAP Port : $WHT$imapPort$NRM\n";
158 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
159 if ($useSendmail eq "true") {
160 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
162 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
163 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
165 print "8. Server : $WHT$imap_server_type$NRM\n";
167 print "R Return to Main Menu\n";
168 } elsif ($menu == 3) {
169 print $WHT."Folder Defaults\n".$NRM;
170 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
171 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
172 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
173 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
174 print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
175 print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
176 print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
177 print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
178 print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
179 print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
180 print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
181 print "12. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
182 print "13. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
184 print "R Return to Main Menu\n";
185 } elsif ($menu == 4) {
186 print $WHT."General Options\n".$NRM;
187 print "1. Default Charset : $WHT$default_charset$NRM\n";
188 print "2. Data Directory : $WHT$data_dir$NRM\n";
189 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
190 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
192 print "R Return to Main Menu\n";
193 } elsif ($menu == 5) {
194 print $WHT."Themes\n".$NRM;
195 print "1. Change Themes\n";
196 for ($count = 0; $count <= $#theme_name; $count++) {
197 print " > $theme_name[$count]\n";
200 print "R Return to Main Menu\n";
201 } elsif ($menu == 6) {
202 print $WHT."Address Books (LDAP)\n".$NRM;
203 print "1. Change Servers\n";
204 for ($count = 0; $count <= $#ldap_host; $count++) {
205 print " > $ldap_host[$count]\n";
207 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
209 print "R Return to Main Menu\n";
210 } elsif ($menu == 7) {
211 print $WHT."Message of the Day (MOTD)\n".$NRM;
214 print "1 Edit the MOTD\n";
216 print "R Return to Main Menu\n";
217 } elsif ($menu == 8) {
218 print $WHT."Plugins\n".$NRM;
219 print "1 Change Plugins\n";
220 for ($count = 0; $count <= $#plugins; $count++) {
221 print " > $plugins[$count]\n";
224 print "R Return to Main Menu\n";
226 print "S Save data\n";
230 print "Command >> ".$WHT;
232 $command =~ s/[\n|\r]//g;
235 # Read the commands they entered.
236 if (($command eq "R") || ($command eq "r")) {
238 } elsif (($command eq "s") || ($command eq "S")) {
240 print "Data saved in config.php\n";
241 print "Press any key to continue...";
244 } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
245 print "You have not saved your data.\n";
246 print "Save? (y/n) [".$WHT."y".$NRM."]: ";
248 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
251 } elsif (($command eq "d") || ($command eq "D")) {
256 if (($command > 0) && ($command < 9)) {
259 } elsif ($menu == 1) {
260 if ($command == 1) { $org_name = command1
(); }
261 elsif ($command == 2) { $org_logo = command2
(); }
262 elsif ($command == 3) { $org_title = command3
(); }
263 } elsif ($menu == 2) {
264 if ($command == 1) { $domain = command11
(); }
265 elsif ($command == 2) { $imapServerAddress = command12
(); }
266 elsif ($command == 3) { $imapPort = command13
(); }
267 elsif ($command == 4) { $useSendmail = command14
(); }
268 elsif ($command == 5) { $sendmail_path = command15
(); }
269 elsif ($command == 6) { $smtpServerAddress = command16
(); }
270 elsif ($command == 7) { $smtpPort = command17
(); }
271 elsif ($command == 8) { $imap_server_type = command18
(); }
272 } elsif ($menu == 3) {
273 if ($command == 1) { $default_folder_prefix = command21
(); }
274 elsif ($command == 2) { $show_prefix_option = command22
(); }
275 elsif ($command == 3) { $trash_folder = command23
(); }
276 elsif ($command == 4) { $sent_folder = command24
(); }
277 elsif ($command == 5) { $default_move_to_trash = command25
(); }
278 elsif ($command == 6) { $default_move_to_sent = command26
(); }
279 elsif ($command == 7) { $list_special_folders_first = command27
(); }
280 elsif ($command == 8) { $use_special_folder_color = command28
(); }
281 elsif ($command == 9) { $auto_expunge = command29
(); }
282 elsif ($command == 10){ $default_sub_of_inbox = command210
(); }
283 elsif ($command == 11){ $show_contain_subfolders_option = command211
(); }
284 elsif ($command == 12){ $default_unseen_notify = command212
(); }
285 elsif ($command == 13){ $default_unseen_type = command213
(); }
286 } elsif ($menu == 4) {
287 if ($command == 1) { $default_charset = command31
(); }
288 elsif ($command == 2) { $data_dir = command33
(); }
289 elsif ($command == 3) { $attachment_dir = command34
(); }
290 elsif ($command == 4) { $default_left_size = command35
(); }
291 } elsif ($menu == 5) {
295 } elsif ($menu == 6) {
296 if ($command == 1) { command61
(); }
297 elsif ($command == 2) { command62
(); }
298 } elsif ($menu == 7) {
299 if ($command == 1) { $motd = command71
(); }
300 } elsif ($menu == 8) {
301 if ($command == 1) { $motd = command81
(); }
306 ####################################################################################
310 print "We have tried to make the name SquirrelMail as transparent as\n";
311 print "possible. If you set up an organization name, most places where\n";
312 print "SquirrelMail would take credit will be credited to your organization.\n";
314 print "[$WHT$org_name$NRM]: $WHT";
315 $new_org_name = <STDIN
>;
316 if ($new_org_name eq "\n") {
317 $new_org_name = $org_name;
319 $new_org_name =~ s/[\r|\n]//g;
321 return $new_org_name;
327 print "Your organization's logo is an image that will be displayed at\n";
328 print "different times throughout SquirrelMail. This is asking for the\n";
329 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
330 print "(../images/logo.jpg) path to your logo.\n";
332 print "[$WHT$org_logo$NRM]: $WHT";
333 $new_org_logo = <STDIN
>;
334 if ($new_org_logo eq "\n") {
335 $new_org_logo = $org_logo;
337 $new_org_logo =~ s/[\r|\n]//g;
339 return $new_org_logo;
344 print "A title is what is displayed at the top of the browser window in\n";
345 print "the titlebar. Usually this will end up looking something like:\n";
346 print "\"Netscape: $org_title\"\n";
348 print "[$WHT$org_title$NRM]: $WHT";
349 $new_org_title = <STDIN
>;
350 if ($new_org_title eq "\n") {
351 $new_org_title = $org_title;
353 $new_org_title =~ s/[\r|\n]//g;
355 return $new_org_title;
358 ####################################################################################
362 print "The domain name is the suffix at the end of all email messages. If\n";
363 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
364 print "would be myorg.com.\n";
366 print "[$WHT$domain$NRM]: $WHT";
367 $new_domain = <STDIN
>;
368 if ($new_domain eq "\n") {
369 $new_domain = $domain;
371 $new_domain =~ s/[\r|\n]//g;
378 print "This is the address where your IMAP server resides.\n";
379 print "[$WHT$imapServerAddress$NRM]: $WHT";
380 $new_imapServerAddress = <STDIN
>;
381 if ($new_imapServerAddress eq "\n") {
382 $new_imapServerAddress = $imapServerAddress;
384 $new_imapServerAddress =~ s/[\r|\n]//g;
386 return $new_imapServerAddress;
391 print "This is the port that your IMAP server is on. Usually this is 143.\n";
392 print "[$WHT$imapPort$NRM]: $WHT";
393 $new_imapPort = <STDIN
>;
394 if ($new_imapPort eq "\n") {
395 $new_imapPort = $imapPort;
397 $new_imapPort =~ s/[\r|\n]//g;
399 return $new_imapPort;
404 print "You now need to choose the method that you will use for sending\n";
405 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
406 print "or use sendmail directly.\n";
407 if ($useSendmail eq "true") {
408 $default_value = "y";
410 $default_value = "n";
413 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
414 $use_sendmail = <STDIN
>;
415 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
416 $useSendmail = "true";
418 $useSendmail = "false";
425 if ($sendmail_path[0] !~ /./) {
426 $sendmail_path = "/usr/sbin/sendmail";
428 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
429 print "[$WHT$sendmail_path$NRM]: $WHT";
430 $new_sendmail_path = <STDIN
>;
431 if ($new_sendmail_path eq "\n") {
432 $new_sendmail_path = $sendmail_path;
434 $new_sendmail_path =~ s/[\r|\n]//g;
436 return $new_sendmail_path;
441 print "This is the location of your SMTP server.\n";
442 print "[$WHT$smtpServerAddress$NRM]: $WHT";
443 $new_smtpServerAddress = <STDIN
>;
444 if ($new_smtpServerAddress eq "\n") {
445 $new_smtpServerAddress = $smtpServerAddress;
447 $new_smtpServerAddress =~ s/[\r|\n]//g;
449 return $new_smtpServerAddress;
454 print "This is the port to connect to for SMTP. Usually 25.\n";
455 print "[$WHT$smtpPort$NRM]: $WHT";
456 $new_smtpPort = <STDIN
>;
457 if ($new_smtpPort eq "\n") {
458 $new_smtpPort = $smtpPort;
460 $new_smtpPort =~ s/[\r|\n]//g;
462 return $new_smtpPort;
466 print "Eash IMAP server has its own quirks. As much as we tried to stick\n";
467 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
468 print "the same principles. We have made some work-arounds for some of\n";
469 print "these servers. If you would like to use them, please select your\n";
470 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
471 print "set this to \"other\", and none will be used.\n";
472 print " cyrus = Cyrus IMAP server\n";
473 print " uw = University of Washington's IMAP server\n";
474 print " exchange = Microsoft Exchange IMAP server\n";
475 print " courier = Courier IMAP server\n";
476 print "[$WHT$imap_server_type$NRM]: $WHT";
477 $new_imap_server_type = <STDIN
>;
478 if ($new_imap_server_type eq "\n") {
479 $new_imap_server_type = $imap_server_type;
481 $new_imap_server_type =~ s/[\r|\n]//g;
483 return $new_imap_server_type;
488 print "\nYou can now create the welcome message that is displayed\n";
489 print "every time a user logs on. You can use HTML or just plain\n";
490 print "text.\n\n(Type @ on a blank line to exit)\n";
496 $line =~ s/[\r|\n]//g;
498 $line =~ s/ /\ \ /g;
499 $line =~ s/\t/\ \ \ \ /g;
501 $line =~ s/\"/\\\"/g;
503 $new_motd = $new_motd . $line;
505 } while ($line ne "@");
509 ################# PLUGINS ###################
512 print "\nThis is where you can define plugins. The plugin must already exist in the\n";
513 print "plugins/ directory in order to add them here. A plugin name is the name of the\n";
514 print "directory that it resides in. For example, if you have a plugin in the directory\n";
515 print "plugins/myplug, the name is \"myplug\".\n\n";
516 print "[plugins] command (?=help) > ";
518 $input =~ s/[\r|\n]//g;
519 while ($input ne "d") {
520 if ($input =~ /^\s*l\s*/i) {
522 while ($count <= $#plugins) {
523 print " $count. $plugins[$count]\n";
527 } elsif ($input =~ /^\s*\+/) {
528 print "What is the name of this plugin: ";
530 $name =~ s/[\r|\n]//g;
532 if (-e
"../plugins/$name") {
534 for ($m=0; $m <= $#plugins; $m++) {
535 if ($plugins[$m] eq $name) {
540 print "\nThat plugin already exists in the list!\n";
542 $plugins[$#plugins+1] = $name;
546 print "\nThat plugin does not exist in the plugins/ directory!\n\n";
548 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
549 if ($input =~ /[0-9]+\s*$/) {
551 $rem_num =~ s/^\s*-\s*//g;
552 $rem_num =~ s/\s*$//;
554 $rem_num = $#plugins;
559 while ($count <= $#plugins) {
560 if ($count != $rem_num) {
561 @new_plugins = (@new_plugins, $plugins[$count]);
565 @plugins = @new_plugins;
566 } elsif ($input =~ /^\s*\?\s*/) {
567 print ".-------------------------.\n";
568 print "| + (add plugin) |\n";
569 print "| - N (remove plugin) |\n";
570 print "| l (list plugins) |\n";
571 print "| d (done) |\n";
572 print "`-------------------------'\n";
574 print "[plugins] command (?=help) > ";
576 $input =~ s/[\r|\n]//g;
580 ################# FOLDERS ###################
582 # default_folder_prefix
584 print "Some IMAP servers (UW, for example) store mail and folders in\n";
585 print "your user space in a separate subdirectory. This is where you\n";
586 print "specify what that directory is.\n";
588 print "EXAMPLE: mail/";
590 print "NOTE: If you use Cyrus, or some server that would not use this\n";
591 print " option, you must set this to 'none'.\n";
593 print "[$WHT$default_folder_prefix$NRM]: $WHT";
594 $new_default_folder_prefix = <STDIN
>;
595 if ($new_default_folder_prefix eq "\n") {
596 $new_default_folder_prefix = $default_folder_prefix;
598 $new_default_folder_prefix =~ s/[\r|\n]//g;
600 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
601 $new_default_folder_prefix = "";
603 $new_default_folder_prefix =~ s/\/*$//g
;
604 $new_default_folder_prefix =~ s/$/\//g
;
606 return $new_default_folder_prefix;
611 print "It is possible to set up the default folder prefix as a user\n";
612 print "specific option, where each user can specify what their mail\n";
613 print "folder is. If you set this to false, they will never see the\n";
614 print "option, but if it is true, this option will appear in the\n";
615 print "'options' section.\n";
617 print "NOTE: You set the default folder prefix in option '1' of this\n";
618 print " section. That will be the default if the user doesn't\n";
619 print " specify anything different.\n";
622 if ($show_prefix_option eq "true") {
623 $default_value = "y";
625 $default_value = "n";
628 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
630 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
631 $show_prefix_option = "true";
633 $show_prefix_option = "false";
635 return $show_prefix_option;
640 print "You can now specify where the default trash folder is located.\n";
641 print "On servers where you do not want this, you can set it to anything\n";
642 print "and set option 7 to false.\n";
644 print "This is relative to where the rest of your email is kept. You do\n";
645 print "not need to worry about their mail directory. If this folder\n";
646 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
647 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
650 print "[$WHT$trash_folder$NRM]: $WHT";
651 $new_trash_folder = <STDIN
>;
652 if ($new_trash_folder eq "\n") {
653 $new_trash_folder = $trash_folder;
655 $new_trash_folder =~ s/[\r|\n]//g;
657 return $new_trash_folder;
662 print "This is where messages that are sent will be stored. SquirrelMail\n";
663 print "by default puts a copy of all outgoing messages in this folder.\n";
665 print "This is relative to where the rest of your email is kept. You do\n";
666 print "not need to worry about their mail directory. If this folder\n";
667 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
668 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
671 print "[$WHT$sent_folder$NRM]: $WHT";
672 $new_sent_folder = <STDIN
>;
673 if ($new_sent_folder eq "\n") {
674 $new_sent_folder = $sent_folder;
676 $new_sent_folder =~ s/[\r|\n]//g;
678 return $new_sent_folder;
681 # default move to trash
683 print "By default, should messages get moved to the trash folder? You\n";
684 print "can specify the default trash folder in option 3. If this is set\n";
685 print "to false, messages will get deleted immediately without moving\n";
686 print "to the trash folder.\n";
688 print "Trash folder is currently: $trash_folder\n";
691 if ($default_move_to_trash eq "true") {
692 $default_value = "y";
694 $default_value = "n";
696 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
698 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
699 $default_move_to_trash = "true";
701 $default_move_to_trash = "false";
703 return $default_move_to_trash;
706 # default move to sent
708 print "By default, should messages get moved to the sent folder? You\n";
709 print "can specify the default sent folder in option 4. If this is set\n";
710 print "to false, messages will get sent an no copy will be made.\n";
712 print "Trash folder is currently: $sent_folder\n";
715 if ($default_move_to_sent eq "true") {
716 $default_value = "y";
718 $default_value = "n";
720 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
722 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
723 $default_move_to_sent = "true";
725 $default_move_to_sent = "false";
727 return $default_move_to_sent;
730 # List special folders first
732 print "SquirrelMail has what we call 'special folders' that are not\n";
733 print "manipulated and viewed like normal folders. Some examples of\n";
734 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
735 print "Simply asks if you want these folders listed first in the folder\n";
739 if ($list_special_folders_first eq "true") {
740 $default_value = "y";
742 $default_value = "n";
745 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
747 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
748 $list_special_folders_first = "true";
750 $list_special_folders_first = "false";
752 return $list_special_folders_first;
755 # Show special folders color
757 print "SquirrelMail has what we call 'special folders' that are not\n";
758 print "manipulated and viewed like normal folders. Some examples of\n";
759 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
760 print "wants to know if we should display special folders in a\n";
761 print "color than the other folders.\n";
764 if ($use_special_folder_color eq "true") {
765 $default_value = "y";
767 $default_value = "n";
770 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
772 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
773 $use_special_folder_color = "true";
775 $use_special_folder_color = "false";
777 return $use_special_folder_color;
782 print "The way that IMAP handles deleting messages is as follows. You\n";
783 print "mark the message as deleted, and then to 'really' delete it, you\n";
784 print "expunge it. This option asks if you want to just have messages\n";
785 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
786 print "messages too.\n";
789 if ($auto_expunge eq "true") {
790 $default_value = "y";
792 $default_value = "n";
794 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
796 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
797 $auto_expunge = "true";
799 $auto_expunge = "false";
801 return $auto_expunge;
804 # Default sub of inbox
806 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
807 print "This can cause some confusion in folder creation for users when\n";
808 print "they try to create folders and don't put it as a subfolder of INBOX\n";
809 print "and get permission errors. This option asks if you want folders\n";
810 print "to be subfolders of INBOX by default.\n";
813 if ($default_sub_of_inbox eq "true") {
814 $default_value = "y";
816 $default_value = "n";
818 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
820 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
821 $default_sub_of_inbox = "true";
823 $default_sub_of_inbox = "false";
825 return $default_sub_of_inbox;
828 # Show contain subfolder option
830 print "Some IMAP servers (UW) make it so that there are two types of\n";
831 print "folders. Those that contain messages, and those that contain\n";
832 print "subfolders. If this is the case for your server, set this to\n";
833 print "true, and it will ask the user whether the folder they are\n";
834 print "creating contains subfolders or messages.\n";
837 if ($show_contain_subfolders_option eq "true") {
838 $default_value = "y";
840 $default_value = "n";
842 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
844 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
845 $show_contain_subfolders_option = "true";
847 $show_contain_subfolders_option = "false";
849 return $show_contain_subfolders_option;
852 # Default Unseen Notify
854 print "This option specifies where the users will receive notification\n";
855 print "about unseen messages by default. This is of course an option that\n";
856 print "can be changed on a user level.\n";
857 print " 1 = No notification\n";
858 print " 2 = Only on the INBOX\n";
859 print " 3 = On all folders\n";
862 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
864 if ($new_show =~ /^[1|2|3]\n/i) {
865 $default_unseen_notify = $new_show;
867 $default_unseen_notify =~ s/[\r|\n]//g;
868 return $default_unseen_notify;
871 # Default Unseen Type
873 print "Here you can define the default way that unseen messages will be displayed\n";
874 print "to the user in the folder listing on the left side.\n";
875 print " 1 = Only unseen messages (4)\n";
876 print " 2 = Unseen and Total messages (4/27)\n";
879 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
881 if ($new_show =~ /^[1|2]\n/i) {
882 $default_unseen_type = $new_show;
884 $default_unseen_type =~ s/[\r|\n]//g;
885 return $default_unseen_type;
889 ############# GENERAL OPTIONS #####################
893 print "This option controls what character set is used when sending\n";
894 print "mail and when sending HTML to the browser. Do not set this\n";
895 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
896 print "to use KOI8-R, since this implementation is faster than most\n";
897 print "of the alternatives\n";
900 print "[$WHT$default_charset$NRM]: $WHT";
901 $new_default_charset = <STDIN
>;
902 if ($new_default_charset eq "\n") {
903 $new_default_charset = $default_charset;
905 $new_default_charset =~ s/[\r|\n]//g;
907 return $new_default_charset;
912 print "It is a possible security hole to have a writable directory\n";
913 print "under the web server's root directory (ex: /home/httpd/html).\n";
914 print "For this reason, it is possible to put the data directory\n";
915 print "anywhere you would like. The path name can be absolute or\n";
916 print "relative (to the config directory). It doesn't matter. Here\n";
917 print "are two examples:\n";
918 print " Absolute: /usr/local/squirrelmail/data/\n";
919 print " Relative: ../data/\n";
922 print "[$WHT$data_dir$NRM]: $WHT";
923 $new_data_dir = <STDIN
>;
924 if ($new_data_dir eq "\n") {
925 $new_data_dir = $data_dir;
927 $new_data_dir =~ s/[\r|\n]//g;
929 if ($new_data_dir =~ /^\s*$/) {
932 $new_data_dir =~ s/\/*$//g
;
933 $new_data_dir =~ s/$/\//g
;
935 return $new_data_dir;
938 # Attachment directory
940 print "Path to directory used for storing attachments while a mail is\n";
941 print "being sent. There are a few security considerations regarding this\n";
942 print "directory:\n";
943 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
944 print " impossible for a random person with access to the webserver\n";
945 print " to list files in this directory. Confidential data might\n";
946 print " be laying around in there.\n";
947 print " 2. Since the webserver is not able to list the files in the\n";
948 print " content is also impossible for the webserver to delete files\n";
949 print " lying around there for too long.\n";
950 print " 3. It should probably be another directory than the data\n";
951 print " directory specified in option 3.\n";
954 print "[$WHT$attachment_dir$NRM]: $WHT";
955 $new_attachment_dir = <STDIN
>;
956 if ($new_attachment_dir eq "\n") {
957 $new_attachment_dir = $attachment_dir;
959 $new_attachment_dir =~ s/[\r|\n]//g;
961 if ($new_attachment_dir =~ /^\s*$/) {
962 $new_attachment_dir = "";
964 $new_attachment_dir =~ s/\/*$//g
;
965 $new_attachment_dir =~ s/$/\//g
;
967 return $new_attachment_dir;
972 print "This is the default size (in pixels) of the left folder list.\n";
973 print "Default is 200, but you can set it to whatever you wish. This\n";
974 print "is a user preference, so this will only show up as their default.\n";
976 print "[$WHT$default_left_size$NRM]: $WHT";
977 $new_default_left_size = <STDIN
>;
978 if ($new_default_left_size eq "\n") {
979 $new_default_left_size = $default_left_size;
981 $new_default_left_size =~ s/[\r|\n]//g;
983 return $new_default_left_size;
988 print "\nNow we will define the themes that you wish to use. If you have added\n";
989 print "a theme of your own, just follow the instructions (?) about how to add\n";
990 print "them. You can also change the default theme.\n";
991 print "[theme] command (?=help) > ";
993 $input =~ s/[\r|\n]//g;
994 while ($input ne "d") {
995 if ($input =~ /^\s*l\s*/i) {
997 while ($count <= $#theme_name) {
998 if ($count == $theme_default) {
1003 $name = $theme_name[$count];
1004 $num_spaces = 25 - length($name);
1005 for ($i = 0; $i < $num_spaces;$i++) {
1006 $name = $name . " ";
1009 print " $count. $name";
1010 print "($theme_path[$count])\n";
1014 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1015 $old_def = $theme_default;
1016 $theme_default = $input;
1017 $theme_default =~ s/^\s*m\s*//;
1018 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1019 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1020 $theme_default = $old_def;
1022 } elsif ($input =~ /^\s*\+/) {
1023 print "What is the name of this theme: ";
1025 $name =~ s/[\r|\n]//g;
1026 $theme_name[$#theme_name+1] = $name;
1027 print "Be sure to put ../config/ before the filename.\n";
1028 print "What file is this stored in (ex: ../config/default_theme.php): ";
1030 $name =~ s/[\r|\n]//g;
1031 $theme_path[$#theme_path+1] = $name;
1032 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1033 if ($input =~ /[0-9]+\s*$/) {
1035 $rem_num =~ s/^\s*-\s*//g;
1036 $rem_num =~ s/\s*$//;
1038 $rem_num = $#theme_name;
1040 if ($rem_num == $theme_default) {
1041 print "You cannot remove the default theme!\n";
1044 @new_theme_name = ();
1045 @new_theme_path = ();
1046 while ($count <= $#theme_name) {
1047 if ($count != $rem_num) {
1048 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1049 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1053 @theme_name = @new_theme_name;
1054 @theme_path = @new_theme_path;
1055 if ($theme_default > $rem_num) {
1059 } elsif ($input =~ /^\s*\?\s*/) {
1060 print ".-------------------------.\n";
1061 print "| + (add theme) |\n";
1062 print "| - N (remove theme) |\n";
1063 print "| m N (mark default) |\n";
1064 print "| l (list themes) |\n";
1065 print "| d (done) |\n";
1066 print "`-------------------------'\n";
1068 print "[theme] command (?=help) > ";
1070 $input =~ s/[\r|\n]//g;
1076 print "You can now define different LDAP servers.\n";
1077 print "[ldap] command (?=help) > ";
1079 $input =~ s/[\r|\n]//g;
1080 while ($input ne "d") {
1081 if ($input =~ /^\s*l\s*/i) {
1083 while ($count <= $#ldap_host) {
1084 print "$count. $ldap_host[$count]\n";
1085 print " base: $ldap_base[$count]\n";
1086 if ($ldap_charset[$count]) {
1087 print " charset: $ldap_charset[$count]\n";
1089 if ($ldap_port[$count]) {
1090 print " port: $ldap_port[$count]\n";
1092 if ($ldap_name[$count]) {
1093 print " name: $ldap_name[$count]\n";
1095 if ($ldap_maxrows[$count]) {
1096 print " maxrows: $ldap_maxrows[$count]\n";
1101 } elsif ($input =~ /^\s*\+/) {
1102 $sub = $#ldap_host + 1;
1104 print "First, we need to have the hostname or the IP address where\n";
1105 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1108 $name =~ s/[\r|\n]//g;
1109 $ldap_host[$sub] = $name;
1113 print "Next, we need the server root (base dn). For this, an empty\n";
1114 print "string is allowed.\n";
1115 print "Example: ou=member_directory,o=netcenter.com\n";
1118 $name =~ s/[\r|\n]//g;
1119 $ldap_base[$sub] = $name;
1123 print "This is the TCP/IP port number for the LDAP server. Default\n";
1124 print "port is 389. This is optional. Press ENTER for default.\n";
1127 $name =~ s/[\r|\n]//g;
1128 $ldap_port[$sub] = $name;
1132 print "This is the charset for the server. Default is utf-8. This\n";
1133 print "is also optional. Press ENTER for default.\n";
1136 $name =~ s/[\r|\n]//g;
1137 $ldap_charset[$sub] = $name;
1141 print "This is the name for the server, used to tag the results of\n";
1142 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1145 $name =~ s/[\r|\n]//g;
1146 $ldap_name[$sub] = $name;
1150 print "You can specify the maximum number of rows in the search result.\n";
1151 print "Default is unlimited. Press ENTER for default.\n";
1154 $name =~ s/[\r|\n]//g;
1155 $ldap_maxrows[$sub] = $name;
1159 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1160 if ($input =~ /[0-9]+\s*$/) {
1162 $rem_num =~ s/^\s*-\s*//g;
1163 $rem_num =~ s/\s*$//;
1165 $rem_num = $#ldap_host;
1168 @new_ldap_host = ();
1169 @new_ldap_base = ();
1170 @new_ldap_port = ();
1171 @new_ldap_name = ();
1172 @new_ldap_charset = ();
1173 @new_ldap_maxrows = ();
1174 while ($count <= $#ldap_host) {
1175 if ($count != $rem_num) {
1176 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1177 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1178 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1179 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1180 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1181 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1185 @ldap_host = @new_ldap_host;
1186 @ldap_base = @new_ldap_base;
1187 @ldap_port = @new_ldap_port;
1188 @ldap_name = @new_ldap_name;
1189 @ldap_charset = @new_ldap_charset;
1190 @ldap_maxrows = @new_ldap_maxrows;
1191 } elsif ($input =~ /^\s*\?\s*/) {
1192 print ".-------------------------.\n";
1193 print "| + (add host) |\n";
1194 print "| - N (remove host) |\n";
1195 print "| l (list hosts) |\n";
1196 print "| d (done) |\n";
1197 print "`-------------------------'\n";
1199 print "[ldap] command (?=help) > ";
1201 $input =~ s/[\r|\n]//g;
1206 print "Some of our developers have come up with very good javascript interface\n";
1207 print "for searching through address books, however, our original goals said\n";
1208 print "that we would be 100% HTML. In order to make it possible to use their\n";
1209 print "interface, and yet stick with our goals, we have also written a plain\n";
1210 print "HTML version of the search. Here, you can choose which version to use.\n";
1212 print "This is just the default value. It is also a user option that each\n";
1213 print "user can configure individually\n";
1216 if ($default_use_javascript_addr_book eq "true") {
1217 $default_value = "y";
1219 $default_use_javascript_addr_book = "false";
1220 $default_value = "n";
1222 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1223 $new_show = <STDIN
>;
1224 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1225 $default_use_javascript_addr_book = "true";
1227 $default_use_javascript_addr_book = "false";
1229 return $default_use_javascript_addr_book;
1234 open (FILE
, ">config.php");
1236 print FILE
"<?php\n\t/** SquirrelMail configuration\n";
1237 print FILE
"\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1239 print FILE
"\t\$org_name = \"$org_name\";\n";
1240 print FILE
"\t\$org_logo = \"$org_logo\";\n";
1241 print FILE
"\t\$org_title = \"$org_title\";\n";
1245 print FILE
"\t\$domain = \"$domain\";\n";
1246 print FILE
"\t\$imapServerAddress = \"$imapServerAddress\";\n";
1247 print FILE
"\t\$imapPort = $imapPort;\n";
1248 print FILE
"\t\$useSendmail = $useSendmail;\n";
1249 print FILE
"\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1250 print FILE
"\t\$smtpPort = $smtpPort;\n";
1251 print FILE
"\t\$sendmailPath = \"$sendmail_path\";\n";
1252 print FILE
"\t\$imap_server_type = \"$imap_server_type\";\n";
1256 print FILE
"\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1257 print FILE
"\t\$trash_folder = \"$trash_folder\";\n";
1258 print FILE
"\t\$sent_folder = \"$sent_folder\";\n";
1259 print FILE
"\t\$default_move_to_trash = $default_move_to_trash;\n";
1260 print FILE
"\t\$default_move_to_sent = $default_move_to_sent;\n";
1261 print FILE
"\t\$show_prefix_option = $show_prefix_option;\n";
1262 print FILE
"\t\$list_special_folders_first = $list_special_folders_first;\n";
1263 print FILE
"\t\$use_special_folder_color = $use_special_folder_color;\n";
1264 print FILE
"\t\$auto_expunge = $auto_expunge;\n";
1265 print FILE
"\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1266 print FILE
"\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1267 print FILE
"\t\$default_unseen_notify = $default_unseen_notify;\n";
1268 print FILE
"\t\$default_unseen_type = $default_unseen_type;\n";
1271 print FILE
"\t\$default_charset = \"$default_charset\";\n";
1272 print FILE
"\t\$data_dir = \"$data_dir\";\n";
1273 print FILE
"\t\$attachment_dir = \"$attachment_dir\";\n";
1274 print FILE
"\t\$default_left_size = $default_left_size;\n";
1278 for ($count=0; $count <= $#plugins; $count++) {
1279 print FILE
"\t\$plugins[$count] = \"$plugins[$count]\";\n";
1284 for ($count=0; $count <= $#theme_name; $count++) {
1285 print FILE
"\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1286 print FILE
"\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1291 if ($default_use_javascript_addr_book ne "true") {
1292 $default_use_javascript_addr_book = "false";
1294 print FILE
"\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1295 for ($count=0; $count <= $#ldap_host; $count++) {
1296 print FILE
"\t\$ldap_server[$count] = Array(\n";
1297 print FILE
"\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1298 print FILE
"\t\t\t\"base\" => \"$ldap_base[$count]\"";
1299 if ($ldap_name[$count]) {
1300 print FILE
",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1302 if ($ldap_port[$count]) {
1303 print FILE
",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1305 if ($ldap_charset[$count]) {
1306 print FILE
",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1308 if ($ldap_maxrows[$count]) {
1309 print FILE
",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1311 print FILE
");\n\n";
1315 print FILE
"\t\$motd = \"$motd\";\n";
1323 print "While we have been building SquirrelMail, we have discovered some\n";
1324 print "preferences that work better with some servers that don't work so\n";
1325 print "well with others. If you select your IMAP server, this option will\n";
1326 print "set some pre-defined settings for that server.\n";
1328 print "Please note that you will still need to go through and make sure\n";
1329 print "everything is correct. This does not change everything. There are\n";
1330 print "only a few settings that this will change.\n";
1334 while ($continue != 1) {
1335 print "Please select your IMAP server:\n";
1336 print " cyrus = Cyrus IMAP server\n";
1337 print " uw = University of Washington's IMAP server\n";
1338 print " exchange = Microsoft Exchange IMAP server\n";
1339 print " courier = Courier IMAP server\n";
1340 print " quit = Do not change anything\n";
1341 print "Command >> ";
1343 $server =~ s/[\r|\n]//g;
1346 if ($server eq "cyrus") {
1347 $default_folder_prefix = "INBOX";
1348 $trash_folder = "INBOX.Trash";
1349 $sent_folder = "INBOX.Sent";
1350 $show_prefix_option = false
;
1351 $default_sub_of_inbox = true
;
1352 $show_contain_subfolders_option = false
;
1353 $imap_server_type = "cyrus";
1355 print " default_folder_prefix = INBOX\n";
1356 print " trash_folder = INBOX.Trash\n";
1357 print " sent_folder = INBOX.Sent\n";
1358 print " show_prefix_option = false\n";
1359 print " default_sub_of_inbox = true\n";
1360 print "show_contain_subfolders_option = false\n";
1361 print " imap_server_type = cyrus\n";
1364 } elsif ($server eq "uw") {
1365 $default_folder_prefix = "mail/";
1366 $trash_folder = "Trash";
1367 $sent_folder = "Sent";
1368 $show_prefix_option = true
;
1369 $default_sub_of_inbox = false
;
1370 $show_contain_subfolders_option = true
;
1371 $imap_server_type = "uw";
1373 print " default_folder_prefix = mail/\n";
1374 print " trash_folder = Trash\n";
1375 print " sent_folder = Sent\n";
1376 print " show_prefix_option = true\n";
1377 print " default_sub_of_inbox = false\n";
1378 print "show_contain_subfolders_option = true\n";
1379 print " imap_server_type = uw\n";
1382 } elsif ($server eq "exchange") {
1383 $default_folder_prefix = "INBOX/";
1384 $default_sub_of_inbox = true
;
1385 $trash_folder = "INBOX/Deleted Items";
1386 $sent_folder = "INBOX/Sent Items";
1387 $show_prefix_option = false
;
1388 $show_contain_subfolders_option = false
;
1390 $imap_server_type = "exchange";
1393 } elsif ($server eq "courier") {
1394 $imap_server_type = "courier";
1397 } elsif ($server eq "quit") {
1400 print "Unrecognized server: $server\n";
1404 print "\nPress any key to continue...";