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