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