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