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