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