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