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