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