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