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