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