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