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