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