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