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