3 # Luke Ehresman (luke@squirrelmail.org)
5 # A simple configure script to configure squirrelmail
8 ############################################################
9 $conf_pl_version = "1.2.0";
11 ############################################################
12 # Check what directory we're supposed to be running in, and
13 # change there if necessary. File::Basename has been in
14 # Perl since at least 5.003_7, and nobody sane runs anything
15 # before that, but just in case.
16 ############################################################
18 if (eval q{require "File/Basename.pm"}) {
19 my $dir = File
::Basename
::dirname
($0);
24 ############################################################
25 # Some people try to run this as a CGI. That's wrong!
26 ############################################################
27 if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) ||
28 defined($ENV{'REQUEST_METHOD'})) {
29 print "Content-Type: text/html\n\n";
30 print "You must run this script from the command line.";
34 ############################################################
35 # First, lets read in the data already in there...
36 ############################################################
37 if ( -e
"config.php") {
38 open (FILE
, "config.php");
39 while ($line = <FILE
>) {
45 if ($var =~ /^([a-z]|[A-Z])/) {
46 @o = split(/\s*EQUALS\s*/, $var);
47 if ($o[0] eq "config_version") {
48 $o[1] =~ s/[\n|\r]//g;
49 $o[1] =~ s/[\'|\"];\s*$//;
51 $o[1] =~ s/^[\'|\"]//;
53 $config_version = $o[1];
60 if ($config_version ne $conf_pl_version) {
62 print $WHT."WARNING:\n".$NRM;
63 print " The file \"config/config.php\" was found, but it is for\n";
64 print " an older version of SquirrelMail. It is possible to still\n";
65 print " read the defaults from this file but be warned that many\n";
66 print " preferences change between versions. It is recommended that\n";
67 print " you start with a clean config.php for each upgrade that you\n";
68 print " do. To do this, just move config/config.php out of the way.\n";
70 print "Continue loading with the old config.php [y/N]? ";
72 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
76 print "\nDo you want me to stop warning you [y/N]? ";
78 if ($ctu =~ /^y\n/i) {
79 $print_config_version = $conf_pl_version;
81 $print_config_version = $config_version;
84 $print_config_version = $config_version;
88 open (FILE
, "config.php");
89 } elsif (-e
"config_default.php") {
90 open (FILE
, "config_default.php");
91 while ($line = <FILE
>) {
97 if ($var =~ /^([a-z]|[A-Z])/) {
98 @o = split(/\s*EQUALS\s*/, $var);
99 if ($o[0] eq "config_version") {
100 $o[1] =~ s/[\n|\r]//g;
101 $o[1] =~ s/[\'|\"];\s*$//;
103 $o[1] =~ s/^[\'|\"]//;
105 $config_version = $o[1];
112 if ($config_version ne $conf_pl_version) {
114 print $WHT."WARNING:\n".$NRM;
115 print " You are trying to use a 'config_default.php' from an older\n";
116 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
117 print " should get the 'config_default.php' that matches the version\n";
118 print " of SquirrelMail that you are running. You can get this from\n";
119 print " the SquirrelMail web page by going to the following URL:\n";
120 print " http://www.squirrelmail.org.\n";
122 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
124 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
128 print "\nDo you want me to stop warning you [y/N]? ";
130 if ($ctu =~ /^y\n/i) {
131 $print_config_version = $conf_pl_version;
133 $print_config_version = $config_version;
136 $print_config_version = $config_version;
139 open (FILE
, "config_default.php");
141 print "No configuration file found. Please get config_default.php\n";
142 print "or config.php before running this again. This program needs\n";
143 print "a default config file to get default values.\n";
147 # Read and parse the current configuration file
148 # (either config.php or config_default.php).
149 while ($line = <FILE
>) {
155 if ($var =~ /^([a-z]|[A-Z])/) {
156 @options = split(/\s*EQUALS\s*/, $var);
157 $options[1] =~ s/[\n|\r]//g;
158 $options[1] =~ s/[\'|\"];\s*$//;
159 $options[1] =~ s/;$//;
160 $options[1] =~ s/^[\'|\"]//;
162 if ($options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/) {
164 $sub =~ s/\]\[['|"]PATH['|"]\]//;
166 if (-e
"../themes") {
167 $options[1] =~ s/^\.\.\/config/\
.\
.\
/themes/;
169 $theme_path[$sub] = $options[1];
170 } elsif ($options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/) {
172 $sub =~ s/\]\[['|"]NAME['|"]\]//;
174 $theme_name[$sub] = $options[1];
175 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
178 $sub =~ s/^plugins\[//;
179 $plugins[$sub] = $options[1];
180 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
183 $sub =~ s/^ldap_server\[//;
185 while (($tmp = <FILE
>) && ($continue != 1)) {
186 if ($tmp =~ /\);\s*$/) {
190 if ($tmp =~ /^\s*[\'|\"]host[\'|\"]/i) {
191 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
192 $tmp =~ s/[\'|\"],?\s*$//;
193 $tmp =~ s/[\'|\"]\);\s*$//;
195 } elsif ($tmp =~ /^\s*[\'|\"]base[\'|\"]/i) {
196 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
197 $tmp =~ s/[\'|\"],?\s*$//;
198 $tmp =~ s/[\'|\"]\);\s*$//;
200 } elsif ($tmp =~ /^\s*[\'|\"]charset[\'|\"]/i) {
201 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
202 $tmp =~ s/[\'|\"],?\s*$//;
203 $tmp =~ s/[\'|\"]\);\s*$//;
205 } elsif ($tmp =~ /^\s*[\'|\"]port[\'|\"]/i) {
206 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
207 $tmp =~ s/[\'|\"],?\s*$//;
208 $tmp =~ s/[\'|\"]\);\s*$//;
210 } elsif ($tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i) {
211 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
212 $tmp =~ s/[\'|\"],?\s*$//;
213 $tmp =~ s/[\'|\"]\);\s*$//;
215 } elsif ($tmp =~ /^\s*[\'|\"]name[\'|\"]/i) {
216 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
217 $tmp =~ s/[\'|\"],?\s*$//;
218 $tmp =~ s/[\'|\"]\);\s*$//;
222 $ldap_host[$sub] = $host;
223 $ldap_base[$sub] = $base;
224 $ldap_name[$sub] = $name;
225 $ldap_port[$sub] = $port;
226 $ldap_maxrows[$sub] = $maxrows;
227 $ldap_charset[$sub] = $charset;
229 ${$options[0]} = $options[1];
234 if ($useSendmail ne "true") {
235 $useSendmail = "false";
237 if (!$sendmail_path) {
238 $sendmail_path = "/usr/sbin/sendmail";
240 if (!$default_unseen_notify) {
241 $default_unseen_notify = 2;
243 if (!$default_unseen_type) {
244 $default_unseen_type = 1;
246 if (!$config_use_color) {
247 $config_use_color = 0;
250 $invert_time = "false";
252 if (!$force_username_lowercase) {
253 $force_username_lowercase = "false";
255 if (!$optional_delimiter) {
256 $optional_delimiter = "detect";
258 if (!$use_authenticated_smtp) {
259 $use_authenticated_smtp = "false";
261 if (!$auto_create_special) {
262 $auto_create_special = "false";
264 if(!$default_use_priority) {
265 $default_use_priority = "true";
267 if(!$hide_sm_attributions) {
268 $hide_sm_attributions = "false";
271 #####################################################################################
272 if ($config_use_color == 1) {
278 $config_use_color = 2;
281 while (($command ne "q") && ($command ne "Q")) {
283 print $WHT."SquirrelMail Configuration : ".$NRM;
284 if ($config == 1) { print "Read: config.php"; }
285 elsif ($config == 2) { print "Read: config_default.php"; }
286 print " ($print_config_version)\n";
287 print "---------------------------------------------------------\n";
290 print $WHT."Main Menu --\n".$NRM;
291 print "1. Organization Preferences\n";
292 print "2. Server Settings\n";
293 print "3. Folder Defaults\n";
294 print "4. General Options\n";
296 print "6. Address Books (LDAP)\n";
297 print "7. Message of the Day (MOTD)\n";
298 print "8. Plugins\n";
300 print "D. Set pre-defined settings for specific IMAP servers\n";
302 } elsif ($menu == 1) {
303 print $WHT."Organization Preferences\n".$NRM;
304 print "1. Organization Name : $WHT$org_name$NRM\n";
305 print "2. Organization Logo : $WHT$org_logo$NRM\n";
306 print "3. Organization Title : $WHT$org_title$NRM\n";
307 print "4. Signout Page : $WHT$signout_page$NRM\n";
308 print "5. Default Language : $WHT$squirrelmail_default_language$NRM\n";
310 print "R Return to Main Menu\n";
311 } elsif ($menu == 2) {
312 print $WHT."Server Settings\n".$NRM;
313 print "1. Domain : $WHT$domain$NRM\n";
314 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
315 print "3. IMAP Port : $WHT$imapPort$NRM\n";
316 print "4. Use Sendmail/SMTP : $WHT";
317 if ($useSendmail eq "true") {
323 if ($useSendmail eq "true") {
324 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
326 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
327 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
328 print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
330 print "9. Server : $WHT$imap_server_type$NRM\n";
331 print "10. Invert Time : $WHT$invert_time$NRM\n";
332 print "11. Delimiter : $WHT$optional_delimiter$NRM\n";
334 print "R Return to Main Menu\n";
335 } elsif ($menu == 3) {
336 print $WHT."Folder Defaults\n".$NRM;
337 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
338 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
339 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
340 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
341 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
342 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
343 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
344 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
345 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
346 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
347 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
348 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
349 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
350 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
351 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
352 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
354 print "R Return to Main Menu\n";
355 } elsif ($menu == 4) {
356 print $WHT."General Options\n".$NRM;
357 print "1. Default Charset : $WHT$default_charset$NRM\n";
358 print "2. Data Directory : $WHT$data_dir$NRM\n";
359 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
360 print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
361 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
362 print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
363 print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
364 print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
366 print "R Return to Main Menu\n";
367 } elsif ($menu == 5) {
368 print $WHT."Themes\n".$NRM;
369 print "1. Change Themes\n";
370 for ($count = 0; $count <= $#theme_name; $count++) {
371 print " > $theme_name[$count]\n";
373 print "2. CSS File : $WHT$theme_css$NRM\n";
375 print "R Return to Main Menu\n";
376 } elsif ($menu == 6) {
377 print $WHT."Address Books (LDAP)\n".$NRM;
378 print "1. Change Servers\n";
379 for ($count = 0; $count <= $#ldap_host; $count++) {
380 print " > $ldap_host[$count]\n";
382 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
384 print "R Return to Main Menu\n";
385 } elsif ($menu == 7) {
386 print $WHT."Message of the Day (MOTD)\n".$NRM;
389 print "1 Edit the MOTD\n";
391 print "R Return to Main Menu\n";
392 } elsif ($menu == 8) {
393 print $WHT."Plugins\n".$NRM;
394 print " Installed Plugins\n";
396 for ($count = 0; $count <= $#plugins; $count++) {
398 print " $num. $plugins[$count]\n";
400 print "\n Available Plugins:\n";
401 opendir(DIR
, "../plugins");
402 @files = readdir(DIR
);
404 @unused_plugins = ();
405 for ($i=0; $i <= $#files; $i++) {
406 if ( -d
"../plugins/" . $files[$i] &&
407 $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
409 for ($k=0; $k<=$#plugins; $k++) {
410 if ($plugins[$k] eq $files[$i]) {
415 $unused_plugins[$pos] = $files[$i];
421 for ($i=0; $i<=$#unused_plugins; $i++) {
423 print " $num. $unused_plugins[$i]\n";
428 print "A Sanitize all plugins for use with Squirrelmail 1.2\n";
430 print "R Return to Main Menu\n";
432 if ($config_use_color == 1) {
433 print "C. Turn color off\n";
435 print "C. Turn color on\n";
437 print "S Save data\n";
441 print "Command >> ".$WHT;
443 $command =~ s/[\n|\r]//g;
444 $command =~ tr/A-Z/a-z/;
447 # Read the commands they entered.
448 if ($command eq "r") {
450 } elsif ($command eq "s") {
452 print "Data saved in config.php\n";
453 print "Press enter to continue...";
456 } elsif (($command eq "q") && ($saved == 0)) {
457 print "You have not saved your data.\n";
458 print "Save? [".$WHT."Y".$NRM."/n]: ";
460 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
463 } elsif ($command eq "c") {
464 if ($config_use_color == 1) {
465 $config_use_color = 2;
469 $config_use_color = 1;
473 } elsif ($command eq "d" && $menu == 0) {
478 if (($command > 0) && ($command < 9)) {
481 } elsif ($menu == 1) {
482 if ($command == 1) { $org_name = command1
(); }
483 elsif ($command == 2) { $org_logo = command2
(); }
484 elsif ($command == 3) { $org_title = command3
(); }
485 elsif ($command == 4) { $signout_page = command4
(); }
486 elsif ($command == 5) { $squirrelmail_default_language = command5
(); }
487 } elsif ($menu == 2) {
488 if ($command == 1) { $domain = command11
(); }
489 elsif ($command == 2) { $imapServerAddress = command12
(); }
490 elsif ($command == 3) { $imapPort = command13
(); }
491 elsif ($command == 4) { $useSendmail = command14
(); }
492 elsif ($command == 5) { $sendmail_path = command15
(); }
493 elsif ($command == 6) { $smtpServerAddress = command16
(); }
494 elsif ($command == 7) { $smtpPort = command17
(); }
495 elsif ($command == 8) { $use_authenticated_smtp = command18
(); }
496 elsif ($command == 9) { $imap_server_type = command19
(); }
497 elsif ($command == 10) { $invert_time = command110
(); }
498 elsif ($command == 11) { $optional_delimiter = command111
(); }
499 } elsif ($menu == 3) {
500 if ($command == 1) { $default_folder_prefix = command21
(); }
501 elsif ($command == 2) { $show_prefix_option = command22
(); }
502 elsif ($command == 3) { $trash_folder = command23a
(); }
503 elsif ($command == 4) { $sent_folder = command23b
(); }
504 elsif ($command == 5) { $draft_folder = command23c
(); }
505 elsif ($command == 6) { $default_move_to_trash = command24a
(); }
506 elsif ($command == 7) { $default_move_to_sent = command24b
(); }
507 elsif ($command == 8) { $default_save_as_draft = command24c
(); }
508 elsif ($command == 9) { $list_special_folders_first = command27
(); }
509 elsif ($command == 10) { $use_special_folder_color = command28
(); }
510 elsif ($command == 11) { $auto_expunge = command29
(); }
511 elsif ($command == 12) { $default_sub_of_inbox = command210
(); }
512 elsif ($command == 13) { $show_contain_subfolders_option = command211
(); }
513 elsif ($command == 14) { $default_unseen_notify = command212
(); }
514 elsif ($command == 15) { $default_unseen_type = command213
(); }
515 elsif ($command == 16) { $auto_create_special = command214
(); }
516 } elsif ($menu == 4) {
517 if ($command == 1) { $default_charset = command31
(); }
518 elsif ($command == 2) { $data_dir = command33a
(); }
519 elsif ($command == 3) { $attachment_dir = command33b
(); }
520 elsif ($command == 4) { $dir_hash_level = command33c
(); }
521 elsif ($command == 5) { $default_left_size = command35
(); }
522 elsif ($command == 6) { $force_username_lowercase = command36
(); }
523 elsif ($command == 7) { $default_use_priority = command37
(); }
524 elsif ($command == 8) { $hide_sm_attributions = command38
(); }
525 } elsif ($menu == 5) {
526 if ($command == 1) { command41
(); }
527 elsif ($command == 2) { $theme_css = command42
(); }
528 } elsif ($menu == 6) {
529 if ($command == 1) { command61
(); }
530 elsif ($command == 2) { command62
(); }
531 } elsif ($menu == 7) {
532 if ($command == 1) { $motd = command71
(); }
533 } elsif ($menu == 8) {
534 if ($command =~ /^[0-9]+/) { @plugins = command81
(); }
535 elsif ($command eq "a") { command8s
(); }
540 ####################################################################################
544 print "We have tried to make the name SquirrelMail as transparent as\n";
545 print "possible. If you set up an organization name, most places where\n";
546 print "SquirrelMail would take credit will be credited to your organization.\n";
548 print "[$WHT$org_name$NRM]: $WHT";
549 $new_org_name = <STDIN
>;
550 if ($new_org_name eq "\n") {
551 $new_org_name = $org_name;
553 $new_org_name =~ s/[\r|\n]//g;
555 return $new_org_name;
561 print "Your organization's logo is an image that will be displayed at\n";
562 print "different times throughout SquirrelMail. This is asking for the\n";
563 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
564 print "(../images/logo.jpg) path to your logo.\n";
566 print "[$WHT$org_logo$NRM]: $WHT";
567 $new_org_logo = <STDIN
>;
568 if ($new_org_logo eq "\n") {
569 $new_org_logo = $org_logo;
571 $new_org_logo =~ s/[\r|\n]//g;
573 return $new_org_logo;
578 print "A title is what is displayed at the top of the browser window in\n";
579 print "the titlebar. Usually this will end up looking something like:\n";
580 print "\"Netscape: $org_title\"\n";
582 print "[$WHT$org_title$NRM]: $WHT";
583 $new_org_title = <STDIN
>;
584 if ($new_org_title eq "\n") {
585 $new_org_title = $org_title;
587 $new_org_title =~ s/[\r|\n]//g;
589 return $new_org_title;
594 print "When users click the Sign Out button they will be logged out and\n";
595 print "then sent to signout_page. If signout_page is left empty,\n";
596 print "(hit space and then return) they will be taken, as normal,\n";
597 print "to the default and rather sparse SquirrelMail signout page.\n";
599 print "[$WHT$signout_page$NRM]: $WHT";
600 $new_signout_page = <STDIN
>;
601 if ($new_signout_page eq "\n") {
602 $new_signout_page = $signout_page;
604 $new_signout_page =~ s/[\r|\n]//g;
605 $new_signout_page =~ s/^\s+$//g;
607 return $new_signout_page;
612 print "SquirrelMail attempts to set the language in many ways. If it\n";
613 print "can not figure it out in another way, it will default to this\n";
614 print "language. Please use the two-letter code for the desired language.\n";
616 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
617 $new_signout_page = <STDIN
>;
618 if ($new_signout_page eq "\n") {
619 $new_signout_page = $squirrelmail_default_language;
621 $new_signout_page =~ s/[\r|\n]//g;
622 $new_signout_page =~ s/^\s+$//g;
624 return $new_signout_page;
627 ####################################################################################
631 print "The domain name is the suffix at the end of all email messages. If\n";
632 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
633 print "would be myorg.com.\n";
635 print "[$WHT$domain$NRM]: $WHT";
636 $new_domain = <STDIN
>;
637 if ($new_domain eq "\n") {
638 $new_domain = $domain;
640 $new_domain =~ s/[\r|\n]//g;
647 print "This is the address where your IMAP server resides.\n";
648 print "[$WHT$imapServerAddress$NRM]: $WHT";
649 $new_imapServerAddress = <STDIN
>;
650 if ($new_imapServerAddress eq "\n") {
651 $new_imapServerAddress = $imapServerAddress;
653 $new_imapServerAddress =~ s/[\r|\n]//g;
655 return $new_imapServerAddress;
660 print "This is the port that your IMAP server is on. Usually this is 143.\n";
661 print "[$WHT$imapPort$NRM]: $WHT";
662 $new_imapPort = <STDIN
>;
663 if ($new_imapPort eq "\n") {
664 $new_imapPort = $imapPort;
666 $new_imapPort =~ s/[\r|\n]//g;
668 return $new_imapPort;
673 print "You now need to choose the method that you will use for sending\n";
674 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
675 print "or use sendmail directly.\n";
676 if ($useSendmail eq "true") {
677 $default_value = "1";
679 $default_value = "2";
682 print " 1. Sendmail\n";
684 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
685 $use_sendmail = <STDIN
>;
686 if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
687 $useSendmail = "true";
689 $useSendmail = "false";
696 if ($sendmail_path[0] !~ /./) {
697 $sendmail_path = "/usr/sbin/sendmail";
699 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
700 print "[$WHT$sendmail_path$NRM]: $WHT";
701 $new_sendmail_path = <STDIN
>;
702 if ($new_sendmail_path eq "\n") {
703 $new_sendmail_path = $sendmail_path;
705 $new_sendmail_path =~ s/[\r|\n]//g;
707 return $new_sendmail_path;
712 print "This is the location of your SMTP server.\n";
713 print "[$WHT$smtpServerAddress$NRM]: $WHT";
714 $new_smtpServerAddress = <STDIN
>;
715 if ($new_smtpServerAddress eq "\n") {
716 $new_smtpServerAddress = $smtpServerAddress;
718 $new_smtpServerAddress =~ s/[\r|\n]//g;
720 return $new_smtpServerAddress;
725 print "This is the port to connect to for SMTP. Usually 25.\n";
726 print "[$WHT$smtpPort$NRM]: $WHT";
727 $new_smtpPort = <STDIN
>;
728 if ($new_smtpPort eq "\n") {
729 $new_smtpPort = $smtpPort;
731 $new_smtpPort =~ s/[\r|\n]//g;
733 return $new_smtpPort;
736 # authenticated server
738 print "Do you wish to use an authenticated SMTP server? Your server must\n";
739 print "support this in order for SquirrelMail to work with it. We implemented\n";
740 print "it according to RFC 2554.\n";
743 $YesNo = 'y' if ($use_authenticated_smtp eq "true");
745 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
747 $new_use_authenticated_smtp = <STDIN
>;
748 $new_use_authenticated_smtp =~ tr/yn//cd;
749 return "true" if ($new_use_authenticated_smtp eq "y");
750 return "false" if ($new_use_authenticated_smtp eq "n");
751 return $use_authenticated_smtp;
756 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
757 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
758 print "the same principles. We have made some work-arounds for some of\n";
759 print "these servers. If you would like to use them, please select your\n";
760 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
761 print "set this to \"other\", and none will be used.\n";
762 print " cyrus = Cyrus IMAP server\n";
763 print " uw = University of Washington's IMAP server\n";
764 print " exchange = Microsoft Exchange IMAP server\n";
765 print " courier = Courier IMAP server\n";
766 print " other = Not one of the above servers\n";
767 print "[$WHT$imap_server_type$NRM]: $WHT";
768 $new_imap_server_type = <STDIN
>;
769 if ($new_imap_server_type eq "\n") {
770 $new_imap_server_type = $imap_server_type;
772 $new_imap_server_type =~ s/[\r|\n]//g;
774 return $new_imap_server_type;
779 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
780 print "on some machines). Typically this happens if the system doesn't support\n";
781 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
782 print "This most often occurs on Solaris 7 machines in the United States.\n";
783 print "By default, this is off. It should be kept off unless problems surface\n";
784 print "about the time that messages are sent.\n";
785 print " no = Do NOT fix time -- almost always correct\n";
786 print " yes = Fix the time for this system\n";
789 $YesNo = 'y' if ($invert_time eq "true");
791 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
793 $new_invert_time = <STDIN
>;
794 $new_invert_time =~ tr/yn//cd;
795 return "true" if ($new_invert_time eq "y");
796 return "false" if ($new_invert_time eq "n");
801 print "This is the delimiter that your IMAP server uses to distinguish between\n";
802 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
803 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
804 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
805 print "but if you are sure you know what delimiter your server uses, you can\n";
806 print "specify it here.\n";
807 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
808 print "[$WHT$optional_delimiter$NRM]: $WHT";
809 $new_optional_delimiter = <STDIN
>;
810 if ($new_optional_delimiter eq "\n") {
811 $new_optional_delimiter = $optional_delimiter;
813 $new_optional_delimiter =~ s/[\r|\n]//g;
815 return $new_optional_delimiter;
820 print "\nYou can now create the welcome message that is displayed\n";
821 print "every time a user logs on. You can use HTML or just plain\n";
822 print "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
828 $line =~ s/[\r|\n]//g;
830 $line =~ s/ /\ \ /g;
831 $line =~ s/\t/\ \ \ \ /g;
833 $line =~ s/\'/\\\'/g;
835 $new_motd = $new_motd . $line;
837 } while ($line ne "@");
841 ################# PLUGINS ###################
844 $command =~ s/[\s|\n|\r]*//g;
846 $command = $command - 1;
847 if ($command <= $#plugins) {
850 while ($ct <= $#plugins) {
851 if ($ct != $command) {
852 @newplugins = (@newplugins, $plugins[$ct]);
856 @plugins = @newplugins;
857 } elsif ($command <= $#plugins + $#unused_plugins + 1) {
858 $num = $command - $#plugins - 1;
859 @newplugins = @plugins;
861 while ($ct <= $#unused_plugins) {
863 @newplugins = (@newplugins, $unused_plugins[$ct]);
864 # sanitize the plugin
865 $dir = $unused_plugins[$ct];
866 `./ri_once.pl ../plugins/$dir`;
870 @plugins = @newplugins;
877 print "This command will sanitize all plugins for use with\n";
878 print "Squirrelmail 1.2. That is, it will rewrite some php-\n";
879 print "constructs that are *incompatible* with the 1.2 design\n";
880 print "into ones that are *compatible*\n";
881 print "Do you wish to issue this command [y/N]? ";
883 if ($ctu =~ /^y\n/i) {
884 `./ri_once.pl ../plugins`;
888 ################# FOLDERS ###################
890 # default_folder_prefix
892 print "Some IMAP servers (UW, for example) store mail and folders in\n";
893 print "your user space in a separate subdirectory. This is where you\n";
894 print "specify what that directory is.\n";
896 print "EXAMPLE: mail/";
898 print "NOTE: If you use Cyrus, or some server that would not use this\n";
899 print " option, you must set this to 'none'.\n";
901 print "[$WHT$default_folder_prefix$NRM]: $WHT";
902 $new_default_folder_prefix = <STDIN
>;
903 if ($new_default_folder_prefix eq "\n") {
904 $new_default_folder_prefix = $default_folder_prefix;
906 $new_default_folder_prefix =~ s/[\r|\n]//g;
908 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
909 $new_default_folder_prefix = "";
911 $new_default_folder_prefix =~ s/\/*$//g
;
912 $new_default_folder_prefix =~ s/$/\//g
;
914 return $new_default_folder_prefix;
919 print "It is possible to set up the default folder prefix as a user\n";
920 print "specific option, where each user can specify what their mail\n";
921 print "folder is. If you set this to false, they will never see the\n";
922 print "option, but if it is true, this option will appear in the\n";
923 print "'options' section.\n";
925 print "NOTE: You set the default folder prefix in option '1' of this\n";
926 print " section. That will be the default if the user doesn't\n";
927 print " specify anything different.\n";
930 if ($show_prefix_option eq "true") {
931 $default_value = "y";
933 $default_value = "n";
936 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
938 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
939 $show_prefix_option = "true";
941 $show_prefix_option = "false";
943 return $show_prefix_option;
948 print "You can now specify where the default trash folder is located.\n";
949 print "On servers where you do not want this, you can set it to anything\n";
950 print "and set option 6 to false.\n";
952 print "This is relative to where the rest of your email is kept. You do\n";
953 print "not need to worry about their mail directory. If this folder\n";
954 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
955 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
958 print "[$WHT$trash_folder$NRM]: $WHT";
959 $new_trash_folder = <STDIN
>;
960 if ($new_trash_folder eq "\n") {
961 $new_trash_folder = $trash_folder;
963 $new_trash_folder =~ s/[\r|\n]//g;
965 return $new_trash_folder;
970 print "This is where messages that are sent will be stored. SquirrelMail\n";
971 print "by default puts a copy of all outgoing messages in this folder.\n";
973 print "This is relative to where the rest of your email is kept. You do\n";
974 print "not need to worry about their mail directory. If this folder\n";
975 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
976 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
979 print "[$WHT$sent_folder$NRM]: $WHT";
980 $new_sent_folder = <STDIN
>;
981 if ($new_sent_folder eq "\n") {
982 $new_sent_folder = $sent_folder;
984 $new_sent_folder =~ s/[\r|\n]//g;
986 return $new_sent_folder;
991 print "You can now specify where the default draft folder is located.\n";
992 print "On servers where you do not want this, you can set it to anything\n";
993 print "and set option 9 to false.\n";
995 print "This is relative to where the rest of your email is kept. You do\n";
996 print "not need to worry about their mail directory. If this folder\n";
997 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
998 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1001 print "[$WHT$draft_folder$NRM]: $WHT";
1002 $new_draft_folder = <STDIN
>;
1003 if ($new_draft_folder eq "\n") {
1004 $new_draft_folder = $draft_folder;
1006 $new_draft_folder =~ s/[\r|\n]//g;
1008 return $new_draft_folder;
1011 # default move to trash
1013 print "By default, should messages get moved to the trash folder? You\n";
1014 print "can specify the default trash folder in option 3. If this is set\n";
1015 print "to false, messages will get deleted immediately without moving\n";
1016 print "to the trash folder.\n";
1018 print "Trash folder is currently: $trash_folder\n";
1021 if ($default_move_to_trash eq "true") {
1022 $default_value = "y";
1024 $default_value = "n";
1026 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1027 $new_show = <STDIN
>;
1028 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1029 $default_move_to_trash = "true";
1031 $default_move_to_trash = "false";
1033 return $default_move_to_trash;
1036 # default move to sent
1038 print "By default, should messages get moved to the sent folder? You\n";
1039 print "can specify the default sent folder in option 4. If this is set\n";
1040 print "to false, messages will get sent an no copy will be made.\n";
1042 print "Trash folder is currently: $sent_folder\n";
1045 if ($default_move_to_sent eq "true") {
1046 $default_value = "y";
1048 $default_value = "n";
1050 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1051 $new_show = <STDIN
>;
1052 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1053 $default_move_to_sent = "true";
1055 $default_move_to_sent = "false";
1057 return $default_move_to_sent;
1060 # default save as draft
1062 print "By default, should the save to draft option be shown? You can\n";
1063 print "specify the default drafts folder in option 5. If this is set\n";
1064 print "to false, users will not be shown the save to draft option.\n";
1066 print "Drafts folder is currently: $draft_folder\n";
1069 if ($default_move_to_draft eq "true") {
1070 $default_value = "y";
1072 $default_value = "n";
1074 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1075 $new_show = <STDIN
>;
1076 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1077 $default_save_as_draft = "true";
1079 $default_save_as_draft = "false";
1081 return $default_save_as_draft;
1084 # List special folders first
1086 print "SquirrelMail has what we call 'special folders' that are not\n";
1087 print "manipulated and viewed like normal folders. Some examples of\n";
1088 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1089 print "Simply asks if you want these folders listed first in the folder\n";
1093 if ($list_special_folders_first eq "true") {
1094 $default_value = "y";
1096 $default_value = "n";
1099 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1100 $new_show = <STDIN
>;
1101 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1102 $list_special_folders_first = "true";
1104 $list_special_folders_first = "false";
1106 return $list_special_folders_first;
1109 # Show special folders color
1111 print "SquirrelMail has what we call 'special folders' that are not\n";
1112 print "manipulated and viewed like normal folders. Some examples of\n";
1113 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1114 print "wants to know if we should display special folders in a\n";
1115 print "color than the other folders.\n";
1118 if ($use_special_folder_color eq "true") {
1119 $default_value = "y";
1121 $default_value = "n";
1124 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1125 $new_show = <STDIN
>;
1126 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1127 $use_special_folder_color = "true";
1129 $use_special_folder_color = "false";
1131 return $use_special_folder_color;
1136 print "The way that IMAP handles deleting messages is as follows. You\n";
1137 print "mark the message as deleted, and then to 'really' delete it, you\n";
1138 print "expunge it. This option asks if you want to just have messages\n";
1139 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1140 print "messages too.\n";
1143 if ($auto_expunge eq "true") {
1144 $default_value = "y";
1146 $default_value = "n";
1148 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1149 $new_show = <STDIN
>;
1150 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1151 $auto_expunge = "true";
1153 $auto_expunge = "false";
1155 return $auto_expunge;
1158 # Default sub of inbox
1160 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1161 print "This can cause some confusion in folder creation for users when\n";
1162 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1163 print "and get permission errors. This option asks if you want folders\n";
1164 print "to be subfolders of INBOX by default.\n";
1167 if ($default_sub_of_inbox eq "true") {
1168 $default_value = "y";
1170 $default_value = "n";
1172 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1173 $new_show = <STDIN
>;
1174 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1175 $default_sub_of_inbox = "true";
1177 $default_sub_of_inbox = "false";
1179 return $default_sub_of_inbox;
1182 # Show contain subfolder option
1184 print "Some IMAP servers (UW) make it so that there are two types of\n";
1185 print "folders. Those that contain messages, and those that contain\n";
1186 print "subfolders. If this is the case for your server, set this to\n";
1187 print "true, and it will ask the user whether the folder they are\n";
1188 print "creating contains subfolders or messages.\n";
1191 if ($show_contain_subfolders_option eq "true") {
1192 $default_value = "y";
1194 $default_value = "n";
1196 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1197 $new_show = <STDIN
>;
1198 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1199 $show_contain_subfolders_option = "true";
1201 $show_contain_subfolders_option = "false";
1203 return $show_contain_subfolders_option;
1206 # Default Unseen Notify
1208 print "This option specifies where the users will receive notification\n";
1209 print "about unseen messages by default. This is of course an option that\n";
1210 print "can be changed on a user level.\n";
1211 print " 1 = No notification\n";
1212 print " 2 = Only on the INBOX\n";
1213 print " 3 = On all folders\n";
1216 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1217 $new_show = <STDIN
>;
1218 if ($new_show =~ /^[1|2|3]\n/i) {
1219 $default_unseen_notify = $new_show;
1221 $default_unseen_notify =~ s/[\r|\n]//g;
1222 return $default_unseen_notify;
1225 # Default Unseen Type
1227 print "Here you can define the default way that unseen messages will be displayed\n";
1228 print "to the user in the folder listing on the left side.\n";
1229 print " 1 = Only unseen messages (4)\n";
1230 print " 2 = Unseen and Total messages (4/27)\n";
1233 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1234 $new_show = <STDIN
>;
1235 if ($new_show =~ /^[1|2]\n/i) {
1236 $default_unseen_type = $new_show;
1238 $default_unseen_type =~ s/[\r|\n]//g;
1239 return $default_unseen_type;
1242 # Auto create special folders
1244 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1245 print "automatically print for you when a user logs in? If the user\n";
1246 print "accidentally deletes their special folders, this option will\n";
1247 print "automatically create it again for them.\n";
1250 if ($auto_create_special eq "true") {
1251 $default_value = "y";
1253 $default_value = "n";
1255 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1256 $new_show = <STDIN
>;
1257 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1258 $auto_create_special = "true";
1260 $auto_create_special = "false";
1262 return $auto_create_special;
1266 ############# GENERAL OPTIONS #####################
1270 print "This option controls what character set is used when sending\n";
1271 print "mail and when sending HTML to the browser. Do not set this\n";
1272 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1273 print "to use KOI8-R, since this implementation is faster than most\n";
1274 print "of the alternatives\n";
1277 print "[$WHT$default_charset$NRM]: $WHT";
1278 $new_default_charset = <STDIN
>;
1279 if ($new_default_charset eq "\n") {
1280 $new_default_charset = $default_charset;
1282 $new_default_charset =~ s/[\r|\n]//g;
1284 return $new_default_charset;
1289 print "It is a possible security hole to have a writable directory\n";
1290 print "under the web server's root directory (ex: /home/httpd/html).\n";
1291 print "For this reason, it is possible to put the data directory\n";
1292 print "anywhere you would like. The path name can be absolute or\n";
1293 print "relative (to the config directory). It doesn't matter. Here\n";
1294 print "are two examples:\n";
1295 print " Absolute: /usr/local/squirrelmail/data/\n";
1296 print " Relative: ../data/\n";
1299 print "[$WHT$data_dir$NRM]: $WHT";
1300 $new_data_dir = <STDIN
>;
1301 if ($new_data_dir eq "\n") {
1302 $new_data_dir = $data_dir;
1304 $new_data_dir =~ s/[\r|\n]//g;
1306 if ($new_data_dir =~ /^\s*$/) {
1309 $new_data_dir =~ s/\/*$//g
;
1310 $new_data_dir =~ s/$/\//g
;
1312 return $new_data_dir;
1315 # Attachment directory
1317 print "Path to directory used for storing attachments while a mail is\n";
1318 print "being sent. There are a few security considerations regarding this\n";
1319 print "directory:\n";
1320 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1321 print " impossible for a random person with access to the webserver\n";
1322 print " to list files in this directory. Confidential data might\n";
1323 print " be laying around in there.\n";
1324 print " 2. Since the webserver is not able to list the files in the\n";
1325 print " content is also impossible for the webserver to delete files\n";
1326 print " lying around there for too long.\n";
1327 print " 3. It should probably be another directory than the data\n";
1328 print " directory specified in option 3.\n";
1331 print "[$WHT$attachment_dir$NRM]: $WHT";
1332 $new_attachment_dir = <STDIN
>;
1333 if ($new_attachment_dir eq "\n") {
1334 $new_attachment_dir = $attachment_dir;
1336 $new_attachment_dir =~ s/[\r|\n]//g;
1338 if ($new_attachment_dir =~ /^\s*$/) {
1339 $new_attachment_dir = "";
1341 $new_attachment_dir =~ s/\/*$//g
;
1342 $new_attachment_dir =~ s/$/\//g
;
1344 return $new_attachment_dir;
1348 print "The directory hash level setting allows you to configure the level\n";
1349 print "of hashing that Squirremail employs in your data and attachment\n";
1350 print "directories. This value must be an integer ranging from 0 to 4.\n";
1351 print "When this value is set to 0, Squirrelmail will simply store all\n";
1352 print "files as normal in the data and attachment directories. However,\n";
1353 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1354 print "used to organize the files in this directory. In short, the crc32\n";
1355 print "value for a username will be computed. Then, up to the first 4\n";
1356 print "digits of the hash, as set by this configuration value, will be\n";
1357 print "used to directory hash the files for that user in the data and\n";
1358 print "attachment directory. This allows for better performance on\n";
1359 print "servers with larger numbers of users.\n";
1362 print "[$WHT$dir_hash_level$NRM]: $WHT";
1363 $new_dir_hash_level = <STDIN
>;
1364 if ($new_dir_hash_level eq "\n") {
1365 $new_dir_hash_level = $dir_hash_level;
1367 $new_dir_hash_level =~ s/[\r|\n]//g;
1369 if ((int($new_dir_hash_level) < 0) ||
1370 (int($new_dir_hash_level) > 4) ||
1371 !(int($new_dir_hash_level) eq $new_dir_hash_level )) {
1372 print "Invalid Directory Hash Level.\n";
1373 print "Value must be an integer ranging from 0 to 4\n";
1374 print "Hit enter to continue.\n";
1375 $enter_key = <STDIN
>;
1377 $new_dir_hash_level = $dir_hash_level;
1380 return $new_dir_hash_level;
1384 print "This is the default size (in pixels) of the left folder list.\n";
1385 print "Default is 200, but you can set it to whatever you wish. This\n";
1386 print "is a user preference, so this will only show up as their default.\n";
1388 print "[$WHT$default_left_size$NRM]: $WHT";
1389 $new_default_left_size = <STDIN
>;
1390 if ($new_default_left_size eq "\n") {
1391 $new_default_left_size = $default_left_size;
1393 $new_default_left_size =~ s/[\r|\n]//g;
1395 return $new_default_left_size;
1400 print "Some IMAP servers only have lowercase letters in the usernames\n";
1401 print "but they still allow people with uppercase to log in. This\n";
1402 print "causes a problem with the user's preference files. This option\n";
1403 print "transparently changes all usernames to lowercase.";
1406 if ($force_username_lowercase eq "true") {
1407 $default_value = "y";
1409 $default_value = "n";
1411 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1412 $new_show = <STDIN
>;
1413 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1423 if ($default_use_priority eq "true") {
1424 $default_value = "y";
1426 $default_value = "n";
1429 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
1430 $new_show = <STDIN
>;
1431 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1442 if ($default_hide_attribution eq "true") {
1443 $default_value = "y";
1445 $default_value = "n";
1448 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
1449 $new_show = <STDIN
>;
1450 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1458 print "\nNow we will define the themes that you wish to use. If you have added\n";
1459 print "a theme of your own, just follow the instructions (?) about how to add\n";
1460 print "them. You can also change the default theme.\n";
1461 print "[theme] command (?=help) > ";
1463 $input =~ s/[\r|\n]//g;
1464 while ($input ne "d") {
1465 if ($input =~ /^\s*l\s*/i) {
1467 while ($count <= $#theme_name) {
1468 if ($count == $theme_default) {
1473 $name = $theme_name[$count];
1474 $num_spaces = 25 - length($name);
1475 for ($i = 0; $i < $num_spaces;$i++) {
1476 $name = $name . " ";
1479 print " $count. $name";
1480 print "($theme_path[$count])\n";
1484 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1485 $old_def = $theme_default;
1486 $theme_default = $input;
1487 $theme_default =~ s/^\s*m\s*//;
1488 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1489 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1490 $theme_default = $old_def;
1492 } elsif ($input =~ /^\s*\+/) {
1493 print "What is the name of this theme: ";
1495 $name =~ s/[\r|\n]//g;
1496 $theme_name[$#theme_name+1] = $name;
1497 print "Be sure to put ../themes/ before the filename.\n";
1498 print "What file is this stored in (ex: ../themes/default_theme.php): ";
1500 $name =~ s/[\r|\n]//g;
1501 $theme_path[$#theme_path+1] = $name;
1502 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1503 if ($input =~ /[0-9]+\s*$/) {
1505 $rem_num =~ s/^\s*-\s*//g;
1506 $rem_num =~ s/\s*$//;
1508 $rem_num = $#theme_name;
1510 if ($rem_num == $theme_default) {
1511 print "You cannot remove the default theme!\n";
1514 @new_theme_name = ();
1515 @new_theme_path = ();
1516 while ($count <= $#theme_name) {
1517 if ($count != $rem_num) {
1518 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1519 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1523 @theme_name = @new_theme_name;
1524 @theme_path = @new_theme_path;
1525 if ($theme_default > $rem_num) {
1529 } elsif ($input =~ /^\s*t\s*/i) {
1530 print "\nStarting detection...\n\n";
1532 opendir(DIR
, "../themes");
1533 @files = grep { /\.php$/i } readdir(DIR
);
1535 while ($cnt <= $#files) {
1536 $filename = "../themes/" . $files[$cnt];
1537 if ($filename ne "../themes/index.php") {
1539 for ($x=0; $x <= $#theme_path; $x++) {
1540 if ($theme_path[$x] eq $filename) {
1545 print "** Found theme: $filename\n";
1546 print " What is its name? ";
1548 $nm =~ s/[\n|\r]//g;
1549 $theme_name[$#theme_name+1] = $nm;
1550 $theme_path[$#theme_path+1] = $filename;
1556 for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
1557 $filename = $theme_path[$cnt];
1558 if (! (-e
$filename)) {
1559 print " Removing $filename (file not found)\n";
1561 @new_theme_name = ();
1562 @new_theme_path = ();
1563 for ($x=0; $x < $#theme_path; $x++) {
1564 if ($theme_path[$x] eq $filename) {
1568 $new_theme_name[$x] = $theme_name[$x+1];
1569 $new_theme_path[$x] = $theme_path[$x+1];
1571 $new_theme_name[$x] = $theme_name[$x];
1572 $new_theme_path[$x] = $theme_path[$x];
1575 @theme_name = @new_theme_name;
1576 @theme_path = @new_theme_path;
1579 print "\nDetection complete!\n\n";
1582 } elsif ($input =~ /^\s*\?\s*/) {
1583 print ".-------------------------.\n";
1584 print "| t (detect themes) |\n";
1585 print "| + (add theme) |\n";
1586 print "| - N (remove theme) |\n";
1587 print "| m N (mark default) |\n";
1588 print "| l (list themes) |\n";
1589 print "| d (done) |\n";
1590 print "`-------------------------'\n";
1592 print "[theme] command (?=help) > ";
1594 $input =~ s/[\r|\n]//g;
1601 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1602 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1603 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1604 print "files, leave this blank.\n";
1606 print "To clear out an existing value, just type a space for the input.\n";
1608 print "[$WHT$theme_css$NRM]: $WHT";
1609 $new_theme_css = <STDIN
>;
1610 if ($new_theme_css eq "\n") {
1611 $new_theme_css = $theme_css;
1613 $new_theme_css =~ s/[\r|\n]//g;
1615 $new_theme_css =~ s/^\s*//;
1616 return $new_theme_css;
1621 print "You can now define different LDAP servers.\n";
1622 print "[ldap] command (?=help) > ";
1624 $input =~ s/[\r|\n]//g;
1625 while ($input ne "d") {
1626 if ($input =~ /^\s*l\s*/i) {
1628 while ($count <= $#ldap_host) {
1629 print "$count. $ldap_host[$count]\n";
1630 print " base: $ldap_base[$count]\n";
1631 if ($ldap_charset[$count]) {
1632 print " charset: $ldap_charset[$count]\n";
1634 if ($ldap_port[$count]) {
1635 print " port: $ldap_port[$count]\n";
1637 if ($ldap_name[$count]) {
1638 print " name: $ldap_name[$count]\n";
1640 if ($ldap_maxrows[$count]) {
1641 print " maxrows: $ldap_maxrows[$count]\n";
1646 } elsif ($input =~ /^\s*\+/) {
1647 $sub = $#ldap_host + 1;
1649 print "First, we need to have the hostname or the IP address where\n";
1650 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1653 $name =~ s/[\r|\n]//g;
1654 $ldap_host[$sub] = $name;
1658 print "Next, we need the server root (base dn). For this, an empty\n";
1659 print "string is allowed.\n";
1660 print "Example: ou=member_directory,o=netcenter.com\n";
1663 $name =~ s/[\r|\n]//g;
1664 $ldap_base[$sub] = $name;
1668 print "This is the TCP/IP port number for the LDAP server. Default\n";
1669 print "port is 389. This is optional. Press ENTER for default.\n";
1672 $name =~ s/[\r|\n]//g;
1673 $ldap_port[$sub] = $name;
1677 print "This is the charset for the server. Default is utf-8. This\n";
1678 print "is also optional. Press ENTER for default.\n";
1681 $name =~ s/[\r|\n]//g;
1682 $ldap_charset[$sub] = $name;
1686 print "This is the name for the server, used to tag the results of\n";
1687 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1690 $name =~ s/[\r|\n]//g;
1691 $ldap_name[$sub] = $name;
1695 print "You can specify the maximum number of rows in the search result.\n";
1696 print "Default is unlimited. Press ENTER for default.\n";
1699 $name =~ s/[\r|\n]//g;
1700 $ldap_maxrows[$sub] = $name;
1704 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1705 if ($input =~ /[0-9]+\s*$/) {
1707 $rem_num =~ s/^\s*-\s*//g;
1708 $rem_num =~ s/\s*$//;
1710 $rem_num = $#ldap_host;
1713 @new_ldap_host = ();
1714 @new_ldap_base = ();
1715 @new_ldap_port = ();
1716 @new_ldap_name = ();
1717 @new_ldap_charset = ();
1718 @new_ldap_maxrows = ();
1719 while ($count <= $#ldap_host) {
1720 if ($count != $rem_num) {
1721 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1722 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1723 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1724 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1725 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1726 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1730 @ldap_host = @new_ldap_host;
1731 @ldap_base = @new_ldap_base;
1732 @ldap_port = @new_ldap_port;
1733 @ldap_name = @new_ldap_name;
1734 @ldap_charset = @new_ldap_charset;
1735 @ldap_maxrows = @new_ldap_maxrows;
1736 } elsif ($input =~ /^\s*\?\s*/) {
1737 print ".-------------------------.\n";
1738 print "| + (add host) |\n";
1739 print "| - N (remove host) |\n";
1740 print "| l (list hosts) |\n";
1741 print "| d (done) |\n";
1742 print "`-------------------------'\n";
1744 print "[ldap] command (?=help) > ";
1746 $input =~ s/[\r|\n]//g;
1751 print "Some of our developers have come up with very good javascript interface\n";
1752 print "for searching through address books, however, our original goals said\n";
1753 print "that we would be 100% HTML. In order to make it possible to use their\n";
1754 print "interface, and yet stick with our goals, we have also written a plain\n";
1755 print "HTML version of the search. Here, you can choose which version to use.\n";
1757 print "This is just the default value. It is also a user option that each\n";
1758 print "user can configure individually\n";
1761 if ($default_use_javascript_addr_book eq "true") {
1762 $default_value = "y";
1764 $default_use_javascript_addr_book = "false";
1765 $default_value = "n";
1767 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1768 $new_show = <STDIN
>;
1769 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1770 $default_use_javascript_addr_book = "true";
1772 $default_use_javascript_addr_book = "false";
1774 return $default_use_javascript_addr_book;
1780 open (CF
, ">config.php");
1786 print CF
" * SquirrelMail Configuration File\n";
1787 print CF
" * Created using the configure script, conf.pl\n";
1791 print CF
"global \$config_version, \$config_use_color;\n";
1792 if ($print_config_version) {
1793 print CF
"\$config_version = '$print_config_version';\n";
1795 print CF
"\$config_use_color = $config_use_color;\n";
1798 print CF
"global \$org_name, \$org_logo, \$org_title, \$signout_page;\n";
1799 print CF
"\$org_name = \"$org_name\";\n";
1800 print CF
"\$org_logo = '$org_logo';\n";
1801 print CF
"\$org_title = \"$org_title\";\n";
1802 print CF
"\$signout_page = '$signout_page';\n";
1805 print CF
"global \$motd;\n";
1806 print CF
"\$motd = '$motd';\n";
1809 print CF
"global \$squirrelmail_default_language;\n";
1810 print CF
"\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
1813 print CF
"global \$domain, \$imapServerAddress, \$imapPort;\n";
1814 print CF
"global \$useSendmail, \$smtpServerAddress, \$smtpPort;\n";
1815 print CF
"global \$sendmail_path, \$use_authenticated_smtp;\n";
1816 print CF
"global \$imap_server_type, \$invert_time;\n";
1817 print CF
"global \$optional_delimiter;\n";
1818 print CF
"\$domain = '$domain';\n";
1819 print CF
"\$imapServerAddress = '$imapServerAddress';\n";
1820 print CF
"\$imapPort = $imapPort;\n";
1821 print CF
"\$useSendmail = $useSendmail;\n";
1822 print CF
"\$smtpServerAddress = '$smtpServerAddress';\n";
1823 print CF
"\$smtpPort = $smtpPort;\n";
1824 print CF
"\$sendmail_path = '$sendmail_path';\n";
1825 print CF
"\$use_authenticated_smtp = $use_authenticated_smtp;\n";
1826 print CF
"\$imap_server_type = '$imap_server_type';\n";
1827 print CF
"\$invert_time = $invert_time;\n";
1828 print CF
"\$optional_delimiter = '$optional_delimiter';\n";
1831 print CF
"global \$default_folder_prefix;\n";
1832 print CF
"global \$trash_folder, \$default_move_to_trash;\n";
1833 print CF
"global \$sent_folder, \$default_move_to_sent;\n";
1834 print CF
"global \$draft_folder, \$default_save_to_draft;\n";
1835 print CF
"global \$show_prefix_option, \$list_special_folders_first;\n";
1836 print CF
"global \$use_special_folder_color, \$auto_expunge;\n";
1837 print CF
"global \$default_sub_of_inbox;\n";
1838 print CF
"global \$show_contain_subfolders_option;\n";
1839 print CF
"global \$default_unseen_notify;\n";
1840 print CF
"global \$default_unseen_type, \$auto_create_special;\n";
1841 print CF
"\$default_folder_prefix = '$default_folder_prefix';\n";
1842 print CF
"\$trash_folder = '$trash_folder';\n";
1843 print CF
"\$sent_folder = '$sent_folder';\n";
1844 print CF
"\$draft_folder = '$draft_folder';\n";
1845 print CF
"\$default_move_to_trash = $default_move_to_trash;\n";
1846 print CF
"\$default_move_to_sent = $default_move_to_sent;\n";
1847 print CF
"\$default_save_as_draft = $default_save_as_draft;\n";
1848 print CF
"\$show_prefix_option = $show_prefix_option;\n";
1849 print CF
"\$list_special_folders_first = $list_special_folders_first;\n";
1850 print CF
"\$use_special_folder_color = $use_special_folder_color;\n";
1851 print CF
"\$auto_expunge = $auto_expunge;\n";
1852 print CF
"\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1853 print CF
"\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1854 print CF
"\$default_unseen_notify = $default_unseen_notify;\n";
1855 print CF
"\$default_unseen_type = $default_unseen_type;\n";
1856 print CF
"\$auto_create_special = $auto_create_special;\n";
1859 print CF
"global \$default_charset;\n";
1860 print CF
"global \$data_dir, \$attachment_dir, \$dir_hash_level;\n";
1861 print CF
"global \$default_left_size, \$force_username_lowercase;\n";
1862 print CF
"global \$default_use_priority, \$hide_sm_attributions;\n";
1863 print CF
"\$default_charset = '$default_charset';\n";
1864 print CF
"\$data_dir = '$data_dir';\n";
1865 print CF
"\$attachment_dir = \"$attachment_dir\";\n";
1866 print CF
"\$dir_hash_level = $dir_hash_level;\n";
1867 print CF
"\$default_left_size = $default_left_size;\n";
1868 print CF
"\$force_username_lowercase = $force_username_lowercase;\n";
1869 print CF
"\$default_use_priority = $default_use_priority;\n";
1870 print CF
"\$hide_sm_attributions = $hide_sm_attributions;\n";
1873 print CF
"global \$plugins;\n";
1874 for ($ct=0; $ct <= $#plugins; $ct++) {
1875 print CF
"\$plugins[$ct] = '$plugins[$ct]';\n";
1879 print CF
"global \$theme_css, \$theme;\n";
1880 print CF
"\$theme_css = '$theme_css';\n";
1881 for ($count=0; $count <= $#theme_name; $count++) {
1882 print CF
"\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
1883 print CF
"\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
1887 if ($default_use_javascript_addr_book ne "true") {
1888 $default_use_javascript_addr_book = "false";
1890 print CF
"global \$default_use_javascript_addr_book, \$ldap_server;\n";
1891 print CF
"\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1892 for ($count=0; $count <= $#ldap_host; $count++) {
1893 print CF
"\$ldap_server[$count] = array(\n";
1894 print CF
" 'host' => '$ldap_host[$count]',\n";
1895 print CF
" 'base' => '$ldap_base[$count]'";
1896 if ($ldap_name[$count]) {
1898 print CF
" 'name' => '$ldap_name[$count]'";
1900 if ($ldap_port[$count]) {
1902 print CF
" 'port' => '$ldap_port[$count]'";
1904 if ($ldap_charset[$count]) {
1906 print CF
" 'charset' => '$ldap_charset[$count]'";
1908 if ($ldap_maxrows[$count]) {
1910 print CF
" 'maxrows' => '$ldap_maxrows[$count]'";
1918 print CF
" * Make sure there are no characters after the PHP closing\n";
1919 print CF
" * tag below (including newline characters and whitespace).\n";
1920 print CF
" * Otherwise, that character will cause the headers to be\n";
1921 print CF
" * sent and regular output to begin, which will majorly screw\n";
1922 print CF
" * things up when we try to send more headers later.\n";
1931 print $WHT."SquirrelMail Configuration : ".$NRM;
1932 if ($config == 1) { print "Read: config.php"; }
1933 elsif ($config == 2) { print "Read: config_default.php"; }
1935 print "---------------------------------------------------------\n";
1937 print "While we have been building SquirrelMail, we have discovered some\n";
1938 print "preferences that work better with some servers that don't work so\n";
1939 print "well with others. If you select your IMAP server, this option will\n";
1940 print "set some pre-defined settings for that server.\n";
1942 print "Please note that you will still need to go through and make sure\n";
1943 print "everything is correct. This does not change everything. There are\n";
1944 print "only a few settings that this will change.\n";
1948 while ($continue != 1) {
1949 print "Please select your IMAP server:\n";
1950 print " cyrus = Cyrus IMAP server\n";
1951 print " uw = University of Washington's IMAP server\n";
1952 print " exchange = Microsoft Exchange IMAP server\n";
1953 print " courier = Courier IMAP server\n";
1954 print " quit = Do not change anything\n";
1955 print "Command >> ";
1957 $server =~ s/[\r|\n]//g;
1960 if ($server eq "cyrus") {
1961 $imap_server_type = "cyrus";
1962 $default_folder_prefix = "";
1963 $trash_folder = "INBOX.Trash";
1964 $sent_folder = "INBOX.Sent";
1965 $draft_folder = "INBOX.Drafts";
1966 $show_prefix_option = false
;
1967 $default_sub_of_inbox = true
;
1968 $show_contain_subfolders_option = false
;
1969 $optional_delimiter = ".";
1970 $disp_default_folder_prefix = "<none>";
1973 } elsif ($server eq "uw") {
1974 $imap_server_type = "uw";
1975 $default_folder_prefix = "mail/";
1976 $trash_folder = "Trash";
1977 $sent_folder = "Sent";
1978 $draft_folder = "Drafts";
1979 $show_prefix_option = true
;
1980 $default_sub_of_inbox = false
;
1981 $show_contain_subfolders_option = true
;
1982 $optional_delimiter = "/";
1983 $disp_default_folder_prefix = $default_folder_prefix;
1986 } elsif ($server eq "exchange") {
1987 $imap_server_type = "exchange";
1988 $default_folder_prefix = "";
1989 $default_sub_of_inbox = true
;
1990 $trash_folder = "INBOX/Deleted Items";
1991 $sent_folder = "INBOX/Sent Items";
1992 $drafts_folder = "INBOX/Drafts";
1993 $show_prefix_option = false
;
1994 $show_contain_subfolders_option = false
;
1995 $optional_delimiter = "detect";
1996 $disp_default_folder_prefix = "<none>";
1999 } elsif ($server eq "courier") {
2000 $imap_server_type = "courier";
2001 $default_folder_prefix = "INBOX.";
2002 $trash_folder = "Trash";
2003 $sent_folder = "Sent";
2004 $draft_folder = "Drafts";
2005 $show_prefix_option = false
;
2006 $default_sub_of_inbox = false
;
2007 $show_contain_subfolders_option = false
;
2008 $optional_delimiter = ".";
2009 $disp_default_folder_prefix = $default_folder_prefix;
2012 } elsif ($server eq "quit") {
2015 $disp_default_folder_prefix = $default_folder_prefix;
2016 print "Unrecognized server: $server\n";
2020 print " imap_server_type = $imap_server_type\n";
2021 print " default_folder_prefix = $disp_default_folder_prefix\n";
2022 print " trash_folder = $trash_folder\n";
2023 print " sent_folder = $sent_folder\n";
2024 print " draft_folder = $draft_folder\n";
2025 print " show_prefix_option = $show_prefix_option\n";
2026 print " default_sub_of_inbox = $default_sub_of_inbox\n";
2027 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
2028 print " optional_delimiter = $optional_delimiter\n";
2030 print "\nPress any key to continue...";