- fixed bug in conf.pl where no default was set for $force_username_lowercase
[squirrelmail.git] / config / conf.pl
CommitLineData
bbd30ac8 1#!/usr/bin/perl
2# conf.pl
8beafbbc 3# Luke Ehresman (luke@squirrelmail.org)
bbd30ac8 4#
5# A simple configure script to configure squirrelmail
ccfb2029 6############################################################
985f7c88 7$conf_pl_version = "x62";
bbd30ac8 8
d595e32e 9############################################################
10# Some people try to run this as a CGI. That's wrong!
11############################################################
12if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) ||
13 defined($ENV{'REQUEST_METHOD'})) {
14 print "Content-Type: text/html\n\n";
15 print "You must run this script from the command line.";
16 exit;
17}
18
ccfb2029 19############################################################
bbd30ac8 20# First, lets read in the data already in there...
ccfb2029 21############################################################
bbd30ac8 22if ( -e "config.php") {
4011c3ca 23 open (FILE, "config.php");
24 while ($line = <FILE>) {
25 if ($line =~ /^\s+\$/) {
26 $line =~ s/^\s+\$//;
27 $var = $line;
28
29 $var =~ s/=/EQUALS/;
30 if ($var =~ /^([a-z]|[A-Z])/) {
31 @o = split(/\s*EQUALS\s*/, $var);
32 if ($o[0] eq "config_version") {
33 $o[1] =~ s/[\n|\r]//g;
34 $o[1] =~ s/\";\s*$//;
35 $o[1] =~ s/;$//;
36 $o[1] =~ s/^"//;
37
38 $config_version = $o[1];
39 close (FILE);
40 }
41 }
42 }
43 }
44 close (FILE);
45
46 if ($config_version ne $conf_pl_version) {
47 system "clear";
48 print $WHT."WARNING:\n".$NRM;
6b638171 49 print " The file \"config/config.php\" was found, but it is for an older version of\n";
4011c3ca 50 print " SquirrelMail. It is possible to still read the defaults from this file\n";
51 print " but be warned that many preferences change between versions. It is\n";
52 print " recommended that you start with a clean config.php for each upgrade that\n";
6b638171 53 print " you do. To do this, just move config/config.php out of the way.\n\n";
f0bc4d36 54 print "Continue loading with the old config.php [y/N]? ";
4011c3ca 55 $ctu = <STDIN>;
f0bc4d36 56 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
4011c3ca 57 exit;
58 }
59
f0bc4d36 60 print "\nDo you want me to stop warning you [y/N]? ";
4011c3ca 61 $ctu = <STDIN>;
62 if ($ctu =~ /^y\n/i) {
63 $print_config_version = $conf_pl_version;
64 } else {
65 $print_config_version = $config_version;
66 }
67 } else {
68 $print_config_version = $config_version;
69 }
70
a93b12ba 71 $config = 1;
ccfb2029 72 open (FILE, "config.php");
1e0628fb 73} elsif (-e "config_default.php") {
4011c3ca 74 open (FILE, "config_default.php");
75 while ($line = <FILE>) {
76 if ($line =~ /^\s+\$/) {
77 $line =~ s/^\s+\$//;
78 $var = $line;
79
80 $var =~ s/=/EQUALS/;
81 if ($var =~ /^([a-z]|[A-Z])/) {
82 @o = split(/\s*EQUALS\s*/, $var);
83 if ($o[0] eq "config_version") {
84 $o[1] =~ s/[\n|\r]//g;
85 $o[1] =~ s/\";\s*$//;
86 $o[1] =~ s/;$//;
87 $o[1] =~ s/^"//;
88
89 $config_version = $o[1];
90 close (FILE);
91 }
92 }
93 }
94 }
95 close (FILE);
96
97 if ($config_version ne $conf_pl_version) {
98 system "clear";
99 print $WHT."WARNING:\n".$NRM;
100 print " You are trying to use a \"config_default.php\" from an older version of\n";
101 print " SquirrelMail. This is HIGHLY unrecommended. You should get the\n";
102 print " \"config_default.php\" that matches the version of SquirrelMail that you\n";
103 print " are running. You can get this from the SquirrelMail web page by going\n";
104 print " to: http://www.squirrelmail.org.\n\n";
f0bc4d36 105 print "Continue loading with the old config_default.php (not a good idea) [y/N]? ";
4011c3ca 106 $ctu = <STDIN>;
f0bc4d36 107 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
4011c3ca 108 exit;
109 }
110
f0bc4d36 111 print "\nDo you want me to stop warning you [y/N]? ";
4011c3ca 112 $ctu = <STDIN>;
113 if ($ctu =~ /^y\n/i) {
114 $print_config_version = $conf_pl_version;
115 } else {
116 $print_config_version = $config_version;
117 }
118 } else {
119 $print_config_version = $config_version;
120 }
a93b12ba 121 $config = 2;
ccfb2029 122 open (FILE, "config_default.php");
1e0628fb 123} else {
a93b12ba 124 print "No configuration file found. Please get config_default.php or\n";
125 print "config.php before running this again. This program needs a\n";
126 print "default config file to get default values.\n";
127 exit;
bbd30ac8 128}
129
130# Reads and parses the current configuration file (either
131# config.php or config_default.php).
132
133while ($line = <FILE>) {
ccfb2029 134 if ($line =~ /^\s+\$/) {
135 $line =~ s/^\s+\$//;
136 $var = $line;
137
e9f8ea4e 138 $var =~ s/=/EQUALS/;
ccfb2029 139 if ($var =~ /^([a-z]|[A-Z])/) {
e9f8ea4e 140 @options = split(/\s*EQUALS\s*/, $var);
ccfb2029 141 $options[1] =~ s/[\n|\r]//g;
9d0c7bee 142 $options[1] =~ s/\";\s*$//;
e9f8ea4e 143 $options[1] =~ s/;$//;
f0bc4d36 144 $options[1] =~ s/^\"//;
ccfb2029 145
1e0628fb 146 if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
ccfb2029 147 $sub = $options[0];
148 $sub =~ s/\]\["PATH"\]//;
1fe8fc34 149 $sub =~ s/.*\[//;
98fe1e9f 150 if (-e "../themes") {
151 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
152 }
ccfb2029 153 $theme_path[$sub] = $options[1];
154 } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
155 $sub = $options[0];
156 $sub =~ s/\]\["NAME"\]//;
aa8dcbd5 157 $sub =~ s/.*\[//;
ccfb2029 158 $theme_name[$sub] = $options[1];
9d0c7bee 159 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
160 $sub = $options[0];
161 $sub =~ s/\]//;
162 $sub =~ s/^plugins\[//;
163 $plugins[$sub] = $options[1];
a93b12ba 164 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
1e0628fb 165 $sub = $options[0];
1fe8fc34 166 $sub =~ s/\]//;
167 $sub =~ s/^ldap_server\[//;
a93b12ba 168 $continue = 0;
169 while (($tmp = <FILE>) && ($continue != 1)) {
170 if ($tmp =~ /\);\s*$/) {
171 $continue = 1;
172 }
173
f0bc4d36 174 if ($tmp =~ /^\s*\"host\"/i) {
175 $tmp =~ s/^\s*\"host\"\s*=>\s*\"//i;
176 $tmp =~ s/\",\s*$//;
177 $tmp =~ s/\"\);\s*$//;
a93b12ba 178 $host = $tmp;
f0bc4d36 179 } elsif ($tmp =~ /^\s*\"base\"/i) {
180 $tmp =~ s/^\s*\"base\"\s*=>\s*\"//i;
181 $tmp =~ s/\",\s*$//;
182 $tmp =~ s/\"\);\s*$//;
a93b12ba 183 $base = $tmp;
f0bc4d36 184 } elsif ($tmp =~ /^\s*\"charset\"/i) {
185 $tmp =~ s/^\s*\"charset\"\s*=>\s*\"//i;
186 $tmp =~ s/\",\s*$//;
187 $tmp =~ s/\"\);\s*$//;
a93b12ba 188 $charset = $tmp;
f0bc4d36 189 } elsif ($tmp =~ /^\s*\"port\"/i) {
190 $tmp =~ s/^\s*\"port\"\s*=>\s*\"//i;
191 $tmp =~ s/\",\s*$//;
192 $tmp =~ s/\"\);\s*$//;
a93b12ba 193 $port = $tmp;
f0bc4d36 194 } elsif ($tmp =~ /^\s*\"maxrows\"/i) {
195 $tmp =~ s/^\s*\"maxrows\"\s*=>\s*\"//i;
196 $tmp =~ s/\",\s*$//;
197 $tmp =~ s/\"\);\s*$//;
a93b12ba 198 $maxrows = $tmp;
f0bc4d36 199 } elsif ($tmp =~ /^\s*\"name\"/i) {
200 $tmp =~ s/^\s*\"name\"\s*=>\s*\"//i;
201 $tmp =~ s/\",\s*$//;
202 $tmp =~ s/\"\);\s*$//;
a93b12ba 203 $name = $tmp;
204 }
205 }
1e0628fb 206 $ldap_host[$sub] = $host;
a93b12ba 207 $ldap_base[$sub] = $base;
208 $ldap_name[$sub] = $name;
209 $ldap_port[$sub] = $port;
210 $ldap_maxrows[$sub] = $maxrows;
211 $ldap_charset[$sub] = $charset;
ccfb2029 212 } else {
213 ${$options[0]} = $options[1];
214 }
215 }
216 }
bbd30ac8 217}
1a7a2fcc 218close FILE;
828b4753 219if ($useSendmail ne "true") {
ccfb2029 220 $useSendmail = "false";
828b4753 221}
222if (!$sendmail_path) {
ccfb2029 223 $sendmail_path = "/usr/sbin/sendmail";
828b4753 224}
24fc5dd2 225if (!$default_unseen_notify) {
226 $default_unseen_notify = 2;
227}
228if (!$default_unseen_type) {
229 $default_unseen_type = 1;
230}
0ecb47e5 231if (!$config_use_color) {
232 $config_use_color = 1;
233}
a1f1f9bc 234if (!$invert_time) {
235 $invert_time = "false";
236}
23a8095f 237if (!$force_username_lowercase) {
238 $force_username_lowercase = "false";
239}
bbd30ac8 240
5b6ae78a 241#####################################################################################
0ecb47e5 242if ($config_use_color == 1) {
243 $WHT = "\x1B[37;1m";
244 $NRM = "\x1B[0m";
245} else {
246 $WHT = "";
247 $NRM = "";
248 $config_use_color = 2;
249}
5b6ae78a 250
828b4753 251while (($command ne "q") && ($command ne "Q")) {
ccfb2029 252 system "clear";
612eda0a 253 print $WHT."SquirrelMail Configuration : ".$NRM;
254 if ($config == 1) { print "Read: config.php"; }
255 elsif ($config == 2) { print "Read: config_default.php"; }
256 print "\n";
257 print "---------------------------------------------------------\n";
1e0628fb 258
612eda0a 259 if ($menu == 0) {
ccfb2029 260 print $WHT."Main Menu --\n".$NRM;
261 print "1. Organization Preferences\n";
262 print "2. Server Settings\n";
263 print "3. Folder Defaults\n";
264 print "4. General Options\n";
265 print "5. Themes\n";
266 print "6. Address Books (LDAP)\n";
267 print "7. Message of the Day (MOTD)\n";
9d0c7bee 268 print "8. Plugins\n";
ccfb2029 269 print "\n";
a93b12ba 270 print "D. Set pre-defined settings for specific IMAP servers\n";
271 print "\n";
ccfb2029 272 } elsif ($menu == 1) {
273 print $WHT."Organization Preferences\n".$NRM;
274 print "1. Organization Name : $WHT$org_name$NRM\n";
275 print "2. Organization Logo : $WHT$org_logo$NRM\n";
276 print "3. Organization Title : $WHT$org_title$NRM\n";
277 print "\n";
278 print "R Return to Main Menu\n";
279 } elsif ($menu == 2) {
280 print $WHT."Server Settings\n".$NRM;
281 print "1. Domain : $WHT$domain$NRM\n";
282 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
283 print "3. IMAP Port : $WHT$imapPort$NRM\n";
996d34de 284 print "4. Use Sendmail/SMTP : $WHT";
285 if ($useSendmail eq "true") {
286 print "Sendmail";
287 } else {
288 print "SMTP";
289 }
290 print "$NRM\n";
ccfb2029 291 if ($useSendmail eq "true") {
292 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
293 } else {
294 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
295 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
296 }
a93b12ba 297 print "8. Server : $WHT$imap_server_type$NRM\n";
d47b2518 298 print "9. Invert Time : $WHT$invert_time$NRM\n";
ccfb2029 299 print "\n";
300 print "R Return to Main Menu\n";
301 } elsif ($menu == 3) {
302 print $WHT."Folder Defaults\n".$NRM;
303 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
304 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
305 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
306 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
2f287147 307 print "5. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
308 print "6. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
309 print "7. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
310 print "8. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
311 print "9. Auto Expunge : $WHT$auto_expunge$NRM\n";
312 print "10. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
313 print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
24fc5dd2 314 print "12. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
315 print "13. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
ccfb2029 316 print "\n";
317 print "R Return to Main Menu\n";
318 } elsif ($menu == 4) {
319 print $WHT."General Options\n".$NRM;
985f7c88 320 print "1. Default Charset : $WHT$default_charset$NRM\n";
321 print "2. Data Directory : $WHT$data_dir$NRM\n";
322 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
323 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
324 print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
ccfb2029 325 print "\n";
326 print "R Return to Main Menu\n";
327 } elsif ($menu == 5) {
328 print $WHT."Themes\n".$NRM;
329 print "1. Change Themes\n";
330 for ($count = 0; $count <= $#theme_name; $count++) {
70391dd0 331 print " > $theme_name[$count]\n";
ccfb2029 332 }
6f3bfa54 333 print "2. CSS File : $WHT$theme_css$NRM\n";
ccfb2029 334 print "\n";
335 print "R Return to Main Menu\n";
336 } elsif ($menu == 6) {
337 print $WHT."Address Books (LDAP)\n".$NRM;
1e0628fb 338 print "1. Change Servers\n";
339 for ($count = 0; $count <= $#ldap_host; $count++) {
340 print " > $ldap_host[$count]\n";
341 }
3806fa52 342 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
ccfb2029 343 print "\n";
344 print "R Return to Main Menu\n";
345 } elsif ($menu == 7) {
346 print $WHT."Message of the Day (MOTD)\n".$NRM;
347 print "\n$motd\n";
348 print "\n";
349 print "1 Edit the MOTD\n";
350 print "\n";
351 print "R Return to Main Menu\n";
9d0c7bee 352 } elsif ($menu == 8) {
353 print $WHT."Plugins\n".$NRM;
1a7a2fcc 354 print " Installed Plugins\n";
355 $num = 0;
9d0c7bee 356 for ($count = 0; $count <= $#plugins; $count++) {
1a7a2fcc 357 $num = $count + 1;
358 print " $num. $plugins[$count]\n";
9d0c7bee 359 }
1a7a2fcc 360 print "\n Available Plugins:\n";
361 opendir(DIR, "../plugins");
362 @files = readdir(DIR);
363 $pos=0;
364 @unused_plugins = ();
1a7a2fcc 365 for ($i=0; $i <= $#files; $i++) {
f0bc4d36 366 if ( -d "../plugins/" . $files[$i] &&
2a15d00c 367 $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
1a7a2fcc 368 $match = 0;
369 for ($k=0; $k<=$#plugins; $k++) {
370 if ($plugins[$k] eq $files[$i]) {
371 $match = 1;
372 }
373 }
374 if ($match == 0) {
375 $unused_plugins[$pos] = $files[$i];
376 $pos++;
377 }
378 }
379 }
1a7a2fcc 380
381 for ($i=0; $i<=$#unused_plugins; $i++) {
382 $num = $num + 1;
383 print " $num. $unused_plugins[$i]\n";
384 }
385 closedir DIR;
386
9d0c7bee 387 print "\n";
388 print "R Return to Main Menu\n";
ccfb2029 389 }
3ed2faff 390 if ($config_use_color == 1) {
391 print "C. Turn color off\n";
392 } else {
393 print "C. Turn color on\n";
394 }
ccfb2029 395 print "S Save data\n";
396 print "Q Quit\n";
397
398 print "\n";
399 print "Command >> ".$WHT;
400 $command = <STDIN>;
f0bc4d36 401 $command =~ s/[\n|\r]//g;
402 $command =~ tr/A-Z/a-z/;
ccfb2029 403 print "$NRM\n";
404
405 # Read the commands they entered.
f0bc4d36 406 if ($command eq "r") {
ccfb2029 407 $menu = 0;
f0bc4d36 408 } elsif ($command eq "s") {
ccfb2029 409 save_data ();
8ad99a99 410 print "Data saved in config.php\n";
f0bc4d36 411 print "Press enter to continue...";
ccfb2029 412 $tmp = <STDIN>;
413 $saved = 1;
f0bc4d36 414 } elsif (($command eq "q") && ($saved == 0)) {
ccfb2029 415 print "You have not saved your data.\n";
f0bc4d36 416 print "Save? [".$WHT."Y".$NRM."/n]: ";
ccfb2029 417 $save = <STDIN>;
418 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
419 save_data ();
420 }
f0bc4d36 421 } elsif ($command eq "c") {
0ecb47e5 422 if ($config_use_color == 1) {
423 $config_use_color = 2;
424 $WHT = "";
425 $NRM = "";
426 } else {
427 $config_use_color = 1;
428 $WHT = "\x1B[37;1m";
429 $NRM = "\x1B[0m";
430 }
f0bc4d36 431 } elsif ($command eq "d" && $menu == 0) {
a93b12ba 432 set_defaults ();
ccfb2029 433 } else {
434 $saved = 0;
435 if ($menu == 0) {
9d0c7bee 436 if (($command > 0) && ($command < 9)) {
ccfb2029 437 $menu = $command;
438 }
439 } elsif ($menu == 1) {
440 if ($command == 1) { $org_name = command1 (); }
441 elsif ($command == 2) { $org_logo = command2 (); }
442 elsif ($command == 3) { $org_title = command3 (); }
443 } elsif ($menu == 2) {
444 if ($command == 1) { $domain = command11 (); }
445 elsif ($command == 2) { $imapServerAddress = command12 (); }
446 elsif ($command == 3) { $imapPort = command13 (); }
447 elsif ($command == 4) { $useSendmail = command14 (); }
448 elsif ($command == 5) { $sendmail_path = command15 (); }
449 elsif ($command == 6) { $smtpServerAddress = command16 (); }
450 elsif ($command == 7) { $smtpPort = command17 (); }
a93b12ba 451 elsif ($command == 8) { $imap_server_type = command18 (); }
d47b2518 452 elsif ($command == 9) { $invert_time = command19 (); }
ccfb2029 453 } elsif ($menu == 3) {
454 if ($command == 1) { $default_folder_prefix = command21 (); }
455 elsif ($command == 2) { $show_prefix_option = command22 (); }
456 elsif ($command == 3) { $trash_folder = command23 (); }
457 elsif ($command == 4) { $sent_folder = command24 (); }
2f287147 458 elsif ($command == 5) { $default_move_to_trash = command25 (); }
459 elsif ($command == 6) { $default_move_to_sent = command26 (); }
460 elsif ($command == 7) { $list_special_folders_first = command27 (); }
461 elsif ($command == 8) { $use_special_folder_color = command28 (); }
462 elsif ($command == 9) { $auto_expunge = command29 (); }
463 elsif ($command == 10){ $default_sub_of_inbox = command210(); }
464 elsif ($command == 11){ $show_contain_subfolders_option = command211(); }
24fc5dd2 465 elsif ($command == 12){ $default_unseen_notify = command212(); }
466 elsif ($command == 13){ $default_unseen_type = command213(); }
ccfb2029 467 } elsif ($menu == 4) {
985f7c88 468 if ($command == 1) { $default_charset = command31 (); }
469 elsif ($command == 2) { $data_dir = command33 (); }
470 elsif ($command == 3) { $attachment_dir = command34 (); }
471 elsif ($command == 4) { $default_left_size = command35 (); }
472 elsif ($command == 5) { $force_username_lowercase = command36 (); }
ccfb2029 473 } elsif ($menu == 5) {
6f3bfa54 474 if ($command == 1) { command41 (); }
475 elsif ($command == 2) { $theme_css = command42 (); }
ccfb2029 476 } elsif ($menu == 6) {
3806fa52 477 if ($command == 1) { command61(); }
478 elsif ($command == 2) { command62(); }
ccfb2029 479 } elsif ($menu == 7) {
a37f3771 480 if ($command == 1) { $motd = command71(); }
9d0c7bee 481 } elsif ($menu == 8) {
1a7a2fcc 482 if ($command =~ /^[0-9]+/) { @plugins = command81(); }
ccfb2029 483 }
484 }
828b4753 485}
486
487####################################################################################
488
5b6ae78a 489# org_name
490sub command1 {
491 print "We have tried to make the name SquirrelMail as transparent as\n";
492 print "possible. If you set up an organization name, most places where\n";
493 print "SquirrelMail would take credit will be credited to your organization.\n";
494 print "\n";
828b4753 495 print "[$WHT$org_name$NRM]: $WHT";
496 $new_org_name = <STDIN>;
497 if ($new_org_name eq "\n") {
498 $new_org_name = $org_name;
499 } else {
500 $new_org_name =~ s/[\r|\n]//g;
501 }
5b6ae78a 502 return $new_org_name;
503}
504
828b4753 505
5b6ae78a 506# org_logo
507sub command2 {
508 print "Your organization's logo is an image that will be displayed at\n";
509 print "different times throughout SquirrelMail. This is asking for the\n";
510 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
511 print "(../images/logo.jpg) path to your logo.\n";
512 print "\n";
828b4753 513 print "[$WHT$org_logo$NRM]: $WHT";
5b6ae78a 514 $new_org_logo = <STDIN>;
515 if ($new_org_logo eq "\n") {
516 $new_org_logo = $org_logo;
bbd30ac8 517 } else {
5b6ae78a 518 $new_org_logo =~ s/[\r|\n]//g;
bbd30ac8 519 }
5b6ae78a 520 return $new_org_logo;
521}
522
523# org_title
524sub command3 {
525 print "A title is what is displayed at the top of the browser window in\n";
526 print "the titlebar. Usually this will end up looking something like:\n";
527 print "\"Netscape: $org_title\"\n";
528 print "\n";
828b4753 529 print "[$WHT$org_title$NRM]: $WHT";
5b6ae78a 530 $new_org_title = <STDIN>;
531 if ($new_org_title eq "\n") {
532 $new_org_title = $org_title;
bbd30ac8 533 } else {
5b6ae78a 534 $new_org_title =~ s/[\r|\n]//g;
bbd30ac8 535 }
5b6ae78a 536 return $new_org_title;
537}
5b6ae78a 538
828b4753 539####################################################################################
5b6ae78a 540
828b4753 541# domain
542sub command11 {
ccfb2029 543 print "The domain name is the suffix at the end of all email messages. If\n";
544 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
545 print "would be myorg.com.\n";
546 print "\n";
547 print "[$WHT$domain$NRM]: $WHT";
548 $new_domain = <STDIN>;
549 if ($new_domain eq "\n") {
550 $new_domain = $domain;
551 } else {
552 $new_domain =~ s/[\r|\n]//g;
553 }
554 return $new_domain;
828b4753 555}
5b6ae78a 556
828b4753 557# imapServerAddress
558sub command12 {
ccfb2029 559 print "This is the address where your IMAP server resides.\n";
560 print "[$WHT$imapServerAddress$NRM]: $WHT";
561 $new_imapServerAddress = <STDIN>;
562 if ($new_imapServerAddress eq "\n") {
563 $new_imapServerAddress = $imapServerAddress;
564 } else {
565 $new_imapServerAddress =~ s/[\r|\n]//g;
566 }
567 return $new_imapServerAddress;
828b4753 568}
5b6ae78a 569
828b4753 570# imapPort
571sub command13 {
ccfb2029 572 print "This is the port that your IMAP server is on. Usually this is 143.\n";
573 print "[$WHT$imapPort$NRM]: $WHT";
574 $new_imapPort = <STDIN>;
575 if ($new_imapPort eq "\n") {
576 $new_imapPort = $imapPort;
577 } else {
578 $new_imapPort =~ s/[\r|\n]//g;
579 }
580 return $new_imapPort;
828b4753 581}
582
583# useSendmail
584sub command14 {
ccfb2029 585 print "You now need to choose the method that you will use for sending\n";
586 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
587 print "or use sendmail directly.\n";
588 if ($useSendmail eq "true") {
996d34de 589 $default_value = "1";
ccfb2029 590 } else {
996d34de 591 $default_value = "2";
ccfb2029 592 }
593 print "\n";
996d34de 594 print " 1. Sendmail\n";
595 print " 2. SMTP\n";
596 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
ccfb2029 597 $use_sendmail = <STDIN>;
996d34de 598 if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
ccfb2029 599 $useSendmail = "true";
600 } else {
601 $useSendmail = "false";
602 }
603 return $useSendmail;
828b4753 604}
5b6ae78a 605
828b4753 606# sendmail_path
607sub command15 {
608 if ($sendmail_path[0] !~ /./) {
609 $sendmail_path = "/usr/sbin/sendmail";
610 }
ccfb2029 611 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
828b4753 612 print "[$WHT$sendmail_path$NRM]: $WHT";
613 $new_sendmail_path = <STDIN>;
614 if ($new_sendmail_path eq "\n") {
615 $new_sendmail_path = $sendmail_path;
616 } else {
617 $new_sendmail_path =~ s/[\r|\n]//g;
618 }
ccfb2029 619 return $new_sendmail_path;
828b4753 620}
5b6ae78a 621
828b4753 622# smtpServerAddress
623sub command16 {
ccfb2029 624 print "This is the location of your SMTP server.\n";
828b4753 625 print "[$WHT$smtpServerAddress$NRM]: $WHT";
626 $new_smtpServerAddress = <STDIN>;
627 if ($new_smtpServerAddress eq "\n") {
628 $new_smtpServerAddress = $smtpServerAddress;
629 } else {
630 $new_smtpServerAddress =~ s/[\r|\n]//g;
631 }
ccfb2029 632 return $new_smtpServerAddress;
828b4753 633}
634
635# smtpPort
636sub command17 {
ccfb2029 637 print "This is the port to connect to for SMTP. Usually 25.\n";
828b4753 638 print "[$WHT$smtpPort$NRM]: $WHT";
639 $new_smtpPort = <STDIN>;
640 if ($new_smtpPort eq "\n") {
641 $new_smtpPort = $smtpPort;
642 } else {
643 $new_smtpPort =~ s/[\r|\n]//g;
644 }
ccfb2029 645 return $new_smtpPort;
bbd30ac8 646}
a93b12ba 647# imap_server_type
648sub command18 {
d47b2518 649 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
a93b12ba 650 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
651 print "the same principles. We have made some work-arounds for some of\n";
652 print "these servers. If you would like to use them, please select your\n";
653 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
654 print "set this to \"other\", and none will be used.\n";
655 print " cyrus = Cyrus IMAP server\n";
656 print " uw = University of Washington's IMAP server\n";
657 print " exchange = Microsoft Exchange IMAP server\n";
658 print " courier = Courier IMAP server\n";
659 print "[$WHT$imap_server_type$NRM]: $WHT";
660 $new_imap_server_type = <STDIN>;
661 if ($new_imap_server_type eq "\n") {
662 $new_imap_server_type = $imap_server_type;
663 } else {
664 $new_imap_server_type =~ s/[\r|\n]//g;
665 }
666 return $new_imap_server_type;
667}
3f8fe68e 668
d47b2518 669# invert_time
670sub command19 {
671 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
672 print "on some machines). Typically this happens if the system doesn't support\n";
673 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
674 print "This most often occurs on Solaris 7 machines in the United States.\n";
675 print "By default, this is off. It should be kept off unless problems surface\n";
676 print "about the time that messages are sent.\n";
677 print " no = Do NOT fix time -- almost always correct\n";
678 print " yes = Fix the time for this system\n";
679
680 $YesNo = 'n';
681 $YesNo = 'y' if ($invert_time eq "true");
682
683 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
684
685 $new_invert_time = <STDIN>;
686 $new_invert_time =~ tr/yn//cd;
687 return "true" if ($new_invert_time eq "y");
688 return "false" if ($new_invert_time eq "n");
689 return $invert_time;
690}
691
3f8fe68e 692# MOTD
693sub command71 {
ccfb2029 694 print "\nYou can now create the welcome message that is displayed\n";
695 print "every time a user logs on. You can use HTML or just plain\n";
a37f3771 696 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 697
e9f8ea4e 698 $new_motd = "";
ccfb2029 699 do {
700 print "] ";
701 $line = <STDIN>;
702 $line =~ s/[\r|\n]//g;
ccfb2029 703 if ($line ne "@") {
c4809aca 704 $line =~ s/ /\&nbsp;\&nbsp;/g;
705 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
706 $line =~ s/$/ /;
e9f8ea4e 707 $line =~ s/\"/\\\"/g;
c4809aca 708
ccfb2029 709 $new_motd = $new_motd . $line;
710 }
711 } while ($line ne "@");
712 return $new_motd;
3f8fe68e 713}
911ad01c 714
9d0c7bee 715################# PLUGINS ###################
716
717sub command81 {
1a7a2fcc 718 $command =~ s/[\s|\n|\r]*//g;
719 if ($command > 0) {
720 $command = $command - 1;
721 if ($command <= $#plugins) {
722 @newplugins = ();
723 $ct=0;
724 while ($ct <= $#plugins) {
725 if ($ct != $command) {
726 @newplugins = (@newplugins, $plugins[$ct]);
9d0c7bee 727 }
1a7a2fcc 728 $ct++;
9d0c7bee 729 }
1a7a2fcc 730 @plugins = @newplugins;
731 } elsif ($command <= $#plugins + $#unused_plugins + 1) {
732 $num = $command - $#plugins - 1;
733 @newplugins = @plugins;
734 $ct=0;
735 while ($ct <= $#unused_plugins) {
736 if ($ct == $num) {
737 @newplugins = (@newplugins, $unused_plugins[$ct]);
9d0c7bee 738 }
1a7a2fcc 739 $ct++;
9d0c7bee 740 }
1a7a2fcc 741 @plugins = @newplugins;
9d0c7bee 742 }
1a7a2fcc 743 }
744 return @plugins;
9d0c7bee 745}
746
911ad01c 747################# FOLDERS ###################
748
749# default_folder_prefix
750sub command21 {
ccfb2029 751 print "Some IMAP servers (UW, for example) store mail and folders in\n";
752 print "your user space in a separate subdirectory. This is where you\n";
753 print "specify what that directory is.\n";
754 print "\n";
755 print "EXAMPLE: mail/";
756 print "\n";
757 print "NOTE: If you use Cyrus, or some server that would not use this\n";
758 print " option, you must set this to 'none'.\n";
759 print "\n";
911ad01c 760 print "[$WHT$default_folder_prefix$NRM]: $WHT";
761 $new_default_folder_prefix = <STDIN>;
762 if ($new_default_folder_prefix eq "\n") {
763 $new_default_folder_prefix = $default_folder_prefix;
764 } else {
765 $new_default_folder_prefix =~ s/[\r|\n]//g;
766 }
ccfb2029 767 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
768 $new_default_folder_prefix = "";
769 } else {
770 $new_default_folder_prefix =~ s/\/*$//g;
771 $new_default_folder_prefix =~ s/$/\//g;
772 }
911ad01c 773 return $new_default_folder_prefix;
774}
775
776# Show Folder Prefix
777sub command22 {
ccfb2029 778 print "It is possible to set up the default folder prefix as a user\n";
779 print "specific option, where each user can specify what their mail\n";
780 print "folder is. If you set this to false, they will never see the\n";
781 print "option, but if it is true, this option will appear in the\n";
782 print "'options' section.\n";
783 print "\n";
784 print "NOTE: You set the default folder prefix in option '1' of this\n";
785 print " section. That will be the default if the user doesn't\n";
786 print " specify anything different.\n";
787 print "\n";
788
789 if ($show_prefix_option eq "true") {
790 $default_value = "y";
791 } else {
792 $default_value = "n";
793 }
794 print "\n";
795 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
796 $new_show = <STDIN>;
797 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
798 $show_prefix_option = "true";
799 } else {
800 $show_prefix_option = "false";
801 }
802 return $show_prefix_option;
911ad01c 803}
804
805# Trash Folder
806sub command23 {
ccfb2029 807 print "You can now specify where the default trash folder is located.\n";
808 print "On servers where you do not want this, you can set it to anything\n";
809 print "and set option 7 to false.\n";
810 print "\n";
811 print "This is relative to where the rest of your email is kept. You do\n";
812 print "not need to worry about their mail directory. If this folder\n";
813 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
814 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
815 print "\n";
911ad01c 816
817 print "[$WHT$trash_folder$NRM]: $WHT";
818 $new_trash_folder = <STDIN>;
819 if ($new_trash_folder eq "\n") {
820 $new_trash_folder = $trash_folder;
821 } else {
822 $new_trash_folder =~ s/[\r|\n]//g;
823 }
ccfb2029 824 return $new_trash_folder;
911ad01c 825}
826
827# Sent Folder
828sub command24 {
ccfb2029 829 print "This is where messages that are sent will be stored. SquirrelMail\n";
830 print "by default puts a copy of all outgoing messages in this folder.\n";
831 print "\n";
832 print "This is relative to where the rest of your email is kept. You do\n";
833 print "not need to worry about their mail directory. If this folder\n";
834 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
835 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
836 print "\n";
911ad01c 837
838 print "[$WHT$sent_folder$NRM]: $WHT";
839 $new_sent_folder = <STDIN>;
840 if ($new_sent_folder eq "\n") {
841 $new_sent_folder = $sent_folder;
842 } else {
843 $new_sent_folder =~ s/[\r|\n]//g;
844 }
ccfb2029 845 return $new_sent_folder;
911ad01c 846}
847
2f287147 848# default move to trash
911ad01c 849sub command25 {
2f287147 850 print "By default, should messages get moved to the trash folder? You\n";
851 print "can specify the default trash folder in option 3. If this is set\n";
852 print "to false, messages will get deleted immediately without moving\n";
853 print "to the trash folder.\n";
854 print "\n";
855 print "Trash folder is currently: $trash_folder\n";
856 print "\n";
857
858 if ($default_move_to_trash eq "true") {
859 $default_value = "y";
860 } else {
861 $default_value = "n";
862 }
863 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
864 $new_show = <STDIN>;
865 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
866 $default_move_to_trash = "true";
867 } else {
868 $default_move_to_trash = "false";
869 }
870 return $default_move_to_trash;
871}
872
873# default move to sent
874sub command26 {
875 print "By default, should messages get moved to the sent folder? You\n";
876 print "can specify the default sent folder in option 4. If this is set\n";
776c7431 877 print "to false, messages will get sent an no copy will be made.\n";
2f287147 878 print "\n";
879 print "Trash folder is currently: $sent_folder\n";
880 print "\n";
881
882 if ($default_move_to_sent eq "true") {
883 $default_value = "y";
884 } else {
885 $default_value = "n";
886 }
887 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
888 $new_show = <STDIN>;
889 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
890 $default_move_to_sent = "true";
891 } else {
892 $default_move_to_sent = "false";
893 }
894 return $default_move_to_sent;
895}
896
897# List special folders first
898sub command27 {
ccfb2029 899 print "SquirrelMail has what we call 'special folders' that are not\n";
900 print "manipulated and viewed like normal folders. Some examples of\n";
901 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
902 print "Simply asks if you want these folders listed first in the folder\n";
903 print "listing.\n";
904 print "\n";
905
906 if ($list_special_folders_first eq "true") {
907 $default_value = "y";
908 } else {
909 $default_value = "n";
910 }
911 print "\n";
912 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
913 $new_show = <STDIN>;
914 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
915 $list_special_folders_first = "true";
916 } else {
917 $list_special_folders_first = "false";
918 }
919 return $list_special_folders_first;
911ad01c 920}
921
922# Show special folders color
2f287147 923sub command28 {
ccfb2029 924 print "SquirrelMail has what we call 'special folders' that are not\n";
925 print "manipulated and viewed like normal folders. Some examples of\n";
926 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
927 print "wants to know if we should display special folders in a\n";
928 print "color than the other folders.\n";
929 print "\n";
930
931 if ($use_special_folder_color eq "true") {
932 $default_value = "y";
933 } else {
934 $default_value = "n";
935 }
936 print "\n";
937 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
938 $new_show = <STDIN>;
939 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
940 $use_special_folder_color = "true";
941 } else {
942 $use_special_folder_color = "false";
943 }
944 return $use_special_folder_color;
911ad01c 945}
946
911ad01c 947# Auto expunge
2f287147 948sub command29 {
ccfb2029 949 print "The way that IMAP handles deleting messages is as follows. You\n";
950 print "mark the message as deleted, and then to 'really' delete it, you\n";
951 print "expunge it. This option asks if you want to just have messages\n";
952 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
953 print "messages too.\n";
954 print "\n";
955
956 if ($auto_expunge eq "true") {
957 $default_value = "y";
958 } else {
959 $default_value = "n";
960 }
961 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
962 $new_show = <STDIN>;
963 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
964 $auto_expunge = "true";
965 } else {
966 $auto_expunge = "false";
967 }
968 return $auto_expunge;
911ad01c 969}
970
971# Default sub of inbox
2f287147 972sub command210 {
ccfb2029 973 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
974 print "This can cause some confusion in folder creation for users when\n";
975 print "they try to create folders and don't put it as a subfolder of INBOX\n";
976 print "and get permission errors. This option asks if you want folders\n";
977 print "to be subfolders of INBOX by default.\n";
978 print "\n";
979
980 if ($default_sub_of_inbox eq "true") {
981 $default_value = "y";
982 } else {
983 $default_value = "n";
984 }
985 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
986 $new_show = <STDIN>;
987 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
988 $default_sub_of_inbox = "true";
989 } else {
990 $default_sub_of_inbox = "false";
991 }
992 return $default_sub_of_inbox;
911ad01c 993}
994
995# Show contain subfolder option
2f287147 996sub command211 {
ccfb2029 997 print "Some IMAP servers (UW) make it so that there are two types of\n";
998 print "folders. Those that contain messages, and those that contain\n";
999 print "subfolders. If this is the case for your server, set this to\n";
1000 print "true, and it will ask the user whether the folder they are\n";
1001 print "creating contains subfolders or messages.\n";
1002 print "\n";
1003
1004 if ($show_contain_subfolders_option eq "true") {
1005 $default_value = "y";
1006 } else {
1007 $default_value = "n";
1008 }
1009 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1010 $new_show = <STDIN>;
1011 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1012 $show_contain_subfolders_option = "true";
1013 } else {
1014 $show_contain_subfolders_option = "false";
1015 }
1016 return $show_contain_subfolders_option;
911ad01c 1017}
1018
24fc5dd2 1019# Default Unseen Notify
1020sub command212 {
1021 print "This option specifies where the users will receive notification\n";
1022 print "about unseen messages by default. This is of course an option that\n";
1023 print "can be changed on a user level.\n";
1024 print " 1 = No notification\n";
1025 print " 2 = Only on the INBOX\n";
1026 print " 3 = On all folders\n";
1027 print "\n";
1028
1029 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1030 $new_show = <STDIN>;
1031 if ($new_show =~ /^[1|2|3]\n/i) {
1032 $default_unseen_notify = $new_show;
1033 }
1034 $default_unseen_notify =~ s/[\r|\n]//g;
1035 return $default_unseen_notify;
1036}
1037
1038# Default Unseen Type
1039sub command213 {
1040 print "Here you can define the default way that unseen messages will be displayed\n";
1041 print "to the user in the folder listing on the left side.\n";
1042 print " 1 = Only unseen messages (4)\n";
1043 print " 2 = Unseen and Total messages (4/27)\n";
1044 print "\n";
1045
1046 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1047 $new_show = <STDIN>;
1048 if ($new_show =~ /^[1|2]\n/i) {
1049 $default_unseen_type = $new_show;
1050 }
1051 $default_unseen_type =~ s/[\r|\n]//g;
1052 return $default_unseen_type;
1053}
1054
1055
ccfb2029 1056############# GENERAL OPTIONS #####################
1057
1058# Default Charset
1059sub command31 {
1060 print "This option controls what character set is used when sending\n";
1061 print "mail and when sending HTML to the browser. Do not set this\n";
1062 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1063 print "to use KOI8-R, since this implementation is faster than most\n";
1064 print "of the alternatives\n";
1065 print "\n";
1066
1067 print "[$WHT$default_charset$NRM]: $WHT";
1068 $new_default_charset = <STDIN>;
1069 if ($new_default_charset eq "\n") {
1070 $new_default_charset = $default_charset;
1071 } else {
1072 $new_default_charset =~ s/[\r|\n]//g;
1073 }
1074 return $new_default_charset;
1075}
1076
ccfb2029 1077# Data directory
1078sub command33 {
1079 print "It is a possible security hole to have a writable directory\n";
1080 print "under the web server's root directory (ex: /home/httpd/html).\n";
1081 print "For this reason, it is possible to put the data directory\n";
1082 print "anywhere you would like. The path name can be absolute or\n";
1083 print "relative (to the config directory). It doesn't matter. Here\n";
1084 print "are two examples:\n";
1085 print " Absolute: /usr/local/squirrelmail/data/\n";
1086 print " Relative: ../data/\n";
1087 print "\n";
1088
1089 print "[$WHT$data_dir$NRM]: $WHT";
1090 $new_data_dir = <STDIN>;
1091 if ($new_data_dir eq "\n") {
1092 $new_data_dir = $data_dir;
1093 } else {
1094 $new_data_dir =~ s/[\r|\n]//g;
1095 }
1096 if ($new_data_dir =~ /^\s*$/) {
1097 $new_data_dir = "";
1098 } else {
1099 $new_data_dir =~ s/\/*$//g;
1100 $new_data_dir =~ s/$/\//g;
1101 }
1102 return $new_data_dir;
1103}
1104
1105# Attachment directory
1106sub command34 {
1107 print "Path to directory used for storing attachments while a mail is\n";
1108 print "being sent. There are a few security considerations regarding this\n";
1109 print "directory:\n";
1110 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1111 print " impossible for a random person with access to the webserver\n";
1112 print " to list files in this directory. Confidential data might\n";
1113 print " be laying around in there.\n";
1114 print " 2. Since the webserver is not able to list the files in the\n";
1115 print " content is also impossible for the webserver to delete files\n";
1116 print " lying around there for too long.\n";
1117 print " 3. It should probably be another directory than the data\n";
1118 print " directory specified in option 3.\n";
1119 print "\n";
1120
1121 print "[$WHT$attachment_dir$NRM]: $WHT";
1122 $new_attachment_dir = <STDIN>;
1123 if ($new_attachment_dir eq "\n") {
1124 $new_attachment_dir = $attachment_dir;
1125 } else {
1126 $new_attachment_dir =~ s/[\r|\n]//g;
1127 }
1128 if ($new_attachment_dir =~ /^\s*$/) {
1129 $new_attachment_dir = "";
1130 } else {
1131 $new_attachment_dir =~ s/\/*$//g;
1132 $new_attachment_dir =~ s/$/\//g;
1133 }
1134 return $new_attachment_dir;
1135}
1136
1137
1138sub command35 {
1139 print "This is the default size (in pixels) of the left folder list.\n";
1140 print "Default is 200, but you can set it to whatever you wish. This\n";
1141 print "is a user preference, so this will only show up as their default.\n";
1142 print "\n";
1143 print "[$WHT$default_left_size$NRM]: $WHT";
1144 $new_default_left_size = <STDIN>;
1145 if ($new_default_left_size eq "\n") {
1146 $new_default_left_size = $default_left_size;
1147 } else {
1148 $new_default_left_size =~ s/[\r|\n]//g;
1149 }
1150 return $new_default_left_size;
1151}
1152
1153
985f7c88 1154sub command36 {
1155 print "Some IMAP servers only have lowercase letters in the usernames\n";
1156 print "but they still allow people with uppercase to log in. This\n";
1157 print "causes a problem with the user's preference files. This option\n";
1158 print "transparently changes all usernames to lowercase.";
1159 print "\n";
1160
1161 if ($force_username_lowercase eq "true") {
1162 $default_value = "y";
1163 } else {
1164 $default_value = "n";
1165 }
1166 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1167 $new_show = <STDIN>;
1168 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1169 return "true";
1170 }
1171 return "false";
1172}
1173
1174
ccfb2029 1175sub command41 {
1176 print "\nNow we will define the themes that you wish to use. If you have added\n";
1177 print "a theme of your own, just follow the instructions (?) about how to add\n";
1178 print "them. You can also change the default theme.\n";
1179 print "[theme] command (?=help) > ";
1180 $input = <STDIN>;
1181 $input =~ s/[\r|\n]//g;
1182 while ($input ne "d") {
1183 if ($input =~ /^\s*l\s*/i) {
1184 $count = 0;
1185 while ($count <= $#theme_name) {
1186 if ($count == $theme_default) {
1187 print " *";
1188 } else {
1189 print " ";
1190 }
1191 $name = $theme_name[$count];
1192 $num_spaces = 25 - length($name);
1193 for ($i = 0; $i < $num_spaces;$i++) {
1194 $name = $name . " ";
1195 }
1196
1197 print " $count. $name";
1198 print "($theme_path[$count])\n";
1199
1200 $count++;
1201 }
1202 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1203 $old_def = $theme_default;
1204 $theme_default = $input;
1205 $theme_default =~ s/^\s*m\s*//;
1206 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1207 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1208 $theme_default = $old_def;
1209 }
1210 } elsif ($input =~ /^\s*\+/) {
1211 print "What is the name of this theme: ";
1212 $name = <STDIN>;
1213 $name =~ s/[\r|\n]//g;
1214 $theme_name[$#theme_name+1] = $name;
390372b4 1215 print "Be sure to put ../themes/ before the filename.\n";
1216 print "What file is this stored in (ex: ../themes/default_theme.php): ";
ccfb2029 1217 $name = <STDIN>;
1218 $name =~ s/[\r|\n]//g;
1219 $theme_path[$#theme_path+1] = $name;
1220 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1221 if ($input =~ /[0-9]+\s*$/) {
1222 $rem_num = $input;
1223 $rem_num =~ s/^\s*-\s*//g;
1224 $rem_num =~ s/\s*$//;
1225 } else {
1226 $rem_num = $#theme_name;
1227 }
1228 if ($rem_num == $theme_default) {
1229 print "You cannot remove the default theme!\n";
1230 } else {
1231 $count = 0;
1232 @new_theme_name = ();
1233 @new_theme_path = ();
1234 while ($count <= $#theme_name) {
1235 if ($count != $rem_num) {
1236 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1237 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1238 }
1239 $count++;
1240 }
1241 @theme_name = @new_theme_name;
1242 @theme_path = @new_theme_path;
1243 if ($theme_default > $rem_num) {
1244 $theme_default--;
1245 }
1246 }
8442ac08 1247 } elsif ($input =~ /^\s*t\s*/i) {
1248 print "\nStarting detection...\n\n";
1249
1250 opendir(DIR, "../themes");
1251 @files = grep { /\.php$/i } readdir(DIR);
1252 $cnt = 0;
1253 while ($cnt <= $#files) {
1254 $filename = "../themes/" . $files[$cnt];
5cb1d69b 1255 if ($filename ne "../themes/index.php") {
1256 $found = 0;
1257 for ($x=0; $x <= $#theme_path; $x++) {
1258 if ($theme_path[$x] eq $filename) {
1259 $found = 1;
1260 }
1261 }
1262 if ($found != 1) {
1263 print "** Found theme: $filename\n";
1264 print " What is its name? ";
1265 $nm = <STDIN>;
1266 $nm =~ s/[\n|\r]//g;
1267 $theme_name[$#theme_name+1] = $nm;
1268 $theme_path[$#theme_path+1] = $filename;
8442ac08 1269 }
8442ac08 1270 }
1271 $cnt++;
1272 }
1273 print "\n";
1274 for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
1275 $filename = $theme_path[$cnt];
1276 if (! (-e $filename)) {
1277 print " Removing $filename (file not found)\n";
1278 $offset = 0;
1279 @new_theme_name = ();
1280 @new_theme_path = ();
1281 for ($x=0; $x < $#theme_path; $x++) {
1282 if ($theme_path[$x] eq $filename) {
1283 $offset = 1;
1284 }
1285 if ($offset == 1) {
1286 $new_theme_name[$x] = $theme_name[$x+1];
1287 $new_theme_path[$x] = $theme_path[$x+1];
1288 } else {
1289 $new_theme_name[$x] = $theme_name[$x];
1290 $new_theme_path[$x] = $theme_path[$x];
1291 }
1292 }
1293 @theme_name = @new_theme_name;
1294 @theme_path = @new_theme_path;
1295 }
1296 }
1297 print "\nDetection complete!\n\n";
1298
1299 closedir DIR;
ccfb2029 1300 } elsif ($input =~ /^\s*\?\s*/) {
1301 print ".-------------------------.\n";
8442ac08 1302 print "| t (detect themes) |\n";
ccfb2029 1303 print "| + (add theme) |\n";
1304 print "| - N (remove theme) |\n";
1305 print "| m N (mark default) |\n";
1306 print "| l (list themes) |\n";
1307 print "| d (done) |\n";
1308 print "`-------------------------'\n";
1309 }
1310 print "[theme] command (?=help) > ";
1311 $input = <STDIN>;
1312 $input =~ s/[\r|\n]//g;
1313 }
1314}
1315
1316
6f3bfa54 1317# Theme - CSS file
1318sub command42 {
1319 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1320 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1321 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1322 print "files, leave this blank.\n";
1323 print "\n";
1324 print "To clear out an existing value, just type a space for the input.\n";
1325 print "\n";
1326 print "[$WHT$theme_css$NRM]: $WHT";
1327 $new_theme_css = <STDIN>;
1328 if ($new_theme_css eq "\n") {
1329 $new_theme_css = $theme_css;
1330 } else {
1331 $new_theme_css =~ s/[\r|\n]//g;
1332 }
1333 $new_theme_css =~ s/^\s*//;
1334 return $new_theme_css;
1335}
1336
1337
1e0628fb 1338sub command61 {
a93b12ba 1339 print "You can now define different LDAP servers.\n";
1e0628fb 1340 print "[ldap] command (?=help) > ";
1341 $input = <STDIN>;
1342 $input =~ s/[\r|\n]//g;
1343 while ($input ne "d") {
1344 if ($input =~ /^\s*l\s*/i) {
1345 $count = 0;
1346 while ($count <= $#ldap_host) {
a93b12ba 1347 print "$count. $ldap_host[$count]\n";
1348 print " base: $ldap_base[$count]\n";
1349 if ($ldap_charset[$count]) {
1350 print " charset: $ldap_charset[$count]\n";
1351 }
1352 if ($ldap_port[$count]) {
1353 print " port: $ldap_port[$count]\n";
1354 }
1355 if ($ldap_name[$count]) {
1356 print " name: $ldap_name[$count]\n";
1357 }
1358 if ($ldap_maxrows[$count]) {
1359 print " maxrows: $ldap_maxrows[$count]\n";
1360 }
1361 print "\n";
1e0628fb 1362 $count++;
1363 }
1364 } elsif ($input =~ /^\s*\+/) {
a93b12ba 1365 $sub = $#ldap_host + 1;
1e0628fb 1366
a93b12ba 1367 print "First, we need to have the hostname or the IP address where\n";
1368 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1369 print "hostname: ";
1e0628fb 1370 $name = <STDIN>;
1371 $name =~ s/[\r|\n]//g;
1372 $ldap_host[$sub] = $name;
a93b12ba 1373
1374 print "\n";
1e0628fb 1375
a93b12ba 1376 print "Next, we need the server root (base dn). For this, an empty\n";
1377 print "string is allowed.\n";
1378 print "Example: ou=member_directory,o=netcenter.com\n";
1379 print "base: ";
1e0628fb 1380 $name = <STDIN>;
1381 $name =~ s/[\r|\n]//g;
1382 $ldap_base[$sub] = $name;
1383
a93b12ba 1384 print "\n";
1e0628fb 1385
a93b12ba 1386 print "This is the TCP/IP port number for the LDAP server. Default\n";
1387 print "port is 389. This is optional. Press ENTER for default.\n";
1388 print "port: ";
1e0628fb 1389 $name = <STDIN>;
1390 $name =~ s/[\r|\n]//g;
1391 $ldap_port[$sub] = $name;
1392
a93b12ba 1393 print "\n";
1e0628fb 1394
a93b12ba 1395 print "This is the charset for the server. Default is utf-8. This\n";
1396 print "is also optional. Press ENTER for default.\n";
1397 print "charset: ";
1e0628fb 1398 $name = <STDIN>;
1399 $name =~ s/[\r|\n]//g;
1400 $ldap_charset[$sub] = $name;
1401
a93b12ba 1402 print "\n";
1e0628fb 1403
a93b12ba 1404 print "This is the name for the server, used to tag the results of\n";
1405 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1406 print "name: ";
1e0628fb 1407 $name = <STDIN>;
1408 $name =~ s/[\r|\n]//g;
1409 $ldap_name[$sub] = $name;
1410
a93b12ba 1411 print "\n";
1e0628fb 1412
a93b12ba 1413 print "You can specify the maximum number of rows in the search result.\n";
1414 print "Default is unlimited. Press ENTER for default.\n";
1415 print "maxrows: ";
1e0628fb 1416 $name = <STDIN>;
1417 $name =~ s/[\r|\n]//g;
1418 $ldap_maxrows[$sub] = $name;
1419
a93b12ba 1420 print "\n";
1e0628fb 1421
1422 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1423 if ($input =~ /[0-9]+\s*$/) {
1424 $rem_num = $input;
1425 $rem_num =~ s/^\s*-\s*//g;
1426 $rem_num =~ s/\s*$//;
1427 } else {
1428 $rem_num = $#ldap_host;
1429 }
1430 $count = 0;
1431 @new_ldap_host = ();
1432 @new_ldap_base = ();
1433 @new_ldap_port = ();
1434 @new_ldap_name = ();
1435 @new_ldap_charset = ();
1436 @new_ldap_maxrows = ();
1437 while ($count <= $#ldap_host) {
1438 if ($count != $rem_num) {
1439 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1440 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1441 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1442 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1443 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1444 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1445 }
1446 $count++;
1447 }
1448 @ldap_host = @new_ldap_host;
1449 @ldap_base = @new_ldap_base;
1450 @ldap_port = @new_ldap_port;
1451 @ldap_name = @new_ldap_name;
1452 @ldap_charset = @new_ldap_charset;
1453 @ldap_maxrows = @new_ldap_maxrows;
1454 } elsif ($input =~ /^\s*\?\s*/) {
1455 print ".-------------------------.\n";
1456 print "| + (add host) |\n";
1457 print "| - N (remove host) |\n";
1458 print "| l (list hosts) |\n";
1459 print "| d (done) |\n";
1460 print "`-------------------------'\n";
1461 }
1462 print "[ldap] command (?=help) > ";
1463 $input = <STDIN>;
1464 $input =~ s/[\r|\n]//g;
1465 }
1466}
1467
3806fa52 1468sub command62 {
591000ec 1469 print "Some of our developers have come up with very good javascript interface\n";
1470 print "for searching through address books, however, our original goals said\n";
1471 print "that we would be 100% HTML. In order to make it possible to use their\n";
1472 print "interface, and yet stick with our goals, we have also written a plain\n";
1473 print "HTML version of the search. Here, you can choose which version to use.\n";
3806fa52 1474 print "\n";
1475 print "This is just the default value. It is also a user option that each\n";
1476 print "user can configure individually\n";
1477 print "\n";
1478
1479 if ($default_use_javascript_addr_book eq "true") {
1480 $default_value = "y";
1481 } else {
1482 $default_use_javascript_addr_book = "false";
1483 $default_value = "n";
1484 }
c4809aca 1485 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
3806fa52 1486 $new_show = <STDIN>;
1487 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1488 $default_use_javascript_addr_book = "true";
1489 } else {
1490 $default_use_javascript_addr_book = "false";
1491 }
1492 return $default_use_javascript_addr_book;
1493}
1e0628fb 1494
ccfb2029 1495
1496sub save_data {
1497 open (FILE, ">config.php");
1498
349ca9f7 1499 print FILE "<?php\n\t/** SquirrelMail configuration\n";
ccfb2029 1500 print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
1501
6b638171 1502 if ($print_config_version) {
1503 print FILE "\t\$config_version = \"$print_config_version\";\n";
6b638171 1504 }
0ecb47e5 1505 print FILE "\t\$config_use_color = $config_use_color;\n";
1506 print FILE "\n";
4011c3ca 1507
ccfb2029 1508 print FILE "\t\$org_name = \"$org_name\";\n";
1509 print FILE "\t\$org_logo = \"$org_logo\";\n";
1510 print FILE "\t\$org_title = \"$org_title\";\n";
1511
1512 print FILE "\n";
1513
c39a6b45 1514 print FILE "\t\$domain = \"$domain\";\n";
1515 print FILE "\t\$imapServerAddress = \"$imapServerAddress\";\n";
1516 print FILE "\t\$imapPort = $imapPort;\n";
1517 print FILE "\t\$useSendmail = $useSendmail;\n";
1518 print FILE "\t\$smtpServerAddress = \"$smtpServerAddress\";\n";
1519 print FILE "\t\$smtpPort = $smtpPort;\n";
d47b2518 1520 print FILE "\t\$sendmail_path = \"$sendmail_path\";\n";
a93b12ba 1521 print FILE "\t\$imap_server_type = \"$imap_server_type\";\n";
d47b2518 1522 print FILE "\t\$invert_time = $invert_time;\n";
ccfb2029 1523
1524 print FILE "\n";
1525
1526 print FILE "\t\$default_folder_prefix = \"$default_folder_prefix\";\n";
8ad99a99 1527 print FILE "\t\$trash_folder = \"$trash_folder\";\n";
ccfb2029 1528 print FILE "\t\$sent_folder = \"$sent_folder\";\n";
2f287147 1529 print FILE "\t\$default_move_to_trash = $default_move_to_trash;\n";
1530 print FILE "\t\$default_move_to_sent = $default_move_to_sent;\n";
ccfb2029 1531 print FILE "\t\$show_prefix_option = $show_prefix_option;\n";
1532 print FILE "\t\$list_special_folders_first = $list_special_folders_first;\n";
1533 print FILE "\t\$use_special_folder_color = $use_special_folder_color;\n";
ccfb2029 1534 print FILE "\t\$auto_expunge = $auto_expunge;\n";
1535 print FILE "\t\$default_sub_of_inbox = $default_sub_of_inbox;\n";
c39a6b45 1536 print FILE "\t\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
24fc5dd2 1537 print FILE "\t\$default_unseen_notify = $default_unseen_notify;\n";
1538 print FILE "\t\$default_unseen_type = $default_unseen_type;\n";
ccfb2029 1539 print FILE "\n";
1540
985f7c88 1541 print FILE "\t\$default_charset = \"$default_charset\";\n";
1542 print FILE "\t\$data_dir = \"$data_dir\";\n";
1543 print FILE "\t\$attachment_dir = \"$attachment_dir\";\n";
1544 print FILE "\t\$default_left_size = $default_left_size;\n";
1545 print FILE "\t\$force_username_lowercase = $force_username_lowercase;\n";
ccfb2029 1546
1547 print FILE "\n";
1548
1a7a2fcc 1549 for ($ct=0; $ct <= $#plugins; $ct++) {
1550 print FILE "\t\$plugins[$ct] = \"$plugins[$ct]\";\n";
9d0c7bee 1551 }
1552
1553 print FILE "\n";
1554
6f3bfa54 1555 print FILE "\t\$theme_css = \"$theme_css\";\n";
ccfb2029 1556 for ($count=0; $count <= $#theme_name; $count++) {
8ad99a99 1557 print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
1558 print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
1559 }
1560
ccfb2029 1561 print FILE "\n";
1562
3806fa52 1563 if ($default_use_javascript_addr_book ne "true") {
1564 $default_use_javascript_addr_book = "false";
1565 }
1566 print FILE "\t\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
1e0628fb 1567 for ($count=0; $count <= $#ldap_host; $count++) {
a93b12ba 1568 print FILE "\t\$ldap_server[$count] = Array(\n";
1569 print FILE "\t\t\t\"host\" => \"$ldap_host[$count]\",\n";
1570 print FILE "\t\t\t\"base\" => \"$ldap_base[$count]\"";
1571 if ($ldap_name[$count]) {
1572 print FILE ",\n\t\t\t\"name\" => \"$ldap_name[$count]\"";
1573 }
1574 if ($ldap_port[$count]) {
1575 print FILE ",\n\t\t\t\"port\" => \"$ldap_port[$count]\"";
1576 }
1577 if ($ldap_charset[$count]) {
1578 print FILE ",\n\t\t\t\"charset\" => \"$ldap_charset[$count]\"";
1579 }
1580 if ($ldap_maxrows[$count]) {
1581 print FILE ",\n\t\t\t\"maxrows\" => \"$ldap_maxrows[$count]\"";
1582 }
1583 print FILE ");\n\n";
1e0628fb 1584 }
1585
8ad99a99 1586 print FILE "\t\$motd = \"$motd\";\n";
ccfb2029 1587
1588 print FILE "?>\n";
1589 close FILE;
911ad01c 1590}
a93b12ba 1591
1592sub set_defaults {
1593 system "clear";
612eda0a 1594 print $WHT."SquirrelMail Configuration : ".$NRM;
1595 if ($config == 1) { print "Read: config.php"; }
1596 elsif ($config == 2) { print "Read: config_default.php"; }
1597 print "\n";
1598 print "---------------------------------------------------------\n";
1599
a93b12ba 1600 print "While we have been building SquirrelMail, we have discovered some\n";
1601 print "preferences that work better with some servers that don't work so\n";
1602 print "well with others. If you select your IMAP server, this option will\n";
1603 print "set some pre-defined settings for that server.\n";
1604 print "\n";
1605 print "Please note that you will still need to go through and make sure\n";
1606 print "everything is correct. This does not change everything. There are\n";
e9f8ea4e 1607 print "only a few settings that this will change.\n";
a93b12ba 1608 print "\n";
1609
1610 $continue = 0;
1611 while ($continue != 1) {
1612 print "Please select your IMAP server:\n";
1613 print " cyrus = Cyrus IMAP server\n";
1614 print " uw = University of Washington's IMAP server\n";
1615 print " exchange = Microsoft Exchange IMAP server\n";
1616 print " courier = Courier IMAP server\n";
1617 print " quit = Do not change anything\n";
1618 print "Command >> ";
1619 $server = <STDIN>;
1620 $server =~ s/[\r|\n]//g;
1621
c4809aca 1622 print "\n";
1623 if ($server eq "cyrus") {
1624 $default_folder_prefix = "INBOX";
a93b12ba 1625 $trash_folder = "INBOX.Trash";
1626 $sent_folder = "INBOX.Sent";
1627 $show_prefix_option = false;
1628 $default_sub_of_inbox = true;
1629 $show_contain_subfolders_option = false;
1630 $imap_server_type = "cyrus";
1631
c4809aca 1632 print " default_folder_prefix = INBOX\n";
1633 print " trash_folder = INBOX.Trash\n";
1634 print " sent_folder = INBOX.Sent\n";
e9f8ea4e 1635 print " show_prefix_option = false\n";
c4809aca 1636 print " default_sub_of_inbox = true\n";
1637 print "show_contain_subfolders_option = false\n";
1638 print " imap_server_type = cyrus\n";
1639
a93b12ba 1640 $continue = 1;
1641 } elsif ($server eq "uw") {
1642 $default_folder_prefix = "mail/";
1643 $trash_folder = "Trash";
1644 $sent_folder = "Sent";
1645 $show_prefix_option = true;
1646 $default_sub_of_inbox = false;
1647 $show_contain_subfolders_option = true;
1648 $imap_server_type = "uw";
c4809aca 1649
1650 print " default_folder_prefix = mail/\n";
1651 print " trash_folder = Trash\n";
1652 print " sent_folder = Sent\n";
1653 print " show_prefix_option = true\n";
1654 print " default_sub_of_inbox = false\n";
1655 print "show_contain_subfolders_option = true\n";
1656 print " imap_server_type = uw\n";
a93b12ba 1657
1658 $continue = 1;
1659 } elsif ($server eq "exchange") {
1660 $default_folder_prefix = "INBOX/";
1661 $default_sub_of_inbox = true;
1662 $trash_folder = "INBOX/Deleted Items";
1663 $sent_folder = "INBOX/Sent Items";
1664 $show_prefix_option = false;
1665 $show_contain_subfolders_option = false;
a93b12ba 1666 $imap_server_type = "exchange";
1667
612eda0a 1668 print " default_folder_prefix = INBOX/\n";
1669 print " default_sub_of_inbox = true\n";
1670 print " trash_folder = \"INBOX/Deleted Items\"\n";
1671 print " sent_folder = \"INBOX/Sent Items\"\n";
1672 print " show_prefix_option = false\n";
1673 print " show_contain_subfolders_option = false\n";
1674 print " imap_server_type = exchange\n";
1675
a93b12ba 1676 $continue = 1;
1677 } elsif ($server eq "courier") {
1678 $imap_server_type = "courier";
612eda0a 1679
1680 print " imap_server_type = courier\n";
a93b12ba 1681
1682 $continue = 1;
1683 } elsif ($server eq "quit") {
1684 $continue = 1;
1685 } else {
1686 print "Unrecognized server: $server\n";
1687 print "\n";
1688 }
1689 }
c4809aca 1690 print "\nPress any key to continue...";
1691 $tmp = <STDIN>;
a93b12ba 1692}