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