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