Added sent_subfolders plugin, tweaked config stuff, other stuff.
[squirrelmail.git] / config / conf.pl
1 #!/usr/bin/perl
2 # conf.pl
3 # Luke Ehresman (luke@squirrelmail.org)
4 #
5 # A simple configure script to configure squirrelmail
6 #
7 # $Id$
8 ############################################################
9 $conf_pl_version = "1.2.0";
10
11 ############################################################
12 # Some people try to run this as a CGI. That's wrong!
13 ############################################################
14 if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) ||
15 defined($ENV{'REQUEST_METHOD'})) {
16 print "Content-Type: text/html\n\n";
17 print "You must run this script from the command line.";
18 exit;
19 }
20
21 ############################################################
22 # First, lets read in the data already in there...
23 ############################################################
24 if ( -e "config.php") {
25 open (FILE, "config.php");
26 while ($line = <FILE>) {
27 $line =~ s/^\s+//;
28 $line =~ s/^\$//;
29 $var = $line;
30
31 $var =~ s/=/EQUALS/;
32 if ($var =~ /^([a-z]|[A-Z])/) {
33 @o = split(/\s*EQUALS\s*/, $var);
34 if ($o[0] eq "config_version") {
35 $o[1] =~ s/[\n|\r]//g;
36 $o[1] =~ s/[\'|\"];\s*$//;
37 $o[1] =~ s/;$//;
38 $o[1] =~ s/^[\'|\"]//;
39
40 $config_version = $o[1];
41 close (FILE);
42 }
43 }
44 }
45 close (FILE);
46
47 if ($config_version ne $conf_pl_version) {
48 system "clear";
49 print $WHT."WARNING:\n".$NRM;
50 print " The file \"config/config.php\" was found, but it is for\n";
51 print " an older version of SquirrelMail. It is possible to still\n";
52 print " read the defaults from this file but be warned that many\n";
53 print " preferences change between versions. It is recommended that\n";
54 print " you start with a clean config.php for each upgrade that you\n";
55 print " do. To do this, just move config/config.php out of the way.\n";
56 print "\n";
57 print "Continue loading with the old config.php [y/N]? ";
58 $ctu = <STDIN>;
59 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
60 exit;
61 }
62
63 print "\nDo you want me to stop warning you [y/N]? ";
64 $ctu = <STDIN>;
65 if ($ctu =~ /^y\n/i) {
66 $print_config_version = $conf_pl_version;
67 } else {
68 $print_config_version = $config_version;
69 }
70 } else {
71 $print_config_version = $config_version;
72 }
73
74 $config = 1;
75 open (FILE, "config.php");
76 } elsif (-e "config_default.php") {
77 open (FILE, "config_default.php");
78 while ($line = <FILE>) {
79 $line =~ s/^\s+//;
80 $line =~ s/^\$//;
81 $var = $line;
82
83 $var =~ s/=/EQUALS/;
84 if ($var =~ /^([a-z]|[A-Z])/) {
85 @o = split(/\s*EQUALS\s*/, $var);
86 if ($o[0] eq "config_version") {
87 $o[1] =~ s/[\n|\r]//g;
88 $o[1] =~ s/[\'|\"];\s*$//;
89 $o[1] =~ s/;$//;
90 $o[1] =~ s/^[\'|\"]//;
91
92 $config_version = $o[1];
93 close (FILE);
94 }
95 }
96 }
97 close (FILE);
98
99 if ($config_version ne $conf_pl_version) {
100 system "clear";
101 print $WHT."WARNING:\n".$NRM;
102 print " You are trying to use a 'config_default.php' from an older\n";
103 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
104 print " should get the 'config_default.php' that matches the version\n";
105 print " of SquirrelMail that you are running. You can get this from\n";
106 print " the SquirrelMail web page by going to the following URL:\n";
107 print " http://www.squirrelmail.org.\n";
108 print "\n";
109 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
110 $ctu = <STDIN>;
111 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
112 exit;
113 }
114
115 print "\nDo you want me to stop warning you [y/N]? ";
116 $ctu = <STDIN>;
117 if ($ctu =~ /^y\n/i) {
118 $print_config_version = $conf_pl_version;
119 } else {
120 $print_config_version = $config_version;
121 }
122 } else {
123 $print_config_version = $config_version;
124 }
125 $config = 2;
126 open (FILE, "config_default.php");
127 } else {
128 print "No configuration file found. Please get config_default.php\n";
129 print "or config.php before running this again. This program needs\n";
130 print "a default config file to get default values.\n";
131 exit;
132 }
133
134 # Read and parse the current configuration file
135 # (either config.php or config_default.php).
136 while ($line = <FILE>) {
137 $line =~ s/^\s+//;
138 $line =~ s/^\$//;
139 $var = $line;
140
141 $var =~ s/=/EQUALS/;
142 if ($var =~ /^([a-z]|[A-Z])/) {
143 @options = split(/\s*EQUALS\s*/, $var);
144 $options[1] =~ s/[\n|\r]//g;
145 $options[1] =~ s/[\'|\"];\s*$//;
146 $options[1] =~ s/;$//;
147 $options[1] =~ s/^[\'|\"]//;
148
149 if ($options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/) {
150 $sub = $options[0];
151 $sub =~ s/\]\[['|"]PATH['|"]\]//;
152 $sub =~ s/.*\[//;
153 if (-e "../themes") {
154 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
155 }
156 $theme_path[$sub] = $options[1];
157 } elsif ($options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/) {
158 $sub = $options[0];
159 $sub =~ s/\]\[['|"]NAME['|"]\]//;
160 $sub =~ s/.*\[//;
161 $theme_name[$sub] = $options[1];
162 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
163 $sub = $options[0];
164 $sub =~ s/\]//;
165 $sub =~ s/^plugins\[//;
166 $plugins[$sub] = $options[1];
167 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
168 $sub = $options[0];
169 $sub =~ s/\]//;
170 $sub =~ s/^ldap_server\[//;
171 $continue = 0;
172 while (($tmp = <FILE>) && ($continue != 1)) {
173 if ($tmp =~ /\);\s*$/) {
174 $continue = 1;
175 }
176
177 if ($tmp =~ /^\s*[\'|\"]host[\'|\"]/i) {
178 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
179 $tmp =~ s/[\'|\"],?\s*$//;
180 $tmp =~ s/[\'|\"]\);\s*$//;
181 $host = $tmp;
182 } elsif ($tmp =~ /^\s*[\'|\"]base[\'|\"]/i) {
183 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
184 $tmp =~ s/[\'|\"],?\s*$//;
185 $tmp =~ s/[\'|\"]\);\s*$//;
186 $base = $tmp;
187 } elsif ($tmp =~ /^\s*[\'|\"]charset[\'|\"]/i) {
188 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
189 $tmp =~ s/[\'|\"],?\s*$//;
190 $tmp =~ s/[\'|\"]\);\s*$//;
191 $charset = $tmp;
192 } elsif ($tmp =~ /^\s*[\'|\"]port[\'|\"]/i) {
193 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
194 $tmp =~ s/[\'|\"],?\s*$//;
195 $tmp =~ s/[\'|\"]\);\s*$//;
196 $port = $tmp;
197 } elsif ($tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i) {
198 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
199 $tmp =~ s/[\'|\"],?\s*$//;
200 $tmp =~ s/[\'|\"]\);\s*$//;
201 $maxrows = $tmp;
202 } elsif ($tmp =~ /^\s*[\'|\"]name[\'|\"]/i) {
203 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
204 $tmp =~ s/[\'|\"],?\s*$//;
205 $tmp =~ s/[\'|\"]\);\s*$//;
206 $name = $tmp;
207 }
208 }
209 $ldap_host[$sub] = $host;
210 $ldap_base[$sub] = $base;
211 $ldap_name[$sub] = $name;
212 $ldap_port[$sub] = $port;
213 $ldap_maxrows[$sub] = $maxrows;
214 $ldap_charset[$sub] = $charset;
215 } else {
216 ${$options[0]} = $options[1];
217 }
218 }
219 }
220 close FILE;
221 if ($useSendmail ne "true") {
222 $useSendmail = "false";
223 }
224 if (!$sendmail_path) {
225 $sendmail_path = "/usr/sbin/sendmail";
226 }
227 if (!$default_unseen_notify) {
228 $default_unseen_notify = 2;
229 }
230 if (!$default_unseen_type) {
231 $default_unseen_type = 1;
232 }
233 if (!$config_use_color) {
234 $config_use_color = 1;
235 }
236 if (!$invert_time) {
237 $invert_time = "false";
238 }
239 if (!$force_username_lowercase) {
240 $force_username_lowercase = "false";
241 }
242 if (!$optional_delimiter) {
243 $optional_delimiter = "detect";
244 }
245 if (!$use_authenticated_smtp) {
246 $use_authenticated_smtp = "false";
247 }
248 if (!$auto_create_special) {
249 $auto_create_special = "false";
250 }
251 if(!$default_use_priority) {
252 $default_use_priority = "true";
253 }
254 if(!$hide_sm_attributions) {
255 $hide_sm_attributions = "false";
256 }
257
258 #####################################################################################
259 if ($config_use_color == 1) {
260 $WHT = "\x1B[37;1m";
261 $NRM = "\x1B[0m";
262 } else {
263 $WHT = "";
264 $NRM = "";
265 $config_use_color = 2;
266 }
267
268 while (($command ne "q") && ($command ne "Q")) {
269 system "clear";
270 print $WHT."SquirrelMail Configuration : ".$NRM;
271 if ($config == 1) { print "Read: config.php"; }
272 elsif ($config == 2) { print "Read: config_default.php"; }
273 print " ($print_config_version)\n";
274 print "---------------------------------------------------------\n";
275
276 if ($menu == 0) {
277 print $WHT."Main Menu --\n".$NRM;
278 print "1. Organization Preferences\n";
279 print "2. Server Settings\n";
280 print "3. Folder Defaults\n";
281 print "4. General Options\n";
282 print "5. Themes\n";
283 print "6. Address Books (LDAP)\n";
284 print "7. Message of the Day (MOTD)\n";
285 print "8. Plugins\n";
286 print "\n";
287 print "D. Set pre-defined settings for specific IMAP servers\n";
288 print "\n";
289 } elsif ($menu == 1) {
290 print $WHT."Organization Preferences\n".$NRM;
291 print "1. Organization Name : $WHT$org_name$NRM\n";
292 print "2. Organization Logo : $WHT$org_logo$NRM\n";
293 print "3. Organization Title : $WHT$org_title$NRM\n";
294 print "4. Signout Page : $WHT$signout_page$NRM\n";
295 print "5. Default Language : $WHT$squirrelmail_default_language$NRM\n";
296 print "\n";
297 print "R Return to Main Menu\n";
298 } elsif ($menu == 2) {
299 print $WHT."Server Settings\n".$NRM;
300 print "1. Domain : $WHT$domain$NRM\n";
301 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
302 print "3. IMAP Port : $WHT$imapPort$NRM\n";
303 print "4. Use Sendmail/SMTP : $WHT";
304 if ($useSendmail eq "true") {
305 print "Sendmail";
306 } else {
307 print "SMTP";
308 }
309 print "$NRM\n";
310 if ($useSendmail eq "true") {
311 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
312 } else {
313 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
314 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
315 print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
316 }
317 print "9. Server : $WHT$imap_server_type$NRM\n";
318 print "10. Invert Time : $WHT$invert_time$NRM\n";
319 print "11. Delimiter : $WHT$optional_delimiter$NRM\n";
320 print "\n";
321 print "R Return to Main Menu\n";
322 } elsif ($menu == 3) {
323 print $WHT."Folder Defaults\n".$NRM;
324 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
325 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
326 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
327 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
328 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
329 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
330 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
331 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
332 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
333 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
334 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
335 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
336 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
337 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
338 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
339 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
340 print "\n";
341 print "R Return to Main Menu\n";
342 } elsif ($menu == 4) {
343 print $WHT."General Options\n".$NRM;
344 print "1. Default Charset : $WHT$default_charset$NRM\n";
345 print "2. Data Directory : $WHT$data_dir$NRM\n";
346 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
347 print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
348 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
349 print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
350 print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
351 print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
352 print "\n";
353 print "R Return to Main Menu\n";
354 } elsif ($menu == 5) {
355 print $WHT."Themes\n".$NRM;
356 print "1. Change Themes\n";
357 for ($count = 0; $count <= $#theme_name; $count++) {
358 print " > $theme_name[$count]\n";
359 }
360 print "2. CSS File : $WHT$theme_css$NRM\n";
361 print "\n";
362 print "R Return to Main Menu\n";
363 } elsif ($menu == 6) {
364 print $WHT."Address Books (LDAP)\n".$NRM;
365 print "1. Change Servers\n";
366 for ($count = 0; $count <= $#ldap_host; $count++) {
367 print " > $ldap_host[$count]\n";
368 }
369 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
370 print "\n";
371 print "R Return to Main Menu\n";
372 } elsif ($menu == 7) {
373 print $WHT."Message of the Day (MOTD)\n".$NRM;
374 print "\n$motd\n";
375 print "\n";
376 print "1 Edit the MOTD\n";
377 print "\n";
378 print "R Return to Main Menu\n";
379 } elsif ($menu == 8) {
380 print $WHT."Plugins\n".$NRM;
381 print " Installed Plugins\n";
382 $num = 0;
383 for ($count = 0; $count <= $#plugins; $count++) {
384 $num = $count + 1;
385 print " $num. $plugins[$count]\n";
386 }
387 print "\n Available Plugins:\n";
388 opendir(DIR, "../plugins");
389 @files = readdir(DIR);
390 $pos=0;
391 @unused_plugins = ();
392 for ($i=0; $i <= $#files; $i++) {
393 if ( -d "../plugins/" . $files[$i] &&
394 $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
395 $match = 0;
396 for ($k=0; $k<=$#plugins; $k++) {
397 if ($plugins[$k] eq $files[$i]) {
398 $match = 1;
399 }
400 }
401 if ($match == 0) {
402 $unused_plugins[$pos] = $files[$i];
403 $pos++;
404 }
405 }
406 }
407
408 for ($i=0; $i<=$#unused_plugins; $i++) {
409 $num = $num + 1;
410 print " $num. $unused_plugins[$i]\n";
411 }
412 closedir DIR;
413
414 print "\n";
415 print "A Sanitize all plugins for use with Squirrelmail 1.2\n";
416 print "\n";
417 print "R Return to Main Menu\n";
418 }
419 if ($config_use_color == 1) {
420 print "C. Turn color off\n";
421 } else {
422 print "C. Turn color on\n";
423 }
424 print "S Save data\n";
425 print "Q Quit\n";
426
427 print "\n";
428 print "Command >> ".$WHT;
429 $command = <STDIN>;
430 $command =~ s/[\n|\r]//g;
431 $command =~ tr/A-Z/a-z/;
432 print "$NRM\n";
433
434 # Read the commands they entered.
435 if ($command eq "r") {
436 $menu = 0;
437 } elsif ($command eq "s") {
438 save_data ();
439 print "Data saved in config.php\n";
440 print "Press enter to continue...";
441 $tmp = <STDIN>;
442 $saved = 1;
443 } elsif (($command eq "q") && ($saved == 0)) {
444 print "You have not saved your data.\n";
445 print "Save? [".$WHT."Y".$NRM."/n]: ";
446 $save = <STDIN>;
447 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
448 save_data ();
449 }
450 } elsif ($command eq "c") {
451 if ($config_use_color == 1) {
452 $config_use_color = 2;
453 $WHT = "";
454 $NRM = "";
455 } else {
456 $config_use_color = 1;
457 $WHT = "\x1B[37;1m";
458 $NRM = "\x1B[0m";
459 }
460 } elsif ($command eq "d" && $menu == 0) {
461 set_defaults ();
462 } else {
463 $saved = 0;
464 if ($menu == 0) {
465 if (($command > 0) && ($command < 9)) {
466 $menu = $command;
467 }
468 } elsif ($menu == 1) {
469 if ($command == 1) { $org_name = command1 (); }
470 elsif ($command == 2) { $org_logo = command2 (); }
471 elsif ($command == 3) { $org_title = command3 (); }
472 elsif ($command == 4) { $signout_page = command4 (); }
473 elsif ($command == 5) { $squirrelmail_default_language = command5(); }
474 } elsif ($menu == 2) {
475 if ($command == 1) { $domain = command11 (); }
476 elsif ($command == 2) { $imapServerAddress = command12 (); }
477 elsif ($command == 3) { $imapPort = command13 (); }
478 elsif ($command == 4) { $useSendmail = command14 (); }
479 elsif ($command == 5) { $sendmail_path = command15 (); }
480 elsif ($command == 6) { $smtpServerAddress = command16 (); }
481 elsif ($command == 7) { $smtpPort = command17 (); }
482 elsif ($command == 8) { $use_authenticated_smtp = command18 (); }
483 elsif ($command == 9) { $imap_server_type = command19 (); }
484 elsif ($command == 10) { $invert_time = command110 (); }
485 elsif ($command == 11) { $optional_delimiter = command111 (); }
486 } elsif ($menu == 3) {
487 if ($command == 1) { $default_folder_prefix = command21 (); }
488 elsif ($command == 2) { $show_prefix_option = command22 (); }
489 elsif ($command == 3) { $trash_folder = command23a (); }
490 elsif ($command == 4) { $sent_folder = command23b (); }
491 elsif ($command == 5) { $draft_folder = command23c (); }
492 elsif ($command == 6) { $default_move_to_trash = command24a (); }
493 elsif ($command == 7) { $default_move_to_sent = command24b (); }
494 elsif ($command == 8) { $default_save_as_draft = command24c (); }
495 elsif ($command == 9) { $list_special_folders_first = command27 (); }
496 elsif ($command == 10) { $use_special_folder_color = command28 (); }
497 elsif ($command == 11) { $auto_expunge = command29 (); }
498 elsif ($command == 12) { $default_sub_of_inbox = command210(); }
499 elsif ($command == 13) { $show_contain_subfolders_option = command211(); }
500 elsif ($command == 14) { $default_unseen_notify = command212(); }
501 elsif ($command == 15) { $default_unseen_type = command213(); }
502 elsif ($command == 16) { $auto_create_special = command214(); }
503 } elsif ($menu == 4) {
504 if ($command == 1) { $default_charset = command31 (); }
505 elsif ($command == 2) { $data_dir = command33a (); }
506 elsif ($command == 3) { $attachment_dir = command33b (); }
507 elsif ($command == 4) { $dir_hash_level = command33c (); }
508 elsif ($command == 5) { $default_left_size = command35 (); }
509 elsif ($command == 6) { $force_username_lowercase = command36 (); }
510 elsif ($command == 7) { $default_use_priority = command37 (); }
511 elsif ($command == 8) { $hide_sm_attributions = command38 (); }
512 } elsif ($menu == 5) {
513 if ($command == 1) { command41 (); }
514 elsif ($command == 2) { $theme_css = command42 (); }
515 } elsif ($menu == 6) {
516 if ($command == 1) { command61(); }
517 elsif ($command == 2) { command62(); }
518 } elsif ($menu == 7) {
519 if ($command == 1) { $motd = command71(); }
520 } elsif ($menu == 8) {
521 if ($command =~ /^[0-9]+/) { @plugins = command81(); }
522 elsif ($command eq "a") { command8s(); }
523 }
524 }
525 }
526
527 ####################################################################################
528
529 # org_name
530 sub command1 {
531 print "We have tried to make the name SquirrelMail as transparent as\n";
532 print "possible. If you set up an organization name, most places where\n";
533 print "SquirrelMail would take credit will be credited to your organization.\n";
534 print "\n";
535 print "[$WHT$org_name$NRM]: $WHT";
536 $new_org_name = <STDIN>;
537 if ($new_org_name eq "\n") {
538 $new_org_name = $org_name;
539 } else {
540 $new_org_name =~ s/[\r|\n]//g;
541 }
542 return $new_org_name;
543 }
544
545
546 # org_logo
547 sub command2 {
548 print "Your organization's logo is an image that will be displayed at\n";
549 print "different times throughout SquirrelMail. This is asking for the\n";
550 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
551 print "(../images/logo.jpg) path to your logo.\n";
552 print "\n";
553 print "[$WHT$org_logo$NRM]: $WHT";
554 $new_org_logo = <STDIN>;
555 if ($new_org_logo eq "\n") {
556 $new_org_logo = $org_logo;
557 } else {
558 $new_org_logo =~ s/[\r|\n]//g;
559 }
560 return $new_org_logo;
561 }
562
563 # org_title
564 sub command3 {
565 print "A title is what is displayed at the top of the browser window in\n";
566 print "the titlebar. Usually this will end up looking something like:\n";
567 print "\"Netscape: $org_title\"\n";
568 print "\n";
569 print "[$WHT$org_title$NRM]: $WHT";
570 $new_org_title = <STDIN>;
571 if ($new_org_title eq "\n") {
572 $new_org_title = $org_title;
573 } else {
574 $new_org_title =~ s/[\r|\n]//g;
575 }
576 return $new_org_title;
577 }
578
579 # signout_page
580 sub command4 {
581 print "When users click the Sign Out button they will be logged out and\n";
582 print "then sent to signout_page. If signout_page is left empty,\n";
583 print "(hit space and then return) they will be taken, as normal,\n";
584 print "to the default and rather sparse SquirrelMail signout page.\n";
585 print "\n";
586 print "[$WHT$signout_page$NRM]: $WHT";
587 $new_signout_page = <STDIN>;
588 if ($new_signout_page eq "\n") {
589 $new_signout_page = $signout_page;
590 } else {
591 $new_signout_page =~ s/[\r|\n]//g;
592 $new_signout_page =~ s/^\s+$//g;
593 }
594 return $new_signout_page;
595 }
596
597 # Default language
598 sub command5 {
599 print "SquirrelMail attempts to set the language in many ways. If it\n";
600 print "can not figure it out in another way, it will default to this\n";
601 print "language. Please use the two-letter code for the desired language.\n";
602 print "\n";
603 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
604 $new_signout_page = <STDIN>;
605 if ($new_signout_page eq "\n") {
606 $new_signout_page = $squirrelmail_default_language;
607 } else {
608 $new_signout_page =~ s/[\r|\n]//g;
609 $new_signout_page =~ s/^\s+$//g;
610 }
611 return $new_signout_page;
612 }
613
614 ####################################################################################
615
616 # domain
617 sub command11 {
618 print "The domain name is the suffix at the end of all email messages. If\n";
619 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
620 print "would be myorg.com.\n";
621 print "\n";
622 print "[$WHT$domain$NRM]: $WHT";
623 $new_domain = <STDIN>;
624 if ($new_domain eq "\n") {
625 $new_domain = $domain;
626 } else {
627 $new_domain =~ s/[\r|\n]//g;
628 }
629 return $new_domain;
630 }
631
632 # imapServerAddress
633 sub command12 {
634 print "This is the address where your IMAP server resides.\n";
635 print "[$WHT$imapServerAddress$NRM]: $WHT";
636 $new_imapServerAddress = <STDIN>;
637 if ($new_imapServerAddress eq "\n") {
638 $new_imapServerAddress = $imapServerAddress;
639 } else {
640 $new_imapServerAddress =~ s/[\r|\n]//g;
641 }
642 return $new_imapServerAddress;
643 }
644
645 # imapPort
646 sub command13 {
647 print "This is the port that your IMAP server is on. Usually this is 143.\n";
648 print "[$WHT$imapPort$NRM]: $WHT";
649 $new_imapPort = <STDIN>;
650 if ($new_imapPort eq "\n") {
651 $new_imapPort = $imapPort;
652 } else {
653 $new_imapPort =~ s/[\r|\n]//g;
654 }
655 return $new_imapPort;
656 }
657
658 # useSendmail
659 sub command14 {
660 print "You now need to choose the method that you will use for sending\n";
661 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
662 print "or use sendmail directly.\n";
663 if ($useSendmail eq "true") {
664 $default_value = "1";
665 } else {
666 $default_value = "2";
667 }
668 print "\n";
669 print " 1. Sendmail\n";
670 print " 2. SMTP\n";
671 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
672 $use_sendmail = <STDIN>;
673 if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
674 $useSendmail = "true";
675 } else {
676 $useSendmail = "false";
677 }
678 return $useSendmail;
679 }
680
681 # sendmail_path
682 sub command15 {
683 if ($sendmail_path[0] !~ /./) {
684 $sendmail_path = "/usr/sbin/sendmail";
685 }
686 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
687 print "[$WHT$sendmail_path$NRM]: $WHT";
688 $new_sendmail_path = <STDIN>;
689 if ($new_sendmail_path eq "\n") {
690 $new_sendmail_path = $sendmail_path;
691 } else {
692 $new_sendmail_path =~ s/[\r|\n]//g;
693 }
694 return $new_sendmail_path;
695 }
696
697 # smtpServerAddress
698 sub command16 {
699 print "This is the location of your SMTP server.\n";
700 print "[$WHT$smtpServerAddress$NRM]: $WHT";
701 $new_smtpServerAddress = <STDIN>;
702 if ($new_smtpServerAddress eq "\n") {
703 $new_smtpServerAddress = $smtpServerAddress;
704 } else {
705 $new_smtpServerAddress =~ s/[\r|\n]//g;
706 }
707 return $new_smtpServerAddress;
708 }
709
710 # smtpPort
711 sub command17 {
712 print "This is the port to connect to for SMTP. Usually 25.\n";
713 print "[$WHT$smtpPort$NRM]: $WHT";
714 $new_smtpPort = <STDIN>;
715 if ($new_smtpPort eq "\n") {
716 $new_smtpPort = $smtpPort;
717 } else {
718 $new_smtpPort =~ s/[\r|\n]//g;
719 }
720 return $new_smtpPort;
721 }
722
723 # authenticated server
724 sub command18 {
725 print "Do you wish to use an authenticated SMTP server? Your server must\n";
726 print "support this in order for SquirrelMail to work with it. We implemented\n";
727 print "it according to RFC 2554.\n";
728
729 $YesNo = 'n';
730 $YesNo = 'y' if ($use_authenticated_smtp eq "true");
731
732 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
733
734 $new_use_authenticated_smtp = <STDIN>;
735 $new_use_authenticated_smtp =~ tr/yn//cd;
736 return "true" if ($new_use_authenticated_smtp eq "y");
737 return "false" if ($new_use_authenticated_smtp eq "n");
738 return $use_authenticated_smtp;
739 }
740
741 # imap_server_type
742 sub command19 {
743 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
744 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
745 print "the same principles. We have made some work-arounds for some of\n";
746 print "these servers. If you would like to use them, please select your\n";
747 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
748 print "set this to \"other\", and none will be used.\n";
749 print " cyrus = Cyrus IMAP server\n";
750 print " uw = University of Washington's IMAP server\n";
751 print " exchange = Microsoft Exchange IMAP server\n";
752 print " courier = Courier IMAP server\n";
753 print " other = Not one of the above servers\n";
754 print "[$WHT$imap_server_type$NRM]: $WHT";
755 $new_imap_server_type = <STDIN>;
756 if ($new_imap_server_type eq "\n") {
757 $new_imap_server_type = $imap_server_type;
758 } else {
759 $new_imap_server_type =~ s/[\r|\n]//g;
760 }
761 return $new_imap_server_type;
762 }
763
764 # invert_time
765 sub command110 {
766 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
767 print "on some machines). Typically this happens if the system doesn't support\n";
768 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
769 print "This most often occurs on Solaris 7 machines in the United States.\n";
770 print "By default, this is off. It should be kept off unless problems surface\n";
771 print "about the time that messages are sent.\n";
772 print " no = Do NOT fix time -- almost always correct\n";
773 print " yes = Fix the time for this system\n";
774
775 $YesNo = 'n';
776 $YesNo = 'y' if ($invert_time eq "true");
777
778 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
779
780 $new_invert_time = <STDIN>;
781 $new_invert_time =~ tr/yn//cd;
782 return "true" if ($new_invert_time eq "y");
783 return "false" if ($new_invert_time eq "n");
784 return $invert_time;
785 }
786
787 sub command111 {
788 print "This is the delimiter that your IMAP server uses to distinguish between\n";
789 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
790 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
791 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
792 print "but if you are sure you know what delimiter your server uses, you can\n";
793 print "specify it here.\n";
794 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
795 print "[$WHT$optional_delimiter$NRM]: $WHT";
796 $new_optional_delimiter = <STDIN>;
797 if ($new_optional_delimiter eq "\n") {
798 $new_optional_delimiter = $optional_delimiter;
799 } else {
800 $new_optional_delimiter =~ s/[\r|\n]//g;
801 }
802 return $new_optional_delimiter;
803 }
804
805 # MOTD
806 sub command71 {
807 print "\nYou can now create the welcome message that is displayed\n";
808 print "every time a user logs on. You can use HTML or just plain\n";
809 print "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
810
811 $new_motd = "";
812 do {
813 print "] ";
814 $line = <STDIN>;
815 $line =~ s/[\r|\n]//g;
816 if ($line ne "@") {
817 $line =~ s/ /\&nbsp;\&nbsp;/g;
818 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
819 $line =~ s/$/ /;
820 $line =~ s/\"/\\\"/g;
821
822 $new_motd = $new_motd . $line;
823 }
824 } while ($line ne "@");
825 return $new_motd;
826 }
827
828 ################# PLUGINS ###################
829
830 sub command81 {
831 $command =~ s/[\s|\n|\r]*//g;
832 if ($command > 0) {
833 $command = $command - 1;
834 if ($command <= $#plugins) {
835 @newplugins = ();
836 $ct=0;
837 while ($ct <= $#plugins) {
838 if ($ct != $command) {
839 @newplugins = (@newplugins, $plugins[$ct]);
840 }
841 $ct++;
842 }
843 @plugins = @newplugins;
844 } elsif ($command <= $#plugins + $#unused_plugins + 1) {
845 $num = $command - $#plugins - 1;
846 @newplugins = @plugins;
847 $ct=0;
848 while ($ct <= $#unused_plugins) {
849 if ($ct == $num) {
850 @newplugins = (@newplugins, $unused_plugins[$ct]);
851 # sanitize the plugin
852 $dir = $unused_plugins[$ct];
853 `./ri_once.pl ../plugins/$dir`;
854 }
855 $ct++;
856 }
857 @plugins = @newplugins;
858 }
859 }
860 return @plugins;
861 }
862
863 sub command8s {
864 print "This command will sanitize all plugins for use with\n";
865 print "Squirrelmail 1.2. That is, it will rewrite some php-\n";
866 print "constructs that are *incompatible* with the 1.2 design\n";
867 print "into ones that are *compatible*\n";
868 print "Do you wish to issue this command [y/N]? ";
869 $ctu = <STDIN>;
870 if ($ctu =~ /^y\n/i) {
871 `./ri_once.pl ../plugins`;
872 }
873 }
874
875 ################# FOLDERS ###################
876
877 # default_folder_prefix
878 sub command21 {
879 print "Some IMAP servers (UW, for example) store mail and folders in\n";
880 print "your user space in a separate subdirectory. This is where you\n";
881 print "specify what that directory is.\n";
882 print "\n";
883 print "EXAMPLE: mail/";
884 print "\n";
885 print "NOTE: If you use Cyrus, or some server that would not use this\n";
886 print " option, you must set this to 'none'.\n";
887 print "\n";
888 print "[$WHT$default_folder_prefix$NRM]: $WHT";
889 $new_default_folder_prefix = <STDIN>;
890 if ($new_default_folder_prefix eq "\n") {
891 $new_default_folder_prefix = $default_folder_prefix;
892 } else {
893 $new_default_folder_prefix =~ s/[\r|\n]//g;
894 }
895 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
896 $new_default_folder_prefix = "";
897 } else {
898 $new_default_folder_prefix =~ s/\/*$//g;
899 $new_default_folder_prefix =~ s/$/\//g;
900 }
901 return $new_default_folder_prefix;
902 }
903
904 # Show Folder Prefix
905 sub command22 {
906 print "It is possible to set up the default folder prefix as a user\n";
907 print "specific option, where each user can specify what their mail\n";
908 print "folder is. If you set this to false, they will never see the\n";
909 print "option, but if it is true, this option will appear in the\n";
910 print "'options' section.\n";
911 print "\n";
912 print "NOTE: You set the default folder prefix in option '1' of this\n";
913 print " section. That will be the default if the user doesn't\n";
914 print " specify anything different.\n";
915 print "\n";
916
917 if ($show_prefix_option eq "true") {
918 $default_value = "y";
919 } else {
920 $default_value = "n";
921 }
922 print "\n";
923 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
924 $new_show = <STDIN>;
925 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
926 $show_prefix_option = "true";
927 } else {
928 $show_prefix_option = "false";
929 }
930 return $show_prefix_option;
931 }
932
933 # Trash Folder
934 sub command23a {
935 print "You can now specify where the default trash folder is located.\n";
936 print "On servers where you do not want this, you can set it to anything\n";
937 print "and set option 6 to false.\n";
938 print "\n";
939 print "This is relative to where the rest of your email is kept. You do\n";
940 print "not need to worry about their mail directory. If this folder\n";
941 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
942 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
943 print "\n";
944
945 print "[$WHT$trash_folder$NRM]: $WHT";
946 $new_trash_folder = <STDIN>;
947 if ($new_trash_folder eq "\n") {
948 $new_trash_folder = $trash_folder;
949 } else {
950 $new_trash_folder =~ s/[\r|\n]//g;
951 }
952 return $new_trash_folder;
953 }
954
955 # Sent Folder
956 sub command23b {
957 print "This is where messages that are sent will be stored. SquirrelMail\n";
958 print "by default puts a copy of all outgoing messages in this folder.\n";
959 print "\n";
960 print "This is relative to where the rest of your email is kept. You do\n";
961 print "not need to worry about their mail directory. If this folder\n";
962 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
963 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
964 print "\n";
965
966 print "[$WHT$sent_folder$NRM]: $WHT";
967 $new_sent_folder = <STDIN>;
968 if ($new_sent_folder eq "\n") {
969 $new_sent_folder = $sent_folder;
970 } else {
971 $new_sent_folder =~ s/[\r|\n]//g;
972 }
973 return $new_sent_folder;
974 }
975
976 # Draft Folder
977 sub command23c {
978 print "You can now specify where the default draft folder is located.\n";
979 print "On servers where you do not want this, you can set it to anything\n";
980 print "and set option 9 to false.\n";
981 print "\n";
982 print "This is relative to where the rest of your email is kept. You do\n";
983 print "not need to worry about their mail directory. If this folder\n";
984 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
985 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
986 print "\n";
987
988 print "[$WHT$draft_folder$NRM]: $WHT";
989 $new_draft_folder = <STDIN>;
990 if ($new_draft_folder eq "\n") {
991 $new_draft_folder = $draft_folder;
992 } else {
993 $new_draft_folder =~ s/[\r|\n]//g;
994 }
995 return $new_draft_folder;
996 }
997
998 # default move to trash
999 sub command24a {
1000 print "By default, should messages get moved to the trash folder? You\n";
1001 print "can specify the default trash folder in option 3. If this is set\n";
1002 print "to false, messages will get deleted immediately without moving\n";
1003 print "to the trash folder.\n";
1004 print "\n";
1005 print "Trash folder is currently: $trash_folder\n";
1006 print "\n";
1007
1008 if ($default_move_to_trash eq "true") {
1009 $default_value = "y";
1010 } else {
1011 $default_value = "n";
1012 }
1013 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1014 $new_show = <STDIN>;
1015 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1016 $default_move_to_trash = "true";
1017 } else {
1018 $default_move_to_trash = "false";
1019 }
1020 return $default_move_to_trash;
1021 }
1022
1023 # default move to sent
1024 sub command24b {
1025 print "By default, should messages get moved to the sent folder? You\n";
1026 print "can specify the default sent folder in option 4. If this is set\n";
1027 print "to false, messages will get sent an no copy will be made.\n";
1028 print "\n";
1029 print "Trash folder is currently: $sent_folder\n";
1030 print "\n";
1031
1032 if ($default_move_to_sent eq "true") {
1033 $default_value = "y";
1034 } else {
1035 $default_value = "n";
1036 }
1037 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1038 $new_show = <STDIN>;
1039 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1040 $default_move_to_sent = "true";
1041 } else {
1042 $default_move_to_sent = "false";
1043 }
1044 return $default_move_to_sent;
1045 }
1046
1047 # default save as draft
1048 sub command24c {
1049 print "By default, should the save to draft option be shown? You can\n";
1050 print "specify the default drafts folder in option 5. If this is set\n";
1051 print "to false, users will not be shown the save to draft option.\n";
1052 print "\n";
1053 print "Drafts folder is currently: $draft_folder\n";
1054 print "\n";
1055
1056 if ($default_move_to_draft eq "true") {
1057 $default_value = "y";
1058 } else {
1059 $default_value = "n";
1060 }
1061 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1062 $new_show = <STDIN>;
1063 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1064 $default_save_as_draft = "true";
1065 } else {
1066 $default_save_as_draft = "false";
1067 }
1068 return $default_save_as_draft;
1069 }
1070
1071 # List special folders first
1072 sub command27 {
1073 print "SquirrelMail has what we call 'special folders' that are not\n";
1074 print "manipulated and viewed like normal folders. Some examples of\n";
1075 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1076 print "Simply asks if you want these folders listed first in the folder\n";
1077 print "listing.\n";
1078 print "\n";
1079
1080 if ($list_special_folders_first eq "true") {
1081 $default_value = "y";
1082 } else {
1083 $default_value = "n";
1084 }
1085 print "\n";
1086 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1087 $new_show = <STDIN>;
1088 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1089 $list_special_folders_first = "true";
1090 } else {
1091 $list_special_folders_first = "false";
1092 }
1093 return $list_special_folders_first;
1094 }
1095
1096 # Show special folders color
1097 sub command28 {
1098 print "SquirrelMail has what we call 'special folders' that are not\n";
1099 print "manipulated and viewed like normal folders. Some examples of\n";
1100 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1101 print "wants to know if we should display special folders in a\n";
1102 print "color than the other folders.\n";
1103 print "\n";
1104
1105 if ($use_special_folder_color eq "true") {
1106 $default_value = "y";
1107 } else {
1108 $default_value = "n";
1109 }
1110 print "\n";
1111 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1112 $new_show = <STDIN>;
1113 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1114 $use_special_folder_color = "true";
1115 } else {
1116 $use_special_folder_color = "false";
1117 }
1118 return $use_special_folder_color;
1119 }
1120
1121 # Auto expunge
1122 sub command29 {
1123 print "The way that IMAP handles deleting messages is as follows. You\n";
1124 print "mark the message as deleted, and then to 'really' delete it, you\n";
1125 print "expunge it. This option asks if you want to just have messages\n";
1126 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1127 print "messages too.\n";
1128 print "\n";
1129
1130 if ($auto_expunge eq "true") {
1131 $default_value = "y";
1132 } else {
1133 $default_value = "n";
1134 }
1135 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1136 $new_show = <STDIN>;
1137 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1138 $auto_expunge = "true";
1139 } else {
1140 $auto_expunge = "false";
1141 }
1142 return $auto_expunge;
1143 }
1144
1145 # Default sub of inbox
1146 sub command210 {
1147 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1148 print "This can cause some confusion in folder creation for users when\n";
1149 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1150 print "and get permission errors. This option asks if you want folders\n";
1151 print "to be subfolders of INBOX by default.\n";
1152 print "\n";
1153
1154 if ($default_sub_of_inbox eq "true") {
1155 $default_value = "y";
1156 } else {
1157 $default_value = "n";
1158 }
1159 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1160 $new_show = <STDIN>;
1161 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1162 $default_sub_of_inbox = "true";
1163 } else {
1164 $default_sub_of_inbox = "false";
1165 }
1166 return $default_sub_of_inbox;
1167 }
1168
1169 # Show contain subfolder option
1170 sub command211 {
1171 print "Some IMAP servers (UW) make it so that there are two types of\n";
1172 print "folders. Those that contain messages, and those that contain\n";
1173 print "subfolders. If this is the case for your server, set this to\n";
1174 print "true, and it will ask the user whether the folder they are\n";
1175 print "creating contains subfolders or messages.\n";
1176 print "\n";
1177
1178 if ($show_contain_subfolders_option eq "true") {
1179 $default_value = "y";
1180 } else {
1181 $default_value = "n";
1182 }
1183 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1184 $new_show = <STDIN>;
1185 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1186 $show_contain_subfolders_option = "true";
1187 } else {
1188 $show_contain_subfolders_option = "false";
1189 }
1190 return $show_contain_subfolders_option;
1191 }
1192
1193 # Default Unseen Notify
1194 sub command212 {
1195 print "This option specifies where the users will receive notification\n";
1196 print "about unseen messages by default. This is of course an option that\n";
1197 print "can be changed on a user level.\n";
1198 print " 1 = No notification\n";
1199 print " 2 = Only on the INBOX\n";
1200 print " 3 = On all folders\n";
1201 print "\n";
1202
1203 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1204 $new_show = <STDIN>;
1205 if ($new_show =~ /^[1|2|3]\n/i) {
1206 $default_unseen_notify = $new_show;
1207 }
1208 $default_unseen_notify =~ s/[\r|\n]//g;
1209 return $default_unseen_notify;
1210 }
1211
1212 # Default Unseen Type
1213 sub command213 {
1214 print "Here you can define the default way that unseen messages will be displayed\n";
1215 print "to the user in the folder listing on the left side.\n";
1216 print " 1 = Only unseen messages (4)\n";
1217 print " 2 = Unseen and Total messages (4/27)\n";
1218 print "\n";
1219
1220 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1221 $new_show = <STDIN>;
1222 if ($new_show =~ /^[1|2]\n/i) {
1223 $default_unseen_type = $new_show;
1224 }
1225 $default_unseen_type =~ s/[\r|\n]//g;
1226 return $default_unseen_type;
1227 }
1228
1229 # Auto create special folders
1230 sub command214 {
1231 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1232 print "automatically print for you when a user logs in? If the user\n";
1233 print "accidentally deletes their special folders, this option will\n";
1234 print "automatically create it again for them.\n";
1235 print "\n";
1236
1237 if ($auto_create_special eq "true") {
1238 $default_value = "y";
1239 } else {
1240 $default_value = "n";
1241 }
1242 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1243 $new_show = <STDIN>;
1244 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1245 $auto_create_special = "true";
1246 } else {
1247 $auto_create_special = "false";
1248 }
1249 return $auto_create_special;
1250 }
1251
1252
1253 ############# GENERAL OPTIONS #####################
1254
1255 # Default Charset
1256 sub command31 {
1257 print "This option controls what character set is used when sending\n";
1258 print "mail and when sending HTML to the browser. Do not set this\n";
1259 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1260 print "to use KOI8-R, since this implementation is faster than most\n";
1261 print "of the alternatives\n";
1262 print "\n";
1263
1264 print "[$WHT$default_charset$NRM]: $WHT";
1265 $new_default_charset = <STDIN>;
1266 if ($new_default_charset eq "\n") {
1267 $new_default_charset = $default_charset;
1268 } else {
1269 $new_default_charset =~ s/[\r|\n]//g;
1270 }
1271 return $new_default_charset;
1272 }
1273
1274 # Data directory
1275 sub command33a {
1276 print "It is a possible security hole to have a writable directory\n";
1277 print "under the web server's root directory (ex: /home/httpd/html).\n";
1278 print "For this reason, it is possible to put the data directory\n";
1279 print "anywhere you would like. The path name can be absolute or\n";
1280 print "relative (to the config directory). It doesn't matter. Here\n";
1281 print "are two examples:\n";
1282 print " Absolute: /usr/local/squirrelmail/data/\n";
1283 print " Relative: ../data/\n";
1284 print "\n";
1285
1286 print "[$WHT$data_dir$NRM]: $WHT";
1287 $new_data_dir = <STDIN>;
1288 if ($new_data_dir eq "\n") {
1289 $new_data_dir = $data_dir;
1290 } else {
1291 $new_data_dir =~ s/[\r|\n]//g;
1292 }
1293 if ($new_data_dir =~ /^\s*$/) {
1294 $new_data_dir = "";
1295 } else {
1296 $new_data_dir =~ s/\/*$//g;
1297 $new_data_dir =~ s/$/\//g;
1298 }
1299 return $new_data_dir;
1300 }
1301
1302 # Attachment directory
1303 sub command33b {
1304 print "Path to directory used for storing attachments while a mail is\n";
1305 print "being sent. There are a few security considerations regarding this\n";
1306 print "directory:\n";
1307 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1308 print " impossible for a random person with access to the webserver\n";
1309 print " to list files in this directory. Confidential data might\n";
1310 print " be laying around in there.\n";
1311 print " 2. Since the webserver is not able to list the files in the\n";
1312 print " content is also impossible for the webserver to delete files\n";
1313 print " lying around there for too long.\n";
1314 print " 3. It should probably be another directory than the data\n";
1315 print " directory specified in option 3.\n";
1316 print "\n";
1317
1318 print "[$WHT$attachment_dir$NRM]: $WHT";
1319 $new_attachment_dir = <STDIN>;
1320 if ($new_attachment_dir eq "\n") {
1321 $new_attachment_dir = $attachment_dir;
1322 } else {
1323 $new_attachment_dir =~ s/[\r|\n]//g;
1324 }
1325 if ($new_attachment_dir =~ /^\s*$/) {
1326 $new_attachment_dir = "";
1327 } else {
1328 $new_attachment_dir =~ s/\/*$//g;
1329 $new_attachment_dir =~ s/$/\//g;
1330 }
1331 return $new_attachment_dir;
1332 }
1333
1334 sub command33c {
1335 print "The directory hash level setting allows you to configure the level\n";
1336 print "of hashing that Squirremail employs in your data and attachment\n";
1337 print "directories. This value must be an integer ranging from 0 to 4.\n";
1338 print "When this value is set to 0, Squirrelmail will simply store all\n";
1339 print "files as normal in the data and attachment directories. However,\n";
1340 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1341 print "used to organize the files in this directory. In short, the crc32\n";
1342 print "value for a username will be computed. Then, up to the first 4\n";
1343 print "digits of the hash, as set by this configuration value, will be\n";
1344 print "used to directory hash the files for that user in the data and\n";
1345 print "attachment directory. This allows for better performance on\n";
1346 print "servers with larger numbers of users.\n";
1347 print "\n";
1348
1349 print "[$WHT$dir_hash_level$NRM]: $WHT";
1350 $new_dir_hash_level = <STDIN>;
1351 if ($new_dir_hash_level eq "\n") {
1352 $new_dir_hash_level = $dir_hash_level;
1353 } else {
1354 $new_dir_hash_level =~ s/[\r|\n]//g;
1355 }
1356 if ((int($new_dir_hash_level) < 0) ||
1357 (int($new_dir_hash_level) > 4) ||
1358 !(int($new_dir_hash_level) eq $new_dir_hash_level )) {
1359 print "Invalid Directory Hash Level.\n";
1360 print "Value must be an integer ranging from 0 to 4\n";
1361 print "Hit enter to continue.\n";
1362 $enter_key = <STDIN>;
1363
1364 $new_dir_hash_level = $dir_hash_level;
1365 }
1366
1367 return $new_dir_hash_level;
1368 }
1369
1370 sub command35 {
1371 print "This is the default size (in pixels) of the left folder list.\n";
1372 print "Default is 200, but you can set it to whatever you wish. This\n";
1373 print "is a user preference, so this will only show up as their default.\n";
1374 print "\n";
1375 print "[$WHT$default_left_size$NRM]: $WHT";
1376 $new_default_left_size = <STDIN>;
1377 if ($new_default_left_size eq "\n") {
1378 $new_default_left_size = $default_left_size;
1379 } else {
1380 $new_default_left_size =~ s/[\r|\n]//g;
1381 }
1382 return $new_default_left_size;
1383 }
1384
1385
1386 sub command36 {
1387 print "Some IMAP servers only have lowercase letters in the usernames\n";
1388 print "but they still allow people with uppercase to log in. This\n";
1389 print "causes a problem with the user's preference files. This option\n";
1390 print "transparently changes all usernames to lowercase.";
1391 print "\n";
1392
1393 if ($force_username_lowercase eq "true") {
1394 $default_value = "y";
1395 } else {
1396 $default_value = "n";
1397 }
1398 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1399 $new_show = <STDIN>;
1400 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1401 return "true";
1402 }
1403 return "false";
1404 }
1405
1406 sub command37 {
1407 print "";
1408 print "\n";
1409
1410 if ($default_use_priority eq "true") {
1411 $default_value = "y";
1412 } else {
1413 $default_value = "n";
1414 }
1415
1416 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
1417 $new_show = <STDIN>;
1418 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1419 return "true";
1420 }
1421 return "false";
1422 }
1423
1424
1425 sub command38 {
1426 print "";
1427 print "\n";
1428
1429 if ($default_hide_attribution eq "true") {
1430 $default_value = "y";
1431 } else {
1432 $default_value = "n";
1433 }
1434
1435 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
1436 $new_show = <STDIN>;
1437 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1438 return "true";
1439 }
1440 return "false";
1441 }
1442
1443
1444 sub command41 {
1445 print "\nNow we will define the themes that you wish to use. If you have added\n";
1446 print "a theme of your own, just follow the instructions (?) about how to add\n";
1447 print "them. You can also change the default theme.\n";
1448 print "[theme] command (?=help) > ";
1449 $input = <STDIN>;
1450 $input =~ s/[\r|\n]//g;
1451 while ($input ne "d") {
1452 if ($input =~ /^\s*l\s*/i) {
1453 $count = 0;
1454 while ($count <= $#theme_name) {
1455 if ($count == $theme_default) {
1456 print " *";
1457 } else {
1458 print " ";
1459 }
1460 $name = $theme_name[$count];
1461 $num_spaces = 25 - length($name);
1462 for ($i = 0; $i < $num_spaces;$i++) {
1463 $name = $name . " ";
1464 }
1465
1466 print " $count. $name";
1467 print "($theme_path[$count])\n";
1468
1469 $count++;
1470 }
1471 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1472 $old_def = $theme_default;
1473 $theme_default = $input;
1474 $theme_default =~ s/^\s*m\s*//;
1475 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1476 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1477 $theme_default = $old_def;
1478 }
1479 } elsif ($input =~ /^\s*\+/) {
1480 print "What is the name of this theme: ";
1481 $name = <STDIN>;
1482 $name =~ s/[\r|\n]//g;
1483 $theme_name[$#theme_name+1] = $name;
1484 print "Be sure to put ../themes/ before the filename.\n";
1485 print "What file is this stored in (ex: ../themes/default_theme.php): ";
1486 $name = <STDIN>;
1487 $name =~ s/[\r|\n]//g;
1488 $theme_path[$#theme_path+1] = $name;
1489 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1490 if ($input =~ /[0-9]+\s*$/) {
1491 $rem_num = $input;
1492 $rem_num =~ s/^\s*-\s*//g;
1493 $rem_num =~ s/\s*$//;
1494 } else {
1495 $rem_num = $#theme_name;
1496 }
1497 if ($rem_num == $theme_default) {
1498 print "You cannot remove the default theme!\n";
1499 } else {
1500 $count = 0;
1501 @new_theme_name = ();
1502 @new_theme_path = ();
1503 while ($count <= $#theme_name) {
1504 if ($count != $rem_num) {
1505 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1506 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1507 }
1508 $count++;
1509 }
1510 @theme_name = @new_theme_name;
1511 @theme_path = @new_theme_path;
1512 if ($theme_default > $rem_num) {
1513 $theme_default--;
1514 }
1515 }
1516 } elsif ($input =~ /^\s*t\s*/i) {
1517 print "\nStarting detection...\n\n";
1518
1519 opendir(DIR, "../themes");
1520 @files = grep { /\.php$/i } readdir(DIR);
1521 $cnt = 0;
1522 while ($cnt <= $#files) {
1523 $filename = "../themes/" . $files[$cnt];
1524 if ($filename ne "../themes/index.php") {
1525 $found = 0;
1526 for ($x=0; $x <= $#theme_path; $x++) {
1527 if ($theme_path[$x] eq $filename) {
1528 $found = 1;
1529 }
1530 }
1531 if ($found != 1) {
1532 print "** Found theme: $filename\n";
1533 print " What is its name? ";
1534 $nm = <STDIN>;
1535 $nm =~ s/[\n|\r]//g;
1536 $theme_name[$#theme_name+1] = $nm;
1537 $theme_path[$#theme_path+1] = $filename;
1538 }
1539 }
1540 $cnt++;
1541 }
1542 print "\n";
1543 for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
1544 $filename = $theme_path[$cnt];
1545 if (! (-e $filename)) {
1546 print " Removing $filename (file not found)\n";
1547 $offset = 0;
1548 @new_theme_name = ();
1549 @new_theme_path = ();
1550 for ($x=0; $x < $#theme_path; $x++) {
1551 if ($theme_path[$x] eq $filename) {
1552 $offset = 1;
1553 }
1554 if ($offset == 1) {
1555 $new_theme_name[$x] = $theme_name[$x+1];
1556 $new_theme_path[$x] = $theme_path[$x+1];
1557 } else {
1558 $new_theme_name[$x] = $theme_name[$x];
1559 $new_theme_path[$x] = $theme_path[$x];
1560 }
1561 }
1562 @theme_name = @new_theme_name;
1563 @theme_path = @new_theme_path;
1564 }
1565 }
1566 print "\nDetection complete!\n\n";
1567
1568 closedir DIR;
1569 } elsif ($input =~ /^\s*\?\s*/) {
1570 print ".-------------------------.\n";
1571 print "| t (detect themes) |\n";
1572 print "| + (add theme) |\n";
1573 print "| - N (remove theme) |\n";
1574 print "| m N (mark default) |\n";
1575 print "| l (list themes) |\n";
1576 print "| d (done) |\n";
1577 print "`-------------------------'\n";
1578 }
1579 print "[theme] command (?=help) > ";
1580 $input = <STDIN>;
1581 $input =~ s/[\r|\n]//g;
1582 }
1583 }
1584
1585
1586 # Theme - CSS file
1587 sub command42 {
1588 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1589 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1590 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1591 print "files, leave this blank.\n";
1592 print "\n";
1593 print "To clear out an existing value, just type a space for the input.\n";
1594 print "\n";
1595 print "[$WHT$theme_css$NRM]: $WHT";
1596 $new_theme_css = <STDIN>;
1597 if ($new_theme_css eq "\n") {
1598 $new_theme_css = $theme_css;
1599 } else {
1600 $new_theme_css =~ s/[\r|\n]//g;
1601 }
1602 $new_theme_css =~ s/^\s*//;
1603 return $new_theme_css;
1604 }
1605
1606
1607 sub command61 {
1608 print "You can now define different LDAP servers.\n";
1609 print "[ldap] command (?=help) > ";
1610 $input = <STDIN>;
1611 $input =~ s/[\r|\n]//g;
1612 while ($input ne "d") {
1613 if ($input =~ /^\s*l\s*/i) {
1614 $count = 0;
1615 while ($count <= $#ldap_host) {
1616 print "$count. $ldap_host[$count]\n";
1617 print " base: $ldap_base[$count]\n";
1618 if ($ldap_charset[$count]) {
1619 print " charset: $ldap_charset[$count]\n";
1620 }
1621 if ($ldap_port[$count]) {
1622 print " port: $ldap_port[$count]\n";
1623 }
1624 if ($ldap_name[$count]) {
1625 print " name: $ldap_name[$count]\n";
1626 }
1627 if ($ldap_maxrows[$count]) {
1628 print " maxrows: $ldap_maxrows[$count]\n";
1629 }
1630 print "\n";
1631 $count++;
1632 }
1633 } elsif ($input =~ /^\s*\+/) {
1634 $sub = $#ldap_host + 1;
1635
1636 print "First, we need to have the hostname or the IP address where\n";
1637 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1638 print "hostname: ";
1639 $name = <STDIN>;
1640 $name =~ s/[\r|\n]//g;
1641 $ldap_host[$sub] = $name;
1642
1643 print "\n";
1644
1645 print "Next, we need the server root (base dn). For this, an empty\n";
1646 print "string is allowed.\n";
1647 print "Example: ou=member_directory,o=netcenter.com\n";
1648 print "base: ";
1649 $name = <STDIN>;
1650 $name =~ s/[\r|\n]//g;
1651 $ldap_base[$sub] = $name;
1652
1653 print "\n";
1654
1655 print "This is the TCP/IP port number for the LDAP server. Default\n";
1656 print "port is 389. This is optional. Press ENTER for default.\n";
1657 print "port: ";
1658 $name = <STDIN>;
1659 $name =~ s/[\r|\n]//g;
1660 $ldap_port[$sub] = $name;
1661
1662 print "\n";
1663
1664 print "This is the charset for the server. Default is utf-8. This\n";
1665 print "is also optional. Press ENTER for default.\n";
1666 print "charset: ";
1667 $name = <STDIN>;
1668 $name =~ s/[\r|\n]//g;
1669 $ldap_charset[$sub] = $name;
1670
1671 print "\n";
1672
1673 print "This is the name for the server, used to tag the results of\n";
1674 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1675 print "name: ";
1676 $name = <STDIN>;
1677 $name =~ s/[\r|\n]//g;
1678 $ldap_name[$sub] = $name;
1679
1680 print "\n";
1681
1682 print "You can specify the maximum number of rows in the search result.\n";
1683 print "Default is unlimited. Press ENTER for default.\n";
1684 print "maxrows: ";
1685 $name = <STDIN>;
1686 $name =~ s/[\r|\n]//g;
1687 $ldap_maxrows[$sub] = $name;
1688
1689 print "\n";
1690
1691 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1692 if ($input =~ /[0-9]+\s*$/) {
1693 $rem_num = $input;
1694 $rem_num =~ s/^\s*-\s*//g;
1695 $rem_num =~ s/\s*$//;
1696 } else {
1697 $rem_num = $#ldap_host;
1698 }
1699 $count = 0;
1700 @new_ldap_host = ();
1701 @new_ldap_base = ();
1702 @new_ldap_port = ();
1703 @new_ldap_name = ();
1704 @new_ldap_charset = ();
1705 @new_ldap_maxrows = ();
1706 while ($count <= $#ldap_host) {
1707 if ($count != $rem_num) {
1708 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1709 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1710 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1711 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1712 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1713 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1714 }
1715 $count++;
1716 }
1717 @ldap_host = @new_ldap_host;
1718 @ldap_base = @new_ldap_base;
1719 @ldap_port = @new_ldap_port;
1720 @ldap_name = @new_ldap_name;
1721 @ldap_charset = @new_ldap_charset;
1722 @ldap_maxrows = @new_ldap_maxrows;
1723 } elsif ($input =~ /^\s*\?\s*/) {
1724 print ".-------------------------.\n";
1725 print "| + (add host) |\n";
1726 print "| - N (remove host) |\n";
1727 print "| l (list hosts) |\n";
1728 print "| d (done) |\n";
1729 print "`-------------------------'\n";
1730 }
1731 print "[ldap] command (?=help) > ";
1732 $input = <STDIN>;
1733 $input =~ s/[\r|\n]//g;
1734 }
1735 }
1736
1737 sub command62 {
1738 print "Some of our developers have come up with very good javascript interface\n";
1739 print "for searching through address books, however, our original goals said\n";
1740 print "that we would be 100% HTML. In order to make it possible to use their\n";
1741 print "interface, and yet stick with our goals, we have also written a plain\n";
1742 print "HTML version of the search. Here, you can choose which version to use.\n";
1743 print "\n";
1744 print "This is just the default value. It is also a user option that each\n";
1745 print "user can configure individually\n";
1746 print "\n";
1747
1748 if ($default_use_javascript_addr_book eq "true") {
1749 $default_value = "y";
1750 } else {
1751 $default_use_javascript_addr_book = "false";
1752 $default_value = "n";
1753 }
1754 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
1755 $new_show = <STDIN>;
1756 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1757 $default_use_javascript_addr_book = "true";
1758 } else {
1759 $default_use_javascript_addr_book = "false";
1760 }
1761 return $default_use_javascript_addr_book;
1762 }
1763
1764
1765 sub save_data {
1766 $tab = " ";
1767 open (CF, ">config.php");
1768
1769 print CF "<?php\n";
1770 print CF "\n";
1771
1772 print CF "/**\n";
1773 print CF " * SquirrelMail Configuration File\n";
1774 print CF " * Created using the configure script, conf.pl\n";
1775 print CF " */\n";
1776 print CF "\n";
1777
1778 print CF "global \$config_version, \$config_use_color;\n";
1779 if ($print_config_version) {
1780 print CF "\$config_version = '$print_config_version';\n";
1781 }
1782 print CF "\$config_use_color = $config_use_color;\n";
1783 print CF "\n";
1784
1785 print CF "global \$org_name, \$org_logo, \$org_title, \$signout_page;\n";
1786 print CF "\$org_name = \"$org_name\";\n";
1787 print CF "\$org_logo = '$org_logo';\n";
1788 print CF "\$org_title = \"$org_title\";\n";
1789 print CF "\$signout_page = '$signout_page';\n";
1790 print CF "\n";
1791
1792 print CF "global \$motd;\n";
1793 print CF "\$motd = '$motd';\n";
1794 print CF "\n";
1795
1796 print CF "global \$squirrelmail_default_language;\n";
1797 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
1798 print CF "\n";
1799
1800 print CF "global \$domain, \$imapServerAddress, \$imapPort;\n";
1801 print CF "global \$useSendmail, \$smtpServerAddress, \$smtpPort;\n";
1802 print CF "global \$sendmail_path, \$use_authenticated_smtp;\n";
1803 print CF "global \$imap_server_type, \$invert_time;\n";
1804 print CF "global \$optional_delimiter;\n";
1805 print CF "\$domain = '$domain';\n";
1806 print CF "\$imapServerAddress = '$imapServerAddress';\n";
1807 print CF "\$imapPort = $imapPort;\n";
1808 print CF "\$useSendmail = $useSendmail;\n";
1809 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
1810 print CF "\$smtpPort = $smtpPort;\n";
1811 print CF "\$sendmail_path = '$sendmail_path';\n";
1812 print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
1813 print CF "\$imap_server_type = '$imap_server_type';\n";
1814 print CF "\$invert_time = $invert_time;\n";
1815 print CF "\$optional_delimiter = '$optional_delimiter';\n";
1816 print CF "\n";
1817
1818 print CF "global \$default_folder_prefix;\n";
1819 print CF "global \$trash_folder, \$default_move_to_trash;\n";
1820 print CF "global \$sent_folder, \$default_move_to_sent;\n";
1821 print CF "global \$draft_folder, \$default_save_to_draft;\n";
1822 print CF "global \$show_prefix_option, \$list_special_folders_first;\n";
1823 print CF "global \$use_special_folder_color, \$auto_expunge;\n";
1824 print CF "global \$default_sub_of_inbox;\n";
1825 print CF "global \$show_contain_subfolders_option;\n";
1826 print CF "global \$default_unseen_notify;\n";
1827 print CF "global \$default_unseen_type, \$auto_create_special;\n";
1828 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
1829 print CF "\$trash_folder = '$trash_folder';\n";
1830 print CF "\$sent_folder = '$sent_folder';\n";
1831 print CF "\$draft_folder = '$draft_folder';\n";
1832 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
1833 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
1834 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
1835 print CF "\$show_prefix_option = $show_prefix_option;\n";
1836 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
1837 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
1838 print CF "\$auto_expunge = $auto_expunge;\n";
1839 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
1840 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
1841 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
1842 print CF "\$default_unseen_type = $default_unseen_type;\n";
1843 print CF "\$auto_create_special = $auto_create_special;\n";
1844 print CF "\n";
1845
1846 print CF "global \$default_charset;\n";
1847 print CF "global \$data_dir, \$attachment_dir, \$dir_hash_level;\n";
1848 print CF "global \$default_left_size, \$force_username_lowercase;\n";
1849 print CF "global \$default_use_priority, \$hide_sm_attributions;\n";
1850 print CF "\$default_charset = '$default_charset';\n";
1851 print CF "\$data_dir = '$data_dir';\n";
1852 print CF "\$attachment_dir = \"$attachment_dir\";\n";
1853 print CF "\$dir_hash_level = $dir_hash_level;\n";
1854 print CF "\$default_left_size = $default_left_size;\n";
1855 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
1856 print CF "\$default_use_priority = $default_use_priority;\n";
1857 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
1858 print CF "\n";
1859
1860 print CF "global \$plugins;\n";
1861 for ($ct=0; $ct <= $#plugins; $ct++) {
1862 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
1863 }
1864 print CF "\n";
1865
1866 print CF "global \$theme_css, \$theme;\n";
1867 print CF "\$theme_css = '$theme_css';\n";
1868 for ($count=0; $count <= $#theme_name; $count++) {
1869 print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
1870 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
1871 }
1872 print CF "\n";
1873
1874 if ($default_use_javascript_addr_book ne "true") {
1875 $default_use_javascript_addr_book = "false";
1876 }
1877 print CF "global \$default_use_javascript_addr_book, \$ldap_server;\n";
1878 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1879 for ($count=0; $count <= $#ldap_host; $count++) {
1880 print CF "\$ldap_server[$count] = array(\n";
1881 print CF " 'host' => '$ldap_host[$count]',\n";
1882 print CF " 'base' => '$ldap_base[$count]'";
1883 if ($ldap_name[$count]) {
1884 print CF ",\n";
1885 print CF " 'name' => '$ldap_name[$count]'";
1886 }
1887 if ($ldap_port[$count]) {
1888 print CF ",\n";
1889 print CF " 'port' => '$ldap_port[$count]'";
1890 }
1891 if ($ldap_charset[$count]) {
1892 print CF ",\n";
1893 print CF " 'charset' => '$ldap_charset[$count]'";
1894 }
1895 if ($ldap_maxrows[$count]) {
1896 print CF ",\n";
1897 print CF " 'maxrows' => '$ldap_maxrows[$count]'";
1898 }
1899 print CF "\n";
1900 print CF ");\n";
1901 print CF "\n";
1902 }
1903
1904 print CF "/**\n";
1905 print CF " * Make sure there are no characters after the PHP closing\n";
1906 print CF " * tag below (including newline characters and whitespace).\n";
1907 print CF " * Otherwise, that character will cause the headers to be\n";
1908 print CF " * sent and regular output to begin, which will majorly screw\n";
1909 print CF " * things up when we try to send more headers later.\n";
1910 print CF " */\n";
1911 print CF "?>";
1912
1913 close CF;
1914 }
1915
1916 sub set_defaults {
1917 system "clear";
1918 print $WHT."SquirrelMail Configuration : ".$NRM;
1919 if ($config == 1) { print "Read: config.php"; }
1920 elsif ($config == 2) { print "Read: config_default.php"; }
1921 print "\n";
1922 print "---------------------------------------------------------\n";
1923
1924 print "While we have been building SquirrelMail, we have discovered some\n";
1925 print "preferences that work better with some servers that don't work so\n";
1926 print "well with others. If you select your IMAP server, this option will\n";
1927 print "set some pre-defined settings for that server.\n";
1928 print "\n";
1929 print "Please note that you will still need to go through and make sure\n";
1930 print "everything is correct. This does not change everything. There are\n";
1931 print "only a few settings that this will change.\n";
1932 print "\n";
1933
1934 $continue = 0;
1935 while ($continue != 1) {
1936 print "Please select your IMAP server:\n";
1937 print " cyrus = Cyrus IMAP server\n";
1938 print " uw = University of Washington's IMAP server\n";
1939 print " exchange = Microsoft Exchange IMAP server\n";
1940 print " courier = Courier IMAP server\n";
1941 print " quit = Do not change anything\n";
1942 print "Command >> ";
1943 $server = <STDIN>;
1944 $server =~ s/[\r|\n]//g;
1945
1946 print "\n";
1947 if ($server eq "cyrus") {
1948 $default_folder_prefix = "";
1949 $trash_folder = "INBOX.Trash";
1950 $sent_folder = "INBOX.Sent";
1951 $draft_folder = "INBOX.Drafts";
1952 $show_prefix_option = false;
1953 $default_sub_of_inbox = true;
1954 $show_contain_subfolders_option = false;
1955 $imap_server_type = "cyrus";
1956
1957 print " default_folder_prefix = none\n";
1958 print " trash_folder = INBOX.Trash\n";
1959 print " sent_folder = INBOX.Sent\n";
1960 print " draft_folder = INBOX.Drafts\n";
1961 print " show_prefix_option = false\n";
1962 print " default_sub_of_inbox = true\n";
1963 print "show_contain_subfolders_option = false\n";
1964 print " imap_server_type = cyrus\n";
1965
1966 $continue = 1;
1967 } elsif ($server eq "uw") {
1968 $default_folder_prefix = "mail/";
1969 $trash_folder = "Trash";
1970 $sent_folder = "Sent";
1971 $draft_folder = "Drafts";
1972 $show_prefix_option = true;
1973 $default_sub_of_inbox = false;
1974 $show_contain_subfolders_option = true;
1975 $imap_server_type = "uw";
1976
1977 print " default_folder_prefix = mail/\n";
1978 print " trash_folder = Trash\n";
1979 print " sent_folder = Sent\n";
1980 print " draft_folder = Drafts\n";
1981 print " show_prefix_option = true\n";
1982 print " default_sub_of_inbox = false\n";
1983 print "show_contain_subfolders_option = true\n";
1984 print " imap_server_type = uw\n";
1985
1986 $continue = 1;
1987 } elsif ($server eq "exchange") {
1988 $default_folder_prefix = "";
1989 $default_sub_of_inbox = true;
1990 $trash_folder = "INBOX/Deleted Items";
1991 $sent_folder = "INBOX/Sent Items";
1992 $drafts_folder = "INBOX/Drafts";
1993 $show_prefix_option = false;
1994 $show_contain_subfolders_option = false;
1995 $imap_server_type = "exchange";
1996
1997 print " default_folder_prefix = <none>\n";
1998 print " default_sub_of_inbox = true\n";
1999 print " trash_folder = \"INBOX/Deleted Items\"\n";
2000 print " sent_folder = \"INBOX/Sent Items\"\n";
2001 print " draft_folder = \"INBOX/Drafts\"\n";
2002 print " show_prefix_option = false\n";
2003 print " show_contain_subfolders_option = false\n";
2004 print " imap_server_type = exchange\n";
2005
2006 $continue = 1;
2007 } elsif ($server eq "courier") {
2008 $imap_server_type = "courier";
2009
2010 print " imap_server_type = courier\n";
2011
2012 $continue = 1;
2013 } elsif ($server eq "quit") {
2014 $continue = 1;
2015 } else {
2016 print "Unrecognized server: $server\n";
2017 print "\n";
2018 }
2019 }
2020 print "\nPress any key to continue...";
2021 $tmp = <STDIN>;
2022 }