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