Added a "compose in new window" option located in display prefs. Each file that calls...
[squirrelmail.git] / config / conf.pl
CommitLineData
23afd0bd 1#!/usr/bin/env perl
bbd30ac8 2# conf.pl
8beafbbc 3# Luke Ehresman (luke@squirrelmail.org)
bbd30ac8 4#
5# A simple configure script to configure squirrelmail
245a6892 6#
7# $Id$
ccfb2029 8############################################################
a3439b27 9$conf_pl_version = "1.2.0";
bbd30ac8 10
38b69acb 11############################################################
12# Check what directory we're supposed to be running in, and
13# change there if necessary. File::Basename has been in
14# Perl since at least 5.003_7, and nobody sane runs anything
15# before that, but just in case.
16############################################################
17
18if (eval q{require "File/Basename.pm"}) {
19 my $dir = File::Basename::dirname($0);
20 chdir($dir);
21}
22
23
d595e32e 24############################################################
25# Some people try to run this as a CGI. That's wrong!
26############################################################
27if(defined($ENV{'PATH_INFO'}) || defined($ENV{'QUERY_STRING'}) ||
28 defined($ENV{'REQUEST_METHOD'})) {
29 print "Content-Type: text/html\n\n";
30 print "You must run this script from the command line.";
31 exit;
32}
33
ccfb2029 34############################################################
bbd30ac8 35# First, lets read in the data already in there...
ccfb2029 36############################################################
bbd30ac8 37if ( -e "config.php") {
4011c3ca 38 open (FILE, "config.php");
39 while ($line = <FILE>) {
a3439b27 40 $line =~ s/^\s+//;
41 $line =~ s/^\$//;
42 $var = $line;
4011c3ca 43
a3439b27 44 $var =~ s/=/EQUALS/;
45 if ($var =~ /^([a-z]|[A-Z])/) {
46 @o = split(/\s*EQUALS\s*/, $var);
47 if ($o[0] eq "config_version") {
48 $o[1] =~ s/[\n|\r]//g;
49 $o[1] =~ s/[\'|\"];\s*$//;
50 $o[1] =~ s/;$//;
51 $o[1] =~ s/^[\'|\"]//;
52
53 $config_version = $o[1];
54 close (FILE);
4011c3ca 55 }
56 }
57 }
58 close (FILE);
59
60 if ($config_version ne $conf_pl_version) {
61 system "clear";
62 print $WHT."WARNING:\n".$NRM;
a3439b27 63 print " The file \"config/config.php\" was found, but it is for\n";
64 print " an older version of SquirrelMail. It is possible to still\n";
65 print " read the defaults from this file but be warned that many\n";
66 print " preferences change between versions. It is recommended that\n";
67 print " you start with a clean config.php for each upgrade that you\n";
68 print " do. To do this, just move config/config.php out of the way.\n";
69 print "\n";
f0bc4d36 70 print "Continue loading with the old config.php [y/N]? ";
4011c3ca 71 $ctu = <STDIN>;
f0bc4d36 72 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
4011c3ca 73 exit;
74 }
75
f0bc4d36 76 print "\nDo you want me to stop warning you [y/N]? ";
4011c3ca 77 $ctu = <STDIN>;
78 if ($ctu =~ /^y\n/i) {
79 $print_config_version = $conf_pl_version;
80 } else {
81 $print_config_version = $config_version;
82 }
83 } else {
84 $print_config_version = $config_version;
85 }
86
a93b12ba 87 $config = 1;
ccfb2029 88 open (FILE, "config.php");
1e0628fb 89} elsif (-e "config_default.php") {
4011c3ca 90 open (FILE, "config_default.php");
91 while ($line = <FILE>) {
a3439b27 92 $line =~ s/^\s+//;
93 $line =~ s/^\$//;
94 $var = $line;
4011c3ca 95
a3439b27 96 $var =~ s/=/EQUALS/;
97 if ($var =~ /^([a-z]|[A-Z])/) {
98 @o = split(/\s*EQUALS\s*/, $var);
99 if ($o[0] eq "config_version") {
100 $o[1] =~ s/[\n|\r]//g;
101 $o[1] =~ s/[\'|\"];\s*$//;
102 $o[1] =~ s/;$//;
103 $o[1] =~ s/^[\'|\"]//;
104
105 $config_version = $o[1];
106 close (FILE);
4011c3ca 107 }
108 }
109 }
110 close (FILE);
111
112 if ($config_version ne $conf_pl_version) {
113 system "clear";
114 print $WHT."WARNING:\n".$NRM;
a3439b27 115 print " You are trying to use a 'config_default.php' from an older\n";
116 print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
117 print " should get the 'config_default.php' that matches the version\n";
118 print " of SquirrelMail that you are running. You can get this from\n";
119 print " the SquirrelMail web page by going to the following URL:\n";
120 print " http://www.squirrelmail.org.\n";
121 print "\n";
122 print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
4011c3ca 123 $ctu = <STDIN>;
f0bc4d36 124 if (($ctu !~ /^y\n/i) || ($ctu =~ /^\n/)) {
4011c3ca 125 exit;
126 }
127
f0bc4d36 128 print "\nDo you want me to stop warning you [y/N]? ";
4011c3ca 129 $ctu = <STDIN>;
130 if ($ctu =~ /^y\n/i) {
131 $print_config_version = $conf_pl_version;
132 } else {
133 $print_config_version = $config_version;
134 }
135 } else {
136 $print_config_version = $config_version;
137 }
a93b12ba 138 $config = 2;
ccfb2029 139 open (FILE, "config_default.php");
1e0628fb 140} else {
a3439b27 141 print "No configuration file found. Please get config_default.php\n";
142 print "or config.php before running this again. This program needs\n";
143 print "a default config file to get default values.\n";
a93b12ba 144 exit;
bbd30ac8 145}
146
a3439b27 147# Read and parse the current configuration file
148# (either config.php or config_default.php).
bbd30ac8 149while ($line = <FILE>) {
a3439b27 150 $line =~ s/^\s+//;
151 $line =~ s/^\$//;
152 $var = $line;
ccfb2029 153
a3439b27 154 $var =~ s/=/EQUALS/;
155 if ($var =~ /^([a-z]|[A-Z])/) {
156 @options = split(/\s*EQUALS\s*/, $var);
157 $options[1] =~ s/[\n|\r]//g;
158 $options[1] =~ s/[\'|\"];\s*$//;
159 $options[1] =~ s/;$//;
160 $options[1] =~ s/^[\'|\"]//;
161
162 if ($options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/) {
163 $sub = $options[0];
164 $sub =~ s/\]\[['|"]PATH['|"]\]//;
165 $sub =~ s/.*\[//;
166 if (-e "../themes") {
167 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
ccfb2029 168 }
a3439b27 169 $theme_path[$sub] = $options[1];
170 } elsif ($options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/) {
171 $sub = $options[0];
172 $sub =~ s/\]\[['|"]NAME['|"]\]//;
173 $sub =~ s/.*\[//;
174 $theme_name[$sub] = $options[1];
175 } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
176 $sub = $options[0];
177 $sub =~ s/\]//;
178 $sub =~ s/^plugins\[//;
179 $plugins[$sub] = $options[1];
180 } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
181 $sub = $options[0];
182 $sub =~ s/\]//;
183 $sub =~ s/^ldap_server\[//;
184 $continue = 0;
185 while (($tmp = <FILE>) && ($continue != 1)) {
186 if ($tmp =~ /\);\s*$/) {
187 $continue = 1;
188 }
189
190 if ($tmp =~ /^\s*[\'|\"]host[\'|\"]/i) {
191 $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
192 $tmp =~ s/[\'|\"],?\s*$//;
193 $tmp =~ s/[\'|\"]\);\s*$//;
194 $host = $tmp;
195 } elsif ($tmp =~ /^\s*[\'|\"]base[\'|\"]/i) {
196 $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
197 $tmp =~ s/[\'|\"],?\s*$//;
198 $tmp =~ s/[\'|\"]\);\s*$//;
199 $base = $tmp;
200 } elsif ($tmp =~ /^\s*[\'|\"]charset[\'|\"]/i) {
201 $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
202 $tmp =~ s/[\'|\"],?\s*$//;
203 $tmp =~ s/[\'|\"]\);\s*$//;
204 $charset = $tmp;
205 } elsif ($tmp =~ /^\s*[\'|\"]port[\'|\"]/i) {
206 $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
207 $tmp =~ s/[\'|\"],?\s*$//;
208 $tmp =~ s/[\'|\"]\);\s*$//;
209 $port = $tmp;
210 } elsif ($tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i) {
211 $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
212 $tmp =~ s/[\'|\"],?\s*$//;
213 $tmp =~ s/[\'|\"]\);\s*$//;
214 $maxrows = $tmp;
215 } elsif ($tmp =~ /^\s*[\'|\"]name[\'|\"]/i) {
216 $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
217 $tmp =~ s/[\'|\"],?\s*$//;
218 $tmp =~ s/[\'|\"]\);\s*$//;
219 $name = $tmp;
220 }
221 }
222 $ldap_host[$sub] = $host;
223 $ldap_base[$sub] = $base;
224 $ldap_name[$sub] = $name;
225 $ldap_port[$sub] = $port;
226 $ldap_maxrows[$sub] = $maxrows;
227 $ldap_charset[$sub] = $charset;
228 } else {
229 ${$options[0]} = $options[1];
ccfb2029 230 }
a3439b27 231 }
bbd30ac8 232}
1a7a2fcc 233close FILE;
828b4753 234if ($useSendmail ne "true") {
ccfb2029 235 $useSendmail = "false";
828b4753 236}
237if (!$sendmail_path) {
ccfb2029 238 $sendmail_path = "/usr/sbin/sendmail";
828b4753 239}
24fc5dd2 240if (!$default_unseen_notify) {
241 $default_unseen_notify = 2;
242}
243if (!$default_unseen_type) {
244 $default_unseen_type = 1;
245}
0ecb47e5 246if (!$config_use_color) {
a15af05b 247 $config_use_color = 0;
0ecb47e5 248}
a1f1f9bc 249if (!$invert_time) {
250 $invert_time = "false";
251}
23a8095f 252if (!$force_username_lowercase) {
a3439b27 253 $force_username_lowercase = "false";
23a8095f 254}
40ba4d36 255if (!$optional_delimiter) {
a3439b27 256 $optional_delimiter = "detect";
40ba4d36 257}
d2f4c914 258if (!$use_authenticated_smtp) {
259 $use_authenticated_smtp = "false";
260}
f7bfc9de 261if (!$auto_create_special) {
a3439b27 262 $auto_create_special = "false";
f7bfc9de 263}
0d15cd19 264if(!$default_use_priority) {
a3439b27 265 $default_use_priority = "true";
0d15cd19 266}
826b7f71 267if(!$hide_sm_attributions) {
a3439b27 268 $hide_sm_attributions = "false";
826b7f71 269}
8c21da0c 270if(!$default_use_mdn) {
271 $default_use_mdn = "true";
272}
bbd30ac8 273
ebd13f55 274if ($ARGV[0] eq '--install-plugin') {
275 print "Activating plugin " . $ARGV[1]
276 . "\n";
277 push @plugins, $ARGV[1];
278 save_data();
279 exit(0);
280}
281elsif ($ARGV[0] eq '--remove-plugin') {
282 print "Removing plugin " . $ARGV[1]
283 . "\n";
284 foreach $plugin (@plugins) {
285 if ($plugin ne $ARGV[1]) {
286 push @newplugins, $plugin;
287 }
288 }
289 @plugins = @newplugins;
290 save_data();
291 exit(0);
292}
293
294
5b6ae78a 295#####################################################################################
0ecb47e5 296if ($config_use_color == 1) {
297 $WHT = "\x1B[37;1m";
298 $NRM = "\x1B[0m";
299} else {
300 $WHT = "";
301 $NRM = "";
302 $config_use_color = 2;
303}
5b6ae78a 304
828b4753 305while (($command ne "q") && ($command ne "Q")) {
ccfb2029 306 system "clear";
612eda0a 307 print $WHT."SquirrelMail Configuration : ".$NRM;
308 if ($config == 1) { print "Read: config.php"; }
309 elsif ($config == 2) { print "Read: config_default.php"; }
a3439b27 310 print " ($print_config_version)\n";
612eda0a 311 print "---------------------------------------------------------\n";
1e0628fb 312
612eda0a 313 if ($menu == 0) {
ccfb2029 314 print $WHT."Main Menu --\n".$NRM;
315 print "1. Organization Preferences\n";
316 print "2. Server Settings\n";
317 print "3. Folder Defaults\n";
318 print "4. General Options\n";
319 print "5. Themes\n";
320 print "6. Address Books (LDAP)\n";
321 print "7. Message of the Day (MOTD)\n";
9d0c7bee 322 print "8. Plugins\n";
497203d4 323 print "9. Database\n";
ccfb2029 324 print "\n";
a93b12ba 325 print "D. Set pre-defined settings for specific IMAP servers\n";
326 print "\n";
ccfb2029 327 } elsif ($menu == 1) {
328 print $WHT."Organization Preferences\n".$NRM;
329 print "1. Organization Name : $WHT$org_name$NRM\n";
330 print "2. Organization Logo : $WHT$org_logo$NRM\n";
331 print "3. Organization Title : $WHT$org_title$NRM\n";
f923b93d 332 print "4. Signout Page : $WHT$signout_page$NRM\n";
6ef7145f 333 print "5. Default Language : $WHT$squirrelmail_default_language$NRM\n";
80e86e94 334 print "6. Top Frame : $WHT$frame_top$NRM\n";
ccfb2029 335 print "\n";
336 print "R Return to Main Menu\n";
337 } elsif ($menu == 2) {
338 print $WHT."Server Settings\n".$NRM;
339 print "1. Domain : $WHT$domain$NRM\n";
340 print "2. IMAP Server : $WHT$imapServerAddress$NRM\n";
341 print "3. IMAP Port : $WHT$imapPort$NRM\n";
996d34de 342 print "4. Use Sendmail/SMTP : $WHT";
343 if ($useSendmail eq "true") {
344 print "Sendmail";
345 } else {
346 print "SMTP";
347 }
348 print "$NRM\n";
ccfb2029 349 if ($useSendmail eq "true") {
350 print "5. Sendmail Path : $WHT$sendmail_path$NRM\n";
351 } else {
352 print "6. SMTP Server : $WHT$smtpServerAddress$NRM\n";
353 print "7. SMTP Port : $WHT$smtpPort$NRM\n";
d2f4c914 354 print "8. Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
ccfb2029 355 }
d2f4c914 356 print "9. Server : $WHT$imap_server_type$NRM\n";
357 print "10. Invert Time : $WHT$invert_time$NRM\n";
358 print "11. Delimiter : $WHT$optional_delimiter$NRM\n";
ccfb2029 359 print "\n";
360 print "R Return to Main Menu\n";
361 } elsif ($menu == 3) {
362 print $WHT."Folder Defaults\n".$NRM;
4e85a37f 363 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
364 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
365 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
366 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
367 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
368 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
369 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
370 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
371 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
372 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
373 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
374 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
375 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
376 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
377 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
378 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
379 print "17. Don't move folders into Trash : $WHT$delete_folder$NRM\n";
ccfb2029 380 print "\n";
381 print "R Return to Main Menu\n";
382 } elsif ($menu == 4) {
383 print $WHT."General Options\n".$NRM;
985f7c88 384 print "1. Default Charset : $WHT$default_charset$NRM\n";
385 print "2. Data Directory : $WHT$data_dir$NRM\n";
386 print "3. Attachment Directory : $WHT$attachment_dir$NRM\n";
3392dc86 387 print "4. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
388 print "5. Default Left Size : $WHT$default_left_size$NRM\n";
389 print "6. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
390 print "7. Allow use of priority : $WHT$default_use_priority$NRM\n";
391 print "8. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
ae25968c 392 print "9. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
ccfb2029 393 print "\n";
394 print "R Return to Main Menu\n";
395 } elsif ($menu == 5) {
396 print $WHT."Themes\n".$NRM;
397 print "1. Change Themes\n";
398 for ($count = 0; $count <= $#theme_name; $count++) {
70391dd0 399 print " > $theme_name[$count]\n";
ccfb2029 400 }
6f3bfa54 401 print "2. CSS File : $WHT$theme_css$NRM\n";
ccfb2029 402 print "\n";
403 print "R Return to Main Menu\n";
404 } elsif ($menu == 6) {
405 print $WHT."Address Books (LDAP)\n".$NRM;
1e0628fb 406 print "1. Change Servers\n";
407 for ($count = 0; $count <= $#ldap_host; $count++) {
408 print " > $ldap_host[$count]\n";
409 }
3806fa52 410 print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
ccfb2029 411 print "\n";
412 print "R Return to Main Menu\n";
413 } elsif ($menu == 7) {
414 print $WHT."Message of the Day (MOTD)\n".$NRM;
415 print "\n$motd\n";
416 print "\n";
417 print "1 Edit the MOTD\n";
418 print "\n";
419 print "R Return to Main Menu\n";
9d0c7bee 420 } elsif ($menu == 8) {
421 print $WHT."Plugins\n".$NRM;
1a7a2fcc 422 print " Installed Plugins\n";
423 $num = 0;
9d0c7bee 424 for ($count = 0; $count <= $#plugins; $count++) {
1a7a2fcc 425 $num = $count + 1;
426 print " $num. $plugins[$count]\n";
9d0c7bee 427 }
1a7a2fcc 428 print "\n Available Plugins:\n";
429 opendir(DIR, "../plugins");
430 @files = readdir(DIR);
431 $pos=0;
432 @unused_plugins = ();
1a7a2fcc 433 for ($i=0; $i <= $#files; $i++) {
f0bc4d36 434 if ( -d "../plugins/" . $files[$i] &&
2a15d00c 435 $files[$i] !~ /^\./ && $files[$i] ne "CVS") {
1a7a2fcc 436 $match = 0;
437 for ($k=0; $k<=$#plugins; $k++) {
438 if ($plugins[$k] eq $files[$i]) {
439 $match = 1;
440 }
441 }
442 if ($match == 0) {
443 $unused_plugins[$pos] = $files[$i];
444 $pos++;
445 }
446 }
447 }
1a7a2fcc 448
449 for ($i=0; $i<=$#unused_plugins; $i++) {
450 $num = $num + 1;
451 print " $num. $unused_plugins[$i]\n";
452 }
453 closedir DIR;
454
f526c4fe 455 print "\n";
456 print "A Sanitize all plugins for use with Squirrelmail 1.2\n";
9d0c7bee 457 print "\n";
458 print "R Return to Main Menu\n";
497203d4 459 } elsif ($menu == 9) {
460 print $WHT."Database\n".$NRM;
4f40a59d 461 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
462 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
3499f99f 463 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
464 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
497203d4 465 print "\n";
466 print "S Save data\n";
467 print "R Return to Main Menu\n";
ccfb2029 468 }
3ed2faff 469 if ($config_use_color == 1) {
470 print "C. Turn color off\n";
471 } else {
472 print "C. Turn color on\n";
473 }
ccfb2029 474 print "S Save data\n";
475 print "Q Quit\n";
476
477 print "\n";
478 print "Command >> ".$WHT;
479 $command = <STDIN>;
f0bc4d36 480 $command =~ s/[\n|\r]//g;
481 $command =~ tr/A-Z/a-z/;
ccfb2029 482 print "$NRM\n";
483
484 # Read the commands they entered.
f0bc4d36 485 if ($command eq "r") {
ccfb2029 486 $menu = 0;
f0bc4d36 487 } elsif ($command eq "s") {
ccfb2029 488 save_data ();
f0bc4d36 489 print "Press enter to continue...";
ccfb2029 490 $tmp = <STDIN>;
491 $saved = 1;
f0bc4d36 492 } elsif (($command eq "q") && ($saved == 0)) {
ccfb2029 493 print "You have not saved your data.\n";
f0bc4d36 494 print "Save? [".$WHT."Y".$NRM."/n]: ";
ccfb2029 495 $save = <STDIN>;
496 if (($save =~ /^y/i) || ($save =~ /^\s*$/)) {
497 save_data ();
498 }
f0bc4d36 499 } elsif ($command eq "c") {
0ecb47e5 500 if ($config_use_color == 1) {
501 $config_use_color = 2;
502 $WHT = "";
503 $NRM = "";
504 } else {
505 $config_use_color = 1;
506 $WHT = "\x1B[37;1m";
507 $NRM = "\x1B[0m";
508 }
f0bc4d36 509 } elsif ($command eq "d" && $menu == 0) {
a93b12ba 510 set_defaults ();
ccfb2029 511 } else {
512 $saved = 0;
513 if ($menu == 0) {
497203d4 514 if (($command > 0) && ($command < 10)) {
ccfb2029 515 $menu = $command;
516 }
517 } elsif ($menu == 1) {
518 if ($command == 1) { $org_name = command1 (); }
519 elsif ($command == 2) { $org_logo = command2 (); }
520 elsif ($command == 3) { $org_title = command3 (); }
f923b93d 521 elsif ($command == 4) { $signout_page = command4 (); }
80e86e94 522 elsif ($command == 5) { $squirrelmail_default_language = command5(); }
523 elsif ($command == 6) { $frame_top = command6(); }
ccfb2029 524 } elsif ($menu == 2) {
f7b1b3b1 525 if ($command == 1) { $domain = command11 (); }
526 elsif ($command == 2) { $imapServerAddress = command12 (); }
527 elsif ($command == 3) { $imapPort = command13 (); }
528 elsif ($command == 4) { $useSendmail = command14 (); }
529 elsif ($command == 5) { $sendmail_path = command15 (); }
530 elsif ($command == 6) { $smtpServerAddress = command16 (); }
531 elsif ($command == 7) { $smtpPort = command17 (); }
532 elsif ($command == 8) { $use_authenticated_smtp = command18 (); }
533 elsif ($command == 9) { $imap_server_type = command19 (); }
534 elsif ($command == 10) { $invert_time = command110 (); }
535 elsif ($command == 11) { $optional_delimiter = command111 (); }
ccfb2029 536 } elsif ($menu == 3) {
f7b1b3b1 537 if ($command == 1) { $default_folder_prefix = command21 (); }
538 elsif ($command == 2) { $show_prefix_option = command22 (); }
539 elsif ($command == 3) { $trash_folder = command23a (); }
540 elsif ($command == 4) { $sent_folder = command23b (); }
541 elsif ($command == 5) { $draft_folder = command23c (); }
542 elsif ($command == 6) { $default_move_to_trash = command24a (); }
543 elsif ($command == 7) { $default_move_to_sent = command24b (); }
544 elsif ($command == 8) { $default_save_as_draft = command24c (); }
545 elsif ($command == 9) { $list_special_folders_first = command27 (); }
546 elsif ($command == 10) { $use_special_folder_color = command28 (); }
547 elsif ($command == 11) { $auto_expunge = command29 (); }
548 elsif ($command == 12) { $default_sub_of_inbox = command210(); }
549 elsif ($command == 13) { $show_contain_subfolders_option = command211(); }
550 elsif ($command == 14) { $default_unseen_notify = command212(); }
551 elsif ($command == 15) { $default_unseen_type = command213(); }
552 elsif ($command == 16) { $auto_create_special = command214(); }
4e85a37f 553 elsif ($command == 17) { $delete_folder = command215(); }
ccfb2029 554 } elsif ($menu == 4) {
985f7c88 555 if ($command == 1) { $default_charset = command31 (); }
3392dc86 556 elsif ($command == 2) { $data_dir = command33a (); }
557 elsif ($command == 3) { $attachment_dir = command33b (); }
558 elsif ($command == 4) { $dir_hash_level = command33c (); }
559 elsif ($command == 5) { $default_left_size = command35 (); }
560 elsif ($command == 6) { $force_username_lowercase = command36 (); }
561 elsif ($command == 7) { $default_use_priority = command37 (); }
562 elsif ($command == 8) { $hide_sm_attributions = command38 (); }
8c21da0c 563 elsif ($command == 9) { $default_use_mdn = command39 (); }
ccfb2029 564 } elsif ($menu == 5) {
6f3bfa54 565 if ($command == 1) { command41 (); }
566 elsif ($command == 2) { $theme_css = command42 (); }
ccfb2029 567 } elsif ($menu == 6) {
3806fa52 568 if ($command == 1) { command61(); }
569 elsif ($command == 2) { command62(); }
ccfb2029 570 } elsif ($menu == 7) {
a37f3771 571 if ($command == 1) { $motd = command71(); }
9d0c7bee 572 } elsif ($menu == 8) {
1a7a2fcc 573 if ($command =~ /^[0-9]+/) { @plugins = command81(); }
f526c4fe 574 elsif ($command eq "a") { command8s(); }
497203d4 575 } elsif ($menu == 9) {
4f40a59d 576 if ($command == 1) { $addrbook_dsn = command91(); }
577 elsif ($command == 2) { $addrbook_table = command92(); }
3499f99f 578 elsif ($command == 3) { $prefs_dsn = command93(); }
579 elsif ($command == 4) { $prefs_table = command94(); }
ccfb2029 580 }
581 }
828b4753 582}
583
584####################################################################################
585
5b6ae78a 586# org_name
587sub command1 {
588 print "We have tried to make the name SquirrelMail as transparent as\n";
589 print "possible. If you set up an organization name, most places where\n";
590 print "SquirrelMail would take credit will be credited to your organization.\n";
591 print "\n";
828b4753 592 print "[$WHT$org_name$NRM]: $WHT";
593 $new_org_name = <STDIN>;
594 if ($new_org_name eq "\n") {
595 $new_org_name = $org_name;
596 } else {
597 $new_org_name =~ s/[\r|\n]//g;
598 }
5b6ae78a 599 return $new_org_name;
600}
601
828b4753 602
5b6ae78a 603# org_logo
604sub command2 {
605 print "Your organization's logo is an image that will be displayed at\n";
606 print "different times throughout SquirrelMail. This is asking for the\n";
607 print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
608 print "(../images/logo.jpg) path to your logo.\n";
609 print "\n";
828b4753 610 print "[$WHT$org_logo$NRM]: $WHT";
5b6ae78a 611 $new_org_logo = <STDIN>;
612 if ($new_org_logo eq "\n") {
613 $new_org_logo = $org_logo;
bbd30ac8 614 } else {
5b6ae78a 615 $new_org_logo =~ s/[\r|\n]//g;
bbd30ac8 616 }
5b6ae78a 617 return $new_org_logo;
618}
619
620# org_title
621sub command3 {
622 print "A title is what is displayed at the top of the browser window in\n";
623 print "the titlebar. Usually this will end up looking something like:\n";
624 print "\"Netscape: $org_title\"\n";
625 print "\n";
828b4753 626 print "[$WHT$org_title$NRM]: $WHT";
5b6ae78a 627 $new_org_title = <STDIN>;
628 if ($new_org_title eq "\n") {
629 $new_org_title = $org_title;
bbd30ac8 630 } else {
5b6ae78a 631 $new_org_title =~ s/[\r|\n]//g;
bbd30ac8 632 }
5b6ae78a 633 return $new_org_title;
634}
5b6ae78a 635
f923b93d 636# signout_page
637sub command4 {
638 print "When users click the Sign Out button they will be logged out and\n";
639 print "then sent to signout_page. If signout_page is left empty,\n";
640 print "(hit space and then return) they will be taken, as normal,\n";
641 print "to the default and rather sparse SquirrelMail signout page.\n";
642 print "\n";
643 print "[$WHT$signout_page$NRM]: $WHT";
644 $new_signout_page = <STDIN>;
645 if ($new_signout_page eq "\n") {
646 $new_signout_page = $signout_page;
647 } else {
6ef7145f 648 $new_signout_page =~ s/[\r|\n]//g;
649 $new_signout_page =~ s/^\s+$//g;
650 }
651 return $new_signout_page;
652}
653
654# Default language
655sub command5 {
656 print "SquirrelMail attempts to set the language in many ways. If it\n";
657 print "can not figure it out in another way, it will default to this\n";
658 print "language. Please use the two-letter code for the desired language.\n";
659 print "\n";
660 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
661 $new_signout_page = <STDIN>;
662 if ($new_signout_page eq "\n") {
663 $new_signout_page = $squirrelmail_default_language;
664 } else {
f923b93d 665 $new_signout_page =~ s/[\r|\n]//g;
666 $new_signout_page =~ s/^\s+$//g;
667 }
668 return $new_signout_page;
669}
670
80e86e94 671# Default top frame
672sub command6 {
673 print "SquirrelMail defaults to using the whole of the browser window.\n";
674 print "This allows you to keep it within a specified frame. The default\n";
675 print "is '_top'\n";
676 print "\n";
677 print "[$WHT$frame_top$NRM]: $WHT";
678 $new_frame_top = <STDIN>;
679 if ($new_frame_top eq "\n") {
680 $new_frame_top = '_top';
681 } else {
682 $new_frame_top =~ s/[\r|\n]//g;
683 $new_frame_top =~ s/^\s+$//g;
684 }
685 return $new_frame_top;
686}
687
828b4753 688####################################################################################
5b6ae78a 689
828b4753 690# domain
691sub command11 {
ccfb2029 692 print "The domain name is the suffix at the end of all email messages. If\n";
693 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
694 print "would be myorg.com.\n";
695 print "\n";
696 print "[$WHT$domain$NRM]: $WHT";
697 $new_domain = <STDIN>;
698 if ($new_domain eq "\n") {
699 $new_domain = $domain;
700 } else {
701 $new_domain =~ s/[\r|\n]//g;
702 }
703 return $new_domain;
828b4753 704}
5b6ae78a 705
828b4753 706# imapServerAddress
707sub command12 {
ccfb2029 708 print "This is the address where your IMAP server resides.\n";
709 print "[$WHT$imapServerAddress$NRM]: $WHT";
710 $new_imapServerAddress = <STDIN>;
711 if ($new_imapServerAddress eq "\n") {
712 $new_imapServerAddress = $imapServerAddress;
713 } else {
714 $new_imapServerAddress =~ s/[\r|\n]//g;
715 }
716 return $new_imapServerAddress;
828b4753 717}
5b6ae78a 718
828b4753 719# imapPort
720sub command13 {
ccfb2029 721 print "This is the port that your IMAP server is on. Usually this is 143.\n";
722 print "[$WHT$imapPort$NRM]: $WHT";
723 $new_imapPort = <STDIN>;
724 if ($new_imapPort eq "\n") {
725 $new_imapPort = $imapPort;
726 } else {
727 $new_imapPort =~ s/[\r|\n]//g;
728 }
729 return $new_imapPort;
828b4753 730}
731
732# useSendmail
733sub command14 {
ccfb2029 734 print "You now need to choose the method that you will use for sending\n";
735 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
736 print "or use sendmail directly.\n";
737 if ($useSendmail eq "true") {
996d34de 738 $default_value = "1";
ccfb2029 739 } else {
996d34de 740 $default_value = "2";
ccfb2029 741 }
742 print "\n";
996d34de 743 print " 1. Sendmail\n";
744 print " 2. SMTP\n";
745 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
ccfb2029 746 $use_sendmail = <STDIN>;
996d34de 747 if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
ccfb2029 748 $useSendmail = "true";
749 } else {
750 $useSendmail = "false";
751 }
752 return $useSendmail;
828b4753 753}
5b6ae78a 754
828b4753 755# sendmail_path
756sub command15 {
757 if ($sendmail_path[0] !~ /./) {
758 $sendmail_path = "/usr/sbin/sendmail";
759 }
ccfb2029 760 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
828b4753 761 print "[$WHT$sendmail_path$NRM]: $WHT";
762 $new_sendmail_path = <STDIN>;
763 if ($new_sendmail_path eq "\n") {
764 $new_sendmail_path = $sendmail_path;
765 } else {
766 $new_sendmail_path =~ s/[\r|\n]//g;
767 }
ccfb2029 768 return $new_sendmail_path;
828b4753 769}
5b6ae78a 770
828b4753 771# smtpServerAddress
772sub command16 {
ccfb2029 773 print "This is the location of your SMTP server.\n";
828b4753 774 print "[$WHT$smtpServerAddress$NRM]: $WHT";
775 $new_smtpServerAddress = <STDIN>;
776 if ($new_smtpServerAddress eq "\n") {
777 $new_smtpServerAddress = $smtpServerAddress;
778 } else {
779 $new_smtpServerAddress =~ s/[\r|\n]//g;
780 }
ccfb2029 781 return $new_smtpServerAddress;
828b4753 782}
783
784# smtpPort
785sub command17 {
ccfb2029 786 print "This is the port to connect to for SMTP. Usually 25.\n";
828b4753 787 print "[$WHT$smtpPort$NRM]: $WHT";
788 $new_smtpPort = <STDIN>;
789 if ($new_smtpPort eq "\n") {
790 $new_smtpPort = $smtpPort;
791 } else {
792 $new_smtpPort =~ s/[\r|\n]//g;
793 }
ccfb2029 794 return $new_smtpPort;
bbd30ac8 795}
d2f4c914 796
797# authenticated server
a93b12ba 798sub command18 {
d2f4c914 799 print "Do you wish to use an authenticated SMTP server? Your server must\n";
800 print "support this in order for SquirrelMail to work with it. We implemented\n";
801 print "it according to RFC 2554.\n";
802
803 $YesNo = 'n';
804 $YesNo = 'y' if ($use_authenticated_smtp eq "true");
805
806 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
807
808 $new_use_authenticated_smtp = <STDIN>;
809 $new_use_authenticated_smtp =~ tr/yn//cd;
810 return "true" if ($new_use_authenticated_smtp eq "y");
811 return "false" if ($new_use_authenticated_smtp eq "n");
812 return $use_authenticated_smtp;
813}
814
815# imap_server_type
816sub command19 {
d47b2518 817 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
a93b12ba 818 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
819 print "the same principles. We have made some work-arounds for some of\n";
820 print "these servers. If you would like to use them, please select your\n";
821 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
822 print "set this to \"other\", and none will be used.\n";
823 print " cyrus = Cyrus IMAP server\n";
824 print " uw = University of Washington's IMAP server\n";
825 print " exchange = Microsoft Exchange IMAP server\n";
826 print " courier = Courier IMAP server\n";
ce1ff5ba 827 print " other = Not one of the above servers\n";
a93b12ba 828 print "[$WHT$imap_server_type$NRM]: $WHT";
829 $new_imap_server_type = <STDIN>;
830 if ($new_imap_server_type eq "\n") {
831 $new_imap_server_type = $imap_server_type;
832 } else {
833 $new_imap_server_type =~ s/[\r|\n]//g;
834 }
835 return $new_imap_server_type;
836}
3f8fe68e 837
d47b2518 838# invert_time
d2f4c914 839sub command110 {
d47b2518 840 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
841 print "on some machines). Typically this happens if the system doesn't support\n";
842 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
843 print "This most often occurs on Solaris 7 machines in the United States.\n";
844 print "By default, this is off. It should be kept off unless problems surface\n";
845 print "about the time that messages are sent.\n";
846 print " no = Do NOT fix time -- almost always correct\n";
847 print " yes = Fix the time for this system\n";
848
849 $YesNo = 'n';
850 $YesNo = 'y' if ($invert_time eq "true");
851
852 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
853
854 $new_invert_time = <STDIN>;
855 $new_invert_time =~ tr/yn//cd;
856 return "true" if ($new_invert_time eq "y");
857 return "false" if ($new_invert_time eq "n");
858 return $invert_time;
859}
860
d2f4c914 861sub command111 {
40ba4d36 862 print "This is the delimiter that your IMAP server uses to distinguish between\n";
863 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
864 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
865 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
a3439b27 866 print "but if you are sure you know what delimiter your server uses, you can\n";
40ba4d36 867 print "specify it here.\n";
868 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
869 print "[$WHT$optional_delimiter$NRM]: $WHT";
870 $new_optional_delimiter = <STDIN>;
871 if ($new_optional_delimiter eq "\n") {
872 $new_optional_delimiter = $optional_delimiter;
873 } else {
874 $new_optional_delimiter =~ s/[\r|\n]//g;
875 }
876 return $new_optional_delimiter;
877}
878
3f8fe68e 879# MOTD
880sub command71 {
ccfb2029 881 print "\nYou can now create the welcome message that is displayed\n";
882 print "every time a user logs on. You can use HTML or just plain\n";
a37f3771 883 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 884
e9f8ea4e 885 $new_motd = "";
ccfb2029 886 do {
887 print "] ";
888 $line = <STDIN>;
889 $line =~ s/[\r|\n]//g;
ccfb2029 890 if ($line ne "@") {
c4809aca 891 $line =~ s/ /\&nbsp;\&nbsp;/g;
892 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
893 $line =~ s/$/ /;
a73da327 894 $line =~ s/\'/\\\'/g;
c4809aca 895
ccfb2029 896 $new_motd = $new_motd . $line;
897 }
898 } while ($line ne "@");
899 return $new_motd;
3f8fe68e 900}
911ad01c 901
9d0c7bee 902################# PLUGINS ###################
903
904sub command81 {
1a7a2fcc 905 $command =~ s/[\s|\n|\r]*//g;
906 if ($command > 0) {
907 $command = $command - 1;
908 if ($command <= $#plugins) {
909 @newplugins = ();
910 $ct=0;
911 while ($ct <= $#plugins) {
912 if ($ct != $command) {
913 @newplugins = (@newplugins, $plugins[$ct]);
9d0c7bee 914 }
1a7a2fcc 915 $ct++;
9d0c7bee 916 }
1a7a2fcc 917 @plugins = @newplugins;
918 } elsif ($command <= $#plugins + $#unused_plugins + 1) {
919 $num = $command - $#plugins - 1;
920 @newplugins = @plugins;
921 $ct=0;
922 while ($ct <= $#unused_plugins) {
923 if ($ct == $num) {
924 @newplugins = (@newplugins, $unused_plugins[$ct]);
f526c4fe 925 # sanitize the plugin
926 $dir = $unused_plugins[$ct];
927 `./ri_once.pl ../plugins/$dir`;
9d0c7bee 928 }
1a7a2fcc 929 $ct++;
9d0c7bee 930 }
1a7a2fcc 931 @plugins = @newplugins;
9d0c7bee 932 }
1a7a2fcc 933 }
934 return @plugins;
9d0c7bee 935}
936
f526c4fe 937sub command8s {
938 print "This command will sanitize all plugins for use with\n";
939 print "Squirrelmail 1.2. That is, it will rewrite some php-\n";
940 print "constructs that are *incompatible* with the 1.2 design\n";
941 print "into ones that are *compatible*\n";
942 print "Do you wish to issue this command [y/N]? ";
943 $ctu = <STDIN>;
944 if ($ctu =~ /^y\n/i) {
945 `./ri_once.pl ../plugins`;
946 }
947}
948
911ad01c 949################# FOLDERS ###################
950
951# default_folder_prefix
952sub command21 {
ccfb2029 953 print "Some IMAP servers (UW, for example) store mail and folders in\n";
954 print "your user space in a separate subdirectory. This is where you\n";
955 print "specify what that directory is.\n";
956 print "\n";
957 print "EXAMPLE: mail/";
958 print "\n";
959 print "NOTE: If you use Cyrus, or some server that would not use this\n";
960 print " option, you must set this to 'none'.\n";
961 print "\n";
911ad01c 962 print "[$WHT$default_folder_prefix$NRM]: $WHT";
963 $new_default_folder_prefix = <STDIN>;
964 if ($new_default_folder_prefix eq "\n") {
965 $new_default_folder_prefix = $default_folder_prefix;
966 } else {
967 $new_default_folder_prefix =~ s/[\r|\n]//g;
968 }
ccfb2029 969 if (($new_default_folder_prefix =~ /^\s*$/) || ($new_default_folder_prefix =~ /none/i)) {
970 $new_default_folder_prefix = "";
971 } else {
972 $new_default_folder_prefix =~ s/\/*$//g;
973 $new_default_folder_prefix =~ s/$/\//g;
974 }
911ad01c 975 return $new_default_folder_prefix;
976}
977
978# Show Folder Prefix
979sub command22 {
ccfb2029 980 print "It is possible to set up the default folder prefix as a user\n";
981 print "specific option, where each user can specify what their mail\n";
982 print "folder is. If you set this to false, they will never see the\n";
983 print "option, but if it is true, this option will appear in the\n";
984 print "'options' section.\n";
985 print "\n";
986 print "NOTE: You set the default folder prefix in option '1' of this\n";
987 print " section. That will be the default if the user doesn't\n";
988 print " specify anything different.\n";
989 print "\n";
990
991 if ($show_prefix_option eq "true") {
992 $default_value = "y";
993 } else {
994 $default_value = "n";
995 }
996 print "\n";
997 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
998 $new_show = <STDIN>;
999 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1000 $show_prefix_option = "true";
1001 } else {
1002 $show_prefix_option = "false";
1003 }
1004 return $show_prefix_option;
911ad01c 1005}
1006
1007# Trash Folder
f7b1b3b1 1008sub command23a {
ccfb2029 1009 print "You can now specify where the default trash folder is located.\n";
1010 print "On servers where you do not want this, you can set it to anything\n";
a301f0d8 1011 print "and set option 6 to false.\n";
ccfb2029 1012 print "\n";
1013 print "This is relative to where the rest of your email is kept. You do\n";
1014 print "not need to worry about their mail directory. If this folder\n";
1015 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1016 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1017 print "\n";
911ad01c 1018
1019 print "[$WHT$trash_folder$NRM]: $WHT";
1020 $new_trash_folder = <STDIN>;
1021 if ($new_trash_folder eq "\n") {
1022 $new_trash_folder = $trash_folder;
1023 } else {
1024 $new_trash_folder =~ s/[\r|\n]//g;
1025 }
ccfb2029 1026 return $new_trash_folder;
911ad01c 1027}
1028
1029# Sent Folder
f7b1b3b1 1030sub command23b {
ccfb2029 1031 print "This is where messages that are sent will be stored. SquirrelMail\n";
1032 print "by default puts a copy of all outgoing messages in this folder.\n";
1033 print "\n";
1034 print "This is relative to where the rest of your email is kept. You do\n";
1035 print "not need to worry about their mail directory. If this folder\n";
1036 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1037 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1038 print "\n";
911ad01c 1039
1040 print "[$WHT$sent_folder$NRM]: $WHT";
1041 $new_sent_folder = <STDIN>;
1042 if ($new_sent_folder eq "\n") {
1043 $new_sent_folder = $sent_folder;
1044 } else {
1045 $new_sent_folder =~ s/[\r|\n]//g;
1046 }
ccfb2029 1047 return $new_sent_folder;
911ad01c 1048}
1049
f7b1b3b1 1050# Draft Folder
1051sub command23c {
1052 print "You can now specify where the default draft folder is located.\n";
1053 print "On servers where you do not want this, you can set it to anything\n";
1054 print "and set option 9 to false.\n";
1055 print "\n";
1056 print "This is relative to where the rest of your email is kept. You do\n";
1057 print "not need to worry about their mail directory. If this folder\n";
1058 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1059 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1060 print "\n";
1061
1062 print "[$WHT$draft_folder$NRM]: $WHT";
1063 $new_draft_folder = <STDIN>;
1064 if ($new_draft_folder eq "\n") {
1065 $new_draft_folder = $draft_folder;
1066 } else {
1067 $new_draft_folder =~ s/[\r|\n]//g;
1068 }
1069 return $new_draft_folder;
1070}
1071
2f287147 1072# default move to trash
f7b1b3b1 1073sub command24a {
2f287147 1074 print "By default, should messages get moved to the trash folder? You\n";
1075 print "can specify the default trash folder in option 3. If this is set\n";
1076 print "to false, messages will get deleted immediately without moving\n";
1077 print "to the trash folder.\n";
1078 print "\n";
1079 print "Trash folder is currently: $trash_folder\n";
1080 print "\n";
1081
1082 if ($default_move_to_trash eq "true") {
1083 $default_value = "y";
1084 } else {
1085 $default_value = "n";
1086 }
1087 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1088 $new_show = <STDIN>;
1089 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1090 $default_move_to_trash = "true";
1091 } else {
1092 $default_move_to_trash = "false";
1093 }
1094 return $default_move_to_trash;
1095}
1096
1097# default move to sent
f7b1b3b1 1098sub command24b {
2f287147 1099 print "By default, should messages get moved to the sent folder? You\n";
1100 print "can specify the default sent folder in option 4. If this is set\n";
15c5a98c 1101 print "to false, messages will get sent and no copy will be made.\n";
2f287147 1102 print "\n";
1103 print "Trash folder is currently: $sent_folder\n";
1104 print "\n";
1105
1106 if ($default_move_to_sent eq "true") {
1107 $default_value = "y";
1108 } else {
1109 $default_value = "n";
1110 }
1111 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1112 $new_show = <STDIN>;
1113 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1114 $default_move_to_sent = "true";
1115 } else {
1116 $default_move_to_sent = "false";
1117 }
1118 return $default_move_to_sent;
1119}
1120
f7b1b3b1 1121# default save as draft
1122sub command24c {
1123 print "By default, should the save to draft option be shown? You can\n";
1124 print "specify the default drafts folder in option 5. If this is set\n";
1125 print "to false, users will not be shown the save to draft option.\n";
1126 print "\n";
1127 print "Drafts folder is currently: $draft_folder\n";
1128 print "\n";
1129
1130 if ($default_move_to_draft eq "true") {
1131 $default_value = "y";
1132 } else {
1133 $default_value = "n";
1134 }
1135 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1136 $new_show = <STDIN>;
1137 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1138 $default_save_as_draft = "true";
1139 } else {
1140 $default_save_as_draft = "false";
1141 }
1142 return $default_save_as_draft;
1143}
1144
2f287147 1145# List special folders first
1146sub command27 {
ccfb2029 1147 print "SquirrelMail has what we call 'special folders' that are not\n";
1148 print "manipulated and viewed like normal folders. Some examples of\n";
1149 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1150 print "Simply asks if you want these folders listed first in the folder\n";
1151 print "listing.\n";
1152 print "\n";
1153
1154 if ($list_special_folders_first eq "true") {
1155 $default_value = "y";
1156 } else {
1157 $default_value = "n";
1158 }
1159 print "\n";
1160 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1161 $new_show = <STDIN>;
1162 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1163 $list_special_folders_first = "true";
1164 } else {
1165 $list_special_folders_first = "false";
1166 }
1167 return $list_special_folders_first;
911ad01c 1168}
1169
1170# Show special folders color
2f287147 1171sub command28 {
ccfb2029 1172 print "SquirrelMail has what we call 'special folders' that are not\n";
1173 print "manipulated and viewed like normal folders. Some examples of\n";
1174 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1175 print "wants to know if we should display special folders in a\n";
1176 print "color than the other folders.\n";
1177 print "\n";
1178
1179 if ($use_special_folder_color eq "true") {
1180 $default_value = "y";
1181 } else {
1182 $default_value = "n";
1183 }
1184 print "\n";
1185 print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1186 $new_show = <STDIN>;
1187 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1188 $use_special_folder_color = "true";
1189 } else {
1190 $use_special_folder_color = "false";
1191 }
1192 return $use_special_folder_color;
911ad01c 1193}
1194
911ad01c 1195# Auto expunge
2f287147 1196sub command29 {
ccfb2029 1197 print "The way that IMAP handles deleting messages is as follows. You\n";
1198 print "mark the message as deleted, and then to 'really' delete it, you\n";
1199 print "expunge it. This option asks if you want to just have messages\n";
1200 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1201 print "messages too.\n";
1202 print "\n";
1203
1204 if ($auto_expunge eq "true") {
1205 $default_value = "y";
1206 } else {
1207 $default_value = "n";
1208 }
1209 print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1210 $new_show = <STDIN>;
1211 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1212 $auto_expunge = "true";
1213 } else {
1214 $auto_expunge = "false";
1215 }
1216 return $auto_expunge;
911ad01c 1217}
1218
1219# Default sub of inbox
2f287147 1220sub command210 {
ccfb2029 1221 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1222 print "This can cause some confusion in folder creation for users when\n";
1223 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1224 print "and get permission errors. This option asks if you want folders\n";
1225 print "to be subfolders of INBOX by default.\n";
1226 print "\n";
1227
1228 if ($default_sub_of_inbox eq "true") {
1229 $default_value = "y";
1230 } else {
1231 $default_value = "n";
1232 }
1233 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1234 $new_show = <STDIN>;
1235 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1236 $default_sub_of_inbox = "true";
1237 } else {
1238 $default_sub_of_inbox = "false";
1239 }
1240 return $default_sub_of_inbox;
911ad01c 1241}
1242
1243# Show contain subfolder option
2f287147 1244sub command211 {
ccfb2029 1245 print "Some IMAP servers (UW) make it so that there are two types of\n";
1246 print "folders. Those that contain messages, and those that contain\n";
1247 print "subfolders. If this is the case for your server, set this to\n";
1248 print "true, and it will ask the user whether the folder they are\n";
1249 print "creating contains subfolders or messages.\n";
1250 print "\n";
1251
1252 if ($show_contain_subfolders_option eq "true") {
1253 $default_value = "y";
1254 } else {
1255 $default_value = "n";
1256 }
1257 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1258 $new_show = <STDIN>;
1259 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1260 $show_contain_subfolders_option = "true";
1261 } else {
1262 $show_contain_subfolders_option = "false";
1263 }
1264 return $show_contain_subfolders_option;
911ad01c 1265}
1266
24fc5dd2 1267# Default Unseen Notify
1268sub command212 {
1269 print "This option specifies where the users will receive notification\n";
1270 print "about unseen messages by default. This is of course an option that\n";
1271 print "can be changed on a user level.\n";
1272 print " 1 = No notification\n";
1273 print " 2 = Only on the INBOX\n";
1274 print " 3 = On all folders\n";
1275 print "\n";
1276
1277 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1278 $new_show = <STDIN>;
1279 if ($new_show =~ /^[1|2|3]\n/i) {
1280 $default_unseen_notify = $new_show;
1281 }
1282 $default_unseen_notify =~ s/[\r|\n]//g;
1283 return $default_unseen_notify;
1284}
1285
1286# Default Unseen Type
1287sub command213 {
1288 print "Here you can define the default way that unseen messages will be displayed\n";
1289 print "to the user in the folder listing on the left side.\n";
1290 print " 1 = Only unseen messages (4)\n";
1291 print " 2 = Unseen and Total messages (4/27)\n";
1292 print "\n";
1293
1294 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1295 $new_show = <STDIN>;
1296 if ($new_show =~ /^[1|2]\n/i) {
1297 $default_unseen_type = $new_show;
1298 }
1299 $default_unseen_type =~ s/[\r|\n]//g;
1300 return $default_unseen_type;
1301}
1302
f7bfc9de 1303# Auto create special folders
1304sub command214 {
f7b1b3b1 1305 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1306 print "automatically print for you when a user logs in? If the user\n";
1307 print "accidentally deletes their special folders, this option will\n";
1308 print "automatically create it again for them.\n";
f7bfc9de 1309 print "\n";
1310
1311 if ($auto_create_special eq "true") {
1312 $default_value = "y";
1313 } else {
1314 $default_value = "n";
1315 }
1316 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1317 $new_show = <STDIN>;
1318 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1319 $auto_create_special = "true";
1320 } else {
1321 $auto_create_special = "false";
1322 }
1323 return $auto_create_special;
1324}
1325
4e85a37f 1326# Auto create special folders
1327sub command215 {
1328 print "Would you like to automatically completely delete any deleted\n";
1329 print "folders? If not then they will be moved to the Trash folder\n";
1330 print "and can be deleted from there\n";
1331 print "\n";
1332
1333 if ($delete_folder eq "true") {
1334 $default_value = "y";
1335 } else {
1336 $default_value = "n";
1337 }
1338 print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1339 $new_delete = <STDIN>;
1340 if (($new_delete =~ /^y\n/i) || (($new_delete =~ /^\n/) && ($default_value eq "y"))) {
1341 $delete_folder = "true";
1342 } else {
1343 $delete_folder = "false";
1344 }
1345 return $delete_folder;
1346}
1347
24fc5dd2 1348
ccfb2029 1349############# GENERAL OPTIONS #####################
1350
1351# Default Charset
1352sub command31 {
1353 print "This option controls what character set is used when sending\n";
1354 print "mail and when sending HTML to the browser. Do not set this\n";
1355 print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
1356 print "to use KOI8-R, since this implementation is faster than most\n";
1357 print "of the alternatives\n";
1358 print "\n";
1359
1360 print "[$WHT$default_charset$NRM]: $WHT";
1361 $new_default_charset = <STDIN>;
1362 if ($new_default_charset eq "\n") {
1363 $new_default_charset = $default_charset;
1364 } else {
1365 $new_default_charset =~ s/[\r|\n]//g;
1366 }
1367 return $new_default_charset;
1368}
1369
ccfb2029 1370# Data directory
3392dc86 1371sub command33a {
ccfb2029 1372 print "It is a possible security hole to have a writable directory\n";
1373 print "under the web server's root directory (ex: /home/httpd/html).\n";
1374 print "For this reason, it is possible to put the data directory\n";
1375 print "anywhere you would like. The path name can be absolute or\n";
1376 print "relative (to the config directory). It doesn't matter. Here\n";
1377 print "are two examples:\n";
1378 print " Absolute: /usr/local/squirrelmail/data/\n";
1379 print " Relative: ../data/\n";
1380 print "\n";
1381
1382 print "[$WHT$data_dir$NRM]: $WHT";
1383 $new_data_dir = <STDIN>;
1384 if ($new_data_dir eq "\n") {
1385 $new_data_dir = $data_dir;
1386 } else {
1387 $new_data_dir =~ s/[\r|\n]//g;
1388 }
1389 if ($new_data_dir =~ /^\s*$/) {
1390 $new_data_dir = "";
1391 } else {
1392 $new_data_dir =~ s/\/*$//g;
1393 $new_data_dir =~ s/$/\//g;
1394 }
1395 return $new_data_dir;
1396}
1397
1398# Attachment directory
3392dc86 1399sub command33b {
ccfb2029 1400 print "Path to directory used for storing attachments while a mail is\n";
1401 print "being sent. There are a few security considerations regarding this\n";
1402 print "directory:\n";
1403 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1404 print " impossible for a random person with access to the webserver\n";
1405 print " to list files in this directory. Confidential data might\n";
1406 print " be laying around in there.\n";
1407 print " 2. Since the webserver is not able to list the files in the\n";
1408 print " content is also impossible for the webserver to delete files\n";
1409 print " lying around there for too long.\n";
1410 print " 3. It should probably be another directory than the data\n";
1411 print " directory specified in option 3.\n";
1412 print "\n";
1413
1414 print "[$WHT$attachment_dir$NRM]: $WHT";
1415 $new_attachment_dir = <STDIN>;
1416 if ($new_attachment_dir eq "\n") {
1417 $new_attachment_dir = $attachment_dir;
1418 } else {
1419 $new_attachment_dir =~ s/[\r|\n]//g;
1420 }
1421 if ($new_attachment_dir =~ /^\s*$/) {
1422 $new_attachment_dir = "";
1423 } else {
1424 $new_attachment_dir =~ s/\/*$//g;
1425 $new_attachment_dir =~ s/$/\//g;
1426 }
1427 return $new_attachment_dir;
1428}
1429
3392dc86 1430sub command33c {
1431 print "The directory hash level setting allows you to configure the level\n";
1432 print "of hashing that Squirremail employs in your data and attachment\n";
1433 print "directories. This value must be an integer ranging from 0 to 4.\n";
1434 print "When this value is set to 0, Squirrelmail will simply store all\n";
1435 print "files as normal in the data and attachment directories. However,\n";
1436 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1437 print "used to organize the files in this directory. In short, the crc32\n";
1438 print "value for a username will be computed. Then, up to the first 4\n";
1439 print "digits of the hash, as set by this configuration value, will be\n";
1440 print "used to directory hash the files for that user in the data and\n";
1441 print "attachment directory. This allows for better performance on\n";
1442 print "servers with larger numbers of users.\n";
1443 print "\n";
1444
1445 print "[$WHT$dir_hash_level$NRM]: $WHT";
1446 $new_dir_hash_level = <STDIN>;
1447 if ($new_dir_hash_level eq "\n") {
1448 $new_dir_hash_level = $dir_hash_level;
1449 } else {
1450 $new_dir_hash_level =~ s/[\r|\n]//g;
1451 }
63717a85 1452 if ((int($new_dir_hash_level) < 0) ||
1453 (int($new_dir_hash_level) > 4) ||
1454 !(int($new_dir_hash_level) eq $new_dir_hash_level )) {
3392dc86 1455 print "Invalid Directory Hash Level.\n";
1456 print "Value must be an integer ranging from 0 to 4\n";
1457 print "Hit enter to continue.\n";
1458 $enter_key = <STDIN>;
1459
1460 $new_dir_hash_level = $dir_hash_level;
1461 }
1462
1463 return $new_dir_hash_level;
1464}
ccfb2029 1465
1466sub command35 {
1467 print "This is the default size (in pixels) of the left folder list.\n";
1468 print "Default is 200, but you can set it to whatever you wish. This\n";
1469 print "is a user preference, so this will only show up as their default.\n";
1470 print "\n";
1471 print "[$WHT$default_left_size$NRM]: $WHT";
1472 $new_default_left_size = <STDIN>;
1473 if ($new_default_left_size eq "\n") {
1474 $new_default_left_size = $default_left_size;
1475 } else {
1476 $new_default_left_size =~ s/[\r|\n]//g;
1477 }
1478 return $new_default_left_size;
1479}
1480
1481
985f7c88 1482sub command36 {
1483 print "Some IMAP servers only have lowercase letters in the usernames\n";
1484 print "but they still allow people with uppercase to log in. This\n";
1485 print "causes a problem with the user's preference files. This option\n";
1486 print "transparently changes all usernames to lowercase.";
1487 print "\n";
1488
1489 if ($force_username_lowercase eq "true") {
1490 $default_value = "y";
1491 } else {
1492 $default_value = "n";
1493 }
1494 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1495 $new_show = <STDIN>;
1496 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1497 return "true";
1498 }
1499 return "false";
1500}
1501
0d15cd19 1502sub command37 {
1503 print "";
1504 print "\n";
1505
1506 if ($default_use_priority eq "true") {
1507 $default_value = "y";
1508 } else {
1509 $default_value = "n";
1510 }
1511
1512 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
1513 $new_show = <STDIN>;
1514 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1515 return "true";
1516 }
1517 return "false";
1518}
1519
985f7c88 1520
826b7f71 1521sub command38 {
1522 print "";
1523 print "\n";
1524
1525 if ($default_hide_attribution eq "true") {
1526 $default_value = "y";
1527 } else {
1528 $default_value = "n";
1529 }
1530
1531 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
1532 $new_show = <STDIN>;
1533 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1534 return "true";
1535 }
1536 return "false";
1537}
1538
1539
8c21da0c 1540sub command39 {
1541 print "";
1542 print "\n";
1543
1544 if ($default_use_mdn eq "true") {
1545 $default_value = "y";
1546 } else {
1547 $default_value = "n";
1548 }
1549
ae25968c 1550 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
8c21da0c 1551 $new_show = <STDIN>;
1552 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1553 return "true";
1554 }
1555 return "false";
1556}
1557
1558
ccfb2029 1559sub command41 {
1560 print "\nNow we will define the themes that you wish to use. If you have added\n";
1561 print "a theme of your own, just follow the instructions (?) about how to add\n";
1562 print "them. You can also change the default theme.\n";
1563 print "[theme] command (?=help) > ";
1564 $input = <STDIN>;
1565 $input =~ s/[\r|\n]//g;
1566 while ($input ne "d") {
1567 if ($input =~ /^\s*l\s*/i) {
1568 $count = 0;
1569 while ($count <= $#theme_name) {
1570 if ($count == $theme_default) {
1571 print " *";
1572 } else {
1573 print " ";
1574 }
1575 $name = $theme_name[$count];
1576 $num_spaces = 25 - length($name);
1577 for ($i = 0; $i < $num_spaces;$i++) {
1578 $name = $name . " ";
1579 }
1580
1581 print " $count. $name";
1582 print "($theme_path[$count])\n";
1583
1584 $count++;
1585 }
1586 } elsif ($input =~ /^\s*m\s*[0-9]+/i) {
1587 $old_def = $theme_default;
1588 $theme_default = $input;
1589 $theme_default =~ s/^\s*m\s*//;
1590 if (($theme_default > $#theme_name) || ($theme_default < 0)) {
1591 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
1592 $theme_default = $old_def;
1593 }
1594 } elsif ($input =~ /^\s*\+/) {
1595 print "What is the name of this theme: ";
1596 $name = <STDIN>;
1597 $name =~ s/[\r|\n]//g;
1598 $theme_name[$#theme_name+1] = $name;
390372b4 1599 print "Be sure to put ../themes/ before the filename.\n";
1600 print "What file is this stored in (ex: ../themes/default_theme.php): ";
ccfb2029 1601 $name = <STDIN>;
1602 $name =~ s/[\r|\n]//g;
1603 $theme_path[$#theme_path+1] = $name;
1604 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1605 if ($input =~ /[0-9]+\s*$/) {
1606 $rem_num = $input;
1607 $rem_num =~ s/^\s*-\s*//g;
1608 $rem_num =~ s/\s*$//;
1609 } else {
1610 $rem_num = $#theme_name;
1611 }
1612 if ($rem_num == $theme_default) {
1613 print "You cannot remove the default theme!\n";
1614 } else {
1615 $count = 0;
1616 @new_theme_name = ();
1617 @new_theme_path = ();
1618 while ($count <= $#theme_name) {
1619 if ($count != $rem_num) {
1620 @new_theme_name = (@new_theme_name, $theme_name[$count]);
1621 @new_theme_path = (@new_theme_path, $theme_path[$count]);
1622 }
1623 $count++;
1624 }
1625 @theme_name = @new_theme_name;
1626 @theme_path = @new_theme_path;
1627 if ($theme_default > $rem_num) {
1628 $theme_default--;
1629 }
1630 }
8442ac08 1631 } elsif ($input =~ /^\s*t\s*/i) {
1632 print "\nStarting detection...\n\n";
1633
1634 opendir(DIR, "../themes");
1635 @files = grep { /\.php$/i } readdir(DIR);
1636 $cnt = 0;
1637 while ($cnt <= $#files) {
1638 $filename = "../themes/" . $files[$cnt];
5cb1d69b 1639 if ($filename ne "../themes/index.php") {
1640 $found = 0;
1641 for ($x=0; $x <= $#theme_path; $x++) {
1642 if ($theme_path[$x] eq $filename) {
1643 $found = 1;
1644 }
1645 }
1646 if ($found != 1) {
1647 print "** Found theme: $filename\n";
1648 print " What is its name? ";
1649 $nm = <STDIN>;
1650 $nm =~ s/[\n|\r]//g;
1651 $theme_name[$#theme_name+1] = $nm;
1652 $theme_path[$#theme_path+1] = $filename;
8442ac08 1653 }
8442ac08 1654 }
1655 $cnt++;
1656 }
1657 print "\n";
1658 for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
1659 $filename = $theme_path[$cnt];
1660 if (! (-e $filename)) {
1661 print " Removing $filename (file not found)\n";
1662 $offset = 0;
1663 @new_theme_name = ();
1664 @new_theme_path = ();
1665 for ($x=0; $x < $#theme_path; $x++) {
1666 if ($theme_path[$x] eq $filename) {
1667 $offset = 1;
1668 }
1669 if ($offset == 1) {
1670 $new_theme_name[$x] = $theme_name[$x+1];
1671 $new_theme_path[$x] = $theme_path[$x+1];
1672 } else {
1673 $new_theme_name[$x] = $theme_name[$x];
1674 $new_theme_path[$x] = $theme_path[$x];
1675 }
1676 }
1677 @theme_name = @new_theme_name;
1678 @theme_path = @new_theme_path;
1679 }
1680 }
1681 print "\nDetection complete!\n\n";
1682
1683 closedir DIR;
ccfb2029 1684 } elsif ($input =~ /^\s*\?\s*/) {
1685 print ".-------------------------.\n";
8442ac08 1686 print "| t (detect themes) |\n";
ccfb2029 1687 print "| + (add theme) |\n";
1688 print "| - N (remove theme) |\n";
1689 print "| m N (mark default) |\n";
1690 print "| l (list themes) |\n";
1691 print "| d (done) |\n";
1692 print "`-------------------------'\n";
1693 }
1694 print "[theme] command (?=help) > ";
1695 $input = <STDIN>;
1696 $input =~ s/[\r|\n]//g;
1697 }
1698}
1699
1700
6f3bfa54 1701# Theme - CSS file
1702sub command42 {
1703 print "You may specify a cascading style-sheet (CSS) file to be included\n";
1704 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
1705 print "for specifying a site-wide font. If you're not familiar with CSS\n";
1706 print "files, leave this blank.\n";
1707 print "\n";
1708 print "To clear out an existing value, just type a space for the input.\n";
1709 print "\n";
1710 print "[$WHT$theme_css$NRM]: $WHT";
1711 $new_theme_css = <STDIN>;
1712 if ($new_theme_css eq "\n") {
1713 $new_theme_css = $theme_css;
1714 } else {
1715 $new_theme_css =~ s/[\r|\n]//g;
1716 }
1717 $new_theme_css =~ s/^\s*//;
1718 return $new_theme_css;
1719}
1720
1721
1e0628fb 1722sub command61 {
a93b12ba 1723 print "You can now define different LDAP servers.\n";
1e0628fb 1724 print "[ldap] command (?=help) > ";
1725 $input = <STDIN>;
1726 $input =~ s/[\r|\n]//g;
1727 while ($input ne "d") {
1728 if ($input =~ /^\s*l\s*/i) {
1729 $count = 0;
1730 while ($count <= $#ldap_host) {
a93b12ba 1731 print "$count. $ldap_host[$count]\n";
1732 print " base: $ldap_base[$count]\n";
1733 if ($ldap_charset[$count]) {
1734 print " charset: $ldap_charset[$count]\n";
1735 }
1736 if ($ldap_port[$count]) {
1737 print " port: $ldap_port[$count]\n";
1738 }
1739 if ($ldap_name[$count]) {
1740 print " name: $ldap_name[$count]\n";
1741 }
1742 if ($ldap_maxrows[$count]) {
1743 print " maxrows: $ldap_maxrows[$count]\n";
1744 }
1745 print "\n";
1e0628fb 1746 $count++;
1747 }
1748 } elsif ($input =~ /^\s*\+/) {
a93b12ba 1749 $sub = $#ldap_host + 1;
1e0628fb 1750
a93b12ba 1751 print "First, we need to have the hostname or the IP address where\n";
1752 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
1753 print "hostname: ";
1e0628fb 1754 $name = <STDIN>;
1755 $name =~ s/[\r|\n]//g;
1756 $ldap_host[$sub] = $name;
a93b12ba 1757
1758 print "\n";
1e0628fb 1759
a93b12ba 1760 print "Next, we need the server root (base dn). For this, an empty\n";
1761 print "string is allowed.\n";
1762 print "Example: ou=member_directory,o=netcenter.com\n";
1763 print "base: ";
1e0628fb 1764 $name = <STDIN>;
1765 $name =~ s/[\r|\n]//g;
1766 $ldap_base[$sub] = $name;
1767
a93b12ba 1768 print "\n";
1e0628fb 1769
a93b12ba 1770 print "This is the TCP/IP port number for the LDAP server. Default\n";
1771 print "port is 389. This is optional. Press ENTER for default.\n";
1772 print "port: ";
1e0628fb 1773 $name = <STDIN>;
1774 $name =~ s/[\r|\n]//g;
1775 $ldap_port[$sub] = $name;
1776
a93b12ba 1777 print "\n";
1e0628fb 1778
a93b12ba 1779 print "This is the charset for the server. Default is utf-8. This\n";
1780 print "is also optional. Press ENTER for default.\n";
1781 print "charset: ";
1e0628fb 1782 $name = <STDIN>;
1783 $name =~ s/[\r|\n]//g;
1784 $ldap_charset[$sub] = $name;
1785
a93b12ba 1786 print "\n";
1e0628fb 1787
a93b12ba 1788 print "This is the name for the server, used to tag the results of\n";
1789 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
1790 print "name: ";
1e0628fb 1791 $name = <STDIN>;
1792 $name =~ s/[\r|\n]//g;
1793 $ldap_name[$sub] = $name;
1794
a93b12ba 1795 print "\n";
1e0628fb 1796
a93b12ba 1797 print "You can specify the maximum number of rows in the search result.\n";
1798 print "Default is unlimited. Press ENTER for default.\n";
1799 print "maxrows: ";
1e0628fb 1800 $name = <STDIN>;
1801 $name =~ s/[\r|\n]//g;
1802 $ldap_maxrows[$sub] = $name;
1803
a93b12ba 1804 print "\n";
1e0628fb 1805
1806 } elsif ($input =~ /^\s*-\s*[0-9]?/) {
1807 if ($input =~ /[0-9]+\s*$/) {
1808 $rem_num = $input;
1809 $rem_num =~ s/^\s*-\s*//g;
1810 $rem_num =~ s/\s*$//;
1811 } else {
1812 $rem_num = $#ldap_host;
1813 }
1814 $count = 0;
1815 @new_ldap_host = ();
1816 @new_ldap_base = ();
1817 @new_ldap_port = ();
1818 @new_ldap_name = ();
1819 @new_ldap_charset = ();
1820 @new_ldap_maxrows = ();
1821 while ($count <= $#ldap_host) {
1822 if ($count != $rem_num) {
1823 @new_ldap_host = (@new_ldap_host, $ldap_host[$count]);
1824 @new_ldap_base = (@new_ldap_base, $ldap_base[$count]);
1825 @new_ldap_port = (@new_ldap_port, $ldap_port[$count]);
1826 @new_ldap_name = (@new_ldap_name, $ldap_name[$count]);
1827 @new_ldap_charset = (@new_ldap_charset, $ldap_charset[$count]);
1828 @new_ldap_maxrows = (@new_ldap_maxrows, $ldap_maxrows[$count]);
1829 }
1830 $count++;
1831 }
1832 @ldap_host = @new_ldap_host;
1833 @ldap_base = @new_ldap_base;
1834 @ldap_port = @new_ldap_port;
1835 @ldap_name = @new_ldap_name;
1836 @ldap_charset = @new_ldap_charset;
1837 @ldap_maxrows = @new_ldap_maxrows;
1838 } elsif ($input =~ /^\s*\?\s*/) {
1839 print ".-------------------------.\n";
1840 print "| + (add host) |\n";
1841 print "| - N (remove host) |\n";
1842 print "| l (list hosts) |\n";
1843 print "| d (done) |\n";
1844 print "`-------------------------'\n";
1845 }
1846 print "[ldap] command (?=help) > ";
1847 $input = <STDIN>;
1848 $input =~ s/[\r|\n]//g;
1849 }
1850}
1851
3806fa52 1852sub command62 {
591000ec 1853 print "Some of our developers have come up with very good javascript interface\n";
1854 print "for searching through address books, however, our original goals said\n";
1855 print "that we would be 100% HTML. In order to make it possible to use their\n";
1856 print "interface, and yet stick with our goals, we have also written a plain\n";
1857 print "HTML version of the search. Here, you can choose which version to use.\n";
3806fa52 1858 print "\n";
1859 print "This is just the default value. It is also a user option that each\n";
1860 print "user can configure individually\n";
1861 print "\n";
1862
1863 if ($default_use_javascript_addr_book eq "true") {
1864 $default_value = "y";
1865 } else {
1866 $default_use_javascript_addr_book = "false";
1867 $default_value = "n";
1868 }
c4809aca 1869 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
3806fa52 1870 $new_show = <STDIN>;
1871 if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
1872 $default_use_javascript_addr_book = "true";
1873 } else {
1874 $default_use_javascript_addr_book = "false";
1875 }
1876 return $default_use_javascript_addr_book;
1877}
1e0628fb 1878
497203d4 1879sub command91 {
1880 print "If you want to store your users address book details in a database then\n";
1881 print "you need to set this DSN to a valid value. The format for this is:\n";
1882 print "mysql://user:pass\@hostname/dbname\n";
1883 print "Where mysql can be one of the databases PHP supports, the most common\n";
1884 print "of these are mysql, msql and pgsql\n";
1885 print "If the DSN is left empty (hit space and then return) the database\n";
1886 print "related code for address books will not be used\n";
1887 print "\n";
1888
1889 if ($addrbook_dsn eq "") {
1890 $default_value = "Disabled";
1891 } else {
1892 $default_value = $addrbook_dsn;
1893 }
1894 print "[$WHT$addrbook_dsn$NRM]: $WHT";
1895 $new_dsn = <STDIN>;
1896 if ($new_dsn eq "\n") {
1897 $new_dsn = "";
1898 } else {
1899 $new_dsn =~ s/[\r|\n]//g;
1900 $new_dsn =~ s/^\s+$//g;
1901 }
1902 return $new_dsn;
1903}
ccfb2029 1904
4f40a59d 1905sub command92 {
1906 print "This is the name of the table you want to store the address book\n";
1907 print "data in, it defaults to 'address'\n";
1908 print "\n";
1909 print "[$WHT$addrbook_table$NRM]: $WHT";
1910 $new_table = <STDIN>;
1911 if ($new_table eq "\n") {
1912 $new_table = $addrbook_table;
1913 } else {
1914 $new_table =~ s/[\r|\n]//g;
1915 }
1916 return $new_table;
1917}
1918
3499f99f 1919sub command93 {
1920 print "If you want to store your users preferences in a database then\n";
1921 print "you need to set this DSN to a valid value. The format for this is:\n";
1922 print "mysql://user:pass\@hostname/dbname\n";
1923 print "Where mysql can be one of the databases PHP supports, the most common\n";
1924 print "of these are mysql, msql and pgsql\n";
1925 print "If the DSN is left empty (hit space and then return) the database\n";
1926 print "related code for address books will not be used\n";
1927 print "\n";
1928
1929 if ($prefs_dsn eq "") {
1930 $default_value = "Disabled";
1931 } else {
1932 $default_value = $prefs_dsn;
1933 }
1934 print "[$WHT$prefs_dsn$NRM]: $WHT";
1935 $new_dsn = <STDIN>;
1936 if ($new_dsn eq "\n") {
1937 $new_dsn = "";
1938 } else {
1939 $new_dsn =~ s/[\r|\n]//g;
1940 $new_dsn =~ s/^\s+$//g;
1941 }
1942 return $new_dsn;
1943}
1944
1945sub command94 {
1946 print "This is the name of the table you want to store the preferences\n";
1947 print "data in, it defaults to 'address'\n";
1948 print "\n";
1949 print "[$WHT$prefs_table$NRM]: $WHT";
1950 $new_table = <STDIN>;
1951 if ($new_table eq "\n") {
1952 $new_table = $prefs_table;
1953 } else {
1954 $new_table =~ s/[\r|\n]//g;
1955 }
1956 return $new_table;
1957}
1958
ccfb2029 1959sub save_data {
ebd13f55 1960 $tab = " ";
1961 if(open (CF, ">config.php"))
1962 {
1963 print CF "<?php\n";
1964 print CF "\n";
1965
1966 print CF "/**\n";
1967 print CF " * SquirrelMail Configuration File\n";
1968 print CF " * Created using the configure script, conf.pl\n";
1969 print CF " */\n";
1970 print CF "\n";
1971
ebd13f55 1972 if ($print_config_version) {
1973 print CF "\$config_version = '$print_config_version';\n";
1974 }
1975 print CF "\$config_use_color = $config_use_color;\n";
1976 print CF "\n";
1977
ebd13f55 1978 print CF "\$org_name = \"$org_name\";\n";
1979 print CF "\$org_logo = '$org_logo';\n";
1980 print CF "\$org_title = \"$org_title\";\n";
1981 print CF "\$signout_page = '$signout_page';\n";
9ee9cc63 1982 if ($frame_top eq "") {
1983 print CF "\$frame_top = '_top';\n";
1984 } else {
1985 print CF "\$frame_top = '$frame_top';\n";
1986 }
ebd13f55 1987 print CF "\n";
1988
ebd13f55 1989 print CF "\$motd = '$motd';\n";
1990 print CF "\n";
1991
ebd13f55 1992 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
1993 print CF "\n";
1994
ebd13f55 1995 print CF "\$domain = '$domain';\n";
1996 print CF "\$imapServerAddress = '$imapServerAddress';\n";
1997 print CF "\$imapPort = $imapPort;\n";
1998 print CF "\$useSendmail = $useSendmail;\n";
1999 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
2000 print CF "\$smtpPort = $smtpPort;\n";
2001 print CF "\$sendmail_path = '$sendmail_path';\n";
2002 print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
2003 print CF "\$imap_server_type = '$imap_server_type';\n";
2004 print CF "\$invert_time = $invert_time;\n";
2005 print CF "\$optional_delimiter = '$optional_delimiter';\n";
2006 print CF "\n";
2007
ebd13f55 2008 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
2009 print CF "\$trash_folder = '$trash_folder';\n";
2010 print CF "\$sent_folder = '$sent_folder';\n";
2011 print CF "\$draft_folder = '$draft_folder';\n";
2012 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
2013 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
2014 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
2015 print CF "\$show_prefix_option = $show_prefix_option;\n";
2016 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
2017 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
2018 print CF "\$auto_expunge = $auto_expunge;\n";
2019 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
2020 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
2021 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
2022 print CF "\$default_unseen_type = $default_unseen_type;\n";
2023 print CF "\$auto_create_special = $auto_create_special;\n";
4e85a37f 2024 print CF "\$delete_folder = $delete_folder;\n";
ebd13f55 2025 print CF "\n";
2026
ebd13f55 2027 print CF "\$default_charset = '$default_charset';\n";
2028 print CF "\$data_dir = '$data_dir';\n";
2029 print CF "\$attachment_dir = \"$attachment_dir\";\n";
2030 print CF "\$dir_hash_level = $dir_hash_level;\n";
2031 print CF "\$default_left_size = $default_left_size;\n";
2032 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
2033 print CF "\$default_use_priority = $default_use_priority;\n";
2034 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
8c21da0c 2035 print CF "\$default_use_mdn = $default_use_mdn;\n";
ebd13f55 2036 print CF "\n";
2037
ebd13f55 2038 for ($ct=0; $ct <= $#plugins; $ct++) {
2039 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
2040 }
2041 print CF "\n";
2042
ebd13f55 2043 print CF "\$theme_css = '$theme_css';\n";
2044 for ($count=0; $count <= $#theme_name; $count++) {
2045 print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
2046 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
2047 }
2048 print CF "\n";
2049
2050 if ($default_use_javascript_addr_book ne "true") {
2051 $default_use_javascript_addr_book = "false";
2052 }
ebd13f55 2053 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
2054 for ($count=0; $count <= $#ldap_host; $count++) {
2055 print CF "\$ldap_server[$count] = array(\n";
2056 print CF " 'host' => '$ldap_host[$count]',\n";
2057 print CF " 'base' => '$ldap_base[$count]'";
2058 if ($ldap_name[$count]) {
2059 print CF ",\n";
2060 print CF " 'name' => '$ldap_name[$count]'";
2061 }
2062 if ($ldap_port[$count]) {
2063 print CF ",\n";
2064 print CF " 'port' => '$ldap_port[$count]'";
2065 }
2066 if ($ldap_charset[$count]) {
2067 print CF ",\n";
2068 print CF " 'charset' => '$ldap_charset[$count]'";
2069 }
2070 if ($ldap_maxrows[$count]) {
2071 print CF ",\n";
2072 print CF " 'maxrows' => '$ldap_maxrows[$count]'";
2073 }
2074 print CF "\n";
2075 print CF ");\n";
2076 print CF "\n";
2077 }
b622e1b8 2078
4f40a59d 2079 print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
2080 print CF "\$addrbook_table = '$addrbook_table';\n\n";
3499f99f 2081 print CF "\$prefs_dsn = '$prefs_dsn';\n";
2082 print CF "\$prefs_table = '$prefs_table';\n";
ebd13f55 2083
2084 print CF "/**\n";
2085 print CF " * Make sure there are no characters after the PHP closing\n";
2086 print CF " * tag below (including newline characters and whitespace).\n";
2087 print CF " * Otherwise, that character will cause the headers to be\n";
2088 print CF " * sent and regular output to begin, which will majorly screw\n";
2089 print CF " * things up when we try to send more headers later.\n";
2090 print CF " */\n";
2091 print CF "?>";
2092
2093 close CF;
2094
2095 print "Data saved in config.php\n";
2096 } else {
2097 print "Error saving config.php: $!\n";
2098 }
911ad01c 2099}
a93b12ba 2100
2101sub set_defaults {
2102 system "clear";
612eda0a 2103 print $WHT."SquirrelMail Configuration : ".$NRM;
2104 if ($config == 1) { print "Read: config.php"; }
2105 elsif ($config == 2) { print "Read: config_default.php"; }
2106 print "\n";
2107 print "---------------------------------------------------------\n";
2108
a93b12ba 2109 print "While we have been building SquirrelMail, we have discovered some\n";
2110 print "preferences that work better with some servers that don't work so\n";
2111 print "well with others. If you select your IMAP server, this option will\n";
2112 print "set some pre-defined settings for that server.\n";
2113 print "\n";
2114 print "Please note that you will still need to go through and make sure\n";
2115 print "everything is correct. This does not change everything. There are\n";
e9f8ea4e 2116 print "only a few settings that this will change.\n";
a93b12ba 2117 print "\n";
2118
2119 $continue = 0;
2120 while ($continue != 1) {
2121 print "Please select your IMAP server:\n";
2122 print " cyrus = Cyrus IMAP server\n";
2123 print " uw = University of Washington's IMAP server\n";
2124 print " exchange = Microsoft Exchange IMAP server\n";
2125 print " courier = Courier IMAP server\n";
2126 print " quit = Do not change anything\n";
2127 print "Command >> ";
2128 $server = <STDIN>;
2129 $server =~ s/[\r|\n]//g;
2130
c4809aca 2131 print "\n";
2132 if ($server eq "cyrus") {
dbcc5ca3 2133 $imap_server_type = "cyrus";
3a94810f 2134 $default_folder_prefix = "";
2135 $trash_folder = "INBOX.Trash";
2136 $sent_folder = "INBOX.Sent";
2137 $draft_folder = "INBOX.Drafts";
2138 $show_prefix_option = false;
2139 $default_sub_of_inbox = true;
2140 $show_contain_subfolders_option = false;
dbcc5ca3 2141 $optional_delimiter = ".";
3a94810f 2142 $disp_default_folder_prefix = "<none>";
c4809aca 2143
a93b12ba 2144 $continue = 1;
2145 } elsif ($server eq "uw") {
dbcc5ca3 2146 $imap_server_type = "uw";
3a94810f 2147 $default_folder_prefix = "mail/";
2148 $trash_folder = "Trash";
2149 $sent_folder = "Sent";
2150 $draft_folder = "Drafts";
2151 $show_prefix_option = true;
2152 $default_sub_of_inbox = false;
2153 $show_contain_subfolders_option = true;
dbcc5ca3 2154 $optional_delimiter = "/";
3a94810f 2155 $disp_default_folder_prefix = $default_folder_prefix;
2156
a93b12ba 2157 $continue = 1;
2158 } elsif ($server eq "exchange") {
dbcc5ca3 2159 $imap_server_type = "exchange";
3a94810f 2160 $default_folder_prefix = "";
2161 $default_sub_of_inbox = true;
2162 $trash_folder = "INBOX/Deleted Items";
2163 $sent_folder = "INBOX/Sent Items";
2164 $drafts_folder = "INBOX/Drafts";
2165 $show_prefix_option = false;
2166 $show_contain_subfolders_option = false;
dbcc5ca3 2167 $optional_delimiter = "detect";
3a94810f 2168 $disp_default_folder_prefix = "<none>";
612eda0a 2169
3a94810f 2170 $continue = 1;
a93b12ba 2171 } elsif ($server eq "courier") {
dbcc5ca3 2172 $imap_server_type = "courier";
0f529285 2173 $default_folder_prefix = "INBOX.";
3a94810f 2174 $trash_folder = "Trash";
2175 $sent_folder = "Sent";
2176 $draft_folder = "Drafts";
0f529285 2177 $show_prefix_option = false;
3a94810f 2178 $default_sub_of_inbox = false;
0f529285 2179 $show_contain_subfolders_option = false;
dbcc5ca3 2180 $optional_delimiter = ".";
3a94810f 2181 $disp_default_folder_prefix = $default_folder_prefix;
612eda0a 2182
a93b12ba 2183 $continue = 1;
3a94810f 2184 } elsif ($server eq "quit") {
2185 $continue = 1;
a93b12ba 2186 } else {
3a94810f 2187 $disp_default_folder_prefix = $default_folder_prefix;
a93b12ba 2188 print "Unrecognized server: $server\n";
3a94810f 2189 print "\n";
a93b12ba 2190 }
3a94810f 2191
dbcc5ca3 2192 print " imap_server_type = $imap_server_type\n";
3a94810f 2193 print " default_folder_prefix = $disp_default_folder_prefix\n";
2194 print " trash_folder = $trash_folder\n";
2195 print " sent_folder = $sent_folder\n";
2196 print " draft_folder = $draft_folder\n";
2197 print " show_prefix_option = $show_prefix_option\n";
2198 print " default_sub_of_inbox = $default_sub_of_inbox\n";
2199 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
dbcc5ca3 2200 print " optional_delimiter = $optional_delimiter\n";
a93b12ba 2201 }
c4809aca 2202 print "\nPress any key to continue...";
2203 $tmp = <STDIN>;
a93b12ba 2204}