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