bugfixes in conf.pl
[squirrelmail.git] / config / conf.pl
CommitLineData
bbd30ac8 1#!/usr/bin/perl
2# conf.pl
3# Written March 26, 2000
4# Luke Ehresman (lehresma@css.tayloru.edu)
5#
6# A simple configure script to configure squirrelmail
ccfb2029 7############################################################
bbd30ac8 8$WHT = "\x1B[37;1m";
9$NRM = "\x1B[0m";
10
ccfb2029 11############################################################
bbd30ac8 12# First, lets read in the data already in there...
ccfb2029 13############################################################
bbd30ac8 14if ( -e "config.php") {
ccfb2029 15 print "The file \"config.php\" exists. Using it for defaults.\n\n";
16 open (FILE, "config.php");
bbd30ac8 17} else {
ccfb2029 18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE, "config_default.php");
bbd30ac8 20}
21
22# Reads and parses the current configuration file (either
23# config.php or config_default.php).
24
25while ($line = <FILE>) {
ccfb2029 26 if ($line =~ /^\s+\$/) {
27 $line =~ s/^\s+\$//;
28 $var = $line;
29
30 if ($var =~ /^([a-z]|[A-Z])/) {
31 @options = split(/\s*=\s*/, $var);
32 $options[1] =~ s/[\n|\r]//g;
33 $options[1] =~ s/^"//g;
34 $options[1] =~ s/;.*$//g;
35 $options[1] =~ s/"$//g;
36
37 if ($options[0] =~ /^special_folders/) {
38 if ($options[0] =~ /\[.*\]$/) {
39 $sub = $options[0];
40 $sub =~ s/\]$//;
41 $sub = substr ($sub, @sub-1, 1);
42
43 $special_folders[$sub] = $options[1];
44 }
45 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
46 $sub = $options[0];
47 $sub =~ s/\]\["PATH"\]//;
48 $sub = substr ($sub, @sub-1, 1);
49 $theme_path[$sub] = $options[1];
50 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
51 $sub = $options[0];
52 $sub =~ s/\]\["NAME"\]//;
53 $sub = substr ($sub, @sub-1, 1);
54 $theme_name[$sub] = $options[1];
55 } else {
56 ${$options[0]} = $options[1];
57 }
58 }
59 }
bbd30ac8 60}
828b4753 61if ($useSendmail ne "true") {
ccfb2029 62 $useSendmail = "false";
828b4753 63}
64if (!$sendmail_path) {
ccfb2029 65 $sendmail_path = "/usr/sbin/sendmail";
828b4753 66}
bbd30ac8 67
bbd30ac8 68
5b6ae78a 69#####################################################################################
70
828b4753 71while (($command ne "q") && ($command ne "Q")) {
ccfb2029 72 system "clear";
73 if ($menu == 0) {
74 print $WHT."SquirrelMail Configuration Utility\n".$NRM;
75 print $WHT."Main Menu --\n".$NRM;
76 print "1. Organization Preferences\n";
77 print "2. Server Settings\n";
78 print "3. Folder Defaults\n";
79 print "4. General Options\n";
80 print "5. Themes\n";
81 print "6. Address Books (LDAP)\n";
82 print "7. Message of the Day (MOTD)\n";
83 print "\n";
84 } elsif ($menu == 1) {
85 print $WHT."Organization Preferences\n".$NRM;
86 print "1. Organization Name : $WHT$org_name$NRM\n";
87 print "2. Organization Logo : $WHT$org_logo$NRM\n";
88 print "3. Organization Title : $WHT$org_title$NRM\n";
89 print "\n";
90 print "R Return to Main Menu\n";
91 } elsif ($menu == 2) {
92 print $WHT."Server Settings\n".$NRM;
93 print "1. Domain : $WHT$domain$NRM\n";
94 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
95 print "3. IMAP Port : $WHT$imapPort$NRM\n";
96 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
97 if ($useSendmail eq "true") {
98 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
99 } else {
100 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
101 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
102 }
103 print "\n";
104 print "R Return to Main Menu\n";
105 } elsif ($menu == 3) {
106 print $WHT."Folder Defaults\n".$NRM;
107 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
108 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
109 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
110 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
111 print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
112 print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
113 print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
114 print "8. Auto Expunge : $WHT$auto_expunge$NRM\n";
115 print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
116 print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
117 print "11. Special Folders > $WHT$special_folders[0]$NRM\n";
118 for ($count = 1; $count <= $#special_folders; $count++) {
119 print " > $WHT$special_folders[$count]$NRM\n";
120 }
121 print "\n";
122 print "R Return to Main Menu\n";
123 } elsif ($menu == 4) {
124 print $WHT."General Options\n".$NRM;
125 print "1. Default Charset : $WHT$default_charset$NRM\n";
126 print "2. Auto Forward : $WHT$auto_forward$NRM\n";
127 print "3. Data Directory : $WHT$data_dir$NRM\n";
128 print "4. Attachment Directory : $WHT$attachment_dir$NRM\n";
129 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
130 print "\n";
131 print "R Return to Main Menu\n";
132 } elsif ($menu == 5) {
133 print $WHT."Themes\n".$NRM;
134 print "1. Change Themes\n";
135 for ($count = 0; $count <= $#theme_name; $count++) {
136 print " | $theme_name[$count]\n";
137 }
138 print "\n";
139 print "R Return to Main Menu\n";
140 } elsif ($menu == 6) {
141 print $WHT."Address Books (LDAP)\n".$NRM;
142 print "\n";
143 print "R Return to Main Menu\n";
144 } elsif ($menu == 7) {
145 print $WHT."Message of the Day (MOTD)\n".$NRM;
146 print "\n$motd\n";
147 print "\n";
148 print "1 Edit the MOTD\n";
149 print "\n";
150 print "R Return to Main Menu\n";
151 }
152 print "S Save data\n";
153 print "Q Quit\n";
154
155 print "\n";
156 print "Command >> ".$WHT;
157 $command = <STDIN>;
158 $command =~ s/[\n|\r]//g;
159 print "$NRM\n";
160
161 # Read the commands they entered.
162 if (($command eq "R") || ($command eq "r")) {
163 $menu = 0;
164 } elsif (($command eq "s") || ($command eq "S")) {
165 save_data ();
8ad99a99 166 print "Data saved in config.php\n";
ccfb2029 167 print "Press any key to continue...";
168 $tmp = <STDIN>;
169 $saved = 1;
170 } elsif ((($command eq "q") || ($command eq "Q")) && ($saved == 0)) {
171 print "You have not saved your data.\n";
172 print "Save? (y/n) [".$WHT."y".$NRM."]: ";
173 $save = <STDIN>;
174 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
175 save_data ();
176 }
177 } else {
178 $saved = 0;
179 if ($menu == 0) {
180 if (($command > 0) && ($command < 8)) {
181 $menu = $command;
182 }
183 } elsif ($menu == 1) {
184 if ($command == 1) { $org_name = command1 (); }
185 elsif ($command == 2) { $org_logo = command2 (); }
186 elsif ($command == 3) { $org_title = command3 (); }
187 } elsif ($menu == 2) {
188 if ($command == 1) { $domain = command11 (); }
189 elsif ($command == 2) { $imapServerAddress = command12 (); }
190 elsif ($command == 3) { $imapPort = command13 (); }
191 elsif ($command == 4) { $useSendmail = command14 (); }
192 elsif ($command == 5) { $sendmail_path = command15 (); }
193 elsif ($command == 6) { $smtpServerAddress = command16 (); }
194 elsif ($command == 7) { $smtpPort = command17 (); }
195 } elsif ($menu == 3) {
196 if ($command == 1) { $default_folder_prefix = command21 (); }
197 elsif ($command == 2) { $show_prefix_option = command22 (); }
198 elsif ($command == 3) { $trash_folder = command23 (); }
199 elsif ($command == 4) { $sent_folder = command24 (); }
200 elsif ($command == 5) { $list_special_folders_first = command25 (); }
201 elsif ($command == 6) { $use_special_folder_color = command26 (); }
202 elsif ($command == 7) { $default_move_to_trash = command27 (); }
203 elsif ($command == 8) { $auto_expunge = command28 (); }
204 elsif ($command == 9) { $default_sub_of_inbox = command29 (); }
205 elsif ($command == 10){ $show_contain_subfolders_option = command210(); }
206 elsif ($command == 11){ $special_folders = command211(); }
207 } elsif ($menu == 4) {
208 if ($command == 1) { $default_charset = command31 (); }
209 elsif ($command == 2) { $auto_forward = command32 (); }
210 elsif ($command == 3) { $data_dir = command33 (); }
211 elsif ($command == 4) { $attachment_dir = command34 (); }
212 elsif ($command == 5) { $default_left_size = command35 (); }
213 } elsif ($menu == 5) {
214 if ($command == 1) {
215 command41 ();
216 }
217 } elsif ($menu == 6) {
218 } elsif ($menu == 7) {
8ad99a99 219 if ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;}
ccfb2029 220 }
221 }
828b4753 222}
223
224####################################################################################
225
5b6ae78a 226# org_name
227sub command1 {
228 print "We have tried to make the name SquirrelMail as transparent as\n";
229 print "possible. If you set up an organization name, most places where\n";
230 print "SquirrelMail would take credit will be credited to your organization.\n";
231 print "\n";
828b4753 232 print "[$WHT$org_name$NRM]: $WHT";
233 $new_org_name = <STDIN>;
234 if ($new_org_name eq "\n") {
235 $new_org_name = $org_name;
236 } else {
237 $new_org_name =~ s/[\r|\n]//g;
238 }
5b6ae78a 239 return $new_org_name;
240}
241
828b4753 242
5b6ae78a 243# org_logo
244sub command2 {
245 print "Your organization's logo is an image that will be displayed at\n";
246 print "different times throughout SquirrelMail. This is asking for the\n";
247 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
248 print "(../images/logo.jpg) path to your logo.\n";
249 print "\n";
828b4753 250 print "[$WHT$org_logo$NRM]: $WHT";
5b6ae78a 251 $new_org_logo = <STDIN>;
252 if ($new_org_logo eq "\n") {
253 $new_org_logo = $org_logo;
bbd30ac8 254 } else {
5b6ae78a 255 $new_org_logo =~ s/[\r|\n]//g;
bbd30ac8 256 }
5b6ae78a 257 return $new_org_logo;
258}
259
260# org_title
261sub command3 {
262 print "A title is what is displayed at the top of the browser window in\n";
263 print "the titlebar. Usually this will end up looking something like:\n";
264 print "\"Netscape: $org_title\"\n";
265 print "\n";
828b4753 266 print "[$WHT$org_title$NRM]: $WHT";
5b6ae78a 267 $new_org_title = <STDIN>;
268 if ($new_org_title eq "\n") {
269 $new_org_title = $org_title;
bbd30ac8 270 } else {
5b6ae78a 271 $new_org_title =~ s/[\r|\n]//g;
bbd30ac8 272 }
5b6ae78a 273 return $new_org_title;
274}
5b6ae78a 275
828b4753 276####################################################################################
5b6ae78a 277
828b4753 278# domain
279sub command11 {
ccfb2029 280 print "The domain name is the suffix at the end of all email messages. If\n";
281 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
282 print "would be myorg.com.\n";
283 print "\n";
284 print "[$WHT$domain$NRM]: $WHT";
285 $new_domain = <STDIN>;
286 if ($new_domain eq "\n") {
287 $new_domain = $domain;
288 } else {
289 $new_domain =~ s/[\r|\n]//g;
290 }
291 return $new_domain;
828b4753 292}
5b6ae78a 293
828b4753 294# imapServerAddress
295sub command12 {
ccfb2029 296 print "This is the address where your IMAP server resides.\n";
297 print "[$WHT$imapServerAddress$NRM]: $WHT";
298 $new_imapServerAddress = <STDIN>;
299 if ($new_imapServerAddress eq "\n") {
300 $new_imapServerAddress = $imapServerAddress;
301 } else {
302 $new_imapServerAddress =~ s/[\r|\n]//g;
303 }
304 return $new_imapServerAddress;
828b4753 305}
5b6ae78a 306
828b4753 307# imapPort
308sub command13 {
ccfb2029 309 print "This is the port that your IMAP server is on. Usually this is 143.\n";
310 print "[$WHT$imapPort$NRM]: $WHT";
311 $new_imapPort = <STDIN>;
312 if ($new_imapPort eq "\n") {
313 $new_imapPort = $imapPort;
314 } else {
315 $new_imapPort =~ s/[\r|\n]//g;
316 }
317 return $new_imapPort;
828b4753 318}
319
320# useSendmail
321sub command14 {
ccfb2029 322 print "You now need to choose the method that you will use for sending\n";
323 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
324 print "or use sendmail directly.\n";
325 if ($useSendmail eq "true") {
326 $default_value = "y";
327 } else {
328 $default_value = "n";
329 }
330 print "\n";
331 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
332 $use_sendmail = <STDIN>;
333 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
334 $useSendmail = "true";
335 } else {
336 $useSendmail = "false";
337 }
338 return $useSendmail;
828b4753 339}
5b6ae78a 340
828b4753 341# sendmail_path
342sub command15 {
343 if ($sendmail_path[0] !~ /./) {
344 $sendmail_path = "/usr/sbin/sendmail";
345 }
ccfb2029 346 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
828b4753 347 print "[$WHT$sendmail_path$NRM]: $WHT";
348 $new_sendmail_path = <STDIN>;
349 if ($new_sendmail_path eq "\n") {
350 $new_sendmail_path = $sendmail_path;
351 } else {
352 $new_sendmail_path =~ s/[\r|\n]//g;
353 }
ccfb2029 354 return $new_sendmail_path;
828b4753 355}
5b6ae78a 356
828b4753 357# smtpServerAddress
358sub command16 {
ccfb2029 359 print "This is the location of your SMTP server.\n";
828b4753 360 print "[$WHT$smtpServerAddress$NRM]: $WHT";
361 $new_smtpServerAddress = <STDIN>;
362 if ($new_smtpServerAddress eq "\n") {
363 $new_smtpServerAddress = $smtpServerAddress;
364 } else {
365 $new_smtpServerAddress =~ s/[\r|\n]//g;
366 }
ccfb2029 367 return $new_smtpServerAddress;
828b4753 368}
369
370# smtpPort
371sub command17 {
ccfb2029 372 print "This is the port to connect to for SMTP. Usually 25.\n";
828b4753 373 print "[$WHT$smtpPort$NRM]: $WHT";
374 $new_smtpPort = <STDIN>;
375 if ($new_smtpPort eq "\n") {
376 $new_smtpPort = $smtpPort;
377 } else {
378 $new_smtpPort =~ s/[\r|\n]//g;
379 }
ccfb2029 380 return $new_smtpPort;
bbd30ac8 381}
3f8fe68e 382
383# MOTD
384sub command71 {
ccfb2029 385 print "\nYou can now create the welcome message that is displayed\n";
386 print "every time a user logs on. You can use HTML or just plain\n";
387 print "text.\n\n(Type @ on a blank line to exit)\n";
388 do {
389 print "] ";
390 $line = <STDIN>;
391 $line =~ s/[\r|\n]//g;
392 $line =~ s/ /\&nbsp;\&nbsp;/g;
393 if ($line ne "@") {
394 $new_motd = $new_motd . $line;
395 }
396 } while ($line ne "@");
397 return $new_motd;
3f8fe68e 398}
911ad01c 399
400################# FOLDERS ###################
401
402# default_folder_prefix
403sub command21 {
ccfb2029 404 print "Some IMAP servers (UW, for example) store mail and folders in\n";
405 print "your user space in a separate subdirectory. This is where you\n";
406 print "specify what that directory is.\n";
407 print "\n";
408 print "EXAMPLE: mail/";
409 print "\n";
410 print "NOTE: If you use Cyrus, or some server that would not use this\n";
411 print " option, you must set this to 'none'.\n";
412 print "\n";
911ad01c 413 print "[$WHT$default_folder_prefix$NRM]: $WHT";
414 $new_default_folder_prefix = <STDIN>;
415 if ($new_default_folder_prefix eq "\n") {
416 $new_default_folder_prefix = $default_folder_prefix;
417 } else {
418 $new_default_folder_prefix =~ s/[\r|\n]//g;
419 }
ccfb2029 420 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
421 $new_default_folder_prefix = "";
422 } else {
423 $new_default_folder_prefix =~ s/\/*$//g;
424 $new_default_folder_prefix =~ s/$/\//g;
425 }
911ad01c 426 return $new_default_folder_prefix;
427}
428
429# Show Folder Prefix
430sub command22 {
ccfb2029 431 print "It is possible to set up the default folder prefix as a user\n";
432 print "specific option, where each user can specify what their mail\n";
433 print "folder is. If you set this to false, they will never see the\n";
434 print "option, but if it is true, this option will appear in the\n";
435 print "'options' section.\n";
436 print "\n";
437 print "NOTE: You set the default folder prefix in option '1' of this\n";
438 print " section. That will be the default if the user doesn't\n";
439 print " specify anything different.\n";
440 print "\n";
441
442 if ($show_prefix_option eq "true") {
443 $default_value = "y";
444 } else {
445 $default_value = "n";
446 }
447 print "\n";
448 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
449 $new_show = <STDIN>;
450 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
451 $show_prefix_option = "true";
452 } else {
453 $show_prefix_option = "false";
454 }
455 return $show_prefix_option;
911ad01c 456}
457
458# Trash Folder
459sub command23 {
ccfb2029 460 print "You can now specify where the default trash folder is located.\n";
461 print "On servers where you do not want this, you can set it to anything\n";
462 print "and set option 7 to false.\n";
463 print "\n";
464 print "This is relative to where the rest of your email is kept. You do\n";
465 print "not need to worry about their mail directory. If this folder\n";
466 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
467 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
468 print "\n";
911ad01c 469
470 print "[$WHT$trash_folder$NRM]: $WHT";
471 $new_trash_folder = <STDIN>;
472 if ($new_trash_folder eq "\n") {
473 $new_trash_folder = $trash_folder;
474 } else {
475 $new_trash_folder =~ s/[\r|\n]//g;
476 }
ccfb2029 477 return $new_trash_folder;
911ad01c 478}
479
480# Sent Folder
481sub command24 {
ccfb2029 482 print "This is where messages that are sent will be stored. SquirrelMail\n";
483 print "by default puts a copy of all outgoing messages in this folder.\n";
484 print "\n";
485 print "This is relative to where the rest of your email is kept. You do\n";
486 print "not need to worry about their mail directory. If this folder\n";
487 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
488 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
489 print "\n";
911ad01c 490
491 print "[$WHT$sent_folder$NRM]: $WHT";
492 $new_sent_folder = <STDIN>;
493 if ($new_sent_folder eq "\n") {
494 $new_sent_folder = $sent_folder;
495 } else {
496 $new_sent_folder =~ s/[\r|\n]//g;
497 }
ccfb2029 498 return $new_sent_folder;
911ad01c 499}
500
501# List special folders first
502sub command25 {
ccfb2029 503 print "SquirrelMail has what we call 'special folders' that are not\n";
504 print "manipulated and viewed like normal folders. Some examples of\n";
505 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
506 print "Simply asks if you want these folders listed first in the folder\n";
507 print "listing.\n";
508 print "\n";
509
510 if ($list_special_folders_first eq "true") {
511 $default_value = "y";
512 } else {
513 $default_value = "n";
514 }
515 print "\n";
516 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
517 $new_show = <STDIN>;
518 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
519 $list_special_folders_first = "true";
520 } else {
521 $list_special_folders_first = "false";
522 }
523 return $list_special_folders_first;
911ad01c 524}
525
526# Show special folders color
527sub command26 {
ccfb2029 528 print "SquirrelMail has what we call 'special folders' that are not\n";
529 print "manipulated and viewed like normal folders. Some examples of\n";
530 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
531 print "wants to know if we should display special folders in a\n";
532 print "color than the other folders.\n";
533 print "\n";
534
535 if ($use_special_folder_color eq "true") {
536 $default_value = "y";
537 } else {
538 $default_value = "n";
539 }
540 print "\n";
541 print "Show color (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 $use_special_folder_color = "true";
545 } else {
546 $use_special_folder_color = "false";
547 }
548 return $use_special_folder_color;
911ad01c 549}
550
551# default move to trash
552sub command27 {
ccfb2029 553 print "By default, should messages get moved to the trash folder? You\n";
554 print "can specify the default trash folder in option 3. If this is set\n";
555 print "to false, messages will get deleted immediately without moving\n";
556 print "to the trash folder.\n";
557 print "\n";
558 print "Trash folder is currently: $trash_folder\n";
559 print "\n";
560
561 if ($default_move_to_trash eq "true") {
562 $default_value = "y";
563 } else {
564 $default_value = "n";
565 }
566 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
567 $new_show = <STDIN>;
568 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
569 $default_move_to_trash = "true";
570 } else {
571 $default_move_to_trash = "false";
572 }
573 return $default_move_to_trash;
911ad01c 574}
575
576# Auto expunge
577sub command28 {
ccfb2029 578 print "The way that IMAP handles deleting messages is as follows. You\n";
579 print "mark the message as deleted, and then to 'really' delete it, you\n";
580 print "expunge it. This option asks if you want to just have messages\n";
581 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
582 print "messages too.\n";
583 print "\n";
584
585 if ($auto_expunge eq "true") {
586 $default_value = "y";
587 } else {
588 $default_value = "n";
589 }
590 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
591 $new_show = <STDIN>;
592 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
593 $auto_expunge = "true";
594 } else {
595 $auto_expunge = "false";
596 }
597 return $auto_expunge;
911ad01c 598}
599
600# Default sub of inbox
601sub command29 {
ccfb2029 602 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
603 print "This can cause some confusion in folder creation for users when\n";
604 print "they try to create folders and don't put it as a subfolder of INBOX\n";
605 print "and get permission errors. This option asks if you want folders\n";
606 print "to be subfolders of INBOX by default.\n";
607 print "\n";
608
609 if ($default_sub_of_inbox eq "true") {
610 $default_value = "y";
611 } else {
612 $default_value = "n";
613 }
614 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
615 $new_show = <STDIN>;
616 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
617 $default_sub_of_inbox = "true";
618 } else {
619 $default_sub_of_inbox = "false";
620 }
621 return $default_sub_of_inbox;
911ad01c 622}
623
624# Show contain subfolder option
625sub command210 {
ccfb2029 626 print "Some IMAP servers (UW) make it so that there are two types of\n";
627 print "folders. Those that contain messages, and those that contain\n";
628 print "subfolders. If this is the case for your server, set this to\n";
629 print "true, and it will ask the user whether the folder they are\n";
630 print "creating contains subfolders or messages.\n";
631 print "\n";
632
633 if ($show_contain_subfolders_option eq "true") {
634 $default_value = "y";
635 } else {
636 $default_value = "n";
637 }
638 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
639 $new_show = <STDIN>;
640 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
641 $show_contain_subfolders_option = "true";
642 } else {
643 $show_contain_subfolders_option = "false";
644 }
645 return $show_contain_subfolders_option;
911ad01c 646}
647
648# special folders
649sub command211 {
650 print "\nSpecial folders are folders that can't be manipulated like normal\n";
651 print "user-created folders. A couple of examples of these would be the\n";
652 print "trash folder, the sent folder, etc.\n";
653 print "Special Folders:\n";
654 $count = 0;
655 print "\n";
656 while ($count < @special_folders) {
657 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
658 $count++;
659 }
660 print "\n[folders] command (?=help) > ";
661 $input = <STDIN>;
662 $input =~ s/[\r|\n]//g;
aed206bf 663 while ($input !~ /^d$/i) {
911ad01c 664 ## ADD
665 if ($input =~ /^\s*\+\s*.*/) {
666 $input =~ s/^\s*\+\s*//;
667 $special_folders[$#special_folders+1] = $input;
668 }
669
670 elsif ($input =~ /^\s*-\s*[0-9]?/i) {
671 if ($input =~ /[0-9]+\s*$/) {
672 $rem_num = $input;
673 $rem_num =~ s/^\s*-\s*//g;
674 $rem_num =~ s/\s*$//;
675 } else {
676 $rem_num = $#special_folders;
677 }
678
679 if ($rem_num == 0) {
680 print "You cannot remove INBOX. It is a very special folder.\n";
681 } else {
682 $count = 0;
683 @new_special_folders = ();
ccfb2029 684 $removed = 0;
911ad01c 685 while ($count <= $#special_folders) {
686 if ($count != $rem_num) {
687 @new_special_folders = (@new_special_folders, $special_folders[$count]);
688 }
ccfb2029 689 if ($count == $rem_num) {
690 print "Removed: $special_folders[$rem_num]\n";
691 $removed = 1;
692 }
911ad01c 693 $count++;
694 }
ccfb2029 695 if ($removed != 1) {
696 print "Error: Can't delete an entry that's not there!\n";
697 }
911ad01c 698 @special_folders = @new_special_folders;
699 }
700 }
701
702 elsif ($input =~ /^\s*l\s*/i) {
703 $count = 0;
704 print "\n";
705 while ($count < @special_folders) {
706 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
707 $count++;
708 }
709 } elsif ($input =~ /^\s*\?\s*/) {
710 print ".-------------------------.\n";
711 print "| + Folder (add folder) |\n";
712 print "| - N (remove folder) |\n";
713 print "| l (list folders) |\n";
714 print "| d (done) |\n";
715 print "`-------------------------'\n";
716 }
717
718 else {
719 print "Unrecognized command.\n";
720 }
721
722 print "\n[folders] command (?=help) > ";
723 $input = <STDIN>;
724 $input =~ s/[\r|\n]//g;
725 }
ccfb2029 726 return @special_folders;
727}
728
729############# GENERAL OPTIONS #####################
730
731# Default Charset
732sub command31 {
733 print "This option controls what character set is used when sending\n";
734 print "mail and when sending HTML to the browser. Do not set this\n";
735 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
736 print "to use KOI8-R, since this implementation is faster than most\n";
737 print "of the alternatives\n";
738 print "\n";
739
740 print "[$WHT$default_charset$NRM]: $WHT";
741 $new_default_charset = <STDIN>;
742 if ($new_default_charset eq "\n") {
743 $new_default_charset = $default_charset;
744 } else {
745 $new_default_charset =~ s/[\r|\n]//g;
746 }
747 return $new_default_charset;
748}
749
750# Auto Forward
751sub command32 {
752 print "There are some places that we will automatically forward the user\n";
753 print "rather than display pointless messages like 'Message sent!' or\n";
754 print "stuff like that. Use this or not?\n";
755 print "\n";
756 print "NOTE: This is not working currently as we are trying to find a\n";
757 print " better way to handle this. This option really doesn't do\n";
758 print " much.\n";
759 print "\n";
760
761 if ($auto_forward eq "true") {
762 $default_value = "y";
763 } else {
764 $default_value = "n";
765 }
766 print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT";
767 $new_show = <STDIN>;
768 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
769 $auto_forward = "true";
770 } else {
771 $auto_forward = "false";
772 }
773 return $auto_forward;
774}
775
776# Data directory
777sub command33 {
778 print "It is a possible security hole to have a writable directory\n";
779 print "under the web server's root directory (ex: /home/httpd/html).\n";
780 print "For this reason, it is possible to put the data directory\n";
781 print "anywhere you would like. The path name can be absolute or\n";
782 print "relative (to the config directory). It doesn't matter. Here\n";
783 print "are two examples:\n";
784 print " Absolute: /usr/local/squirrelmail/data/\n";
785 print " Relative: ../data/\n";
786 print "\n";
787
788 print "[$WHT$data_dir$NRM]: $WHT";
789 $new_data_dir = <STDIN>;
790 if ($new_data_dir eq "\n") {
791 $new_data_dir = $data_dir;
792 } else {
793 $new_data_dir =~ s/[\r|\n]//g;
794 }
795 if ($new_data_dir =~ /^\s*$/) {
796 $new_data_dir = "";
797 } else {
798 $new_data_dir =~ s/\/*$//g;
799 $new_data_dir =~ s/$/\//g;
800 }
801 return $new_data_dir;
802}
803
804# Attachment directory
805sub command34 {
806 print "Path to directory used for storing attachments while a mail is\n";
807 print "being sent. There are a few security considerations regarding this\n";
808 print "directory:\n";
809 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
810 print " impossible for a random person with access to the webserver\n";
811 print " to list files in this directory. Confidential data might\n";
812 print " be laying around in there.\n";
813 print " 2. Since the webserver is not able to list the files in the\n";
814 print " content is also impossible for the webserver to delete files\n";
815 print " lying around there for too long.\n";
816 print " 3. It should probably be another directory than the data\n";
817 print " directory specified in option 3.\n";
818 print "\n";
819
820 print "[$WHT$attachment_dir$NRM]: $WHT";
821 $new_attachment_dir = <STDIN>;
822 if ($new_attachment_dir eq "\n") {
823 $new_attachment_dir = $attachment_dir;
824 } else {
825 $new_attachment_dir =~ s/[\r|\n]//g;
826 }
827 if ($new_attachment_dir =~ /^\s*$/) {
828 $new_attachment_dir = "";
829 } else {
830 $new_attachment_dir =~ s/\/*$//g;
831 $new_attachment_dir =~ s/$/\//g;
832 }
833 return $new_attachment_dir;
834}
835
836
837sub command35 {
838 print "This is the default size (in pixels) of the left folder list.\n";
839 print "Default is 200, but you can set it to whatever you wish. This\n";
840 print "is a user preference, so this will only show up as their default.\n";
841 print "\n";
842 print "[$WHT$default_left_size$NRM]: $WHT";
843 $new_default_left_size = <STDIN>;
844 if ($new_default_left_size eq "\n") {
845 $new_default_left_size = $default_left_size;
846 } else {
847 $new_default_left_size =~ s/[\r|\n]//g;
848 }
849 return $new_default_left_size;
850}
851
852
853sub command41 {
854 print "\nNow we will define the themes that you wish to use. If you have added\n";
855 print "a theme of your own, just follow the instructions (?) about how to add\n";
856 print "them. You can also change the default theme.\n";
857 print "[theme] command (?=help) > ";
858 $input = <STDIN>;
859 $input =~ s/[\r|\n]//g;
860 while ($input ne "d") {
861 if ($input =~ /^\s*l\s*/i) {
862 $count = 0;
863 while ($count <= $#theme_name) {
864 if ($count == $theme_default) {
865 print " *";
866 } else {
867 print " ";
868 }
869 $name = $theme_name[$count];
870 $num_spaces = 25 - length($name);
871 for ($i = 0; $i < $num_spaces;$i++) {
872 $name = $name . " ";
873 }
874
875 print " $count. $name";
876 print "($theme_path[$count])\n";
877
878 $count++;
879 }
880 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
881 $old_def = $theme_default;
882 $theme_default = $input;
883 $theme_default =~ s/^\s*m\s*//;
884 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
885 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
886 $theme_default = $old_def;
887 }
888 } elsif ($input =~ /^\s*\+/) {
889 print "What is the name of this theme: ";
890 $name = <STDIN>;
891 $name =~ s/[\r|\n]//g;
892 $theme_name[$#theme_name+1] = $name;
893 print "Be sure to put ../config/ before the filename.\n";
894 print "What file is this stored in (ex: ../config/default_theme.php): ";
895 $name = <STDIN>;
896 $name =~ s/[\r|\n]//g;
897 $theme_path[$#theme_path+1] = $name;
898 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
899 if ($input =~ /[0-9]+\s*$/) {
900 $rem_num = $input;
901 $rem_num =~ s/^\s*-\s*//g;
902 $rem_num =~ s/\s*$//;
903 } else {
904 $rem_num = $#theme_name;
905 }
906 if ($rem_num == $theme_default) {
907 print "You cannot remove the default theme!\n";
908 } else {
909 $count = 0;
910 @new_theme_name = ();
911 @new_theme_path = ();
912 while ($count <= $#theme_name) {
913 if ($count != $rem_num) {
914 @new_theme_name = (@new_theme_name, $theme_name[$count]);
915 @new_theme_path = (@new_theme_path, $theme_path[$count]);
916 }
917 $count++;
918 }
919 @theme_name = @new_theme_name;
920 @theme_path = @new_theme_path;
921 if ($theme_default > $rem_num) {
922 $theme_default--;
923 }
924 }
925 } elsif ($input =~ /^\s*\?\s*/) {
926 print ".-------------------------.\n";
927 print "| + (add theme) |\n";
928 print "| - N (remove theme) |\n";
929 print "| m N (mark default) |\n";
930 print "| l (list themes) |\n";
931 print "| d (done) |\n";
932 print "`-------------------------'\n";
933 }
934 print "[theme] command (?=help) > ";
935 $input = <STDIN>;
936 $input =~ s/[\r|\n]//g;
937 }
938}
939
940
941
942sub save_data {
943 open (FILE, ">config.php");
944
945 print FILE "<?\n\t/** SquirrelMail configuration\n";
946 print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
947
948 print FILE "\t\$org_name = \"$org_name\";\n";
949 print FILE "\t\$org_logo = \"$org_logo\";\n";
950 print FILE "\t\$org_title = \"$org_title\";\n";
951
952 print FILE "\n";
953
c39a6b45 954 print FILE "\t\$domain = \"$domain\";\n";
955 print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n";
956 print FILE "\t\$imapPort = $imapPort;\n";
957 print FILE "\t\$useSendmail = $useSendmail;\n";
958 print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
959 print FILE "\t\$smtpPort = $smtpPort;\n";
960 print FILE "\t\$sendmailPath = \"$sendmail_path\";\n";
ccfb2029 961
962 print FILE "\n";
963
964 print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
8ad99a99 965 print FILE "\t\$trash_folder = \"$trash_folder\";\n";
ccfb2029 966 print FILE "\t\$sent_folder = \"$sent_folder\";\n";
967 print FILE "\t\$show_prefix_option = $show_prefix_option;\n";
968 print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n";
969 print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n";
970 print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n";
971 print FILE "\t\$auto_expunge = $auto_expunge;\n";
972 print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
c39a6b45 973 print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
ccfb2029 974 for ($count=0; $count <= $#special_folders; $count++) {
8ad99a99 975 print FILE "\t\$special_folders[$count] = \"$special_folders[$count]\";\n";
ccfb2029 976 }
977 print FILE "\n";
978
8ad99a99 979 print FILE "\t\$default_charset = \"$default_charset\";\n";
980 print FILE "\t\$auto_forward = $auto_forward;\n";
981 print FILE "\t\$data_dir = \"$data_dir\";\n";
982 print FILE "\t\$attachment_dir = \"$attachment_dir\";\n";
983 print FILE "\t\$default_left_size = $default_left_size;\n";
ccfb2029 984
985 print FILE "\n";
986
987 for ($count=0; $count <= $#theme_name; $count++) {
8ad99a99 988 print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
989 print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
990 }
991
ccfb2029 992 print FILE "\n";
993
8ad99a99 994 print FILE "\t\$motd = \"$motd\";\n";
ccfb2029 995
996 print FILE "?>\n";
997 close FILE;
911ad01c 998}