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