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