fixed the problem with us not being RFC complient for courier
[squirrelmail.git] / config / conf.pl
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
7 ############################################################
8 $WHT = "\x1B[37;1m";
9 $NRM = "\x1B[0m";
10
11 ############################################################
12 # First, lets read in the data already in there...
13 ############################################################
14 if ( -e "config.php") {
15 print "The file \"config.php\" exists. Using it for defaults.\n\n";
16 open (FILE, "config.php");
17 } else {
18 print "No config file found. Reading from config_defaults.php.\n\n";
19 open (FILE, "config_default.php");
20 }
21
22 # Reads and parses the current configuration file (either
23 # config.php or config_default.php).
24
25 while ($line = <FILE>) {
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 }
60 }
61 if ($useSendmail ne "true") {
62 $useSendmail = "false";
63 }
64 if (!$sendmail_path) {
65 $sendmail_path = "/usr/sbin/sendmail";
66 }
67
68
69 #####################################################################################
70
71 while (($command ne "q") && ($command ne "Q")) {
72 system "clear";
73 if ($menu == 0) {
74 print $WHT."Main Menu --\n".$NRM;
75 print "1. Organization Preferences\n";
76 print "2. Server Settings\n";
77 print "3. Folder Defaults\n";
78 print "4. General Options\n";
79 print "5. Themes\n";
80 print "6. Address Books (LDAP)\n";
81 print "7. Message of the Day (MOTD)\n";
82 print "\n";
83 } elsif ($menu == 1) {
84 print $WHT."Organization Preferences\n".$NRM;
85 print "1. Organization Name : $WHT$org_name$NRM\n";
86 print "2. Organization Logo : $WHT$org_logo$NRM\n";
87 print "3. Organization Title : $WHT$org_title$NRM\n";
88 print "\n";
89 print "R Return to Main Menu\n";
90 } elsif ($menu == 2) {
91 print $WHT."Server Settings\n".$NRM;
92 print "1. Domain : $WHT$domain$NRM\n";
93 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
94 print "3. IMAP Port : $WHT$imapPort$NRM\n";
95 print "4. Use Sendmail : $WHT$useSendmail$NRM\n";
96 if ($useSendmail eq "true") {
97 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
98 } else {
99 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
100 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
101 }
102 print "\n";
103 print "R Return to Main Menu\n";
104 } elsif ($menu == 3) {
105 print $WHT."Folder Defaults\n".$NRM;
106 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
107 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
108 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
109 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
110 print "5. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
111 print "6. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
112 print "7. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
113 print "8. Auto Expunge : $WHT$auto_expunge$NRM\n";
114 print "9. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
115 print "10. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
116 print "11. Special Folders > $WHT$special_folders[0]$NRM\n";
117 for ($count = 1; $count <= $#special_folders; $count++) {
118 print " > $WHT$special_folders[$count]$NRM\n";
119 }
120 print "\n";
121 print "R Return to Main Menu\n";
122 } elsif ($menu == 4) {
123 print $WHT."General Options\n".$NRM;
124 print "\n";
125 print "R Return to Main Menu\n";
126 } elsif ($menu == 5) {
127 print $WHT."Themes\n".$NRM;
128 print "\n";
129 print "R Return to Main Menu\n";
130 } elsif ($menu == 6) {
131 print $WHT."Address Books (LDAP)\n".$NRM;
132 print "\n";
133 print "R Return to Main Menu\n";
134 } elsif ($menu == 7) {
135 print $WHT."Message of the Day (MOTD)\n".$NRM;
136 print "\n$motd\n";
137 print "\n";
138 print "1 Edit the MOTD\n";
139 print "\n";
140 print "R Return to Main Menu\n";
141 }
142 print "X Quit without saving\n";
143 print "Q Save and exit\n";
144
145 print "\n";
146 print "Command >> ".$WHT;
147 $command = <STDIN>;
148 $command =~ s/[\n|\r]//g;
149 print "$NRM\n";
150
151 # Read the commands they entered.
152 if (($command eq "R") || ($command eq "r")) {
153 $menu = 0;
154 } else {
155 if ($menu == 0) {
156 if (($command > 0) && ($command < 8)) {
157 $menu = $command;
158 }
159 } elsif ($menu == 1) {
160 if ($command == 1) { $org_name = command1 (); }
161 elsif ($command == 2) { $org_logo = command2 (); }
162 elsif ($command == 3) { $org_title = command3 (); }
163 } elsif ($menu == 2) {
164 if ($command == 1) { $domain = command11 (); }
165 elsif ($command == 2) { $imapServerAddress = command12 (); }
166 elsif ($command == 3) { $imapPort = command13 (); }
167 elsif ($command == 4) { $useSendmail = command14 (); }
168 elsif ($command == 5) { $sendmail_path = command15 (); }
169 elsif ($command == 6) { $smtpServerAddress = command16 (); }
170 elsif ($command == 7) { $smtpPort = command17 (); }
171 } elsif ($menu == 3) {
172 if ($command == 1) { $default_folder_prefix = command21 (); }
173 elsif ($command == 2) { $show_prefix_option = command22 (); }
174 elsif ($command == 3) { $trash_folder = command23 (); }
175 elsif ($command == 4) { $sent_folder = command24 (); }
176 elsif ($command == 5) { $list_special_folders_first = command25 (); }
177 elsif ($command == 6) { $use_special_folder_color = command26 (); }
178 elsif ($command == 7) { $default_move_to_trash = command27 (); }
179 elsif ($command == 8) { $auto_expunge = command28 (); }
180 elsif ($command == 9) { $default_sub_of_inbox = command29 (); }
181 elsif ($command == 10){ $show_contain_subfolders_option = command210(); }
182 elsif ($command == 11){ $special_folders = command211(); }
183 } elsif ($menu == 4) {
184 } elsif ($menu == 5) {
185 } elsif ($menu == 6) {
186 } elsif ($menu == 7) {
187 if ($command == 1) { $motd = command71 (); }
188 }
189 }
190 }
191
192 ####################################################################################
193
194 # org_name
195 sub command1 {
196 print "We have tried to make the name SquirrelMail as transparent as\n";
197 print "possible. If you set up an organization name, most places where\n";
198 print "SquirrelMail would take credit will be credited to your organization.\n";
199 print "\n";
200 print "[$WHT$org_name$NRM]: $WHT";
201 $new_org_name = <STDIN>;
202 if ($new_org_name eq "\n") {
203 $new_org_name = $org_name;
204 } else {
205 $new_org_name =~ s/[\r|\n]//g;
206 }
207 return $new_org_name;
208 }
209
210
211 # org_logo
212 sub command2 {
213 print "Your organization's logo is an image that will be displayed at\n";
214 print "different times throughout SquirrelMail. This is asking for the\n";
215 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
216 print "(../images/logo.jpg) path to your logo.\n";
217 print "\n";
218 print "[$WHT$org_logo$NRM]: $WHT";
219 $new_org_logo = <STDIN>;
220 if ($new_org_logo eq "\n") {
221 $new_org_logo = $org_logo;
222 } else {
223 $new_org_logo =~ s/[\r|\n]//g;
224 }
225 return $new_org_logo;
226 }
227
228 # org_title
229 sub command3 {
230 print "A title is what is displayed at the top of the browser window in\n";
231 print "the titlebar. Usually this will end up looking something like:\n";
232 print "\"Netscape: $org_title\"\n";
233 print "\n";
234 print "[$WHT$org_title$NRM]: $WHT";
235 $new_org_title = <STDIN>;
236 if ($new_org_title eq "\n") {
237 $new_org_title = $org_title;
238 } else {
239 $new_org_title =~ s/[\r|\n]//g;
240 }
241 return $new_org_title;
242 }
243
244 ####################################################################################
245
246 # domain
247 sub command11 {
248 print "The domain name is the suffix at the end of all email messages. If\n";
249 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
250 print "would be myorg.com.\n";
251 print "\n";
252 print "[$WHT$domain$NRM]: $WHT";
253 $new_domain = <STDIN>;
254 if ($new_domain eq "\n") {
255 $new_domain = $domain;
256 } else {
257 $new_domain =~ s/[\r|\n]//g;
258 }
259 return $new_domain;
260 }
261
262 # imapServerAddress
263 sub command12 {
264 print "This is the address where your IMAP server resides.\n";
265 print "[$WHT$imapServerAddress$NRM]: $WHT";
266 $new_imapServerAddress = <STDIN>;
267 if ($new_imapServerAddress eq "\n") {
268 $new_imapServerAddress = $imapServerAddress;
269 } else {
270 $new_imapServerAddress =~ s/[\r|\n]//g;
271 }
272 return $new_imapServerAddress;
273 }
274
275 # imapPort
276 sub command13 {
277 print "This is the port that your IMAP server is on. Usually this is 143.\n";
278 print "[$WHT$imapPort$NRM]: $WHT";
279 $new_imapPort = <STDIN>;
280 if ($new_imapPort eq "\n") {
281 $new_imapPort = $imapPort;
282 } else {
283 $new_imapPort =~ s/[\r|\n]//g;
284 }
285 return $new_imapPort;
286 }
287
288 # useSendmail
289 sub command14 {
290 print "You now need to choose the method that you will use for sending\n";
291 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
292 print "or use sendmail directly.\n";
293 if ($useSendmail eq "true") {
294 $default_value = "y";
295 } else {
296 $default_value = "n";
297 }
298 print "\n";
299 print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
300 $use_sendmail = <STDIN>;
301 if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
302 $useSendmail = "true";
303 } else {
304 $useSendmail = "false";
305 }
306 return $useSendmail;
307 }
308
309 # sendmail_path
310 sub command15 {
311 if ($sendmail_path[0] !~ /./) {
312 $sendmail_path = "/usr/sbin/sendmail";
313 }
314 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
315 print "[$WHT$sendmail_path$NRM]: $WHT";
316 $new_sendmail_path = <STDIN>;
317 if ($new_sendmail_path eq "\n") {
318 $new_sendmail_path = $sendmail_path;
319 } else {
320 $new_sendmail_path =~ s/[\r|\n]//g;
321 }
322 return $new_sendmail_path;
323 }
324
325 # smtpServerAddress
326 sub command16 {
327 print "This is the location of your SMTP server.\n";
328 print "[$WHT$smtpServerAddress$NRM]: $WHT";
329 $new_smtpServerAddress = <STDIN>;
330 if ($new_smtpServerAddress eq "\n") {
331 $new_smtpServerAddress = $smtpServerAddress;
332 } else {
333 $new_smtpServerAddress =~ s/[\r|\n]//g;
334 }
335 return $new_smtpServerAddress;
336 }
337
338 # smtpPort
339 sub command17 {
340 print "This is the port to connect to for SMTP. Usually 25.\n";
341 print "[$WHT$smtpPort$NRM]: $WHT";
342 $new_smtpPort = <STDIN>;
343 if ($new_smtpPort eq "\n") {
344 $new_smtpPort = $smtpPort;
345 } else {
346 $new_smtpPort =~ s/[\r|\n]//g;
347 }
348 return $new_smtpPort;
349 }
350
351 # MOTD
352 sub command71 {
353 print "\nYou can now create the welcome message that is displayed\n";
354 print "every time a user logs on. You can use HTML or just plain\n";
355 print "text.\n\n(Type @ on a blank line to exit)\n";
356 do {
357 print "] ";
358 $line = <STDIN>;
359 $line =~ s/[\r|\n]//g;
360 $line =~ s/ /\&nbsp;\&nbsp;/g;
361 if ($line ne "@") {
362 $new_motd = $new_motd . $line;
363 }
364 } while ($line ne "@");
365 return $new_motd;
366 }
367
368 ################# FOLDERS ###################
369
370 # default_folder_prefix
371 sub command21 {
372 print "Some IMAP servers (UW, for example) store mail and folders in\n";
373 print "your user space in a separate subdirectory. This is where you\n";
374 print "specify what that directory is.\n";
375 print "\n";
376 print "NOTE: If you use Cyrus, or some server that would not use this\n";
377 print " option, you must set this to 'none'.\n";
378 print "\n";
379 print "[$WHT$default_folder_prefix$NRM]: $WHT";
380 $new_default_folder_prefix = <STDIN>;
381 if ($new_default_folder_prefix eq "\n") {
382 $new_default_folder_prefix = $default_folder_prefix;
383 } else {
384 $new_default_folder_prefix =~ s/[\r|\n]//g;
385 }
386 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
387 $new_default_folder_prefix = "";
388 } else {
389 $new_default_folder_prefix =~ s/\/*$//g;
390 $new_default_folder_prefix =~ s/$/\//g;
391 }
392 return $new_default_folder_prefix;
393 }
394
395 # Show Folder Prefix
396 sub command22 {
397 print "It is possible to set up the default folder prefix as a user\n";
398 print "specific option, where each user can specify what their mail\n";
399 print "folder is. If you set this to false, they will never see the\n";
400 print "option, but if it is true, this option will appear in the\n";
401 print "'options' section.\n";
402 print "\n";
403 print "NOTE: You set the default folder prefix in option '1' of this\n";
404 print " section. That will be the default if the user doesn't\n";
405 print " specify anything different.\n";
406 print "\n";
407
408 if ($show_prefix_option eq "true") {
409 $default_value = "y";
410 } else {
411 $default_value = "n";
412 }
413 print "\n";
414 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
415 $new_show = <STDIN>;
416 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
417 $show_prefix_option = "true";
418 } else {
419 $show_prefix_option = "false";
420 }
421 return $show_prefix_option;
422 }
423
424 # Trash Folder
425 sub command23 {
426 print "You can now specify where the default trash folder is located.\n";
427 print "On servers where you do not want this, you can set it to anything\n";
428 print "and set option 7 to false.\n";
429 print "\n";
430 print "This is relative to where the rest of your email is kept. You do\n";
431 print "not need to worry about their mail directory. If this folder\n";
432 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
433 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
434 print "\n";
435
436 print "[$WHT$trash_folder$NRM]: $WHT";
437 $new_trash_folder = <STDIN>;
438 if ($new_trash_folder eq "\n") {
439 $new_trash_folder = $trash_folder;
440 } else {
441 $new_trash_folder =~ s/[\r|\n]//g;
442 }
443 return $new_trash_folder;
444 }
445
446 # Sent Folder
447 sub command24 {
448 print "This is where messages that are sent will be stored. SquirrelMail\n";
449 print "by default puts a copy of all outgoing messages in this folder.\n";
450 print "\n";
451 print "This is relative to where the rest of your email is kept. You do\n";
452 print "not need to worry about their mail directory. If this folder\n";
453 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
454 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
455 print "\n";
456
457 print "[$WHT$sent_folder$NRM]: $WHT";
458 $new_sent_folder = <STDIN>;
459 if ($new_sent_folder eq "\n") {
460 $new_sent_folder = $sent_folder;
461 } else {
462 $new_sent_folder =~ s/[\r|\n]//g;
463 }
464 return $new_sent_folder;
465 }
466
467 # List special folders first
468 sub command25 {
469 print "SquirrelMail has what we call 'special folders' that are not\n";
470 print "manipulated and viewed like normal folders. Some examples of\n";
471 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
472 print "Simply asks if you want these folders listed first in the folder\n";
473 print "listing.\n";
474 print "\n";
475
476 if ($list_special_folders_first eq "true") {
477 $default_value = "y";
478 } else {
479 $default_value = "n";
480 }
481 print "\n";
482 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
483 $new_show = <STDIN>;
484 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
485 $list_special_folders_first = "true";
486 } else {
487 $list_special_folders_first = "false";
488 }
489 return $list_special_folders_first;
490 }
491
492 # Show special folders color
493 sub command26 {
494 print "SquirrelMail has what we call 'special folders' that are not\n";
495 print "manipulated and viewed like normal folders. Some examples of\n";
496 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
497 print "wants to know if we should display special folders in a\n";
498 print "color than the other folders.\n";
499 print "\n";
500
501 if ($use_special_folder_color eq "true") {
502 $default_value = "y";
503 } else {
504 $default_value = "n";
505 }
506 print "\n";
507 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
508 $new_show = <STDIN>;
509 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
510 $use_special_folder_color = "true";
511 } else {
512 $use_special_folder_color = "false";
513 }
514 return $use_special_folder_color;
515 }
516
517 # default move to trash
518 sub command27 {
519 print "By default, should messages get moved to the trash folder? You\n";
520 print "can specify the default trash folder in option 3. If this is set\n";
521 print "to false, messages will get deleted immediately without moving\n";
522 print "to the trash folder.\n";
523 print "\n";
524 print "Trash folder is currently: $trash_folder\n";
525 print "\n";
526
527 if ($default_move_to_trash eq "true") {
528 $default_value = "y";
529 } else {
530 $default_value = "n";
531 }
532 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
533 $new_show = <STDIN>;
534 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
535 $default_move_to_trash = "true";
536 } else {
537 $default_move_to_trash = "false";
538 }
539 return $default_move_to_trash;
540 }
541
542 # Auto expunge
543 sub command28 {
544 print "The way that IMAP handles deleting messages is as follows. You\n";
545 print "mark the message as deleted, and then to 'really' delete it, you\n";
546 print "expunge it. This option asks if you want to just have messages\n";
547 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
548 print "messages too.\n";
549 print "\n";
550
551 if ($auto_expunge eq "true") {
552 $default_value = "y";
553 } else {
554 $default_value = "n";
555 }
556 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
557 $new_show = <STDIN>;
558 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
559 $auto_expunge = "true";
560 } else {
561 $auto_expunge = "false";
562 }
563 return $auto_expunge;
564 }
565
566 # Default sub of inbox
567 sub command29 {
568 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
569 print "This can cause some confusion in folder creation for users when\n";
570 print "they try to create folders and don't put it as a subfolder of INBOX\n";
571 print "and get permission errors. This option asks if you want folders\n";
572 print "to be subfolders of INBOX by default.\n";
573 print "\n";
574
575 if ($default_sub_of_inbox eq "true") {
576 $default_value = "y";
577 } else {
578 $default_value = "n";
579 }
580 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
581 $new_show = <STDIN>;
582 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
583 $default_sub_of_inbox = "true";
584 } else {
585 $default_sub_of_inbox = "false";
586 }
587 return $default_sub_of_inbox;
588 }
589
590 # Show contain subfolder option
591 sub command210 {
592 print "Some IMAP servers (UW) make it so that there are two types of\n";
593 print "folders. Those that contain messages, and those that contain\n";
594 print "subfolders. If this is the case for your server, set this to\n";
595 print "true, and it will ask the user whether the folder they are\n";
596 print "creating contains subfolders or messages.\n";
597 print "\n";
598
599 if ($show_contain_subfolders_option eq "true") {
600 $default_value = "y";
601 } else {
602 $default_value = "n";
603 }
604 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
605 $new_show = <STDIN>;
606 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
607 $show_contain_subfolders_option = "true";
608 } else {
609 $show_contain_subfolders_option = "false";
610 }
611 return $show_contain_subfolders_option;
612 }
613
614 # special folders
615 sub command211 {
616 print "\nSpecial folders are folders that can't be manipulated like normal\n";
617 print "user-created folders. A couple of examples of these would be the\n";
618 print "trash folder, the sent folder, etc.\n";
619 print "Special Folders:\n";
620 $count = 0;
621 print "\n";
622 while ($count < @special_folders) {
623 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
624 $count++;
625 }
626 print "\n[folders] command (?=help) > ";
627 $input = <STDIN>;
628 $input =~ s/[\r|\n]//g;
629 while ($input !~ /^d$/i) {
630 ## ADD
631 if ($input =~ /^\s*\+\s*.*/) {
632 $input =~ s/^\s*\+\s*//;
633 $special_folders[$#special_folders+1] = $input;
634 }
635
636 elsif ($input =~ /^\s*-\s*[0-9]?/i) {
637 if ($input =~ /[0-9]+\s*$/) {
638 $rem_num = $input;
639 $rem_num =~ s/^\s*-\s*//g;
640 $rem_num =~ s/\s*$//;
641 } else {
642 $rem_num = $#special_folders;
643 }
644
645 if ($rem_num == 0) {
646 print "You cannot remove INBOX. It is a very special folder.\n";
647 } else {
648 $count = 0;
649 @new_special_folders = ();
650 $removed = 0;
651 while ($count <= $#special_folders) {
652 if ($count != $rem_num) {
653 @new_special_folders = (@new_special_folders, $special_folders[$count]);
654 }
655 if ($count == $rem_num) {
656 print "Removed: $special_folders[$rem_num]\n";
657 $removed = 1;
658 }
659 $count++;
660 }
661 if ($removed != 1) {
662 print "Error: Can't delete an entry that's not there!\n";
663 }
664 @special_folders = @new_special_folders;
665 }
666 }
667
668 elsif ($input =~ /^\s*l\s*/i) {
669 $count = 0;
670 print "\n";
671 while ($count < @special_folders) {
672 print " $count) $WHT" . $special_folders[$count] . "$NRM\n";
673 $count++;
674 }
675 } elsif ($input =~ /^\s*\?\s*/) {
676 print ".-------------------------.\n";
677 print "| + Folder (add folder) |\n";
678 print "| - N (remove folder) |\n";
679 print "| l (list folders) |\n";
680 print "| d (done) |\n";
681 print "`-------------------------'\n";
682 }
683
684 else {
685 print "Unrecognized command.\n";
686 }
687
688 print "\n[folders] command (?=help) > ";
689 $input = <STDIN>;
690 $input =~ s/[\r|\n]//g;
691 }
692 return @special_folders;
693 }