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