5c73500d98d62ac124b09e567ae366bbbb5511c9
[squirrelmail.git] / config / conf.pl
1 #!/usr/bin/perl
2 # conf.pl
3 # Luke Ehresman (luke@squirrelmail.org)
4 #
5 # A simple configure script to configure squirrelmail
6 #
7 # $Id$
8 ############################################################
9 $conf_pl_version = "x63";
10
11 ############################################################
12 # Some people try to run this as a CGI. That's wrong!
13 ############################################################
14 if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) ||
15 defined($ENV{'REQUEST_METHOD'})) {
16 print "Content-Type: text/html\n\n";
17 print "You must run this script from the command line.";
18 exit;
19 }
20
21 ############################################################
22 # First, lets read in the data already in there...
23 ############################################################
24 if ( -e "config.php") {
25 open (FILE, "config.php");
26 while ($line = <FILE>) {
27 if ($line =~ /^\s+\$/) {
28 $line =~ s/^\s+\$//;
29 $var = $line;
30
31 $var =~ s/=/EQUALS/;
32 if ($var =~ /^([a-z]|[A-Z])/) {
33 @o = split(/\s*EQUALS\s*/, $var);
34 if ($o[0] eq "config_version") {
35 $o[1] =~ s/[\n|\r]//g;
36 $o[1] =~ s/\";\s*$//;
37 $o[1] =~ s/;$//;
38 $o[1] =~ s/^"//;
39
40 $config_version = $o[1];
41 close (FILE);
42 }
43 }
44 }
45 }
46 close (FILE);
47
48 if ($config_version ne $conf_pl_version) {
49 system "clear";
50 print $WHT."WARNING:\n".$NRM;
51 print " The file \"config/config.php\" was found, but it is for an older version of\n";
52 print " SquirrelMail. It is possible to still read the defaults from this file\n";
53 print " but be warned that many preferences change between versions. It is\n";
54 print " recommended that you start with a clean config.php for each upgrade that\n";
55 print " you do. To do this, just move config/config.php out of the way.\n\n";
56 print "Continue loading with the old config.php [y/N]? ";
57 $ctu = <STDIN>;
58 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
59 exit;
60 }
61
62 print "\nDo you want me to stop warning you [y/N]? ";
63 $ctu = <STDIN>;
64 if ($ctu =~ /^y\n/i) {
65 $print_config_version = $conf_pl_version;
66 } else {
67 $print_config_version = $config_version;
68 }
69 } else {
70 $print_config_version = $config_version;
71 }
72
73 $config = 1;
74 open (FILE, "config.php");
75 } elsif (-e "config_default.php") {
76 open (FILE, "config_default.php");
77 while ($line = <FILE>) {
78 if ($line =~ /^\s+\$/) {
79 $line =~ s/^\s+\$//;
80 $var = $line;
81
82 $var =~ s/=/EQUALS/;
83 if ($var =~ /^([a-z]|[A-Z])/) {
84 @o = split(/\s*EQUALS\s*/, $var);
85 if ($o[0] eq "config_version") {
86 $o[1] =~ s/[\n|\r]//g;
87 $o[1] =~ s/\";\s*$//;
88 $o[1] =~ s/;$//;
89 $o[1] =~ s/^"//;
90
91 $config_version = $o[1];
92 close (FILE);
93 }
94 }
95 }
96 }
97 close (FILE);
98
99 if ($config_version ne $conf_pl_version) {
100 system "clear";
101 print $WHT."WARNING:\n".$NRM;
102 print " You are trying to use a \"config_default.php\" from an older version of\n";
103 print " SquirrelMail. This is HIGHLY unrecommended. You should get the\n";
104 print " \"config_default.php\" that matches the version of SquirrelMail that you\n";
105 print " are running. You can get this from the SquirrelMail web page by going\n";
106 print " to: http://www.squirrelmail.org.\n\n";
107 print "Continue loading with the old config_default.php (not a good idea) [y/N]? ";
108 $ctu = <STDIN>;
109 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
110 exit;
111 }
112
113 print "\nDo you want me to stop warning you [y/N]? ";
114 $ctu = <STDIN>;
115 if ($ctu =~ /^y\n/i) {
116 $print_config_version = $conf_pl_version;
117 } else {
118 $print_config_version = $config_version;
119 }
120 } else {
121 $print_config_version = $config_version;
122 }
123 $config = 2;
124 open (FILE, "config_default.php");
125 } else {
126 print "No configuration file found. Please get config_default.php or\n";
127 print "config.php before running this again. This program needs a\n";
128 print "default config file to get default values.\n";
129 exit;
130 }
131
132 # Reads and parses the current configuration file (either
133 # config.php or config_default.php).
134
135 while ($line = <FILE>) {
136 if ($line =~ /^\s+\$/) {
137 $line =~ s/^\s+\$//;
138 $var = $line;
139
140 $var =~ s/=/EQUALS/;
141 if ($var =~ /^([a-z]|[A-Z])/) {
142 @options = split(/\s*EQUALS\s*/, $var);
143 $options[1] =~ s/[\n|\r]//g;
144 $options[1] =~ s/\";\s*$//;
145 $options[1] =~ s/;$//;
146 $options[1] =~ s/^\"//;
147
148 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
149 $sub = $options[0];
150 $sub =~ s/\]\["PATH"\]//;
151 $sub =~ s/.*\[//;
152 if (-e "../themes") {
153 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
154 }
155 $theme_path[$sub] = $options[1];
156 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
157 $sub = $options[0];
158 $sub =~ s/\]\["NAME"\]//;
159 $sub =~ s/.*\[//;
160 $theme_name[$sub] = $options[1];
161 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
162 $sub = $options[0];
163 $sub =~ s/\]//;
164 $sub =~ s/^plugins\[//;
165 $plugins[$sub] = $options[1];
166 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
167 $sub = $options[0];
168 $sub =~ s/\]//;
169 $sub =~ s/^ldap_server\[//;
170 $continue = 0;
171 while (($tmp = <FILE>) && ($continue != 1)) {
172 if ($tmp =~ /\);\s*$/) {
173 $continue = 1;
174 }
175
176 if ($tmp =~ /^\s*\"host\"/i) {
177 $tmp =~ s/^\s*\"host\"\s*=>\s*\"//i;
178 $tmp =~ s/\",\s*$//;
179 $tmp =~ s/\"\);\s*$//;
180 $host = $tmp;
181 } elsif ($tmp =~ /^\s*\"base\"/i) {
182 $tmp =~ s/^\s*\"base\"\s*=>\s*\"//i;
183 $tmp =~ s/\",\s*$//;
184 $tmp =~ s/\"\);\s*$//;
185 $base = $tmp;
186 } elsif ($tmp =~ /^\s*\"charset\"/i) {
187 $tmp =~ s/^\s*\"charset\"\s*=>\s*\"//i;
188 $tmp =~ s/\",\s*$//;
189 $tmp =~ s/\"\);\s*$//;
190 $charset = $tmp;
191 } elsif ($tmp =~ /^\s*\"port\"/i) {
192 $tmp =~ s/^\s*\"port\"\s*=>\s*\"//i;
193 $tmp =~ s/\",\s*$//;
194 $tmp =~ s/\"\);\s*$//;
195 $port = $tmp;
196 } elsif ($tmp =~ /^\s*\"maxrows\"/i) {
197 $tmp =~ s/^\s*\"maxrows\"\s*=>\s*\"//i;
198 $tmp =~ s/\",\s*$//;
199 $tmp =~ s/\"\);\s*$//;
200 $maxrows = $tmp;
201 } elsif ($tmp =~ /^\s*\"name\"/i) {
202 $tmp =~ s/^\s*\"name\"\s*=>\s*\"//i;
203 $tmp =~ s/\",\s*$//;
204 $tmp =~ s/\"\);\s*$//;
205 $name = $tmp;
206 }
207 }
208 $ldap_host[$sub] = $host;
209 $ldap_base[$sub] = $base;
210 $ldap_name[$sub] = $name;
211 $ldap_port[$sub] = $port;
212 $ldap_maxrows[$sub] = $maxrows;
213 $ldap_charset[$sub] = $charset;
214 } else {
215 ${$options[0]} = $options[1];
216 }
217 }
218 }
219 }
220 close FILE;
221 if ($useSendmail ne "true") {
222 $useSendmail = "false";
223 }
224 if (!$sendmail_path) {
225 $sendmail_path = "/usr/sbin/sendmail";
226 }
227 if (!$default_unseen_notify) {
228 $default_unseen_notify = 2;
229 }
230 if (!$default_unseen_type) {
231 $default_unseen_type = 1;
232 }
233 if (!$config_use_color) {
234 $config_use_color = 1;
235 }
236 if (!$invert_time) {
237 $invert_time = "false";
238 }
239 if (!$force_username_lowercase) {
240 $force_username_lowercase = "false";
241 }
242 if (!$optional_delimiter) {
243 $optional_delimiter = "detect";
244 }
245 if (!$use_authenticated_smtp) {
246 $use_authenticated_smtp = "false";
247 }
248
249 #####################################################################################
250 if ($config_use_color == 1) {
251 $WHT = "\x1B[37;1m";
252 $NRM = "\x1B[0m";
253 } else {
254 $WHT = "";
255 $NRM = "";
256 $config_use_color = 2;
257 }
258
259 while (($command ne "q") && ($command ne "Q")) {
260 system "clear";
261 print $WHT."SquirrelMail Configuration : ".$NRM;
262 if ($config == 1) { print "Read: config.php"; }
263 elsif ($config == 2) { print "Read: config_default.php"; }
264 print "\n";
265 print "---------------------------------------------------------\n";
266
267 if ($menu == 0) {
268 print $WHT."Main Menu --\n".$NRM;
269 print "1. Organization Preferences\n";
270 print "2. Server Settings\n";
271 print "3. Folder Defaults\n";
272 print "4. General Options\n";
273 print "5. Themes\n";
274 print "6. Address Books (LDAP)\n";
275 print "7. Message of the Day (MOTD)\n";
276 print "8. Plugins\n";
277 print "\n";
278 print "D. Set pre-defined settings for specific IMAP servers\n";
279 print "\n";
280 } elsif ($menu == 1) {
281 print $WHT."Organization Preferences\n".$NRM;
282 print "1. Organization Name : $WHT$org_name$NRM\n";
283 print "2. Organization Logo : $WHT$org_logo$NRM\n";
284 print "3. Organization Title : $WHT$org_title$NRM\n";
285 print "4. Signout Page : $WHT$signout_page$NRM\n";
286 print "5. Default Language : $WHT$squirrelmail_default_language$NRM\n";
287 print "\n";
288 print "R Return to Main Menu\n";
289 } elsif ($menu == 2) {
290 print $WHT."Server Settings\n".$NRM;
291 print "1. Domain : $WHT$domain$NRM\n";
292 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
293 print "3. IMAP Port : $WHT$imapPort$NRM\n";
294 print "4. Use Sendmail/SMTP : $WHT";
295 if ($useSendmail eq "true") {
296 print "Sendmail";
297 } else {
298 print "SMTP";
299 }
300 print "$NRM\n";
301 if ($useSendmail eq "true") {
302 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
303 } else {
304 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
305 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
306 print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
307 }
308 print "9. Server : $WHT$imap_server_type$NRM\n";
309 print "10. Invert Time : $WHT$invert_time$NRM\n";
310 print "11. Delimiter : $WHT$optional_delimiter$NRM\n";
311 print "\n";
312 print "R Return to Main Menu\n";
313 } elsif ($menu == 3) {
314 print $WHT."Folder Defaults\n".$NRM;
315 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
316 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
317 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
318 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
319 print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
320 print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
321 print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
322 print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
323 print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
324 print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
325 print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
326 print "12. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
327 print "13. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
328 print "\n";
329 print "R Return to Main Menu\n";
330 } elsif ($menu == 4) {
331 print $WHT."General Options\n".$NRM;
332 print "1. Default Charset : $WHT$default_charset$NRM\n";
333 print "2. Data Directory : $WHT$data_dir$NRM\n";
334 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
335 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
336 print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
337 print "\n";
338 print "R Return to Main Menu\n";
339 } elsif ($menu == 5) {
340 print $WHT."Themes\n".$NRM;
341 print "1. Change Themes\n";
342 for ($count = 0; $count <= $#theme_name; $count++) {
343 print " > $theme_name[$count]\n";
344 }
345 print "2. CSS File : $WHT$theme_css$NRM\n";
346 print "\n";
347 print "R Return to Main Menu\n";
348 } elsif ($menu == 6) {
349 print $WHT."Address Books (LDAP)\n".$NRM;
350 print "1. Change Servers\n";
351 for ($count = 0; $count <= $#ldap_host; $count++) {
352 print " > $ldap_host[$count]\n";
353 }
354 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
355 print "\n";
356 print "R Return to Main Menu\n";
357 } elsif ($menu == 7) {
358 print $WHT."Message of the Day (MOTD)\n".$NRM;
359 print "\n$motd\n";
360 print "\n";
361 print "1 Edit the MOTD\n";
362 print "\n";
363 print "R Return to Main Menu\n";
364 } elsif ($menu == 8) {
365 print $WHT."Plugins\n".$NRM;
366 print " Installed Plugins\n";
367 $num = 0;
368 for ($count = 0; $count <= $#plugins; $count++) {
369 $num = $count + 1;
370 print " $num. $plugins[$count]\n";
371 }
372 print "\n Available Plugins:\n";
373 opendir(DIR, "../plugins");
374 @files = readdir(DIR);
375 $pos=0;
376 @unused_plugins = ();
377 for ($i=0; $i <= $#files; $i++) {
378 if ( -d "../plugins/" . $files[$i] &&
379 $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
380 $match = 0;
381 for ($k=0; $k<=$#plugins; $k++) {
382 if ($plugins[$k] eq $files[$i]) {
383 $match = 1;
384 }
385 }
386 if ($match == 0) {
387 $unused_plugins[$pos] = $files[$i];
388 $pos++;
389 }
390 }
391 }
392
393 for ($i=0; $i<=$#unused_plugins; $i++) {
394 $num = $num + 1;
395 print " $num. $unused_plugins[$i]\n";
396 }
397 closedir DIR;
398
399 print "\n";
400 print "R Return to Main Menu\n";
401 }
402 if ($config_use_color == 1) {
403 print "C. Turn color off\n";
404 } else {
405 print "C. Turn color on\n";
406 }
407 print "S Save data\n";
408 print "Q Quit\n";
409
410 print "\n";
411 print "Command >> ".$WHT;
412 $command = <STDIN>;
413 $command =~ s/[\n|\r]//g;
414 $command =~ tr/A-Z/a-z/;
415 print "$NRM\n";
416
417 # Read the commands they entered.
418 if ($command eq "r") {
419 $menu = 0;
420 } elsif ($command eq "s") {
421 save_data ();
422 print "Data saved in config.php\n";
423 print "Press enter to continue...";
424 $tmp = <STDIN>;
425 $saved = 1;
426 } elsif (($command eq "q") && ($saved == 0)) {
427 print "You have not saved your data.\n";
428 print "Save? [".$WHT."Y".$NRM."/n]: ";
429 $save = <STDIN>;
430 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
431 save_data ();
432 }
433 } elsif ($command eq "c") {
434 if ($config_use_color == 1) {
435 $config_use_color = 2;
436 $WHT = "";
437 $NRM = "";
438 } else {
439 $config_use_color = 1;
440 $WHT = "\x1B[37;1m";
441 $NRM = "\x1B[0m";
442 }
443 } elsif ($command eq "d" && $menu == 0) {
444 set_defaults ();
445 } else {
446 $saved = 0;
447 if ($menu == 0) {
448 if (($command > 0) && ($command < 9)) {
449 $menu = $command;
450 }
451 } elsif ($menu == 1) {
452 if ($command == 1) { $org_name = command1 (); }
453 elsif ($command == 2) { $org_logo = command2 (); }
454 elsif ($command == 3) { $org_title = command3 (); }
455 elsif ($command == 4) { $signout_page = command4 (); }
456 elsif ($command == 5) { $squirrelmail_default_language = command5(); }
457 } elsif ($menu == 2) {
458 if ($command == 1) { $domain = command11 (); }
459 elsif ($command == 2) { $imapServerAddress = command12 (); }
460 elsif ($command == 3) { $imapPort = command13 (); }
461 elsif ($command == 4) { $useSendmail = command14 (); }
462 elsif ($command == 5) { $sendmail_path = command15 (); }
463 elsif ($command == 6) { $smtpServerAddress = command16 (); }
464 elsif ($command == 7) { $smtpPort = command17 (); }
465 elsif ($command == 8) { $use_authenticated_smtp = command18 (); }
466 elsif ($command == 9) { $imap_server_type = command19 (); }
467 elsif ($command == 10) { $invert_time = command110 (); }
468 elsif ($command == 11) { $optional_delimiter = command111 (); }
469 } elsif ($menu == 3) {
470 if ($command == 1) { $default_folder_prefix = command21 (); }
471 elsif ($command == 2) { $show_prefix_option = command22 (); }
472 elsif ($command == 3) { $trash_folder = command23 (); }
473 elsif ($command == 4) { $sent_folder = command24 (); }
474 elsif ($command == 5) { $default_move_to_trash = command25 (); }
475 elsif ($command == 6) { $default_move_to_sent = command26 (); }
476 elsif ($command == 7) { $list_special_folders_first = command27 (); }
477 elsif ($command == 8) { $use_special_folder_color = command28 (); }
478 elsif ($command == 9) { $auto_expunge = command29 (); }
479 elsif ($command == 10){ $default_sub_of_inbox = command210(); }
480 elsif ($command == 11){ $show_contain_subfolders_option = command211(); }
481 elsif ($command == 12){ $default_unseen_notify = command212(); }
482 elsif ($command == 13){ $default_unseen_type = command213(); }
483 } elsif ($menu == 4) {
484 if ($command == 1) { $default_charset = command31 (); }
485 elsif ($command == 2) { $data_dir = command33 (); }
486 elsif ($command == 3) { $attachment_dir = command34 (); }
487 elsif ($command == 4) { $default_left_size = command35 (); }
488 elsif ($command == 5) { $force_username_lowercase = command36 (); }
489 } elsif ($menu == 5) {
490 if ($command == 1) { command41 (); }
491 elsif ($command == 2) { $theme_css = command42 (); }
492 } elsif ($menu == 6) {
493 if ($command == 1) { command61(); }
494 elsif ($command == 2) { command62(); }
495 } elsif ($menu == 7) {
496 if ($command == 1) { $motd = command71(); }
497 } elsif ($menu == 8) {
498 if ($command =~ /^[0-9]+/) { @plugins = command81(); }
499 }
500 }
501 }
502
503 ####################################################################################
504
505 # org_name
506 sub command1 {
507 print "We have tried to make the name SquirrelMail as transparent as\n";
508 print "possible. If you set up an organization name, most places where\n";
509 print "SquirrelMail would take credit will be credited to your organization.\n";
510 print "\n";
511 print "[$WHT$org_name$NRM]: $WHT";
512 $new_org_name = <STDIN>;
513 if ($new_org_name eq "\n") {
514 $new_org_name = $org_name;
515 } else {
516 $new_org_name =~ s/[\r|\n]//g;
517 }
518 return $new_org_name;
519 }
520
521
522 # org_logo
523 sub command2 {
524 print "Your organization's logo is an image that will be displayed at\n";
525 print "different times throughout SquirrelMail. This is asking for the\n";
526 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
527 print "(../images/logo.jpg) path to your logo.\n";
528 print "\n";
529 print "[$WHT$org_logo$NRM]: $WHT";
530 $new_org_logo = <STDIN>;
531 if ($new_org_logo eq "\n") {
532 $new_org_logo = $org_logo;
533 } else {
534 $new_org_logo =~ s/[\r|\n]//g;
535 }
536 return $new_org_logo;
537 }
538
539 # org_title
540 sub command3 {
541 print "A title is what is displayed at the top of the browser window in\n";
542 print "the titlebar. Usually this will end up looking something like:\n";
543 print "\"Netscape: $org_title\"\n";
544 print "\n";
545 print "[$WHT$org_title$NRM]: $WHT";
546 $new_org_title = <STDIN>;
547 if ($new_org_title eq "\n") {
548 $new_org_title = $org_title;
549 } else {
550 $new_org_title =~ s/[\r|\n]//g;
551 }
552 return $new_org_title;
553 }
554
555 # signout_page
556 sub command4 {
557 print "When users click the Sign Out button they will be logged out and\n";
558 print "then sent to signout_page. If signout_page is left empty,\n";
559 print "(hit space and then return) they will be taken, as normal,\n";
560 print "to the default and rather sparse SquirrelMail signout page.\n";
561 print "\n";
562 print "[$WHT$signout_page$NRM]: $WHT";
563 $new_signout_page = <STDIN>;
564 if ($new_signout_page eq "\n") {
565 $new_signout_page = $signout_page;
566 } else {
567 $new_signout_page =~ s/[\r|\n]//g;
568 $new_signout_page =~ s/^\s+$//g;
569 }
570 return $new_signout_page;
571 }
572
573 # Default language
574 sub command5 {
575 print "SquirrelMail attempts to set the language in many ways. If it\n";
576 print "can not figure it out in another way, it will default to this\n";
577 print "language. Please use the two-letter code for the desired language.\n";
578 print "\n";
579 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
580 $new_signout_page = <STDIN>;
581 if ($new_signout_page eq "\n") {
582 $new_signout_page = $squirrelmail_default_language;
583 } else {
584 $new_signout_page =~ s/[\r|\n]//g;
585 $new_signout_page =~ s/^\s+$//g;
586 }
587 return $new_signout_page;
588 }
589
590 ####################################################################################
591
592 # domain
593 sub command11 {
594 print "The domain name is the suffix at the end of all email messages. If\n";
595 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
596 print "would be myorg.com.\n";
597 print "\n";
598 print "[$WHT$domain$NRM]: $WHT";
599 $new_domain = <STDIN>;
600 if ($new_domain eq "\n") {
601 $new_domain = $domain;
602 } else {
603 $new_domain =~ s/[\r|\n]//g;
604 }
605 return $new_domain;
606 }
607
608 # imapServerAddress
609 sub command12 {
610 print "This is the address where your IMAP server resides.\n";
611 print "[$WHT$imapServerAddress$NRM]: $WHT";
612 $new_imapServerAddress = <STDIN>;
613 if ($new_imapServerAddress eq "\n") {
614 $new_imapServerAddress = $imapServerAddress;
615 } else {
616 $new_imapServerAddress =~ s/[\r|\n]//g;
617 }
618 return $new_imapServerAddress;
619 }
620
621 # imapPort
622 sub command13 {
623 print "This is the port that your IMAP server is on. Usually this is 143.\n";
624 print "[$WHT$imapPort$NRM]: $WHT";
625 $new_imapPort = <STDIN>;
626 if ($new_imapPort eq "\n") {
627 $new_imapPort = $imapPort;
628 } else {
629 $new_imapPort =~ s/[\r|\n]//g;
630 }
631 return $new_imapPort;
632 }
633
634 # useSendmail
635 sub command14 {
636 print "You now need to choose the method that you will use for sending\n";
637 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
638 print "or use sendmail directly.\n";
639 if ($useSendmail eq "true") {
640 $default_value = "1";
641 } else {
642 $default_value = "2";
643 }
644 print "\n";
645 print " 1. Sendmail\n";
646 print " 2. SMTP\n";
647 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
648 $use_sendmail = <STDIN>;
649 if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
650 $useSendmail = "true";
651 } else {
652 $useSendmail = "false";
653 }
654 return $useSendmail;
655 }
656
657 # sendmail_path
658 sub command15 {
659 if ($sendmail_path[0] !~ /./) {
660 $sendmail_path = "/usr/sbin/sendmail";
661 }
662 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
663 print "[$WHT$sendmail_path$NRM]: $WHT";
664 $new_sendmail_path = <STDIN>;
665 if ($new_sendmail_path eq "\n") {
666 $new_sendmail_path = $sendmail_path;
667 } else {
668 $new_sendmail_path =~ s/[\r|\n]//g;
669 }
670 return $new_sendmail_path;
671 }
672
673 # smtpServerAddress
674 sub command16 {
675 print "This is the location of your SMTP server.\n";
676 print "[$WHT$smtpServerAddress$NRM]: $WHT";
677 $new_smtpServerAddress = <STDIN>;
678 if ($new_smtpServerAddress eq "\n") {
679 $new_smtpServerAddress = $smtpServerAddress;
680 } else {
681 $new_smtpServerAddress =~ s/[\r|\n]//g;
682 }
683 return $new_smtpServerAddress;
684 }
685
686 # smtpPort
687 sub command17 {
688 print "This is the port to connect to for SMTP. Usually 25.\n";
689 print "[$WHT$smtpPort$NRM]: $WHT";
690 $new_smtpPort = <STDIN>;
691 if ($new_smtpPort eq "\n") {
692 $new_smtpPort = $smtpPort;
693 } else {
694 $new_smtpPort =~ s/[\r|\n]//g;
695 }
696 return $new_smtpPort;
697 }
698
699 # authenticated server
700 sub command18 {
701 print "Do you wish to use an authenticated SMTP server? Your server must\n";
702 print "support this in order for SquirrelMail to work with it. We implemented\n";
703 print "it according to RFC 2554.\n";
704
705 $YesNo = 'n';
706 $YesNo = 'y' if ($use_authenticated_smtp eq "true");
707
708 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
709
710 $new_use_authenticated_smtp = <STDIN>;
711 $new_use_authenticated_smtp =~ tr/yn//cd;
712 return "true" if ($new_use_authenticated_smtp eq "y");
713 return "false" if ($new_use_authenticated_smtp eq "n");
714 return $use_authenticated_smtp;
715 }
716
717 # imap_server_type
718 sub command19 {
719 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
720 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
721 print "the same principles. We have made some work-arounds for some of\n";
722 print "these servers. If you would like to use them, please select your\n";
723 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
724 print "set this to \"other\", and none will be used.\n";
725 print " cyrus = Cyrus IMAP server\n";
726 print " uw = University of Washington's IMAP server\n";
727 print " exchange = Microsoft Exchange IMAP server\n";
728 print " courier = Courier IMAP server\n";
729 print " other = Not one of the above servers\n";
730 print "[$WHT$imap_server_type$NRM]: $WHT";
731 $new_imap_server_type = <STDIN>;
732 if ($new_imap_server_type eq "\n") {
733 $new_imap_server_type = $imap_server_type;
734 } else {
735 $new_imap_server_type =~ s/[\r|\n]//g;
736 }
737 return $new_imap_server_type;
738 }
739
740 # invert_time
741 sub command110 {
742 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
743 print "on some machines). Typically this happens if the system doesn't support\n";
744 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
745 print "This most often occurs on Solaris 7 machines in the United States.\n";
746 print "By default, this is off. It should be kept off unless problems surface\n";
747 print "about the time that messages are sent.\n";
748 print " no = Do NOT fix time -- almost always correct\n";
749 print " yes = Fix the time for this system\n";
750
751 $YesNo = 'n';
752 $YesNo = 'y' if ($invert_time eq "true");
753
754 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
755
756 $new_invert_time = <STDIN>;
757 $new_invert_time =~ tr/yn//cd;
758 return "true" if ($new_invert_time eq "y");
759 return "false" if ($new_invert_time eq "n");
760 return $invert_time;
761 }
762
763 sub command111 {
764 print "This is the delimiter that your IMAP server uses to distinguish between\n";
765 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
766 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
767 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
768 print "but if you are sure you konw what delimiter your server uses, you can\n";
769 print "specify it here.\n";
770 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
771 print "[$WHT$optional_delimiter$NRM]: $WHT";
772 $new_optional_delimiter = <STDIN>;
773 if ($new_optional_delimiter eq "\n") {
774 $new_optional_delimiter = $optional_delimiter;
775 } else {
776 $new_optional_delimiter =~ s/[\r|\n]//g;
777 }
778 return $new_optional_delimiter;
779 }
780
781 # MOTD
782 sub command71 {
783 print "\nYou can now create the welcome message that is displayed\n";
784 print "every time a user logs on. You can use HTML or just plain\n";
785 print "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
786
787 $new_motd = "";
788 do {
789 print "] ";
790 $line = <STDIN>;
791 $line =~ s/[\r|\n]//g;
792 if ($line ne "@") {
793 $line =~ s/ /\&nbsp;\&nbsp;/g;
794 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
795 $line =~ s/$/ /;
796 $line =~ s/\"/\\\"/g;
797
798 $new_motd = $new_motd . $line;
799 }
800 } while ($line ne "@");
801 return $new_motd;
802 }
803
804 ################# PLUGINS ###################
805
806 sub command81 {
807 $command =~ s/[\s|\n|\r]*//g;
808 if ($command > 0) {
809 $command = $command - 1;
810 if ($command <= $#plugins) {
811 @newplugins = ();
812 $ct=0;
813 while ($ct <= $#plugins) {
814 if ($ct != $command) {
815 @newplugins = (@newplugins, $plugins[$ct]);
816 }
817 $ct++;
818 }
819 @plugins = @newplugins;
820 } elsif ($command <= $#plugins + $#unused_plugins + 1) {
821 $num = $command - $#plugins - 1;
822 @newplugins = @plugins;
823 $ct=0;
824 while ($ct <= $#unused_plugins) {
825 if ($ct == $num) {
826 @newplugins = (@newplugins, $unused_plugins[$ct]);
827 }
828 $ct++;
829 }
830 @plugins = @newplugins;
831 }
832 }
833 return @plugins;
834 }
835
836 ################# FOLDERS ###################
837
838 # default_folder_prefix
839 sub command21 {
840 print "Some IMAP servers (UW, for example) store mail and folders in\n";
841 print "your user space in a separate subdirectory. This is where you\n";
842 print "specify what that directory is.\n";
843 print "\n";
844 print "EXAMPLE: mail/";
845 print "\n";
846 print "NOTE: If you use Cyrus, or some server that would not use this\n";
847 print " option, you must set this to 'none'.\n";
848 print "\n";
849 print "[$WHT$default_folder_prefix$NRM]: $WHT";
850 $new_default_folder_prefix = <STDIN>;
851 if ($new_default_folder_prefix eq "\n") {
852 $new_default_folder_prefix = $default_folder_prefix;
853 } else {
854 $new_default_folder_prefix =~ s/[\r|\n]//g;
855 }
856 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
857 $new_default_folder_prefix = "";
858 } else {
859 $new_default_folder_prefix =~ s/\/*$//g;
860 $new_default_folder_prefix =~ s/$/\//g;
861 }
862 return $new_default_folder_prefix;
863 }
864
865 # Show Folder Prefix
866 sub command22 {
867 print "It is possible to set up the default folder prefix as a user\n";
868 print "specific option, where each user can specify what their mail\n";
869 print "folder is. If you set this to false, they will never see the\n";
870 print "option, but if it is true, this option will appear in the\n";
871 print "'options' section.\n";
872 print "\n";
873 print "NOTE: You set the default folder prefix in option '1' of this\n";
874 print " section. That will be the default if the user doesn't\n";
875 print " specify anything different.\n";
876 print "\n";
877
878 if ($show_prefix_option eq "true") {
879 $default_value = "y";
880 } else {
881 $default_value = "n";
882 }
883 print "\n";
884 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
885 $new_show = <STDIN>;
886 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
887 $show_prefix_option = "true";
888 } else {
889 $show_prefix_option = "false";
890 }
891 return $show_prefix_option;
892 }
893
894 # Trash Folder
895 sub command23 {
896 print "You can now specify where the default trash folder is located.\n";
897 print "On servers where you do not want this, you can set it to anything\n";
898 print "and set option 7 to false.\n";
899 print "\n";
900 print "This is relative to where the rest of your email is kept. You do\n";
901 print "not need to worry about their mail directory. If this folder\n";
902 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
903 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
904 print "\n";
905
906 print "[$WHT$trash_folder$NRM]: $WHT";
907 $new_trash_folder = <STDIN>;
908 if ($new_trash_folder eq "\n") {
909 $new_trash_folder = $trash_folder;
910 } else {
911 $new_trash_folder =~ s/[\r|\n]//g;
912 }
913 return $new_trash_folder;
914 }
915
916 # Sent Folder
917 sub command24 {
918 print "This is where messages that are sent will be stored. SquirrelMail\n";
919 print "by default puts a copy of all outgoing messages in this folder.\n";
920 print "\n";
921 print "This is relative to where the rest of your email is kept. You do\n";
922 print "not need to worry about their mail directory. If this folder\n";
923 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
924 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
925 print "\n";
926
927 print "[$WHT$sent_folder$NRM]: $WHT";
928 $new_sent_folder = <STDIN>;
929 if ($new_sent_folder eq "\n") {
930 $new_sent_folder = $sent_folder;
931 } else {
932 $new_sent_folder =~ s/[\r|\n]//g;
933 }
934 return $new_sent_folder;
935 }
936
937 # default move to trash
938 sub command25 {
939 print "By default, should messages get moved to the trash folder? You\n";
940 print "can specify the default trash folder in option 3. If this is set\n";
941 print "to false, messages will get deleted immediately without moving\n";
942 print "to the trash folder.\n";
943 print "\n";
944 print "Trash folder is currently: $trash_folder\n";
945 print "\n";
946
947 if ($default_move_to_trash eq "true") {
948 $default_value = "y";
949 } else {
950 $default_value = "n";
951 }
952 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
953 $new_show = <STDIN>;
954 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
955 $default_move_to_trash = "true";
956 } else {
957 $default_move_to_trash = "false";
958 }
959 return $default_move_to_trash;
960 }
961
962 # default move to sent
963 sub command26 {
964 print "By default, should messages get moved to the sent folder? You\n";
965 print "can specify the default sent folder in option 4. If this is set\n";
966 print "to false, messages will get sent an no copy will be made.\n";
967 print "\n";
968 print "Trash folder is currently: $sent_folder\n";
969 print "\n";
970
971 if ($default_move_to_sent eq "true") {
972 $default_value = "y";
973 } else {
974 $default_value = "n";
975 }
976 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
977 $new_show = <STDIN>;
978 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
979 $default_move_to_sent = "true";
980 } else {
981 $default_move_to_sent = "false";
982 }
983 return $default_move_to_sent;
984 }
985
986 # List special folders first
987 sub command27 {
988 print "SquirrelMail has what we call 'special folders' that are not\n";
989 print "manipulated and viewed like normal folders. Some examples of\n";
990 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
991 print "Simply asks if you want these folders listed first in the folder\n";
992 print "listing.\n";
993 print "\n";
994
995 if ($list_special_folders_first eq "true") {
996 $default_value = "y";
997 } else {
998 $default_value = "n";
999 }
1000 print "\n";
1001 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1002 $new_show = <STDIN>;
1003 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1004 $list_special_folders_first = "true";
1005 } else {
1006 $list_special_folders_first = "false";
1007 }
1008 return $list_special_folders_first;
1009 }
1010
1011 # Show special folders color
1012 sub command28 {
1013 print "SquirrelMail has what we call 'special folders' that are not\n";
1014 print "manipulated and viewed like normal folders. Some examples of\n";
1015 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1016 print "wants to know if we should display special folders in a\n";
1017 print "color than the other folders.\n";
1018 print "\n";
1019
1020 if ($use_special_folder_color eq "true") {
1021 $default_value = "y";
1022 } else {
1023 $default_value = "n";
1024 }
1025 print "\n";
1026 print "Show color (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 $use_special_folder_color = "true";
1030 } else {
1031 $use_special_folder_color = "false";
1032 }
1033 return $use_special_folder_color;
1034 }
1035
1036 # Auto expunge
1037 sub command29 {
1038 print "The way that IMAP handles deleting messages is as follows. You\n";
1039 print "mark the message as deleted, and then to 'really' delete it, you\n";
1040 print "expunge it. This option asks if you want to just have messages\n";
1041 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1042 print "messages too.\n";
1043 print "\n";
1044
1045 if ($auto_expunge eq "true") {
1046 $default_value = "y";
1047 } else {
1048 $default_value = "n";
1049 }
1050 print "Auto expunge (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 $auto_expunge = "true";
1054 } else {
1055 $auto_expunge = "false";
1056 }
1057 return $auto_expunge;
1058 }
1059
1060 # Default sub of inbox
1061 sub command210 {
1062 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1063 print "This can cause some confusion in folder creation for users when\n";
1064 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1065 print "and get permission errors. This option asks if you want folders\n";
1066 print "to be subfolders of INBOX by default.\n";
1067 print "\n";
1068
1069 if ($default_sub_of_inbox eq "true") {
1070 $default_value = "y";
1071 } else {
1072 $default_value = "n";
1073 }
1074 print "Default sub of INBOX (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_sub_of_inbox = "true";
1078 } else {
1079 $default_sub_of_inbox = "false";
1080 }
1081 return $default_sub_of_inbox;
1082 }
1083
1084 # Show contain subfolder option
1085 sub command211 {
1086 print "Some IMAP servers (UW) make it so that there are two types of\n";
1087 print "folders. Those that contain messages, and those that contain\n";
1088 print "subfolders. If this is the case for your server, set this to\n";
1089 print "true, and it will ask the user whether the folder they are\n";
1090 print "creating contains subfolders or messages.\n";
1091 print "\n";
1092
1093 if ($show_contain_subfolders_option eq "true") {
1094 $default_value = "y";
1095 } else {
1096 $default_value = "n";
1097 }
1098 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1099 $new_show = <STDIN>;
1100 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1101 $show_contain_subfolders_option = "true";
1102 } else {
1103 $show_contain_subfolders_option = "false";
1104 }
1105 return $show_contain_subfolders_option;
1106 }
1107
1108 # Default Unseen Notify
1109 sub command212 {
1110 print "This option specifies where the users will receive notification\n";
1111 print "about unseen messages by default. This is of course an option that\n";
1112 print "can be changed on a user level.\n";
1113 print " 1 = No notification\n";
1114 print " 2 = Only on the INBOX\n";
1115 print " 3 = On all folders\n";
1116 print "\n";
1117
1118 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1119 $new_show = <STDIN>;
1120 if ($new_show =~ /^[1|2|3]\n/i) {
1121 $default_unseen_notify = $new_show;
1122 }
1123 $default_unseen_notify =~ s/[\r|\n]//g;
1124 return $default_unseen_notify;
1125 }
1126
1127 # Default Unseen Type
1128 sub command213 {
1129 print "Here you can define the default way that unseen messages will be displayed\n";
1130 print "to the user in the folder listing on the left side.\n";
1131 print " 1 = Only unseen messages (4)\n";
1132 print " 2 = Unseen and Total messages (4/27)\n";
1133 print "\n";
1134
1135 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1136 $new_show = <STDIN>;
1137 if ($new_show =~ /^[1|2]\n/i) {
1138 $default_unseen_type = $new_show;
1139 }
1140 $default_unseen_type =~ s/[\r|\n]//g;
1141 return $default_unseen_type;
1142 }
1143
1144
1145 ############# GENERAL OPTIONS #####################
1146
1147 # Default Charset
1148 sub command31 {
1149 print "This option controls what character set is used when sending\n";
1150 print "mail and when sending HTML to the browser. Do not set this\n";
1151 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1152 print "to use KOI8-R, since this implementation is faster than most\n";
1153 print "of the alternatives\n";
1154 print "\n";
1155
1156 print "[$WHT$default_charset$NRM]: $WHT";
1157 $new_default_charset = <STDIN>;
1158 if ($new_default_charset eq "\n") {
1159 $new_default_charset = $default_charset;
1160 } else {
1161 $new_default_charset =~ s/[\r|\n]//g;
1162 }
1163 return $new_default_charset;
1164 }
1165
1166 # Data directory
1167 sub command33 {
1168 print "It is a possible security hole to have a writable directory\n";
1169 print "under the web server's root directory (ex: /home/httpd/html).\n";
1170 print "For this reason, it is possible to put the data directory\n";
1171 print "anywhere you would like. The path name can be absolute or\n";
1172 print "relative (to the config directory). It doesn't matter. Here\n";
1173 print "are two examples:\n";
1174 print " Absolute: /usr/local/squirrelmail/data/\n";
1175 print " Relative: ../data/\n";
1176 print "\n";
1177
1178 print "[$WHT$data_dir$NRM]: $WHT";
1179 $new_data_dir = <STDIN>;
1180 if ($new_data_dir eq "\n") {
1181 $new_data_dir = $data_dir;
1182 } else {
1183 $new_data_dir =~ s/[\r|\n]//g;
1184 }
1185 if ($new_data_dir =~ /^\s*$/) {
1186 $new_data_dir = "";
1187 } else {
1188 $new_data_dir =~ s/\/*$//g;
1189 $new_data_dir =~ s/$/\//g;
1190 }
1191 return $new_data_dir;
1192 }
1193
1194 # Attachment directory
1195 sub command34 {
1196 print "Path to directory used for storing attachments while a mail is\n";
1197 print "being sent. There are a few security considerations regarding this\n";
1198 print "directory:\n";
1199 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1200 print " impossible for a random person with access to the webserver\n";
1201 print " to list files in this directory. Confidential data might\n";
1202 print " be laying around in there.\n";
1203 print " 2. Since the webserver is not able to list the files in the\n";
1204 print " content is also impossible for the webserver to delete files\n";
1205 print " lying around there for too long.\n";
1206 print " 3. It should probably be another directory than the data\n";
1207 print " directory specified in option 3.\n";
1208 print "\n";
1209
1210 print "[$WHT$attachment_dir$NRM]: $WHT";
1211 $new_attachment_dir = <STDIN>;
1212 if ($new_attachment_dir eq "\n") {
1213 $new_attachment_dir = $attachment_dir;
1214 } else {
1215 $new_attachment_dir =~ s/[\r|\n]//g;
1216 }
1217 if ($new_attachment_dir =~ /^\s*$/) {
1218 $new_attachment_dir = "";
1219 } else {
1220 $new_attachment_dir =~ s/\/*$//g;
1221 $new_attachment_dir =~ s/$/\//g;
1222 }
1223 return $new_attachment_dir;
1224 }
1225
1226
1227 sub command35 {
1228 print "This is the default size (in pixels) of the left folder list.\n";
1229 print "Default is 200, but you can set it to whatever you wish. This\n";
1230 print "is a user preference, so this will only show up as their default.\n";
1231 print "\n";
1232 print "[$WHT$default_left_size$NRM]: $WHT";
1233 $new_default_left_size = <STDIN>;
1234 if ($new_default_left_size eq "\n") {
1235 $new_default_left_size = $default_left_size;
1236 } else {
1237 $new_default_left_size =~ s/[\r|\n]//g;
1238 }
1239 return $new_default_left_size;
1240 }
1241
1242
1243 sub command36 {
1244 print "Some IMAP servers only have lowercase letters in the usernames\n";
1245 print "but they still allow people with uppercase to log in. This\n";
1246 print "causes a problem with the user's preference files. This option\n";
1247 print "transparently changes all usernames to lowercase.";
1248 print "\n";
1249
1250 if ($force_username_lowercase eq "true") {
1251 $default_value = "y";
1252 } else {
1253 $default_value = "n";
1254 }
1255 print "Convert usernames to lowercase (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 return "true";
1259 }
1260 return "false";
1261 }
1262
1263
1264 sub command41 {
1265 print "\nNow we will define the themes that you wish to use. If you have added\n";
1266 print "a theme of your own, just follow the instructions (?) about how to add\n";
1267 print "them. You can also change the default theme.\n";
1268 print "[theme] command (?=help) > ";
1269 $input = <STDIN>;
1270 $input =~ s/[\r|\n]//g;
1271 while ($input ne "d") {
1272 if ($input =~ /^\s*l\s*/i) {
1273 $count = 0;
1274 while ($count <= $#theme_name) {
1275 if ($count == $theme_default) {
1276 print " *";
1277 } else {
1278 print " ";
1279 }
1280 $name = $theme_name[$count];
1281 $num_spaces = 25 - length($name);
1282 for ($i = 0; $i < $num_spaces;$i++) {
1283 $name = $name . " ";
1284 }
1285
1286 print " $count. $name";
1287 print "($theme_path[$count])\n";
1288
1289 $count++;
1290 }
1291 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1292 $old_def = $theme_default;
1293 $theme_default = $input;
1294 $theme_default =~ s/^\s*m\s*//;
1295 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1296 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1297 $theme_default = $old_def;
1298 }
1299 } elsif ($input =~ /^\s*\+/) {
1300 print "What is the name of this theme: ";
1301 $name = <STDIN>;
1302 $name =~ s/[\r|\n]//g;
1303 $theme_name[$#theme_name+1] = $name;
1304 print "Be sure to put ../themes/ before the filename.\n";
1305 print "What file is this stored in (ex: ../themes/default_theme.php): ";
1306 $name = <STDIN>;
1307 $name =~ s/[\r|\n]//g;
1308 $theme_path[$#theme_path+1] = $name;
1309 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1310 if ($input =~ /[0-9]+\s*$/) {
1311 $rem_num = $input;
1312 $rem_num =~ s/^\s*-\s*//g;
1313 $rem_num =~ s/\s*$//;
1314 } else {
1315 $rem_num = $#theme_name;
1316 }
1317 if ($rem_num == $theme_default) {
1318 print "You cannot remove the default theme!\n";
1319 } else {
1320 $count = 0;
1321 @new_theme_name = ();
1322 @new_theme_path = ();
1323 while ($count <= $#theme_name) {
1324 if ($count != $rem_num) {
1325 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1326 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1327 }
1328 $count++;
1329 }
1330 @theme_name = @new_theme_name;
1331 @theme_path = @new_theme_path;
1332 if ($theme_default > $rem_num) {
1333 $theme_default--;
1334 }
1335 }
1336 } elsif ($input =~ /^\s*t\s*/i) {
1337 print "\nStarting detection...\n\n";
1338
1339 opendir(DIR, "../themes");
1340 @files = grep { /\.php$/i } readdir(DIR);
1341 $cnt = 0;
1342 while ($cnt <= $#files) {
1343 $filename = "../themes/" . $files[$cnt];
1344 if ($filename ne "../themes/index.php") {
1345 $found = 0;
1346 for ($x=0; $x <= $#theme_path; $x++) {
1347 if ($theme_path[$x] eq $filename) {
1348 $found = 1;
1349 }
1350 }
1351 if ($found != 1) {
1352 print "** Found theme: $filename\n";
1353 print " What is its name? ";
1354 $nm = <STDIN>;
1355 $nm =~ s/[\n|\r]//g;
1356 $theme_name[$#theme_name+1] = $nm;
1357 $theme_path[$#theme_path+1] = $filename;
1358 }
1359 }
1360 $cnt++;
1361 }
1362 print "\n";
1363 for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
1364 $filename = $theme_path[$cnt];
1365 if (! (-e $filename)) {
1366 print " Removing $filename (file not found)\n";
1367 $offset = 0;
1368 @new_theme_name = ();
1369 @new_theme_path = ();
1370 for ($x=0; $x < $#theme_path; $x++) {
1371 if ($theme_path[$x] eq $filename) {
1372 $offset = 1;
1373 }
1374 if ($offset == 1) {
1375 $new_theme_name[$x] = $theme_name[$x+1];
1376 $new_theme_path[$x] = $theme_path[$x+1];
1377 } else {
1378 $new_theme_name[$x] = $theme_name[$x];
1379 $new_theme_path[$x] = $theme_path[$x];
1380 }
1381 }
1382 @theme_name = @new_theme_name;
1383 @theme_path = @new_theme_path;
1384 }
1385 }
1386 print "\nDetection complete!\n\n";
1387
1388 closedir DIR;
1389 } elsif ($input =~ /^\s*\?\s*/) {
1390 print ".-------------------------.\n";
1391 print "| t (detect themes) |\n";
1392 print "| + (add theme) |\n";
1393 print "| - N (remove theme) |\n";
1394 print "| m N (mark default) |\n";
1395 print "| l (list themes) |\n";
1396 print "| d (done) |\n";
1397 print "`-------------------------'\n";
1398 }
1399 print "[theme] command (?=help) > ";
1400 $input = <STDIN>;
1401 $input =~ s/[\r|\n]//g;
1402 }
1403 }
1404
1405
1406 # Theme - CSS file
1407 sub command42 {
1408 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1409 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1410 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1411 print "files, leave this blank.\n";
1412 print "\n";
1413 print "To clear out an existing value, just type a space for the input.\n";
1414 print "\n";
1415 print "[$WHT$theme_css$NRM]: $WHT";
1416 $new_theme_css = <STDIN>;
1417 if ($new_theme_css eq "\n") {
1418 $new_theme_css = $theme_css;
1419 } else {
1420 $new_theme_css =~ s/[\r|\n]//g;
1421 }
1422 $new_theme_css =~ s/^\s*//;
1423 return $new_theme_css;
1424 }
1425
1426
1427 sub command61 {
1428 print "You can now define different LDAP servers.\n";
1429 print "[ldap] command (?=help) > ";
1430 $input = <STDIN>;
1431 $input =~ s/[\r|\n]//g;
1432 while ($input ne "d") {
1433 if ($input =~ /^\s*l\s*/i) {
1434 $count = 0;
1435 while ($count <= $#ldap_host) {
1436 print "$count. $ldap_host[$count]\n";
1437 print " base: $ldap_base[$count]\n";
1438 if ($ldap_charset[$count]) {
1439 print " charset: $ldap_charset[$count]\n";
1440 }
1441 if ($ldap_port[$count]) {
1442 print " port: $ldap_port[$count]\n";
1443 }
1444 if ($ldap_name[$count]) {
1445 print " name: $ldap_name[$count]\n";
1446 }
1447 if ($ldap_maxrows[$count]) {
1448 print " maxrows: $ldap_maxrows[$count]\n";
1449 }
1450 print "\n";
1451 $count++;
1452 }
1453 } elsif ($input =~ /^\s*\+/) {
1454 $sub = $#ldap_host + 1;
1455
1456 print "First, we need to have the hostname or the IP address where\n";
1457 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1458 print "hostname: ";
1459 $name = <STDIN>;
1460 $name =~ s/[\r|\n]//g;
1461 $ldap_host[$sub] = $name;
1462
1463 print "\n";
1464
1465 print "Next, we need the server root (base dn). For this, an empty\n";
1466 print "string is allowed.\n";
1467 print "Example: ou=member_directory,o=netcenter.com\n";
1468 print "base: ";
1469 $name = <STDIN>;
1470 $name =~ s/[\r|\n]//g;
1471 $ldap_base[$sub] = $name;
1472
1473 print "\n";
1474
1475 print "This is the TCP/IP port number for the LDAP server. Default\n";
1476 print "port is 389. This is optional. Press ENTER for default.\n";
1477 print "port: ";
1478 $name = <STDIN>;
1479 $name =~ s/[\r|\n]//g;
1480 $ldap_port[$sub] = $name;
1481
1482 print "\n";
1483
1484 print "This is the charset for the server. Default is utf-8. This\n";
1485 print "is also optional. Press ENTER for default.\n";
1486 print "charset: ";
1487 $name = <STDIN>;
1488 $name =~ s/[\r|\n]//g;
1489 $ldap_charset[$sub] = $name;
1490
1491 print "\n";
1492
1493 print "This is the name for the server, used to tag the results of\n";
1494 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1495 print "name: ";
1496 $name = <STDIN>;
1497 $name =~ s/[\r|\n]//g;
1498 $ldap_name[$sub] = $name;
1499
1500 print "\n";
1501
1502 print "You can specify the maximum number of rows in the search result.\n";
1503 print "Default is unlimited. Press ENTER for default.\n";
1504 print "maxrows: ";
1505 $name = <STDIN>;
1506 $name =~ s/[\r|\n]//g;
1507 $ldap_maxrows[$sub] = $name;
1508
1509 print "\n";
1510
1511 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1512 if ($input =~ /[0-9]+\s*$/) {
1513 $rem_num = $input;
1514 $rem_num =~ s/^\s*-\s*//g;
1515 $rem_num =~ s/\s*$//;
1516 } else {
1517 $rem_num = $#ldap_host;
1518 }
1519 $count = 0;
1520 @new_ldap_host = ();
1521 @new_ldap_base = ();
1522 @new_ldap_port = ();
1523 @new_ldap_name = ();
1524 @new_ldap_charset = ();
1525 @new_ldap_maxrows = ();
1526 while ($count <= $#ldap_host) {
1527 if ($count != $rem_num) {
1528 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1529 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1530 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1531 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1532 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1533 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1534 }
1535 $count++;
1536 }
1537 @ldap_host = @new_ldap_host;
1538 @ldap_base = @new_ldap_base;
1539 @ldap_port = @new_ldap_port;
1540 @ldap_name = @new_ldap_name;
1541 @ldap_charset = @new_ldap_charset;
1542 @ldap_maxrows = @new_ldap_maxrows;
1543 } elsif ($input =~ /^\s*\?\s*/) {
1544 print ".-------------------------.\n";
1545 print "| + (add host) |\n";
1546 print "| - N (remove host) |\n";
1547 print "| l (list hosts) |\n";
1548 print "| d (done) |\n";
1549 print "`-------------------------'\n";
1550 }
1551 print "[ldap] command (?=help) > ";
1552 $input = <STDIN>;
1553 $input =~ s/[\r|\n]//g;
1554 }
1555 }
1556
1557 sub command62 {
1558 print "Some of our developers have come up with very good javascript interface\n";
1559 print "for searching through address books, however, our original goals said\n";
1560 print "that we would be 100% HTML. In order to make it possible to use their\n";
1561 print "interface, and yet stick with our goals, we have also written a plain\n";
1562 print "HTML version of the search. Here, you can choose which version to use.\n";
1563 print "\n";
1564 print "This is just the default value. It is also a user option that each\n";
1565 print "user can configure individually\n";
1566 print "\n";
1567
1568 if ($default_use_javascript_addr_book eq "true") {
1569 $default_value = "y";
1570 } else {
1571 $default_use_javascript_addr_book = "false";
1572 $default_value = "n";
1573 }
1574 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1575 $new_show = <STDIN>;
1576 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1577 $default_use_javascript_addr_book = "true";
1578 } else {
1579 $default_use_javascript_addr_book = "false";
1580 }
1581 return $default_use_javascript_addr_book;
1582 }
1583
1584
1585 sub save_data {
1586 open (FILE, ">config.php");
1587
1588 print FILE "<?php\n\t/** SquirrelMail configuration\n";
1589 print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1590
1591 print FILE "if (defined('config_php'))\n return;\n";
1592 print FILE "define('config_php', true);\n\n";
1593
1594 print FILE "\tglobal \$print_config_version, \$config_version, \$config_use_color;\n";
1595
1596 if ($print_config_version) {
1597 print FILE "\t\$config_version = \"$print_config_version\";\n";
1598 }
1599 print FILE "\t\$config_use_color = $config_use_color;\n";
1600 print FILE "\n";
1601
1602 print FILE "\tglobal \$org_name, \$org_logo, \$org_title, \$signout_page;\n";
1603 print FILE "\t\$org_name = \"$org_name\";\n";
1604 print FILE "\t\$org_logo = \"$org_logo\";\n";
1605 print FILE "\t\$org_title = \"$org_title\";\n";
1606 print FILE "\t\$signout_page = \"$signout_page\";\n";
1607
1608 print FILE "\n";
1609
1610 print FILE "\tglobal \$domain, \$imapServerAddress, \$imapPort;\n";
1611 print FILE "\tglobal \$useSendmail, \$smtpServerAddress, \$smtpPort;\n";
1612 print FILE "\tglobal \$sendmail_path, \$use_authenticated_smtp, \$imap_server_type;\n";
1613 print FILE "\tglobal \$invert_time, \$optional_delimiter;\n";
1614 print FILE "\t\$domain = \"$domain\";\n";
1615 print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n";
1616 print FILE "\t\$imapPort = $imapPort;\n";
1617 print FILE "\t\$useSendmail = $useSendmail;\n";
1618 print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1619 print FILE "\t\$smtpPort = $smtpPort;\n";
1620 print FILE "\t\$sendmail_path = \"$sendmail_path\";\n";
1621 print FILE "\t\$use_authenticated_smtp = $use_authenticated_smtp;\n";
1622 print FILE "\t\$imap_server_type = \"$imap_server_type\";\n";
1623 print FILE "\t\$invert_time = $invert_time;\n";
1624 print FILE "\t\$optional_delimiter = \"$optional_delimiter\";\n";
1625
1626 print FILE "\n";
1627
1628 print FILE "\tglobal \$default_folder_prefix, \$trash_folder, \$sent_folder;\n";
1629 print FILE "\tglobal \$default_move_to_trash, \$default_move_to_sent;\n";
1630 print FILE "\tglobal \$show_prefix_option, \$list_special_folders_first;\n";
1631 print FILE "\tglobal \$use_special_folder_color, \$auto_expunge, \$default_sub_of_inbox;\n";
1632 print FILE "\tglobal \$show_contain_subfolders_option, \$default_unseen_notify;\n";
1633 print FILE "\tglobal \$default_unseen_type;\n";
1634 print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
1635 print FILE "\t\$trash_folder = \"$trash_folder\";\n";
1636 print FILE "\t\$sent_folder = \"$sent_folder\";\n";
1637 print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n";
1638 print FILE "\t\$default_move_to_sent = $default_move_to_sent;\n";
1639 print FILE "\t\$show_prefix_option = $show_prefix_option;\n";
1640 print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n";
1641 print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n";
1642 print FILE "\t\$auto_expunge = $auto_expunge;\n";
1643 print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1644 print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1645 print FILE "\t\$default_unseen_notify = $default_unseen_notify;\n";
1646 print FILE "\t\$default_unseen_type = $default_unseen_type;\n";
1647 print FILE "\n";
1648
1649 print FILE "\tglobal \$default_charset, \$data_dir, \$attachment_dir;\n";
1650 print FILE "\tglobal \$default_left_size, \$force_username_lowercase;\n";
1651 print FILE "\t\$default_charset = \"$default_charset\";\n";
1652 print FILE "\t\$data_dir = \"$data_dir\";\n";
1653 print FILE "\t\$attachment_dir = \"$attachment_dir\";\n";
1654 print FILE "\t\$default_left_size = $default_left_size;\n";
1655 print FILE "\t\$force_username_lowercase = $force_username_lowercase;\n";
1656
1657 print FILE "\n";
1658
1659 print FILE "\tglobal \$plugins;\n";
1660 for ($ct=0; $ct <= $#plugins; $ct++) {
1661 print FILE "\t\$plugins[$ct] = \"$plugins[$ct]\";\n";
1662 }
1663
1664 print FILE "\n";
1665
1666 print FILE "\tglobal \$theme_css, \$theme;\n";
1667 print FILE "\t\$theme_css = \"$theme_css\";\n";
1668 for ($count=0; $count <= $#theme_name; $count++) {
1669 print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1670 print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1671 }
1672
1673 print FILE "\n";
1674
1675 if ($default_use_javascript_addr_book ne "true") {
1676 $default_use_javascript_addr_book = "false";
1677 }
1678 print FILE "\tglobal \$default_use_javascript_addr_book, \$ldap_server;\n";
1679 print FILE "\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1680 for ($count=0; $count <= $#ldap_host; $count++) {
1681 print FILE "\t\$ldap_server[$count] = Array(\n";
1682 print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1683 print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\"";
1684 if ($ldap_name[$count]) {
1685 print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1686 }
1687 if ($ldap_port[$count]) {
1688 print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1689 }
1690 if ($ldap_charset[$count]) {
1691 print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1692 }
1693 if ($ldap_maxrows[$count]) {
1694 print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1695 }
1696 print FILE ");\n\n";
1697 }
1698
1699 print FILE "\tglobal \$motd;\n";
1700 print FILE "\t\$motd = \"$motd\";\n";
1701
1702 close FILE;
1703 }
1704
1705 sub set_defaults {
1706 system "clear";
1707 print $WHT."SquirrelMail Configuration : ".$NRM;
1708 if ($config == 1) { print "Read: config.php"; }
1709 elsif ($config == 2) { print "Read: config_default.php"; }
1710 print "\n";
1711 print "---------------------------------------------------------\n";
1712
1713 print "While we have been building SquirrelMail, we have discovered some\n";
1714 print "preferences that work better with some servers that don't work so\n";
1715 print "well with others. If you select your IMAP server, this option will\n";
1716 print "set some pre-defined settings for that server.\n";
1717 print "\n";
1718 print "Please note that you will still need to go through and make sure\n";
1719 print "everything is correct. This does not change everything. There are\n";
1720 print "only a few settings that this will change.\n";
1721 print "\n";
1722
1723 $continue = 0;
1724 while ($continue != 1) {
1725 print "Please select your IMAP server:\n";
1726 print " cyrus = Cyrus IMAP server\n";
1727 print " uw = University of Washington's IMAP server\n";
1728 print " exchange = Microsoft Exchange IMAP server\n";
1729 print " courier = Courier IMAP server\n";
1730 print " quit = Do not change anything\n";
1731 print "Command >> ";
1732 $server = <STDIN>;
1733 $server =~ s/[\r|\n]//g;
1734
1735 print "\n";
1736 if ($server eq "cyrus") {
1737 $default_folder_prefix = "INBOX";
1738 $trash_folder = "INBOX.Trash";
1739 $sent_folder = "INBOX.Sent";
1740 $show_prefix_option = false;
1741 $default_sub_of_inbox = true;
1742 $show_contain_subfolders_option = false;
1743 $imap_server_type = "cyrus";
1744
1745 print " default_folder_prefix = INBOX\n";
1746 print " trash_folder = INBOX.Trash\n";
1747 print " sent_folder = INBOX.Sent\n";
1748 print " show_prefix_option = false\n";
1749 print " default_sub_of_inbox = true\n";
1750 print "show_contain_subfolders_option = false\n";
1751 print " imap_server_type = cyrus\n";
1752
1753 $continue = 1;
1754 } elsif ($server eq "uw") {
1755 $default_folder_prefix = "mail/";
1756 $trash_folder = "Trash";
1757 $sent_folder = "Sent";
1758 $show_prefix_option = true;
1759 $default_sub_of_inbox = false;
1760 $show_contain_subfolders_option = true;
1761 $imap_server_type = "uw";
1762
1763 print " default_folder_prefix = mail/\n";
1764 print " trash_folder = Trash\n";
1765 print " sent_folder = Sent\n";
1766 print " show_prefix_option = true\n";
1767 print " default_sub_of_inbox = false\n";
1768 print "show_contain_subfolders_option = true\n";
1769 print " imap_server_type = uw\n";
1770
1771 $continue = 1;
1772 } elsif ($server eq "exchange") {
1773 $default_folder_prefix = "";
1774 $default_sub_of_inbox = true;
1775 $trash_folder = "INBOX/Deleted Items";
1776 $sent_folder = "INBOX/Sent Items";
1777 $show_prefix_option = false;
1778 $show_contain_subfolders_option = false;
1779 $imap_server_type = "exchange";
1780
1781 print " default_folder_prefix = <none>\n";
1782 print " default_sub_of_inbox = true\n";
1783 print " trash_folder = \"INBOX/Deleted Items\"\n";
1784 print " sent_folder = \"INBOX/Sent Items\"\n";
1785 print " show_prefix_option = false\n";
1786 print " show_contain_subfolders_option = false\n";
1787 print " imap_server_type = exchange\n";
1788
1789 $continue = 1;
1790 } elsif ($server eq "courier") {
1791 $imap_server_type = "courier";
1792
1793 print " imap_server_type = courier\n";
1794
1795 $continue = 1;
1796 } elsif ($server eq "quit") {
1797 $continue = 1;
1798 } else {
1799 print "Unrecognized server: $server\n";
1800 print "\n";
1801 }
1802 }
1803 print "\nPress any key to continue...";
1804 $tmp = <STDIN>;
1805 }