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