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