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