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