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