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