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