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