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