added conf.pl support for advanced search functionality
[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
268 $useSendmail = 'false' if ( lc($useSendmail) ne 'true' );
269 $sendmail_path = "/usr/sbin/sendmail" if ( !$sendmail_path );
270 $pop_before_smtp = 'false' if ( !$pop_before_smtp );
271 $default_unseen_notify = 2 if ( !$default_unseen_notify );
272 $default_unseen_type = 1 if ( !$default_unseen_type );
273 $config_use_color = 0 if ( !$config_use_color );
274 $invert_time = 'false' if ( !$invert_time );
275 $force_username_lowercase = 'false' if ( !$force_username_lowercase );
276 $optional_delimiter = "detect" if ( !$optional_delimiter );
277 $auto_create_special = 'false' if ( !$auto_create_special );
278 $default_use_priority = 'true' if ( !$default_use_priority );
279 $hide_sm_attributions = 'false' if ( !$hide_sm_attributions );
280 $default_use_mdn = 'true' if ( !$default_use_mdn );
281 $delete_folder = 'false' if ( !$delete_folder );
282 $noselect_fix_enable = 'false' if ( !$noselect_fix_enable );
283 $frame_top = "_top" if ( !$frame_top );
284 $provider_uri = '' if ( !$provider_uri );
285 $provider_name = '' if ( !$provider_name );
286 $edit_identity = 'true' if ( !$edit_identity );
287 $edit_name = 'true' if ( !$edit_name );
288 $allow_thread_sort = 'false' if ( !$allow_thread_sort );
289 $allow_server_sort = 'false' if ( !$allow_server_sort );
290 $no_list_for_subscribe = 'false' if ( !$no_list_for_subscribe );
291 $allow_charset_search = 'true' if ( !$allow_charset_search );
292 $allow_advanced_search = '0' if ( !$allow_advanced_search) ;
293 $prefs_user_field = 'user' if ( !$prefs_user_field );
294 $prefs_key_field = 'prefkey' if ( !$prefs_key_field );
295 $prefs_val_field = 'prefval' if ( !$prefs_val_field );
296 $addrbook_global_table = 'global_abook' if ( !$addrbook_global_table );
297 $addrbook_global_writeable = 'false' if ( !$addrbook_global_writeable );
298 $addrbook_global_listing = 'false' if ( !$addrbook_global_listing );
299 $use_smtp_tls= 'false' if ( !$use_smtp_tls);
300 $smtp_auth_mech = 'none' if ( !$smtp_auth_mech );
301 $use_imap_tls = 'false' if ( !$use_imap_tls );
302 $imap_auth_mech = 'login' if ( !$imap_auth_mech );
303 $session_name = 'SQMSESSID' if ( !$session_name );
304 $show_alternative_names = 'false' if ( !$show_alternative_names );
305 $available_languages = 'all' if ( !$available_languages );
306 $agresive_decoding = 'false' if ( !$agresive_decoding );
307 $advanced_tree = 'false' if ( !$advanced_tree );
308 $oldway = 'false' if ( !$oldway );
309 $use_icons = 'false' if ( !$use_icons );
310 $use_php_recode = 'false' if ( !$use_php_recode );
311 $use_php_iconv = 'false' if ( !$use_php_iconv );
312 $skip_SM_header = 'false' if ( !$skip_SM_header );
313
314 if ( $ARGV[0] eq '--install-plugin' ) {
315 print "Activating plugin " . $ARGV[1] . "\n";
316 push @plugins, $ARGV[1];
317 save_data();
318 exit(0);
319 } elsif ( $ARGV[0] eq '--remove-plugin' ) {
320 print "Removing plugin " . $ARGV[1] . "\n";
321 foreach $plugin (@plugins) {
322 if ( $plugin ne $ARGV[1] ) {
323 push @newplugins, $plugin;
324 }
325 }
326 @plugins = @newplugins;
327 save_data();
328 exit(0);
329 }
330
331 #####################################################################################
332 if ( $config_use_color == 1 ) {
333 $WHT = "\x1B[37;1m";
334 $NRM = "\x1B[0m";
335 } else {
336 $WHT = "";
337 $NRM = "";
338 $config_use_color = 2;
339 }
340
341 while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
342 clear_screen();
343 print $WHT. "SquirrelMail Configuration : " . $NRM;
344 if ( $config == 1 ) { print "Read: config.php"; }
345 elsif ( $config == 2 ) { print "Read: config_default.php"; }
346 print " ($print_config_version)\n";
347 print "---------------------------------------------------------\n";
348
349 if ( $menu == 0 ) {
350 print $WHT. "Main Menu --\n" . $NRM;
351 print "1. Organization Preferences\n";
352 print "2. Server Settings\n";
353 print "3. Folder Defaults\n";
354 print "4. General Options\n";
355 print "5. Themes\n";
356 print "6. Address Books (LDAP)\n";
357 print "7. Message of the Day (MOTD)\n";
358 print "8. Plugins\n";
359 print "9. Database\n";
360 print "10. Language settings\n";
361 print "11. Tweaks\n";
362 print "\n";
363 print "D. Set pre-defined settings for specific IMAP servers\n";
364 print "\n";
365 } elsif ( $menu == 1 ) {
366 print $WHT. "Organization Preferences\n" . $NRM;
367 print "1. Organization Name : $WHT$org_name$NRM\n";
368 print "2. Organization Logo : $WHT$org_logo$NRM\n";
369 print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
370 print "4. Organization Title : $WHT$org_title$NRM\n";
371 print "5. Signout Page : $WHT$signout_page$NRM\n";
372 print "6. Top Frame : $WHT$frame_top$NRM\n";
373 print "7. Provider link : $WHT$provider_uri$NRM\n";
374 print "8. Provider name : $WHT$provider_name$NRM\n";
375
376 print "\n";
377 print "R Return to Main Menu\n";
378 } elsif ( $menu == 2 ) {
379 print $WHT. "Server Settings\n\n" . $NRM;
380 print $WHT . "General" . $NRM . "\n";
381 print "-------\n";
382 print "1. Domain : $WHT$domain$NRM\n";
383 print "2. Invert Time : $WHT$invert_time$NRM\n";
384 print "3. Sendmail or SMTP : $WHT";
385 if ( lc($useSendmail) eq 'true' ) {
386 print "Sendmail";
387 } else {
388 print "SMTP";
389 }
390 print "$NRM\n";
391 print "\n";
392
393 if ( $show_imap_settings ) {
394 print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
395 print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
396 print "5. IMAP Port : $WHT$imapPort$NRM\n";
397 print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
398 print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n";
399 print "8. Server software : $WHT$imap_server_type$NRM\n";
400 print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
401 print "\n";
402 } elsif ( $show_smtp_settings ) {
403 if ( lc($useSendmail) eq 'true' ) {
404 print $WHT . "Sendmail" . $NRM . "\n--------\n";
405 print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
406 print "5. Suppress SM header : $WHT$skip_SM_header$NRM\n";
407 print "\n";
408 } else {
409 print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
410 print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
411 print "5. SMTP Port : $WHT$smtpPort$NRM\n";
412 print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
413 print "7. SMTP Authentication : $WHT$smtp_auth_mech$NRM\n";
414 print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n";
415 print "9. Suppress SM header : $WHT$skip_SM_header$NRM\n";
416 print "\n";
417 }
418 }
419
420 if ($show_imap_settings == 0) {
421 print "A. Update IMAP Settings : ";
422 print "$WHT$imapServerAddress$NRM:";
423 print "$WHT$imapPort$NRM ";
424 print "($WHT$imap_server_type$NRM)\n";
425 }
426 if ($show_smtp_settings == 0) {
427 if ( lc($useSendmail) eq 'true' ) {
428 print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
429 } else {
430 print "B. Update SMTP Settings : ";
431 print "$WHT$smtpServerAddress$NRM:";
432 print "$WHT$smtpPort$NRM\n";
433 }
434 }
435 if ( $show_smtp_settings || $show_imap_settings )
436 {
437 print "H. Hide " .
438 ($show_imap_settings ? "IMAP Server" :
439 (lc($useSendmail) eq 'true') ? "Sendmail" : "SMTP") . " Settings\n";
440 }
441
442 print "\n";
443 print "R Return to Main Menu\n";
444 } elsif ( $menu == 3 ) {
445 print $WHT. "Folder Defaults\n" . $NRM;
446 print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
447 print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
448 print "3. Trash Folder : $WHT$trash_folder$NRM\n";
449 print "4. Sent Folder : $WHT$sent_folder$NRM\n";
450 print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
451 print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
452 print "7. By default, move to sent : $WHT$default_move_to_sent$NRM\n";
453 print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
454 print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
455 print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
456 print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
457 print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
458 print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
459 print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
460 print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
461 print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
462 print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
463 print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
464 print "\n";
465 print "R Return to Main Menu\n";
466 } elsif ( $menu == 4 ) {
467 print $WHT. "General Options\n" . $NRM;
468 print "1. Data Directory : $WHT$data_dir$NRM\n";
469 print "2. Attachment Directory : $WHT$attachment_dir$NRM\n";
470 print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
471 print "4. Default Left Size : $WHT$default_left_size$NRM\n";
472 print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
473 print "6. Allow use of priority : $WHT$default_use_priority$NRM\n";
474 print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
475 print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
476 print "9. Allow editing of identity : $WHT$edit_identity$NRM/$WHT$edit_name$NRM\n";
477 print "10. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
478 print "11. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
479 print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
480 print "13. Allow advanced search : $WHT$allow_advanced_search$NRM\n";
481 print "14. PHP session name : $WHT$session_name$NRM\n";
482 print "\n";
483 print "R Return to Main Menu\n";
484 } elsif ( $menu == 5 ) {
485 print $WHT. "Themes\n" . $NRM;
486 print "1. Change Themes\n";
487 for ( $count = 0 ; $count <= $#theme_name/2 ; $count++ ) {
488 $temp_name = $theme_name[$count*2];
489 printf " %s%*s %s\n", $temp_name,
490 40 - length($temp_name), " ",
491 $theme_name[($count*2)+1];
492 }
493 print "2. CSS File : $WHT$theme_css$NRM\n";
494 print "\n";
495 print "R Return to Main Menu\n";
496 } elsif ( $menu == 6 ) {
497 print $WHT. "Address Books (LDAP)\n" . $NRM;
498 print "1. Change Servers\n";
499 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
500 print " > $ldap_host[$count]\n";
501 }
502 print
503 "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
504 print "\n";
505 print "R Return to Main Menu\n";
506 } elsif ( $menu == 7 ) {
507 print $WHT. "Message of the Day (MOTD)\n" . $NRM;
508 print "\n$motd\n";
509 print "\n";
510 print "1 Edit the MOTD\n";
511 print "\n";
512 print "R Return to Main Menu\n";
513 } elsif ( $menu == 8 ) {
514 print $WHT. "Plugins\n" . $NRM;
515 print " Installed Plugins\n";
516 $num = 0;
517 for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
518 $num = $count + 1;
519 print " $num. $plugins[$count]\n";
520 }
521 print "\n Available Plugins:\n";
522 opendir( DIR, "../plugins" );
523 @files = readdir(DIR);
524 $pos = 0;
525 @unused_plugins = ();
526 for ( $i = 0 ; $i <= $#files ; $i++ ) {
527 if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
528 $match = 0;
529 for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
530 if ( $plugins[$k] eq $files[$i] ) {
531 $match = 1;
532 }
533 }
534 if ( $match == 0 ) {
535 $unused_plugins[$pos] = $files[$i];
536 $pos++;
537 }
538 }
539 }
540
541 for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
542 $num = $num + 1;
543 print " $num. $unused_plugins[$i]\n";
544 }
545 closedir DIR;
546
547 print "\n";
548 print "R Return to Main Menu\n";
549 } elsif ( $menu == 9 ) {
550 print $WHT. "Database\n" . $NRM;
551 print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
552 print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
553 print "\n";
554 print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
555 print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
556 print "5. Field for username : $WHT$prefs_user_field$NRM\n";
557 print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
558 print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
559 print "\n";
560 print "8. DSN for Global Address Book : $WHT$addrbook_global_dsn$NRM\n";
561 print "9. Table for Global Address Book : $WHT$addrbook_global_table$NRM\n";
562 print "10. Allow writing into Global Address Book : $WHT$addrbook_global_writeable$NRM\n";
563 print "11. Allow listing of Global Address Book : $WHT$addrbook_global_listing$NRM\n";
564 print "\n";
565 print "R Return to Main Menu\n";
566 } elsif ( $menu == 10 ) {
567 print $WHT. "Language settings\n" . $NRM;
568 print "1. Default Language : $WHT$squirrelmail_default_language$NRM\n";
569 print "2. Default Charset : $WHT$default_charset$NRM\n";
570 print "3. Show alternative language names : $WHT$show_alternative_names$NRM\n";
571 print "4. Available languages : $WHT$available_languages$NRM\n";
572 print "5. Use agresive decoding : $WHT$agresive_decoding$NRM\n";
573 print "\n";
574 print "R Return to Main Menu\n";
575 } elsif ( $menu == 11 ) {
576 print $WHT. "Interface tweaks\n" . $NRM;
577 print "1. Advanced tree : $WHT$advanced_tree$NRM\n";
578 print "2. Oldway : $WHT$oldway$NRM\n";
579 print "3. Use Icons : $WHT$use_icons$NRM\n";
580 print "\n";
581 print $WHT. "PHP tweaks\n" . $NRM;
582 print "4. Use php recode functions : $WHT$use_php_recode$NRM\n";
583 print "5. Use php iconv functions : $WHT$use_php_iconv$NRM\n";
584 print "\n";
585 print "R Return to Main Menu\n";
586 }
587 if ( $config_use_color == 1 ) {
588 print "C. Turn color off\n";
589 } else {
590 print "C. Turn color on\n";
591 }
592 print "S Save data\n";
593 print "Q Quit\n";
594
595 print "\n";
596 print "Command >> " . $WHT;
597 $command = <STDIN>;
598 $command =~ s/[\n|\r]//g;
599 $command =~ tr/A-Z/a-z/;
600 print "$NRM\n";
601
602 # Read the commands they entered.
603 if ( $command eq "r" ) {
604 $menu = 0;
605 } elsif ( $command eq "s" ) {
606 save_data();
607 print "Press enter to continue...";
608 $tmp = <STDIN>;
609 $saved = 1;
610 } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
611 print "You have not saved your data.\n";
612 print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
613 $save = <STDIN>;
614 if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
615 save_data();
616 }
617 } elsif ( $command eq "c" ) {
618 if ( $config_use_color == 1 ) {
619 $config_use_color = 2;
620 $WHT = "";
621 $NRM = "";
622 } else {
623 $config_use_color = 1;
624 $WHT = "\x1B[37;1m";
625 $NRM = "\x1B[0m";
626 }
627 } elsif ( $command eq "d" && $menu == 0 ) {
628 set_defaults();
629 } else {
630 $saved = 0;
631 if ( $menu == 0 ) {
632 if ( ( $command > 0 ) && ( $command < 12 ) ) {
633 $menu = $command;
634 }
635 } elsif ( $menu == 1 ) {
636 if ( $command == 1 ) { $org_name = command1(); }
637 elsif ( $command == 2 ) { $org_logo = command2(); }
638 elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command2a(); }
639 elsif ( $command == 4 ) { $org_title = command3(); }
640 elsif ( $command == 5 ) { $signout_page = command4(); }
641 elsif ( $command == 6 ) { $frame_top = command6(); }
642 elsif ( $command == 7 ) { $provider_uri = command7(); }
643 elsif ( $command == 8 ) { $provider_name = command8(); }
644
645 } elsif ( $menu == 2 ) {
646 if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
647 elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
648 elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
649 elsif ( $command <= 3 ) {
650 if ( $command == 1 ) { $domain = command11(); }
651 elsif ( $command == 2 ) { $invert_time = command110(); }
652 elsif ( $command == 3 ) { $useSendmail = command14(); }
653 $show_imap_settings = 0; $show_smtp_settings = 0;
654 } elsif ( $show_imap_settings ) {
655 if ( $command == 4 ) { $imapServerAddress = command12(); }
656 elsif ( $command == 5 ) { $imapPort = command13(); }
657 elsif ( $command == 6 ) { $imap_auth_mech = command112a(); }
658 elsif ( $command == 7 ) { $use_imap_tls = command113("IMAP",$use_imap_tls); }
659 elsif ( $command == 8 ) { $imap_server_type = command19(); }
660 elsif ( $command == 9 ) { $optional_delimiter = command111(); }
661 } elsif ( $show_smtp_settings && lc($useSendmail) eq 'true' ) {
662 if ( $command == 4 ) { $sendmail_path = command15(); }
663 } elsif ( $show_smtp_settings ) {
664 if ( $command == 4 ) { $smtpServerAddress = command16(); }
665 elsif ( $command == 5 ) { $smtpPort = command17(); }
666 elsif ( $command == 6 ) { $pop_before_smtp = command18a(); }
667 elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); }
668 elsif ( $command == 8 ) { $use_smtp_tls = command113("SMTP",$use_smtp_tls); }
669 elsif ( $command == 9 ) { $skip_SM_header = command114(); }
670 }
671 } elsif ( $menu == 3 ) {
672 if ( $command == 1 ) { $default_folder_prefix = command21(); }
673 elsif ( $command == 2 ) { $show_prefix_option = command22(); }
674 elsif ( $command == 3 ) { $trash_folder = command23a(); }
675 elsif ( $command == 4 ) { $sent_folder = command23b(); }
676 elsif ( $command == 5 ) { $draft_folder = command23c(); }
677 elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
678 elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
679 elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
680 elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
681 elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
682 elsif ( $command == 11 ) { $auto_expunge = command29(); }
683 elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
684 elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
685 elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
686 elsif ( $command == 15 ) { $default_unseen_type = command213(); }
687 elsif ( $command == 16 ) { $auto_create_special = command214(); }
688 elsif ( $command == 17 ) { $delete_folder = command215(); }
689 elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
690 } elsif ( $menu == 4 ) {
691 if ( $command == 1 ) { $data_dir = command33a(); }
692 elsif ( $command == 2 ) { $attachment_dir = command33b(); }
693 elsif ( $command == 3 ) { $dir_hash_level = command33c(); }
694 elsif ( $command == 4 ) { $default_left_size = command35(); }
695 elsif ( $command == 5 ) { $force_username_lowercase = command36(); }
696 elsif ( $command == 6 ) { $default_use_priority = command37(); }
697 elsif ( $command == 7 ) { $hide_sm_attributions = command38(); }
698 elsif ( $command == 8 ) { $default_use_mdn = command39(); }
699 elsif ( $command == 9 ) { $edit_identity = command310(); }
700 elsif ( $command == 10 ) { $allow_thread_sort = command312(); }
701 elsif ( $command == 11 ) { $allow_server_sort = command313(); }
702 elsif ( $command == 12 ) { $allow_charset_search = command314(); }
703 elsif ( $command == 13 ) { $allow_advanced_search = command316(); }
704 elsif ( $command == 14 ) { $session_name = command317(); }
705 } elsif ( $menu == 5 ) {
706 if ( $command == 1 ) { command41(); }
707 elsif ( $command == 2 ) { $theme_css = command42(); }
708 } elsif ( $menu == 6 ) {
709 if ( $command == 1 ) { command61(); }
710 elsif ( $command == 2 ) { command62(); }
711 } elsif ( $menu == 7 ) {
712 if ( $command == 1 ) { $motd = command71(); }
713 } elsif ( $menu == 8 ) {
714 if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
715 } elsif ( $menu == 9 ) {
716 if ( $command == 1 ) { $addrbook_dsn = command91(); }
717 elsif ( $command == 2 ) { $addrbook_table = command92(); }
718 elsif ( $command == 3 ) { $prefs_dsn = command93(); }
719 elsif ( $command == 4 ) { $prefs_table = command94(); }
720 elsif ( $command == 5 ) { $prefs_user_field = command95(); }
721 elsif ( $command == 6 ) { $prefs_key_field = command96(); }
722 elsif ( $command == 7 ) { $prefs_val_field = command97(); }
723 elsif ( $command == 8 ) { $addrbook_global_dsn = command98(); }
724 elsif ( $command == 9 ) { $addrbook_global_table = command99(); }
725 elsif ( $command == 10 ) { $addrbook_global_writeable = command910(); }
726 elsif ( $command == 11 ) { $addrbook_global_listing = command911(); }
727 } elsif ( $menu == 10 ) {
728 if ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
729 elsif ( $command == 2 ) { $default_charset = commandA2(); }
730 elsif ( $command == 3 ) { $show_alternative_names = commandA3(); }
731 elsif ( $command == 4 ) { $available_languages = commandA4(); }
732 elsif ( $command == 5 ) { $agresive_decoding = commandA5(); }
733 } elsif ( $menu == 11 ) {
734 if ( $command == 1 ) { $advanced_tree = commandB1(); }
735 elsif ( $command == 2 ) { $oldway = commandB2(); }
736 elsif ( $command == 3 ) { $use_icons = commandB3(); }
737 elsif ( $command == 4 ) { $use_php_recode = commandB4(); }
738 elsif ( $command == 5 ) { $use_php_iconv = commandB5(); }
739 }
740 }
741 }
742
743 # we exit here
744 print "\nExiting conf.pl.\n".
745 "You might want to test your configuration by browsing to\n".
746 "http://your-squirrelmail-location/src/configtest.php\n".
747 "Happy SquirrelMailing!\n\n";
748
749
750 ####################################################################################
751
752 # org_name
753 sub command1 {
754 print "We have tried to make the name SquirrelMail as transparent as\n";
755 print "possible. If you set up an organization name, most places where\n";
756 print "SquirrelMail would take credit will be credited to your organization.\n";
757 print "\n";
758 print "If your Organization Name includes a '\$', please precede it with a \\. \n";
759 print "Other '\$' will be considered the beginning of a variable that\n";
760 print "must be defined before the \$org_name is printed.\n";
761 print "\$version, for example, is included by default, and will print the\n";
762 print "string representing the current SquirrelMail version.\n";
763 print "\n";
764 print "[$WHT$org_name$NRM]: $WHT";
765 $new_org_name = <STDIN>;
766 if ( $new_org_name eq "\n" ) {
767 $new_org_name = $org_name;
768 } else {
769 $new_org_name =~ s/[\r|\n]//g;
770 $new_org_name =~ s/\"/&quot;/g;
771 }
772 return $new_org_name;
773 }
774
775 # org_logo
776 sub command2 {
777 print "Your organization's logo is an image that will be displayed at\n";
778 print "different times throughout SquirrelMail. ";
779 print "\n";
780 print "Please be aware of the following: \n";
781 print " - Relative URLs are relative to the config dir\n";
782 print " to use the default logo, use ../images/sm_logo.png\n";
783 print " - To specify a logo defined outside the SquirrelMail source tree\n";
784 print " use the absolute URL the webserver would use to include the file\n";
785 print " e.g. http://some.host.com/images/mylogo.gif or /images/mylogo.jpg\n";
786 print "\n";
787 print "[$WHT$org_logo$NRM]: $WHT";
788 $new_org_logo = <STDIN>;
789 if ( $new_org_logo eq "\n" ) {
790 $new_org_logo = $org_logo;
791 } else {
792 $new_org_logo =~ s/[\r|\n]//g;
793 }
794 return $new_org_logo;
795 }
796
797 # org_logo_width
798 sub command2a {
799 print "Your organization's logo is an image that will be displayed at\n";
800 print "different times throughout SquirrelMail. Width\n";
801 print "and Height of your logo image. Use '0' to disable.\n";
802 print "\n";
803 print "Width: [$WHT$org_logo_width$NRM]: $WHT";
804 $new_org_logo_width = <STDIN>;
805 $new_org_logo_width =~ tr/0-9//cd; # only want digits!
806 if ( $new_org_logo_width eq '' ) {
807 $new_org_logo_width = $org_logo_width;
808 }
809 if ( $new_org_logo_width > 0 ) {
810 print "Height: [$WHT$org_logo_height$NRM]: $WHT";
811 $new_org_logo_height = <STDIN>;
812 $new_org_logo_height =~ tr/0-9//cd; # only want digits!
813 if( $new_org_logo_height eq '' ) {
814 $new_org_logo_height = $org_logo_height;
815 }
816 } else {
817 $new_org_logo_height = 0;
818 }
819 return ($new_org_logo_width, $new_org_logo_height);
820 }
821
822 # org_title
823 sub command3 {
824 print "A title is what is displayed at the top of the browser window in\n";
825 print "the titlebar. Usually this will end up looking something like:\n";
826 print "\"Netscape: $org_title\"\n";
827 print "\n";
828 print "If your Organization Title includes a '\$', please precede it with a \\. \n";
829 print "Other '\$' will be considered the beginning of a variable that\n";
830 print "must be defined before the \$org_title is printed.\n";
831 print "\$version, for example, is included by default, and will print the\n";
832 print "string representing the current SquirrelMail version.\n";
833 print "\n";
834 print "[$WHT$org_title$NRM]: $WHT";
835 $new_org_title = <STDIN>;
836 if ( $new_org_title eq "\n" ) {
837 $new_org_title = $org_title;
838 } else {
839 $new_org_title =~ s/[\r|\n]//g;
840 $new_org_title =~ s/\"/\'/g;
841 }
842 return $new_org_title;
843 }
844
845 # signout_page
846 sub command4 {
847 print "When users click the Sign Out button they will be logged out and\n";
848 print "then sent to signout_page. If signout_page is left empty,\n";
849 print "(hit space and then return) they will be taken, as normal,\n";
850 print "to the default and rather sparse SquirrelMail signout page.\n";
851 print "\n";
852 print "[$WHT$signout_page$NRM]: $WHT";
853 $new_signout_page = <STDIN>;
854 if ( $new_signout_page eq "\n" ) {
855 $new_signout_page = $signout_page;
856 } else {
857 $new_signout_page =~ s/[\r|\n]//g;
858 $new_signout_page =~ s/^\s+$//g;
859 }
860 return $new_signout_page;
861 }
862
863 # Default top frame
864 sub command6 {
865 print "SquirrelMail defaults to using the whole of the browser window.\n";
866 print "This allows you to keep it within a specified frame. The default\n";
867 print "is '_top'\n";
868 print "\n";
869 print "[$WHT$frame_top$NRM]: $WHT";
870 $new_frame_top = <STDIN>;
871 if ( $new_frame_top eq "\n" ) {
872 $new_frame_top = '_top';
873 } else {
874 $new_frame_top =~ s/[\r|\n]//g;
875 $new_frame_top =~ s/^\s+$//g;
876 }
877 return $new_frame_top;
878 }
879
880 # Default link to provider
881 sub command7 {
882 print "Here you can set the link on the right of the page.\n";
883 print "The default is 'http://www.squirrelmail.org/'\n";
884 print "\n";
885 print "[$WHT$provider_uri$NRM]: $WHT";
886 $new_provider_uri = <STDIN>;
887 if ( $new_provider_uri eq "\n" ) {
888 $new_provider_uri = 'http://www.squirrelmail.org/';
889 } else {
890 $new_provider_uri =~ s/[\r|\n]//g;
891 $new_provider_uri =~ s/^\s+$//g;
892 }
893 return $new_provider_uri;
894 }
895
896 sub command8 {
897 print "Here you can set the name of the link on the right of the page.\n";
898 print "The default is 'SquirrelMail/'\n";
899 print "\n";
900 print "[$WHT$provider_name$NRM]: $WHT";
901 $new_provider_name = <STDIN>;
902 if ( $new_provider_name eq "\n" ) {
903 $new_provider_name = 'SquirrelMail';
904 } else {
905 $new_provider_name =~ s/[\r|\n]//g;
906 $new_provider_name =~ s/^\s+$//g;
907 }
908 return $new_provider_name;
909 }
910
911 ####################################################################################
912
913 # domain
914 sub command11 {
915 print "The domain name is the suffix at the end of all email addresses. If\n";
916 print "for example, your email address is jdoe\@myorg.com, then your domain\n";
917 print "would be myorg.com.\n";
918 print "\n";
919 print "[$WHT$domain$NRM]: $WHT";
920 $new_domain = <STDIN>;
921 if ( $new_domain eq "\n" ) {
922 $new_domain = $domain;
923 } else {
924 $new_domain =~ s/[\r|\n]//g;
925 }
926 return $new_domain;
927 }
928
929 # imapServerAddress
930 sub command12 {
931 print "This is the hostname where your IMAP server can be contacted.\n";
932 print "[$WHT$imapServerAddress$NRM]: $WHT";
933 $new_imapServerAddress = <STDIN>;
934 if ( $new_imapServerAddress eq "\n" ) {
935 $new_imapServerAddress = $imapServerAddress;
936 } else {
937 $new_imapServerAddress =~ s/[\r|\n]//g;
938 }
939 return $new_imapServerAddress;
940 }
941
942 # imapPort
943 sub command13 {
944 print "This is the port that your IMAP server is on. Usually this is 143.\n";
945 print "[$WHT$imapPort$NRM]: $WHT";
946 $new_imapPort = <STDIN>;
947 if ( $new_imapPort eq "\n" ) {
948 $new_imapPort = $imapPort;
949 } else {
950 $new_imapPort =~ s/[\r|\n]//g;
951 }
952 return $new_imapPort;
953 }
954
955 # useSendmail
956 sub command14 {
957 print "You now need to choose the method that you will use for sending\n";
958 print "messages in SquirrelMail. You can either connect to an SMTP server\n";
959 print "or use sendmail directly.\n";
960 if ( lc($useSendmail) eq 'true' ) {
961 $default_value = "1";
962 } else {
963 $default_value = "2";
964 }
965 print "\n";
966 print " 1. Sendmail\n";
967 print " 2. SMTP\n";
968 print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
969 $use_sendmail = <STDIN>;
970 if ( ( $use_sendmail =~ /^1\n/i )
971 || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
972 $useSendmail = 'true';
973 } else {
974 $useSendmail = 'false';
975 }
976 return $useSendmail;
977 }
978
979 # sendmail_path
980 sub command15 {
981 if ( $sendmail_path[0] !~ /./ ) {
982 $sendmail_path = "/usr/sbin/sendmail";
983 }
984 print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
985 print "[$WHT$sendmail_path$NRM]: $WHT";
986 $new_sendmail_path = <STDIN>;
987 if ( $new_sendmail_path eq "\n" ) {
988 $new_sendmail_path = $sendmail_path;
989 } else {
990 $new_sendmail_path =~ s/[\r|\n]//g;
991 }
992 return $new_sendmail_path;
993 }
994
995 # smtpServerAddress
996 sub command16 {
997 print "This is the hostname of your SMTP server.\n";
998 print "[$WHT$smtpServerAddress$NRM]: $WHT";
999 $new_smtpServerAddress = <STDIN>;
1000 if ( $new_smtpServerAddress eq "\n" ) {
1001 $new_smtpServerAddress = $smtpServerAddress;
1002 } else {
1003 $new_smtpServerAddress =~ s/[\r|\n]//g;
1004 }
1005 return $new_smtpServerAddress;
1006 }
1007
1008 # smtpPort
1009 sub command17 {
1010 print "This is the port to connect to for SMTP. Usually 25.\n";
1011 print "[$WHT$smtpPort$NRM]: $WHT";
1012 $new_smtpPort = <STDIN>;
1013 if ( $new_smtpPort eq "\n" ) {
1014 $new_smtpPort = $smtpPort;
1015 } else {
1016 $new_smtpPort =~ s/[\r|\n]//g;
1017 }
1018 return $new_smtpPort;
1019 }
1020
1021 # authenticated server
1022 sub command18 {
1023 return;
1024 # This sub disabled by tassium - it has been replaced with smtp_auth_mech
1025 print "Do you wish to use an authenticated SMTP server? Your server must\n";
1026 print "support this in order for SquirrelMail to work with it. We implemented\n";
1027 print "it according to RFC 2554.\n";
1028
1029 $YesNo = 'n';
1030 $YesNo = 'y' if ( lc($use_authenticated_smtp) eq 'true' );
1031
1032 print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
1033
1034 $new_use_authenticated_smtp = <STDIN>;
1035 $new_use_authenticated_smtp =~ tr/yn//cd;
1036 return 'true' if ( $new_use_authenticated_smtp eq "y" );
1037 return 'false' if ( $new_use_authenticated_smtp eq "n" );
1038 return $use_authenticated_smtp;
1039 }
1040
1041 # pop before SMTP
1042 sub command18a {
1043 print "Do you wish to use POP3 before SMTP? Your server must\n";
1044 print "support this in order for SquirrelMail to work with it.\n";
1045
1046 $YesNo = 'n';
1047 $YesNo = 'y' if ( lc($pop_before_smtp) eq 'true' );
1048
1049 print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
1050
1051 $new_pop_before_smtp = <STDIN>;
1052 $new_pop_before_smtp =~ tr/yn//cd;
1053 return 'true' if ( $new_pop_before_smtp eq "y" );
1054 return 'false' if ( $new_pop_before_smtp eq "n" );
1055 return $pop_before_smtp;
1056 }
1057
1058 # imap_server_type
1059 sub command19 {
1060 print "Each IMAP server has its own quirks. As much as we tried to stick\n";
1061 print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
1062 print "the same principles. We have made some work-arounds for some of\n";
1063 print "these servers. If you would like to use them, please select your\n";
1064 print "IMAP server. If you do not wish to use these work-arounds, you can\n";
1065 print "set this to \"other\", and none will be used.\n";
1066 print " cyrus = Cyrus IMAP server\n";
1067 print " uw = University of Washington's IMAP server\n";
1068 print " exchange = Microsoft Exchange IMAP server\n";
1069 print " courier = Courier IMAP server\n";
1070 print " macosx = Mac OS X Mailserver\n";
1071 print " other = Not one of the above servers\n";
1072 print "[$WHT$imap_server_type$NRM]: $WHT";
1073 $new_imap_server_type = <STDIN>;
1074
1075 if ( $new_imap_server_type eq "\n" ) {
1076 $new_imap_server_type = $imap_server_type;
1077 } else {
1078 $new_imap_server_type =~ s/[\r|\n]//g;
1079 }
1080 return $new_imap_server_type;
1081 }
1082
1083 # invert_time
1084 sub command110 {
1085 print "Sometimes the date of messages sent is messed up (off by a few hours\n";
1086 print "on some machines). Typically this happens if the system doesn't support\n";
1087 print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
1088 print "This most often occurs on Solaris 7 machines in the United States.\n";
1089 print "By default, this is off. It should be kept off unless problems surface\n";
1090 print "about the time that messages are sent.\n";
1091 print " no = Do NOT fix time -- almost always correct\n";
1092 print " yes = Fix the time for this system\n";
1093
1094 $YesNo = 'n';
1095 $YesNo = 'y' if ( lc($invert_time) eq 'true' );
1096
1097 print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
1098
1099 $new_invert_time = <STDIN>;
1100 $new_invert_time =~ tr/yn//cd;
1101 return 'true' if ( $new_invert_time eq "y" );
1102 return 'false' if ( $new_invert_time eq "n" );
1103 return $invert_time;
1104 }
1105
1106 sub command111 {
1107 print "This is the delimiter that your IMAP server uses to distinguish between\n";
1108 print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
1109 print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
1110 print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
1111 print "but if you are sure you know what delimiter your server uses, you can\n";
1112 print "specify it here.\n";
1113 print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
1114 print "[$WHT$optional_delimiter$NRM]: $WHT";
1115 $new_optional_delimiter = <STDIN>;
1116
1117 if ( $new_optional_delimiter eq "\n" ) {
1118 $new_optional_delimiter = $optional_delimiter;
1119 } else {
1120 $new_optional_delimiter =~ s/[\r|\n]//g;
1121 }
1122 return $new_optional_delimiter;
1123 }
1124 # IMAP authentication type
1125 # Possible values: login, plain, cram-md5, digest-md5
1126 # Now offers to detect supported mechs, assuming server & port are set correctly
1127
1128 sub command112a {
1129 if ($use_imap_tls =~ /^true\b/i) {
1130 print "Auto-detection of login methods is unavailable when using TLS.\n";
1131 } else {
1132 print "If you have already set the hostname and port number, I can try to\n";
1133 print "detect the mechanisms your IMAP server supports.\n";
1134 print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n";
1135 print "for \"login\" or \"plain\" without knowing a username and password.\n";
1136 print "Auto-detecting is optional - you can safely say \"n\" here.\n";
1137 print "\nTry to detect supported mechanisms? [y/N]: ";
1138 $inval=<STDIN>;
1139 chomp($inval);
1140 if ($inval =~ /^y\b/i) {
1141 # Yes, let's try to detect.
1142 print "Trying to detect IMAP capabilities...\n";
1143 my $host = $imapServerAddress . ':'. $imapPort;
1144 print "CRAM-MD5:\t";
1145 my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
1146 if (defined($tmp)) {
1147 if ($tmp eq 'YES') {
1148 print "$WHT SUPPORTED$NRM\n";
1149 } else {
1150 print "$WHT NOT SUPPORTED$NRM\n";
1151 }
1152 } else {
1153 print $WHT . " ERROR DETECTING$NRM\n";
1154 }
1155
1156 print "DIGEST-MD5:\t";
1157 $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
1158 if (defined($tmp)) {
1159 if ($tmp eq 'YES') {
1160 print "$WHT SUPPORTED$NRM\n";
1161 } else {
1162 print "$WHT NOT SUPPORTED$NRM\n";
1163 }
1164 } else {
1165 print $WHT . " ERROR DETECTING$NRM\n";
1166 }
1167
1168 }
1169 }
1170 print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
1171 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1172 print $WHT . "plain" . $NRM . " - SASL PLAIN. If you need this, you already know it.\n";
1173 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
1174 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1175 print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
1176 print "If you don't understand or are unsure, you probably want \"login\"\n\n";
1177 print "login, plain, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
1178 $inval=<STDIN>;
1179 chomp($inval);
1180 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
1181 return lc($inval);
1182 } else {
1183 # user entered garbage or default value so nothing needs to be set
1184 return $imap_auth_mech;
1185 }
1186 }
1187
1188
1189 # SMTP authentication type
1190 # Possible choices: none, plain, cram-md5, digest-md5
1191 sub command112b {
1192 if ($use_smtp_tls =~ /^true\b/i) {
1193 print "Auto-detection of login methods is unavailable when using TLS.\n";
1194 } else {
1195 print "If you have already set the hostname and port number, I can try to\n";
1196 print "automatically detect some of the mechanisms your SMTP server supports.\n";
1197 print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
1198 print "\nTry to detect auth mechanisms? [y/N]: ";
1199 $inval=<STDIN>;
1200 chomp($inval);
1201 if ($inval =~ /^y\b/i) {
1202 # Yes, let's try to detect.
1203 print "Trying to detect supported methods (SMTP)...\n";
1204
1205 # Special case!
1206 # Check none by trying to relay to junk@microsoft.com
1207 $host = $smtpServerAddress . ':' . $smtpPort;
1208 use IO::Socket;
1209 my $sock = IO::Socket::INET->new($host);
1210 print "Testing none:\t\t$WHT";
1211 if (!defined($sock)) {
1212 print " ERROR TESTING\n";
1213 close $sock;
1214 } else {
1215 print $sock "mail from: tester\@squirrelmail.org\n";
1216 $got = <$sock>; # Discard
1217 print $sock "rcpt to: junk\@microsoft.com\n";
1218 $got = <$sock>; # This is the important line
1219 if ($got =~ /^250\b/) { # SMTP will relay without auth
1220 print "SUPPORTED$NRM\n";
1221 } else {
1222 print "NOT SUPPORTED$NRM\n";
1223 }
1224 print $sock "rset\n";
1225 print $sock "quit\n";
1226 close $sock;
1227 }
1228 # Try login (SquirrelMail default)
1229 print "Testing login:\t\t";
1230 $tmp=detect_auth_support('SMTP',$host,'LOGIN');
1231 if (defined($tmp)) {
1232 if ($tmp eq 'YES') {
1233 print $WHT . "SUPPORTED$NRM\n";
1234 } else {
1235 print $WHT . "NOT SUPPORTED$NRM\n";
1236 }
1237 } else {
1238 print $WHT . "ERROR DETECTING$NRM\n";
1239 }
1240
1241 # Try CRAM-MD5
1242 print "Testing CRAM-MD5:\t";
1243 $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5');
1244 if (defined($tmp)) {
1245 if ($tmp eq 'YES') {
1246 print $WHT . "SUPPORTED$NRM\n";
1247 } else {
1248 print $WHT . "NOT SUPPORTED$NRM\n";
1249 }
1250 } else {
1251 print $WHT . "ERROR DETECTING$NRM\n";
1252 }
1253
1254
1255 print "Testing DIGEST-MD5:\t";
1256 $tmp=detect_auth_support('SMTP',$host,'DIGEST-MD5');
1257 if (defined($tmp)) {
1258 if ($tmp eq 'YES') {
1259 print $WHT . "SUPPORTED$NRM\n";
1260 } else {
1261 print $WHT . "NOT SUPPORTED$NRM\n";
1262 }
1263 } else {
1264 print $WHT . "ERROR DETECTING$NRM\n";
1265 }
1266 }
1267 }
1268 print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
1269 print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
1270 print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1271 print $WHT . "plain" . $NRM . " - SASL PLAIN. You already know it if you need this.\n";
1272 print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1273 print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1274 print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
1275 print "If you don't understand or are unsure, you probably want \"none\"\n\n";
1276 print "none, login, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
1277 $inval=<STDIN>;
1278 chomp($inval);
1279 if ($inval =~ /^none\b/i) {
1280 # SMTP doesn't necessarily require logins
1281 return "none";
1282 }
1283 if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
1284 ($inval =~ /^login\b/i) || ($inval =~/^plain\b/i)) {
1285 return lc($inval);
1286 } else {
1287 # user entered garbage, or default value so nothing needs to be set
1288 return $smtp_auth_mech;
1289 }
1290 }
1291
1292 # TLS
1293 # This sub is reused for IMAP and SMTP
1294 # Args: service name, default value
1295 sub command113 {
1296 my($default_val,$service,$inval);
1297 $service=$_[0];
1298 $default_val=$_[1];
1299 print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
1300 print "If you're familiar with SSL, you get the idea.\n";
1301 print "To use this feature, your " . $service . " server must offer TLS\n";
1302 print "capability, plus PHP 4.3.x with OpenSSL support.\n";
1303 print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
1304 print "If it is remote, you may wish to seriously consider enabling this.\n";
1305 print "Enable TLS (y/n) [$WHT";
1306 if ($default_val eq 'true') {
1307 print "y";
1308 } else {
1309 print "n";
1310 }
1311 print "$NRM]: $WHT";
1312 $inval=<STDIN>;
1313 $inval =~ tr/yn//cd;
1314 return 'true' if ( $inval eq "y" );
1315 return 'false' if ( $inval eq "n" );
1316 return $default_val;
1317 }
1318
1319 sub command114{
1320 print "\nUse this to suppress insertion of SquirrelMail Received: headers\n";
1321 print "in outbound messages.\n\n";
1322
1323 $YesNo = 'n';
1324 $YesNo = 'y' if ( lc($skip_SM_header) eq 'true' );
1325
1326 print "Suppress SM header (y/n) [$WHT$YesNo$NRM]: $WHT";
1327 $new_skip_SM_header = <STDIN>;
1328 chomp($new_skip_SM_header);
1329
1330 return 'true' if ( lc($new_skip_SM_header) eq 'y' );
1331 return 'false' if ( lc($new_skip_SM_header) eq 'n' );
1332 return $skip_SM_header;
1333 }
1334
1335 # MOTD
1336 sub command71 {
1337 print "\nYou can now create the welcome message that is displayed\n";
1338 print "every time a user logs on. You can use HTML or just plain\n";
1339 print
1340 "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1341
1342 $new_motd = "";
1343 do {
1344 print "] ";
1345 $line = <STDIN>;
1346 $line =~ s/[\r|\n]//g;
1347 if ( $line ne "@" ) {
1348 $line =~ s/ /\&nbsp;\&nbsp;/g;
1349 $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
1350 $line =~ s/$/ /;
1351 $line =~ s/\"/&quot;/g;
1352
1353 $new_motd = $new_motd . $line;
1354 }
1355 } while ( $line ne "@" );
1356 return $new_motd;
1357 }
1358
1359 ################# PLUGINS ###################
1360
1361 sub command81 {
1362 $command =~ s/[\s|\n|\r]*//g;
1363 if ( $command > 0 ) {
1364 $command = $command - 1;
1365 if ( $command <= $#plugins ) {
1366 @newplugins = ();
1367 $ct = 0;
1368 while ( $ct <= $#plugins ) {
1369 if ( $ct != $command ) {
1370 @newplugins = ( @newplugins, $plugins[$ct] );
1371 }
1372 $ct++;
1373 }
1374 @plugins = @newplugins;
1375 } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
1376 $num = $command - $#plugins - 1;
1377 @newplugins = @plugins;
1378 $ct = 0;
1379 while ( $ct <= $#unused_plugins ) {
1380 if ( $ct == $num ) {
1381 @newplugins = ( @newplugins, $unused_plugins[$ct] );
1382 }
1383 $ct++;
1384 }
1385 @plugins = @newplugins;
1386 }
1387 }
1388 return @plugins;
1389 }
1390
1391 ################# FOLDERS ###################
1392
1393 # default_folder_prefix
1394 sub command21 {
1395 print "Some IMAP servers (UW, for example) store mail and folders in\n";
1396 print "your user space in a separate subdirectory. This is where you\n";
1397 print "specify what that directory is.\n";
1398 print "\n";
1399 print "EXAMPLE: mail/";
1400 print "\n";
1401 print "NOTE: If you use Cyrus, or some server that would not use this\n";
1402 print " option, you must set this to 'none'.\n";
1403 print "\n";
1404 print "[$WHT$default_folder_prefix$NRM]: $WHT";
1405 $new_default_folder_prefix = <STDIN>;
1406
1407 if ( $new_default_folder_prefix eq "\n" ) {
1408 $new_default_folder_prefix = $default_folder_prefix;
1409 } else {
1410 $new_default_folder_prefix =~ s/[\r\n]//g;
1411 }
1412 if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
1413 $new_default_folder_prefix = "";
1414 } else {
1415 # add the trailing delimiter only if we know what the server is.
1416 if (($imap_server_type eq 'cyrus' and
1417 $optional_delimiter eq 'detect') or
1418 ($imap_server_type eq 'courier' and
1419 $optional_delimiter eq 'detect')) {
1420 $new_default_folder_prefix =~ s/\.*$/\./;
1421 } elsif ($imap_server_type eq 'uw' and
1422 $optional_delimiter eq 'detect') {
1423 $new_default_folder_prefix =~ s/\/*$/\//;
1424 }
1425 }
1426 return $new_default_folder_prefix;
1427 }
1428
1429 # Show Folder Prefix
1430 sub command22 {
1431 print "It is possible to set up the default folder prefix as a user\n";
1432 print "specific option, where each user can specify what their mail\n";
1433 print "folder is. If you set this to false, they will never see the\n";
1434 print "option, but if it is true, this option will appear in the\n";
1435 print "'options' section.\n";
1436 print "\n";
1437 print "NOTE: You set the default folder prefix in option '1' of this\n";
1438 print " section. That will be the default if the user doesn't\n";
1439 print " specify anything different.\n";
1440 print "\n";
1441
1442 if ( lc($show_prefix_option) eq 'true' ) {
1443 $default_value = "y";
1444 } else {
1445 $default_value = "n";
1446 }
1447 print "\n";
1448 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1449 $new_show = <STDIN>;
1450 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1451 $show_prefix_option = 'true';
1452 } else {
1453 $show_prefix_option = 'false';
1454 }
1455 return $show_prefix_option;
1456 }
1457
1458 # Trash Folder
1459 sub command23a {
1460 print "You can now specify where the default trash folder is located.\n";
1461 print "On servers where you do not want this, you can set it to anything\n";
1462 print "and set option 6 to false.\n";
1463 print "\n";
1464 print "This is relative to where the rest of your email is kept. You do\n";
1465 print "not need to worry about their mail directory. If this folder\n";
1466 print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1467 print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1468 print "\n";
1469
1470 print "[$WHT$trash_folder$NRM]: $WHT";
1471 $new_trash_folder = <STDIN>;
1472 if ( $new_trash_folder eq "\n" ) {
1473 $new_trash_folder = $trash_folder;
1474 } else {
1475 $new_trash_folder =~ s/[\r|\n]//g;
1476 }
1477 return $new_trash_folder;
1478 }
1479
1480 # Sent Folder
1481 sub command23b {
1482 print "This is where messages that are sent will be stored. SquirrelMail\n";
1483 print "by default puts a copy of all outgoing messages in this folder.\n";
1484 print "\n";
1485 print "This is relative to where the rest of your email is kept. You do\n";
1486 print "not need to worry about their mail directory. If this folder\n";
1487 print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1488 print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1489 print "\n";
1490
1491 print "[$WHT$sent_folder$NRM]: $WHT";
1492 $new_sent_folder = <STDIN>;
1493 if ( $new_sent_folder eq "\n" ) {
1494 $new_sent_folder = $sent_folder;
1495 } else {
1496 $new_sent_folder =~ s/[\r|\n]//g;
1497 }
1498 return $new_sent_folder;
1499 }
1500
1501 # Draft Folder
1502 sub command23c {
1503 print "You can now specify where the default draft folder is located.\n";
1504 print "On servers where you do not want this, you can set it to anything\n";
1505 print "and set option 9 to false.\n";
1506 print "\n";
1507 print "This is relative to where the rest of your email is kept. You do\n";
1508 print "not need to worry about their mail directory. If this folder\n";
1509 print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1510 print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1511 print "\n";
1512
1513 print "[$WHT$draft_folder$NRM]: $WHT";
1514 $new_draft_folder = <STDIN>;
1515 if ( $new_draft_folder eq "\n" ) {
1516 $new_draft_folder = $draft_folder;
1517 } else {
1518 $new_draft_folder =~ s/[\r|\n]//g;
1519 }
1520 return $new_draft_folder;
1521 }
1522
1523 # default move to trash
1524 sub command24a {
1525 print "By default, should messages get moved to the trash folder? You\n";
1526 print "can specify the default trash folder in option 3. If this is set\n";
1527 print "to false, messages will get deleted immediately without moving\n";
1528 print "to the trash folder.\n";
1529 print "\n";
1530 print "Trash folder is currently: $trash_folder\n";
1531 print "\n";
1532
1533 if ( lc($default_move_to_trash) eq 'true' ) {
1534 $default_value = "y";
1535 } else {
1536 $default_value = "n";
1537 }
1538 print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1539 $new_show = <STDIN>;
1540 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1541 $default_move_to_trash = 'true';
1542 } else {
1543 $default_move_to_trash = 'false';
1544 }
1545 return $default_move_to_trash;
1546 }
1547
1548 # default move to sent
1549 sub command24b {
1550 print "By default, should messages get moved to the sent folder? You\n";
1551 print "can specify the default sent folder in option 4. If this is set\n";
1552 print "to false, messages will get sent and no copy will be made.\n";
1553 print "\n";
1554 print "Sent folder is currently: $sent_folder\n";
1555 print "\n";
1556
1557 if ( lc($default_move_to_sent) eq 'true' ) {
1558 $default_value = "y";
1559 } else {
1560 $default_value = "n";
1561 }
1562 print "By default, move to sent (y/n) [$WHT$default_value$NRM]: $WHT";
1563 $new_show = <STDIN>;
1564 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1565 $default_move_to_sent = 'true';
1566 } else {
1567 $default_move_to_sent = 'false';
1568 }
1569 return $default_move_to_sent;
1570 }
1571
1572 # default save as draft
1573 sub command24c {
1574 print "By default, should the save to draft option be shown? You can\n";
1575 print "specify the default drafts folder in option 5. If this is set\n";
1576 print "to false, users will not be shown the save to draft option.\n";
1577 print "\n";
1578 print "Drafts folder is currently: $draft_folder\n";
1579 print "\n";
1580
1581 if ( lc($default_move_to_draft) eq 'true' ) {
1582 $default_value = "y";
1583 } else {
1584 $default_value = "n";
1585 }
1586 print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1587 $new_show = <STDIN>;
1588 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1589 $default_save_as_draft = 'true';
1590 } else {
1591 $default_save_as_draft = 'false';
1592 }
1593 return $default_save_as_draft;
1594 }
1595
1596 # List special folders first
1597 sub command27 {
1598 print "SquirrelMail has what we call 'special folders' that are not\n";
1599 print "manipulated and viewed like normal folders. Some examples of\n";
1600 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1601 print "Simply asks if you want these folders listed first in the folder\n";
1602 print "listing.\n";
1603 print "\n";
1604
1605 if ( lc($list_special_folders_first) eq 'true' ) {
1606 $default_value = "y";
1607 } else {
1608 $default_value = "n";
1609 }
1610 print "\n";
1611 print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1612 $new_show = <STDIN>;
1613 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1614 $list_special_folders_first = 'true';
1615 } else {
1616 $list_special_folders_first = 'false';
1617 }
1618 return $list_special_folders_first;
1619 }
1620
1621 # Show special folders color
1622 sub command28 {
1623 print "SquirrelMail has what we call 'special folders' that are not\n";
1624 print "manipulated and viewed like normal folders. Some examples of\n";
1625 print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1626 print "wants to know if we should display special folders in a\n";
1627 print "color than the other folders.\n";
1628 print "\n";
1629
1630 if ( lc($use_special_folder_color) eq 'true' ) {
1631 $default_value = "y";
1632 } else {
1633 $default_value = "n";
1634 }
1635 print "\n";
1636 print "Show color (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 $use_special_folder_color = 'true';
1640 } else {
1641 $use_special_folder_color = 'false';
1642 }
1643 return $use_special_folder_color;
1644 }
1645
1646 # Auto expunge
1647 sub command29 {
1648 print "The way that IMAP handles deleting messages is as follows. You\n";
1649 print "mark the message as deleted, and then to 'really' delete it, you\n";
1650 print "expunge it. This option asks if you want to just have messages\n";
1651 print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1652 print "messages too.\n";
1653 print "\n";
1654
1655 if ( lc($auto_expunge) eq 'true' ) {
1656 $default_value = "y";
1657 } else {
1658 $default_value = "n";
1659 }
1660 print "Auto expunge (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 $auto_expunge = 'true';
1664 } else {
1665 $auto_expunge = 'false';
1666 }
1667 return $auto_expunge;
1668 }
1669
1670 # Default sub of inbox
1671 sub command210 {
1672 print "Some IMAP servers (Cyrus) have all folders as subfolders of INBOX.\n";
1673 print "This can cause some confusion in folder creation for users when\n";
1674 print "they try to create folders and don't put it as a subfolder of INBOX\n";
1675 print "and get permission errors. This option asks if you want folders\n";
1676 print "to be subfolders of INBOX by default.\n";
1677 print "\n";
1678
1679 if ( lc($default_sub_of_inbox) eq 'true' ) {
1680 $default_value = "y";
1681 } else {
1682 $default_value = "n";
1683 }
1684 print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1685 $new_show = <STDIN>;
1686 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1687 $default_sub_of_inbox = 'true';
1688 } else {
1689 $default_sub_of_inbox = 'false';
1690 }
1691 return $default_sub_of_inbox;
1692 }
1693
1694 # Show contain subfolder option
1695 sub command211 {
1696 print "Some IMAP servers (UW) make it so that there are two types of\n";
1697 print "folders. Those that contain messages, and those that contain\n";
1698 print "subfolders. If this is the case for your server, set this to\n";
1699 print "true, and it will ask the user whether the folder they are\n";
1700 print "creating contains subfolders or messages.\n";
1701 print "\n";
1702
1703 if ( lc($show_contain_subfolders_option) eq 'true' ) {
1704 $default_value = "y";
1705 } else {
1706 $default_value = "n";
1707 }
1708 print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1709 $new_show = <STDIN>;
1710 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1711 $show_contain_subfolders_option = 'true';
1712 } else {
1713 $show_contain_subfolders_option = 'false';
1714 }
1715 return $show_contain_subfolders_option;
1716 }
1717
1718 # Default Unseen Notify
1719 sub command212 {
1720 print "This option specifies where the users will receive notification\n";
1721 print "about unseen messages by default. This is of course an option that\n";
1722 print "can be changed on a user level.\n";
1723 print " 1 = No notification\n";
1724 print " 2 = Only on the INBOX\n";
1725 print " 3 = On all folders\n";
1726 print "\n";
1727
1728 print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1729 $new_show = <STDIN>;
1730 if ( $new_show =~ /^[1|2|3]\n/i ) {
1731 $default_unseen_notify = $new_show;
1732 }
1733 $default_unseen_notify =~ s/[\r|\n]//g;
1734 return $default_unseen_notify;
1735 }
1736
1737 # Default Unseen Type
1738 sub command213 {
1739 print "Here you can define the default way that unseen messages will be displayed\n";
1740 print "to the user in the folder listing on the left side.\n";
1741 print " 1 = Only unseen messages (4)\n";
1742 print " 2 = Unseen and Total messages (4/27)\n";
1743 print "\n";
1744
1745 print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1746 $new_show = <STDIN>;
1747 if ( $new_show =~ /^[1|2]\n/i ) {
1748 $default_unseen_type = $new_show;
1749 }
1750 $default_unseen_type =~ s/[\r|\n]//g;
1751 return $default_unseen_type;
1752 }
1753
1754 # Auto create special folders
1755 sub command214 {
1756 print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1757 print "automatically print for you when a user logs in? If the user\n";
1758 print "accidentally deletes their special folders, this option will\n";
1759 print "automatically create it again for them.\n";
1760 print "\n";
1761
1762 if ( lc($auto_create_special) eq 'true' ) {
1763 $default_value = "y";
1764 } else {
1765 $default_value = "n";
1766 }
1767 print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1768 $new_show = <STDIN>;
1769 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1770 $auto_create_special = 'true';
1771 } else {
1772 $auto_create_special = 'false';
1773 }
1774 return $auto_create_special;
1775 }
1776
1777 # Automatically delete folders
1778 sub command215 {
1779 if ( $imap_server_type eq "uw" ) {
1780 print "UW IMAP servers will not allow folders containing mail to also contain folders.\n";
1781 print "Deleting folders will bypass the trash folder and be immediately deleted\n\n";
1782 print "If this is not the correct value for your server,\n";
1783 print "please use option D on the Main Menu to configure your server correctly.\n\n";
1784 print "Press any key to continue...\n";
1785 $new_delete = <STDIN>;
1786 $delete_folder = 'true';
1787 } else {
1788 if ( $imap_server_type eq "courier" ) {
1789 print "Courier (or Courier-IMAP) IMAP servers may not support ";
1790 print "subfolders of Trash. \n";
1791 print "Specifically, if Courier is set to always move messages to Trash, \n";
1792 print "Trash will be treated by Courier as a special folder that does not \n";
1793 print "allow subfolders. \n\n";
1794 print "Please verify your Courier configuration, and test folder deletion \n";
1795 print "when changing this setting.\n\n";
1796 }
1797
1798 print "Are subfolders of the Trash supported by your IMAP server?\n";
1799 print "If so, should deleted folders be sent to Trash?\n";
1800 print "If not, say no (deleted folders should not be sent to Trash)\n\n";
1801 # reversal of logic.
1802 # question was: Should folders be automatically deleted instead of sent to trash..
1803 # we've changed the question to make it more clear,
1804 # and are here handling that to avoid changing the answers..
1805 if ( lc($delete_folder) eq 'true' ) {
1806 $default_value = "n";
1807 } else {
1808 $default_value = "y";
1809 }
1810 print "Send deleted folders to Trash? (y/n) [$WHT$default_value$NRM]: $WHT";
1811 $new_delete = <STDIN>;
1812 if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1813 $delete_folder = 'false';
1814 } else {
1815 $delete_folder = 'true';
1816 }
1817 }
1818 return $delete_folder;
1819 }
1820
1821 #noselect fix
1822 sub command216 {
1823 print "Some IMAP server allow subfolders to exist even if the parent\n";
1824 print "folders do not. This fixes some problems with the folder list\n";
1825 print "when this is the case, causing the /NoSelect folders to be displayed\n";
1826 print "\n";
1827
1828 if ( lc($noselect_fix_enable) eq 'true' ) {
1829 $default_value = "y";
1830 } else {
1831 $default_value = "n";
1832 }
1833 print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
1834 $noselect_fix_enable = <STDIN>;
1835 if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1836 $noselect_fix_enable = 'true';
1837 } else {
1838 $noselect_fix_enable = 'false';
1839 }
1840 return $noselect_fix_enable;
1841 }
1842 ############# GENERAL OPTIONS #####################
1843
1844 # Data directory
1845 sub command33a {
1846 print "Specify the location for your data directory.\n";
1847 print "The path name can be absolute or relative (to the config directory).\n";
1848 print "It doesn't matter. Here are two examples:\n";
1849 print " Absolute: /var/spool/data/\n";
1850 print " Relative: ../data/\n";
1851 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1852 print "will be converted to their absolute path equivalents in config.php.\n\n";
1853 print "Note: There are potential security risks with having a writeable directory\n";
1854 print "under the web server's root directory (ex: /home/httpd/html).\n";
1855 print "For this reason, it is recommended to put the data directory\n";
1856 print "in an alternate location of your choice. \n";
1857 print "\n";
1858
1859 print "[$WHT$data_dir$NRM]: $WHT";
1860 $new_data_dir = <STDIN>;
1861 if ( $new_data_dir eq "\n" ) {
1862 $new_data_dir = $data_dir;
1863 } else {
1864 $new_data_dir =~ s/[\r|\n]//g;
1865 }
1866 if ( $new_data_dir =~ /^\s*$/ ) {
1867 $new_data_dir = "";
1868 } else {
1869 $new_data_dir =~ s/\/*$//g;
1870 $new_data_dir =~ s/$/\//g;
1871 }
1872 return $new_data_dir;
1873 }
1874
1875 # Attachment directory
1876 sub command33b {
1877 print "Path to directory used for storing attachments while a mail is\n";
1878 print "being sent. The path name can be absolute or relative (to the config directory).\n";
1879 print "It doesn't matter. Here are two examples:\n";
1880 print " Absolute: /var/spool/attach/\n";
1881 print " Relative: ../attach/\n";
1882 print "Relative paths to directories outside of the SquirrelMail distribution\n";
1883 print "will be converted to their absolute path equivalents in config.php.\n\n";
1884 print "Note: There are a few security considerations regarding this\n";
1885 print "directory:\n";
1886 print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
1887 print " impossible for a random person with access to the webserver\n";
1888 print " to list files in this directory. Confidential data might\n";
1889 print " be laying around in there.\n";
1890 print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
1891 print " may be possible, and more secure (e.g. root:apache)\n";
1892 print " 2. Since the webserver is not able to list the files in the\n";
1893 print " content is also impossible for the webserver to delete files\n";
1894 print " lying around there for too long.\n";
1895 print " 3. It should probably be another directory than the data\n";
1896 print " directory specified in option 3.\n";
1897 print "\n";
1898
1899 print "[$WHT$attachment_dir$NRM]: $WHT";
1900 $new_attachment_dir = <STDIN>;
1901 if ( $new_attachment_dir eq "\n" ) {
1902 $new_attachment_dir = $attachment_dir;
1903 } else {
1904 $new_attachment_dir =~ s/[\r|\n]//g;
1905 }
1906 if ( $new_attachment_dir =~ /^\s*$/ ) {
1907 $new_attachment_dir = "";
1908 } else {
1909 $new_attachment_dir =~ s/\/*$//g;
1910 $new_attachment_dir =~ s/$/\//g;
1911 }
1912 return $new_attachment_dir;
1913 }
1914
1915 sub command33c {
1916 print "The directory hash level setting allows you to configure the level\n";
1917 print "of hashing that Squirremail employs in your data and attachment\n";
1918 print "directories. This value must be an integer ranging from 0 to 4.\n";
1919 print "When this value is set to 0, Squirrelmail will simply store all\n";
1920 print "files as normal in the data and attachment directories. However,\n";
1921 print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
1922 print "used to organize the files in this directory. In short, the crc32\n";
1923 print "value for a username will be computed. Then, up to the first 4\n";
1924 print "digits of the hash, as set by this configuration value, will be\n";
1925 print "used to directory hash the files for that user in the data and\n";
1926 print "attachment directory. This allows for better performance on\n";
1927 print "servers with larger numbers of users.\n";
1928 print "\n";
1929
1930 print "[$WHT$dir_hash_level$NRM]: $WHT";
1931 $new_dir_hash_level = <STDIN>;
1932 if ( $new_dir_hash_level eq "\n" ) {
1933 $new_dir_hash_level = $dir_hash_level;
1934 } else {
1935 $new_dir_hash_level =~ s/[\r|\n]//g;
1936 }
1937 if ( ( int($new_dir_hash_level) < 0 )
1938 || ( int($new_dir_hash_level) > 4 )
1939 || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
1940 print "Invalid Directory Hash Level.\n";
1941 print "Value must be an integer ranging from 0 to 4\n";
1942 print "Hit enter to continue.\n";
1943 $enter_key = <STDIN>;
1944
1945 $new_dir_hash_level = $dir_hash_level;
1946 }
1947
1948 return $new_dir_hash_level;
1949 }
1950
1951 sub command35 {
1952 print "This is the default size (in pixels) of the left folder list.\n";
1953 print "Default is 200, but you can set it to whatever you wish. This\n";
1954 print "is a user preference, so this will only show up as their default.\n";
1955 print "\n";
1956 print "[$WHT$default_left_size$NRM]: $WHT";
1957 $new_default_left_size = <STDIN>;
1958 if ( $new_default_left_size eq "\n" ) {
1959 $new_default_left_size = $default_left_size;
1960 } else {
1961 $new_default_left_size =~ s/[\r|\n]//g;
1962 }
1963 return $new_default_left_size;
1964 }
1965
1966 sub command36 {
1967 print "Some IMAP servers only have lowercase letters in the usernames\n";
1968 print "but they still allow people with uppercase to log in. This\n";
1969 print "causes a problem with the user's preference files. This option\n";
1970 print "transparently changes all usernames to lowercase.";
1971 print "\n";
1972
1973 if ( lc($force_username_lowercase) eq 'true' ) {
1974 $default_value = "y";
1975 } else {
1976 $default_value = "n";
1977 }
1978 print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
1979 $new_show = <STDIN>;
1980 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1981 return 'true';
1982 }
1983 return 'false';
1984 }
1985
1986 sub command37 {
1987 print "";
1988 print "\n";
1989
1990 if ( lc($default_use_priority) eq 'true' ) {
1991 $default_value = "y";
1992 } else {
1993 $default_value = "n";
1994 }
1995
1996 print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
1997 $new_show = <STDIN>;
1998 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1999 return 'true';
2000 }
2001 return 'false';
2002 }
2003
2004 sub command38 {
2005 print "";
2006 print "\n";
2007
2008 if ( lc($default_hide_attribution) eq 'true' ) {
2009 $default_value = "y";
2010 } else {
2011 $default_value = "n";
2012 }
2013
2014 print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
2015 $new_show = <STDIN>;
2016 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2017 return 'true';
2018 }
2019 return 'false';
2020 }
2021
2022 sub command39 {
2023 print "";
2024 print "\n";
2025
2026 if ( lc($default_use_mdn) eq 'true' ) {
2027 $default_value = "y";
2028 } else {
2029 $default_value = "n";
2030 }
2031
2032 print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
2033 $new_show = <STDIN>;
2034 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2035 return 'true';
2036 }
2037 return 'false';
2038 }
2039
2040 sub command310 {
2041 print "This allows you to prevent the editing of the user's name and ";
2042 print "email address. This is mainly useful when used with the ";
2043 print "retrieveuserdata plugin\n";
2044 print "\n";
2045
2046 if ( lc($edit_identity) eq 'true' ) {
2047 $default_value = "y";
2048 } else {
2049 $default_value = "n";
2050 }
2051 print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
2052 $new_edit = <STDIN>;
2053 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2054 $edit_identity = 'true';
2055 $edit_name = 'true';
2056 } else {
2057 $edit_identity = 'false';
2058 $edit_name = command311();
2059 }
2060 return $edit_identity;
2061 }
2062
2063 sub command311 {
2064 print "As a follow-up, this option allows you to choose if the user ";
2065 print "can edit their full name even when you don't want them to ";
2066 print "change their username\n";
2067 print "\n";
2068
2069 if ( lc($edit_name) eq 'true' ) {
2070 $default_value = "y";
2071 } else {
2072 $default_value = "n";
2073 }
2074 print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
2075 $new_edit = <STDIN>;
2076 if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2077 $edit_name = 'true';
2078 } else {
2079 $edit_name = 'false';
2080 }
2081 return $edit_name;
2082 }
2083
2084 sub command312 {
2085 print "This option allows you to choose if users can use thread sorting\n";
2086 print "Your IMAP server must support the THREAD command for this to work\n";
2087 print "PHP versions later than 4.0.3 recommended\n";
2088 print "\n";
2089
2090 if ( lc($allow_thread_sort) eq 'true' ) {
2091 $default_value = "y";
2092 } else {
2093 $default_value = "n";
2094 }
2095 print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2096 $allow_thread_sort = <STDIN>;
2097 if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2098 $allow_thread_sort = 'true';
2099 } else {
2100 $allow_thread_sort = 'false';
2101 }
2102 return $allow_thread_sort;
2103 }
2104
2105 sub command313 {
2106 print "This option allows you to choose if SM uses server-side sorting\n";
2107 print "Your IMAP server must support the SORT command for this to work\n";
2108 print "\n";
2109
2110 if ( lc($allow_server_sort) eq 'true' ) {
2111 $default_value = "y";
2112 } else {
2113 $default_value = "n";
2114 }
2115 print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2116 $allow_server_sort = <STDIN>;
2117 if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2118 $allow_server_sort = 'true';
2119 } else {
2120 $allow_server_sort = 'false';
2121 }
2122 return $allow_server_sort;
2123 }
2124
2125 sub command314 {
2126 print "This option allows you to choose if SM uses charset search\n";
2127 print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2128 print "\n";
2129
2130 if ( lc($allow_charset_search) eq 'true' ) {
2131 $default_value = "y";
2132 } else {
2133 $default_value = "n";
2134 }
2135 print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
2136 $allow_charset_search = <STDIN>;
2137 if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2138 $allow_charset_search = 'true';
2139 } else {
2140 $allow_charset_search = 'false';
2141 }
2142 return $allow_charset_search;
2143 }
2144
2145 # command315 (UID support) obsoleted.
2146
2147 # advanced search option
2148
2149 sub command316 {
2150 print "This option allows you to change the advanced search form.\n";
2151 print "Set to 0 to disable the advanced search, 1 to have advanced\n";
2152 print "and search only or 2 for both forms.\n";
2153 print "[$WHT$allow_advanced_search$NRM]: $WHT";
2154 $allows_advanced_search = <STDIN>;
2155 chomp($allows_advanced_search);
2156 if ( $allows_advanced_search eq "" ) {
2157 $allows_advanced_searchn=0;
2158 }
2159 return $allows_advanced_search;
2160 }
2161
2162
2163 sub command317 {
2164 print "This option allows you to change the name of the PHP session used\n";
2165 print "by SquirrelMail. Unless you know what you are doing, you probably\n";
2166 print "don't need or want to change this from the default of SQMSESSID.\n";
2167 print "[$WHT$session_name$NRM]: $WHT";
2168 $new_session_name = <STDIN>;
2169 chomp($new_session_name);
2170 if ( $new_session_name eq "" ) {
2171 $new_session_name = $session_name;
2172 }
2173 return $new_session_name;
2174 }
2175
2176
2177
2178 sub command41 {
2179 print "\nDefine the themes that you wish to use. If you have added ";
2180 print "a theme of your own, just follow the instructions (?) about how to add ";
2181 print "them. You can also change the default theme.\n";
2182 print "[theme] command (?=help) > ";
2183 $input = <STDIN>;
2184 $input =~ s/[\r|\n]//g;
2185 while ( $input ne "d" ) {
2186 if ( $input =~ /^\s*l\s*/i ) {
2187 $count = 0;
2188 while ( $count <= $#theme_name ) {
2189 if ( $count == $theme_default ) {
2190 print " *";
2191 } else {
2192 print " ";
2193 }
2194 if ( $count < 10 ) {
2195 print " ";
2196 }
2197 $name = $theme_name[$count];
2198 $num_spaces = 35 - length($name);
2199 for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
2200 $name = $name . " ";
2201 }
2202
2203 print " $count. $name";
2204 print "($theme_path[$count])\n";
2205
2206 $count++;
2207 }
2208 } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
2209 $old_def = $theme_default;
2210 $theme_default = $input;
2211 $theme_default =~ s/^\s*m\s*//;
2212 if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
2213 print "Cannot set default theme to $theme_default. That theme does not exist.\n";
2214 $theme_default = $old_def;
2215 }
2216 } elsif ( $input =~ /^\s*\+/ ) {
2217 print "What is the name of this theme: ";
2218 $name = <STDIN>;
2219 $name =~ s/[\r|\n]//g;
2220 $theme_name[ $#theme_name + 1 ] = $name;
2221 print "Be sure to put ../themes/ before the filename.\n";
2222 print "What file is this stored in (ex: ../themes/default_theme.php): ";
2223 $name = <STDIN>;
2224 $name =~ s/[\r|\n]//g;
2225 $theme_path[ $#theme_path + 1 ] = $name;
2226 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2227 if ( $input =~ /[0-9]+\s*$/ ) {
2228 $rem_num = $input;
2229 $rem_num =~ s/^\s*-\s*//g;
2230 $rem_num =~ s/\s*$//;
2231 } else {
2232 $rem_num = $#theme_name;
2233 }
2234 if ( $rem_num == $theme_default ) {
2235 print "You cannot remove the default theme!\n";
2236 } else {
2237 $count = 0;
2238 @new_theme_name = ();
2239 @new_theme_path = ();
2240 while ( $count <= $#theme_name ) {
2241 if ( $count != $rem_num ) {
2242 @new_theme_name = ( @new_theme_name, $theme_name[$count] );
2243 @new_theme_path = ( @new_theme_path, $theme_path[$count] );
2244 }
2245 $count++;
2246 }
2247 @theme_name = @new_theme_name;
2248 @theme_path = @new_theme_path;
2249 if ( $theme_default > $rem_num ) {
2250 $theme_default--;
2251 }
2252 }
2253 } elsif ( $input =~ /^\s*t\s*/i ) {
2254 print "\nStarting detection...\n\n";
2255
2256 opendir( DIR, "../themes" );
2257 @files = grep { /\.php$/i } readdir(DIR);
2258 $cnt = 0;
2259 while ( $cnt <= $#files ) {
2260 $filename = "../themes/" . $files[$cnt];
2261 if ( $filename ne "../themes/index.php" ) {
2262 $found = 0;
2263 for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
2264 if ( $theme_path[$x] eq $filename ) {
2265 $found = 1;
2266 }
2267 }
2268 if ( $found != 1 ) {
2269 print "** Found theme: $filename\n";
2270 print " What is its name? ";
2271 $nm = <STDIN>;
2272 $nm =~ s/[\n|\r]//g;
2273 $theme_name[ $#theme_name + 1 ] = $nm;
2274 $theme_path[ $#theme_path + 1 ] = $filename;
2275 }
2276 }
2277 $cnt++;
2278 }
2279 print "\n";
2280 for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
2281 $filename = $theme_path[$cnt];
2282 if ( !( -e $filename ) ) {
2283 print " Removing $filename (file not found)\n";
2284 $offset = 0;
2285 @new_theme_name = ();
2286 @new_theme_path = ();
2287 for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
2288 if ( $theme_path[$x] eq $filename ) {
2289 $offset = 1;
2290 }
2291 if ( $offset == 1 ) {
2292 $new_theme_name[$x] = $theme_name[ $x + 1 ];
2293 $new_theme_path[$x] = $theme_path[ $x + 1 ];
2294 } else {
2295 $new_theme_name[$x] = $theme_name[$x];
2296 $new_theme_path[$x] = $theme_path[$x];
2297 }
2298 }
2299 @theme_name = @new_theme_name;
2300 @theme_path = @new_theme_path;
2301 }
2302 }
2303 print "\nDetection complete!\n\n";
2304
2305 closedir DIR;
2306 } elsif ( $input =~ /^\s*\?\s*/ ) {
2307 print ".-------------------------.\n";
2308 print "| t (detect themes) |\n";
2309 print "| + (add theme) |\n";
2310 print "| - N (remove theme) |\n";
2311 print "| m N (mark default) |\n";
2312 print "| l (list themes) |\n";
2313 print "| d (done) |\n";
2314 print "`-------------------------'\n";
2315 }
2316 print "[theme] command (?=help) > ";
2317 $input = <STDIN>;
2318 $input =~ s/[\r|\n]//g;
2319 }
2320 }
2321
2322 # Theme - CSS file
2323 sub command42 {
2324 print "You may specify a cascading style-sheet (CSS) file to be included\n";
2325 print "on each html page generated by SquirrelMail. The CSS file is useful\n";
2326 print "for specifying a site-wide font. If you're not familiar with CSS\n";
2327 print "files, leave this blank.\n";
2328 print "\n";
2329 print "To clear out an existing value, just type a space for the input.\n";
2330 print "\n";
2331 print "Please be aware of the following: \n";
2332 print " - Relative URLs are relative to the config dir\n";
2333 print " to use the themes directory, use ../themes/css/newdefault.css\n";
2334 print " - To specify a css file defined outside the SquirrelMail source tree\n";
2335 print " use the absolute URL the webserver would use to include the file\n";
2336 print " e.g. http://some.host.com/css/mystyle.css or /css/mystyle.css\n";
2337 print "\n";
2338 print "[$WHT$theme_css$NRM]: $WHT";
2339 $new_theme_css = <STDIN>;
2340
2341 if ( $new_theme_css eq "\n" ) {
2342 $new_theme_css = $theme_css;
2343 } else {
2344 $new_theme_css =~ s/[\r|\n]//g;
2345 }
2346 $new_theme_css =~ s/^\s*//;
2347 return $new_theme_css;
2348 }
2349
2350 sub command61 {
2351 print "You can now define different LDAP servers.\n";
2352 print "[ldap] command (?=help) > ";
2353 $input = <STDIN>;
2354 $input =~ s/[\r|\n]//g;
2355 while ( $input ne "d" ) {
2356 if ( $input =~ /^\s*l\s*/i ) {
2357 $count = 0;
2358 while ( $count <= $#ldap_host ) {
2359 print "$count. $ldap_host[$count]\n";
2360 print " base: $ldap_base[$count]\n";
2361 if ( $ldap_charset[$count] ) {
2362 print " charset: $ldap_charset[$count]\n";
2363 }
2364 if ( $ldap_port[$count] ) {
2365 print " port: $ldap_port[$count]\n";
2366 }
2367 if ( $ldap_name[$count] ) {
2368 print " name: $ldap_name[$count]\n";
2369 }
2370 if ( $ldap_maxrows[$count] ) {
2371 print " maxrows: $ldap_maxrows[$count]\n";
2372 }
2373 if ( $ldap_binddn[$count] ) {
2374 print " binddn: $ldap_binddn[$count]\n";
2375 if ( $ldap_bindpw[$count] ) {
2376 print " bindpw: $ldap_bindpw[$count]\n";
2377 }
2378 }
2379 if ( $ldap_protocol[$count] ) {
2380 print " protocol: $ldap_protocol[$count]\n";
2381 }
2382
2383 print "\n";
2384 $count++;
2385 }
2386 } elsif ( $input =~ /^\s*\+/ ) {
2387 $sub = $#ldap_host + 1;
2388
2389 print "First, we need to have the hostname or the IP address where\n";
2390 print "this LDAP server resides. Example: ldap.bigfoot.com\n";
2391 print "hostname: ";
2392 $name = <STDIN>;
2393 $name =~ s/[\r|\n]//g;
2394 $ldap_host[$sub] = $name;
2395
2396 print "\n";
2397
2398 print "Next, we need the server root (base dn). For this, an empty\n";
2399 print "string is allowed.\n";
2400 print "Example: ou=member_directory,o=netcenter.com\n";
2401 print "base: ";
2402 $name = <STDIN>;
2403 $name =~ s/[\r|\n]//g;
2404 $ldap_base[$sub] = $name;
2405
2406 print "\n";
2407
2408 print "This is the TCP/IP port number for the LDAP server. Default\n";
2409 print "port is 389. This is optional. Press ENTER for default.\n";
2410 print "port: ";
2411 $name = <STDIN>;
2412 $name =~ s/[\r|\n]//g;
2413 $ldap_port[$sub] = $name;
2414
2415 print "\n";
2416
2417 print "This is the charset for the server. Default is utf-8. This\n";
2418 print "is also optional. Press ENTER for default.\n";
2419 print "charset: ";
2420 $name = <STDIN>;
2421 $name =~ s/[\r|\n]//g;
2422 $ldap_charset[$sub] = $name;
2423
2424 print "\n";
2425
2426 print "This is the name for the server, used to tag the results of\n";
2427 print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
2428 print "name: ";
2429 $name = <STDIN>;
2430 $name =~ s/[\r|\n]//g;
2431 $ldap_name[$sub] = $name;
2432
2433 print "\n";
2434
2435 print "You can specify the maximum number of rows in the search result.\n";
2436 print "Default is unlimited. Press ENTER for default.\n";
2437 print "maxrows: ";
2438 $name = <STDIN>;
2439 $name =~ s/[\r|\n]//g;
2440 $ldap_maxrows[$sub] = $name;
2441
2442 print "\n";
2443
2444 print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
2445 print "Default is none, anonymous bind. Press ENTER for default.\n";
2446 print "binddn: ";
2447 $name = <STDIN>;
2448 $name =~ s/[\r|\n]//g;
2449 $ldap_binddn[$sub] = $name;
2450
2451 print "\n";
2452
2453 if ( $ldap_binddn[$sub] ne '' ) {
2454
2455 print "Now, please specify password for that DN.\n";
2456 print "bindpw: ";
2457 $name = <STDIN>;
2458 $name =~ s/[\r|\n]//g;
2459 $ldap_bindpw[$sub] = $name;
2460
2461 print "\n";
2462 }
2463
2464 print "You can specify bind protocol version here.\n";
2465 print "Default protocol version depends on your php ldap settings.\n";
2466 print "Press ENTER for default.\n";
2467 print "protocol: ";
2468 $name = <STDIN>;
2469 $name =~ s/[\r|\n]//g;
2470 $ldap_protocol[$sub] = $name;
2471
2472 print "\n";
2473
2474 } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2475 if ( $input =~ /[0-9]+\s*$/ ) {
2476 $rem_num = $input;
2477 $rem_num =~ s/^\s*-\s*//g;
2478 $rem_num =~ s/\s*$//;
2479 } else {
2480 $rem_num = $#ldap_host;
2481 }
2482 $count = 0;
2483 @new_ldap_host = ();
2484 @new_ldap_base = ();
2485 @new_ldap_port = ();
2486 @new_ldap_name = ();
2487 @new_ldap_charset = ();
2488 @new_ldap_maxrows = ();
2489 @new_ldap_bindpw = ();
2490 @new_ldap_binddn = ();
2491 @new_ldap_protocol = ();
2492
2493 while ( $count <= $#ldap_host ) {
2494 if ( $count != $rem_num ) {
2495 @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
2496 @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
2497 @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
2498 @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
2499 @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
2500 @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
2501 @new_ldap_binddn = ( @new_ldap_binddn, $ldap_binddn[$count] );
2502 @new_ldap_bindpw = ( @new_ldap_bindpw, $ldap_bindpw[$count] );
2503 @new_ldap_protocol = ( @new_ldap_protocol, $ldap_protocol[$count] );
2504 }
2505 $count++;
2506 }
2507 @ldap_host = @new_ldap_host;
2508 @ldap_base = @new_ldap_base;
2509 @ldap_port = @new_ldap_port;
2510 @ldap_name = @new_ldap_name;
2511 @ldap_charset = @new_ldap_charset;
2512 @ldap_maxrows = @new_ldap_maxrows;
2513 @ldap_binddn = @new_ldap_binddn;
2514 @ldap_bindpw = @new_ldap_bindpw;
2515 @ldap_protocol = @new_ldap_protocol;
2516
2517 } elsif ( $input =~ /^\s*\?\s*/ ) {
2518 print ".-------------------------.\n";
2519 print "| + (add host) |\n";
2520 print "| - N (remove host) |\n";
2521 print "| l (list hosts) |\n";
2522 print "| d (done) |\n";
2523 print "`-------------------------'\n";
2524 }
2525 print "[ldap] command (?=help) > ";
2526 $input = <STDIN>;
2527 $input =~ s/[\r|\n]//g;
2528 }
2529 }
2530
2531 sub command62 {
2532 print "Some of our developers have come up with very good javascript interface\n";
2533 print "for searching through address books, however, our original goals said\n";
2534 print "that we would be 100% HTML. In order to make it possible to use their\n";
2535 print "interface, and yet stick with our goals, we have also written a plain\n";
2536 print "HTML version of the search. Here, you can choose which version to use.\n";
2537 print "\n";
2538 print "This is just the default value. It is also a user option that each\n";
2539 print "user can configure individually\n";
2540 print "\n";
2541
2542 if ( lc($default_use_javascript_addr_book) eq 'true' ) {
2543 $default_value = "y";
2544 } else {
2545 $default_use_javascript_addr_book = 'false';
2546 $default_value = "n";
2547 }
2548 print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
2549 $new_show = <STDIN>;
2550 if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2551 $default_use_javascript_addr_book = 'true';
2552 } else {
2553 $default_use_javascript_addr_book = 'false';
2554 }
2555 return $default_use_javascript_addr_book;
2556 }
2557
2558 sub command91 {
2559 print "If you want to store your users address book details in a database then\n";
2560 print "you need to set this DSN to a valid value. The format for this is:\n";
2561 print "mysql://user:pass\@hostname/dbname\n";
2562 print "Where mysql can be one of the databases PHP supports, the most common\n";
2563 print "of these are mysql, msql and pgsql\n";
2564 print "If the DSN is left empty (hit space and then return) the database\n";
2565 print "related code for address books will not be used\n";
2566 print "\n";
2567
2568 if ( $addrbook_dsn eq "" ) {
2569 $default_value = "Disabled";
2570 } else {
2571 $default_value = $addrbook_dsn;
2572 }
2573 print "[$WHT$addrbook_dsn$NRM]: $WHT";
2574 $new_dsn = <STDIN>;
2575 if ( $new_dsn eq "\n" ) {
2576 $new_dsn = "";
2577 } else {
2578 $new_dsn =~ s/[\r|\n]//g;
2579 $new_dsn =~ s/^\s+$//g;
2580 }
2581 return $new_dsn;
2582 }
2583
2584 sub command92 {
2585 print "This is the name of the table you want to store the address book\n";
2586 print "data in, it defaults to 'address'\n";
2587 print "\n";
2588 print "[$WHT$addrbook_table$NRM]: $WHT";
2589 $new_table = <STDIN>;
2590 if ( $new_table eq "\n" ) {
2591 $new_table = $addrbook_table;
2592 } else {
2593 $new_table =~ s/[\r|\n]//g;
2594 }
2595 return $new_table;
2596 }
2597
2598 sub command93 {
2599 print "If you want to store your users preferences in a database then\n";
2600 print "you need to set this DSN to a valid value. The format for this is:\n";
2601 print "mysql://user:pass\@hostname/dbname\n";
2602 print "Where mysql can be one of the databases PHP supports, the most common\n";
2603 print "of these are mysql, msql and pgsql\n";
2604 print "If the DSN is left empty (hit space and then return) the database\n";
2605 print "related code for address books will not be used\n";
2606 print "\n";
2607
2608 if ( $prefs_dsn eq "" ) {
2609 $default_value = "Disabled";
2610 } else {
2611 $default_value = $prefs_dsn;
2612 }
2613 print "[$WHT$prefs_dsn$NRM]: $WHT";
2614 $new_dsn = <STDIN>;
2615 if ( $new_dsn eq "\n" ) {
2616 $new_dsn = "";
2617 } else {
2618 $new_dsn =~ s/[\r|\n]//g;
2619 $new_dsn =~ s/^\s+$//g;
2620 }
2621 return $new_dsn;
2622 }
2623
2624 sub command94 {
2625 print "This is the name of the table you want to store the preferences\n";
2626 print "data in, it defaults to 'userprefs'\n";
2627 print "\n";
2628 print "[$WHT$prefs_table$NRM]: $WHT";
2629 $new_table = <STDIN>;
2630 if ( $new_table eq "\n" ) {
2631 $new_table = $prefs_table;
2632 } else {
2633 $new_table =~ s/[\r|\n]//g;
2634 }
2635 return $new_table;
2636 }
2637
2638 sub command95 {
2639 print "This is the name of the field in which you want to store the\n";
2640 print "username of the person the prefs are for. It default to 'user'\n";
2641 print "which clashes with a reserved keyword in PostgreSQL so this\n";
2642 print "will need to be changed for that database at least\n";
2643 print "\n";
2644 print "[$WHT$prefs_user_field$NRM]: $WHT";
2645 $new_field = <STDIN>;
2646 if ( $new_field eq "\n" ) {
2647 $new_field = $prefs_user_field;
2648 } else {
2649 $new_field =~ s/[\r|\n]//g;
2650 }
2651 return $new_field;
2652 }
2653
2654 sub command96 {
2655 print "This is the name of the field in which you want to store the\n";
2656 print "preferences keyword. It defaults to 'prefkey'\n";
2657 print "\n";
2658 print "[$WHT$prefs_key_field$NRM]: $WHT";
2659 $new_field = <STDIN>;
2660 if ( $new_field eq "\n" ) {
2661 $new_field = $prefs_key_field;
2662 } else {
2663 $new_field =~ s/[\r|\n]//g;
2664 }
2665 return $new_field;
2666 }
2667
2668 sub command97 {
2669 print "This is the name of the field in which you want to store the\n";
2670 print "preferences value. It defaults to 'prefval'\n";
2671 print "\n";
2672 print "[$WHT$prefs_val_field$NRM]: $WHT";
2673 $new_field = <STDIN>;
2674 if ( $new_field eq "\n" ) {
2675 $new_field = $prefs_val_field;
2676 } else {
2677 $new_field =~ s/[\r|\n]//g;
2678 }
2679 return $new_field;
2680 }
2681
2682 sub command98 {
2683 print "If you want to store your global address book in a database then\n";
2684 print "you need to set this DSN to a valid value. The format for this is:\n";
2685 print "mysql://user:pass\@hostname/dbname\n";
2686 print "Where mysql can be one of the databases PHP supports, the most common\n";
2687 print "of these are mysql, msql and pgsql\n";
2688 print "If the DSN is left empty (hit space and then return) the database\n";
2689 print "related code for global SQL address book will not be used\n";
2690 print "\n";
2691
2692 if ( $addrbook_global_dsn eq "" ) {
2693 $default_value = "Disabled";
2694 } else {
2695 $default_value = $addrbook_global_dsn;
2696 }
2697 print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
2698 $new_dsn = <STDIN>;
2699 if ( $new_dsn eq "\n" ) {
2700 $new_dsn = "";
2701 } else {
2702 $new_dsn =~ s/[\r|\n]//g;
2703 $new_dsn =~ s/^\s+$//g;
2704 }
2705 return $new_dsn;
2706 }
2707
2708 sub command99 {
2709 print "This is the name of the table you want to store the global address book\n";
2710 print "data in, it defaults to 'global_address'\n";
2711 print "\n";
2712 print "[$WHT$addrbook_global_table$NRM]: $WHT";
2713 $new_table = <STDIN>;
2714 if ( $new_table eq "\n" ) {
2715 $new_table = $addrbook_global_table;
2716 } else {
2717 $new_table =~ s/[\r|\n]//g;
2718 }
2719 return $new_table;
2720 }
2721
2722 sub command910 {
2723 print "This option controls users\' ability to add or modify records stored \n";
2724 print "in global address book\n";
2725
2726 if ( lc($addrbook_global_writeable) eq 'true' ) {
2727 $default_value = "y";
2728 } else {
2729 $default_value = "n";
2730 }
2731 print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2732 $addrbook_global_writeable = <STDIN>;
2733 if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2734 $addrbook_global_writeable = 'true';
2735 } else {
2736 $addrbook_global_writeable = 'false';
2737 }
2738 return $addrbook_global_writeable;
2739 }
2740
2741 sub command911 {
2742 print "Enable this option if you want to see listing of addresses stored \n";
2743 print "in global address book\n";
2744
2745 if ( lc($addrbook_global_listing) eq 'true' ) {
2746 $default_value = "y";
2747 } else {
2748 $default_value = "n";
2749 }
2750 print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
2751 $addrbook_global_listing = <STDIN>;
2752 if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2753 $addrbook_global_listing = 'true';
2754 } else {
2755 $addrbook_global_listing = 'false';
2756 }
2757 return $addrbook_global_listing;
2758 }
2759
2760
2761 # Default language
2762 sub commandA1 {
2763 print "SquirrelMail attempts to set the language in many ways. If it\n";
2764 print "can not figure it out in another way, it will default to this\n";
2765 print "language. Please use the code for the desired language.\n";
2766 print "\n";
2767 print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
2768 $new_squirrelmail_default_language = <STDIN>;
2769 if ( $new_squirrelmail_default_language eq "\n" ) {
2770 $new_squirrelmail_default_language = $squirrelmail_default_language;
2771 } else {
2772 $new_squirrelmail_default_language =~ s/[\r|\n]//g;
2773 $new_squirrelmail_default_language =~ s/^\s+$//g;
2774 }
2775 return $new_squirrelmail_default_language;
2776 }
2777 # Default Charset
2778 sub commandA2 {
2779 # print "This option controls what character set is used when sending\n";
2780 # print "mail and when sending HTML to the browser. Do not set this\n";
2781 # print "to US-ASCII, use ISO-8859-1 instead. For cyrillic, it is best\n";
2782 # print "to use KOI8-R, since this implementation is faster than most\n";
2783 # print "of the alternatives\n";
2784 print "This option is obsolate. Default charset depends on language\n";
2785 print "you have selected in \"Default language\" option.\n";
2786 print "\n";
2787
2788 print "[$WHT$default_charset$NRM]: $WHT";
2789 $new_default_charset = <STDIN>;
2790 if ( $new_default_charset eq "\n" ) {
2791 $new_default_charset = $default_charset;
2792 } else {
2793 $new_default_charset =~ s/[\r|\n]//g;
2794 }
2795 return $new_default_charset;
2796 }
2797 # Alternative language names
2798 sub commandA3 {
2799 print "Enable this option if you want to see localized language names in\n";
2800 print "language selection box. Note, that if don't limit list of available\n";
2801 print "languages, this option can trigger installation of foreign language\n";
2802 print "support modules in some browsers.\n";
2803 print "\n";
2804
2805 if ( lc($show_alternative_names) eq 'true' ) {
2806 $default_value = "y";
2807 } else {
2808 $default_value = "n";
2809 }
2810 print "Show alternative language names? (y/n) [$WHT$default_value$NRM]: $WHT";
2811 $show_alternative_names = <STDIN>;
2812 if ( ( $show_alternative_names =~ /^y\n/i ) || ( ( $show_alternative_names =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2813 $show_alternative_names = 'true';
2814 } else {
2815 $show_alternative_names = 'false';
2816 }
2817 return $show_alternative_names;
2818 }
2819 # Available languages
2820 sub commandA4 {
2821 print "This option allows to limit number of languages available in\n";
2822 print "language selection box. You can enter as code of every language that\n";
2823 print "you want to enable. Language codes should be separated by space. If you\n";
2824 print "enter name unsupported by SquirrelMail, it will be ignored. If you enter\n";
2825 print "special key \'all\' - all languages available in SquirrelMail will be\n";
2826 print "listed. If you enter special key \'none\' - user won't be able to change";
2827 print "language and interface will use language set it \"Default language\" option.\n";
2828 print "\n";
2829 print "Valid language names are:\n";
2830 print " ar (Arabic), bg_BG (Bulgarian), ca_ES (Catalan), cy_GB (Welsh)\n";
2831 print " cs_CZ (Chech), da_DK (Danish), de_DE (German), el_GR (Greek),\n";
2832 print " en_US (English), es_ES (Spanish), et_EE (Estonian), fi_FI (Finnish),\n";
2833 print " fo_FO (Faroese), fr_FR (French), he_IL (Hebrew), hr_HR (Croatian),\n";
2834 print " hu_HU (Hungarian), id_ID (Indonesian), is_IS (Icelandic), it_IT (Italian),\n";
2835 print " ja_JP (Japanese), ko_KR (Korean), lt_LT (Lithuanian), ms_MY (Malay),\n";
2836 print " nl_NL (Dutch), nn_NO (Norwegian (Nynorsk)), no_NO (Norwegian (Bokmal)),\n";
2837 print " pl_PL (Polish), pt_BR (Portuguese (Brazil)), pt_PT (Portuguese (Portugal)),\n";
2838 print " ro_RO (Romanian), ru_RU (Russian), sk_SK (Slovak), sl_SI (Slovenian),\n";
2839 print " sr_YU (Serbian), sv_SE (Swedish), th_TH (Thai), tr_TR (Turkish),\n";
2840 print " zh_CN (Chinese Simplified), zh_TW (Chinese Traditional).\n";
2841 print "\n";
2842 print "[$WHT$available_languages$NRM]: $WHT";
2843 $new_available_languages = <STDIN>;
2844 if ( $new_available_languages eq "\n" ) {
2845 $new_available_languages = $available_languages;
2846 } else {
2847 $new_available_languages =~ s/[\r|\n]//g;
2848 $new_available_languages =~ s/^\s+$//g;
2849 }
2850 return $new_available_languages;
2851 }
2852 # Agresive decoding
2853 sub commandA5 {
2854 print "Enable this option if you want to use CPU and memory intensive decoding\n";
2855 print "functions. This option allows reading multibyte charset, that are used\n";
2856 print "in Eastern Asia. SquirrelMail will try to use recode functions here,\n";
2857 print "even when you have disabled use of recode in Tweaks section.\n";
2858 print "\n";
2859
2860 if ( lc($agresive_decoding) eq 'true' ) {
2861 $default_value = "y";
2862 } else {
2863 $default_value = "n";
2864 }
2865 print "Use agresive decoding? (y/n) [$WHT$default_value$NRM]: $WHT";
2866 $agresive_decoding = <STDIN>;
2867 if ( ( $agresive_decoding =~ /^y\n/i ) || ( ( $agresive_decoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2868 $agresive_decoding = 'true';
2869 } else {
2870 $agresive_decoding = 'false';
2871 }
2872 return $agresive_decoding;
2873 }
2874
2875 # Advanced tree
2876 sub commandB1 {
2877 print "Enable this option if you want to use DHTML based folder listing.\n";
2878 print "Code is experimental, works only with some browsers and there might\n";
2879 print "be some glitches.\n";
2880 print "\n";
2881
2882 if ( lc($advanced_tree) eq 'true' ) {
2883 $default_value = "y";
2884 } else {
2885 $default_value = "n";
2886 }
2887 print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
2888 $advanced_tree = <STDIN>;
2889 if ( ( $advanced_tree =~ /^y\n/i ) || ( ( $advanced_tree =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2890 $advanced_tree = 'true';
2891 } else {
2892 $advanced_tree = 'false';
2893 }
2894 return $advanced_tree;
2895 }
2896 # Oldway
2897 sub commandB2 {
2898 print "Setting \$oldway to false causes left_main.php to use the new\n";
2899 print "experimental way of getting the mailbox-tree.\n";
2900 print "\n";
2901
2902 if ( lc($oldway) eq 'true' ) {
2903 $default_value = "y";
2904 } else {
2905 $default_value = "n";
2906 }
2907 print "Use old way of folder list display? (y/n) [$WHT$default_value$NRM]: $WHT";
2908 $oldway = <STDIN>;
2909 if ( ( $oldway =~ /^y\n/i ) || ( ( $oldway =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2910 $oldway = 'true';
2911 } else {
2912 $oldway = 'false';
2913 }
2914 return $oldway;
2915 }
2916 # use icons
2917 sub commandB3 {
2918 print "Enabling this option will cause icons to be used instead of text\n";
2919 print "markers next to each message in mailbox lists that represent\n";
2920 print "new, read, flagged, and deleted messages, as well as those that\n";
2921 print "have been replied to and forwarded. Icons are also used next to\n";
2922 print "(un)expanded folders in the folder list (Oldway = false). These\n";
2923 print "icons are quite small, but will obviously be more of a resource\n";
2924 print "drain than text markers.\n";
2925 print "\n";
2926
2927 if ( lc($use_icons) eq 'true' ) {
2928 $default_value = "y";
2929 } else {
2930 $default_value = "n";
2931 }
2932 print "Use icons? (y/n) [$WHT$default_value$NRM]: $WHT";
2933 $use_icons = <STDIN>;
2934 if ( ( $use_icons =~ /^y\n/i ) || ( ( $use_icons =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2935 $use_icons = 'true';
2936 } else {
2937 $use_icons = 'false';
2938 }
2939 return $use_icons;
2940 }
2941 # php recode
2942 sub commandB4 {
2943 print "Enable this option if you want to use php recode functions to read\n";
2944 print "emails written in charset that differs from the one that is set in\n";
2945 print "translation selected by user. Code is experimental, it might cause\n";
2946 print "errors, if email contains charset unsupported by recode or if your\n";
2947 print "php does not have recode support.\n";
2948 print "\n";
2949
2950 if ( lc($use_php_recode) eq 'true' ) {
2951 $default_value = "y";
2952 } else {
2953 $default_value = "n";
2954 }
2955 print "Use php recode functions? (y/n) [$WHT$default_value$NRM]: $WHT";
2956 $use_php_recode = <STDIN>;
2957 if ( ( $use_php_recode =~ /^y\n/i ) || ( ( $use_php_recode =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2958 $use_php_recode = 'true';
2959 } else {
2960 $use_php_recode = 'false';
2961 }
2962 return $use_php_recode;
2963 }
2964 # php iconv
2965 sub commandB5 {
2966 print "Enable this option if you want to use php iconv functions to read\n";
2967 print "emails written in charset that differs from the one that is set in\n";
2968 print "translation selected by user. Code is experimental, it works only\n";
2969 print "with translations that use utf-8 charset. Code might cause errors,\n";
2970 print "if email contains charset unsupported by iconv or if your php does\n";
2971 print "not have iconv support.\n";
2972 print "\n";
2973
2974 if ( lc($use_php_iconv) eq 'true' ) {
2975 $default_value = "y";
2976 } else {
2977 $default_value = "n";
2978 }
2979 print "Use php iconv functions? (y/n) [$WHT$default_value$NRM]: $WHT";
2980 $use_php_iconv = <STDIN>;
2981 if ( ( $use_php_iconv =~ /^y\n/i ) || ( ( $use_php_iconv =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2982 $use_php_iconv = 'true';
2983 } else {
2984 $use_php_iconv = 'false';
2985 }
2986 return $use_php_iconv;
2987 }
2988
2989
2990 sub save_data {
2991 $tab = " ";
2992 if ( open( CF, ">config.php" ) ) {
2993 print CF "<?php\n";
2994 print CF "\n";
2995
2996 print CF "/**\n";
2997 print CF " * SquirrelMail Configuration File\n";
2998 print CF " * Created using the configure script, conf.pl\n";
2999 print CF " */\n";
3000 print CF "\n";
3001 print CF "global \$version;\n";
3002
3003 if ($print_config_version) {
3004 print CF "\$config_version = '$print_config_version';\n";
3005 }
3006 # integer
3007 print CF "\$config_use_color = $config_use_color;\n";
3008 print CF "\n";
3009
3010 # string
3011 print CF "\$org_name = \"$org_name\";\n";
3012 # string
3013 print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
3014 $org_logo_width |= 0;
3015 $org_logo_height |= 0;
3016 # string
3017 print CF "\$org_logo_width = '$org_logo_width';\n";
3018 # string
3019 print CF "\$org_logo_height = '$org_logo_height';\n";
3020 # string that can contain variables.
3021 print CF "\$org_title = \"$org_title\";\n";
3022 # string
3023 print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
3024 # string
3025 print CF "\$frame_top = '$frame_top';\n";
3026 print CF "\n";
3027
3028 print CF "\$provider_uri = '$provider_uri';\n";
3029 print CF "\n";
3030
3031 print CF "\$provider_name = '$provider_name';\n";
3032 print CF "\n";
3033
3034 # string that can contain variables
3035 print CF "\$motd = \"$motd\";\n";
3036 print CF "\n";
3037
3038 # string
3039 print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
3040 # string
3041 print CF "\$default_charset = '$default_charset';\n";
3042 # boolean
3043 print CF "\$show_alternative_names = $show_alternative_names;\n";
3044 # string
3045 print CF "\$available_languages = '$available_languages';\n";
3046 # boolean
3047 print CF "\$agresive_decoding = $agresive_decoding;\n";
3048 print CF "\n";
3049
3050 # string
3051 print CF "\$domain = '$domain';\n";
3052 # string
3053 print CF "\$imapServerAddress = '$imapServerAddress';\n";
3054 # integer
3055 print CF "\$imapPort = $imapPort;\n";
3056 # boolean
3057 print CF "\$useSendmail = $useSendmail;\n";
3058 # string
3059 print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
3060 # integer
3061 print CF "\$smtpPort = $smtpPort;\n";
3062 # string
3063 print CF "\$sendmail_path = '$sendmail_path';\n";
3064 # boolean
3065 # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
3066 # boolean
3067 print CF "\$pop_before_smtp = $pop_before_smtp;\n";
3068 # string
3069 print CF "\$imap_server_type = '$imap_server_type';\n";
3070 # boolean
3071 print CF "\$invert_time = $invert_time;\n";
3072 # string
3073 print CF "\$optional_delimiter = '$optional_delimiter';\n";
3074 #boolean
3075 print CF "\$skip_SM_header = $skip_SM_header;\n";
3076 print CF "\n";
3077
3078 # string
3079 print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
3080 # string
3081 print CF "\$trash_folder = '$trash_folder';\n";
3082 # string
3083 print CF "\$sent_folder = '$sent_folder';\n";
3084 # string
3085 print CF "\$draft_folder = '$draft_folder';\n";
3086 # boolean
3087 print CF "\$default_move_to_trash = $default_move_to_trash;\n";
3088 # boolean
3089 print CF "\$default_move_to_sent = $default_move_to_sent;\n";
3090 # boolean
3091 print CF "\$default_save_as_draft = $default_save_as_draft;\n";
3092 # boolean
3093 print CF "\$show_prefix_option = $show_prefix_option;\n";
3094 # boolean
3095 print CF "\$list_special_folders_first = $list_special_folders_first;\n";
3096 # boolean
3097 print CF "\$use_special_folder_color = $use_special_folder_color;\n";
3098 # boolean
3099 print CF "\$auto_expunge = $auto_expunge;\n";
3100 # boolean
3101 print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
3102 # boolean
3103 print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
3104 # integer
3105 print CF "\$default_unseen_notify = $default_unseen_notify;\n";
3106 # integer
3107 print CF "\$default_unseen_type = $default_unseen_type;\n";
3108 # boolean
3109 print CF "\$auto_create_special = $auto_create_special;\n";
3110 # boolean
3111 print CF "\$delete_folder = $delete_folder;\n";
3112 # boolean
3113 print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
3114
3115 print CF "\n";
3116
3117 # string
3118 print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
3119 # string that can contain a variable
3120 print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
3121 # integer
3122 print CF "\$dir_hash_level = $dir_hash_level;\n";
3123 # string
3124 print CF "\$default_left_size = '$default_left_size';\n";
3125 # boolean
3126 print CF "\$force_username_lowercase = $force_username_lowercase;\n";
3127 # boolean
3128 print CF "\$default_use_priority = $default_use_priority;\n";
3129 # boolean
3130 print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
3131 # boolean
3132 print CF "\$default_use_mdn = $default_use_mdn;\n";
3133 # boolean
3134 print CF "\$edit_identity = $edit_identity;\n";
3135 # boolean
3136 print CF "\$edit_name = $edit_name;\n";
3137 # boolean
3138 print CF "\$allow_thread_sort = $allow_thread_sort;\n";
3139 # boolean
3140 print CF "\$allow_server_sort = $allow_server_sort;\n";
3141 # boolean
3142 print CF "\$allow_charset_search = $allow_charset_search;\n";
3143 print CF "\n";
3144
3145 # all plugins are strings
3146 for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
3147 print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
3148 }
3149 print CF "\n";
3150
3151 # strings
3152 print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
3153 if ( $theme_default eq '' ) { $theme_default = '0'; }
3154 print CF "\$theme_default = $theme_default;\n";
3155
3156 for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
3157 print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
3158 print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
3159 }
3160 print CF "\n";
3161
3162 if ( $default_use_javascript_addr_book ne 'true' ) {
3163 $default_use_javascript_addr_book = 'false';
3164 }
3165
3166 # boolean
3167 print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
3168 for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
3169 print CF "\$ldap_server[$count] = array(\n";
3170 # string
3171 print CF " 'host' => '$ldap_host[$count]',\n";
3172 # string
3173 print CF " 'base' => '$ldap_base[$count]'";
3174 if ( $ldap_name[$count] ) {
3175 print CF ",\n";
3176 # string
3177 print CF " 'name' => '$ldap_name[$count]'";
3178 }
3179 if ( $ldap_port[$count] ) {
3180 print CF ",\n";
3181 # integer
3182 print CF " 'port' => $ldap_port[$count]";
3183 }
3184 if ( $ldap_charset[$count] ) {
3185 print CF ",\n";
3186 # string
3187 print CF " 'charset' => '$ldap_charset[$count]'";
3188 }
3189 if ( $ldap_maxrows[$count] ) {
3190 print CF ",\n";
3191 # integer
3192 print CF " 'maxrows' => $ldap_maxrows[$count]";
3193 }
3194 if ( $ldap_binddn[$count] ) {
3195 print CF ",\n";
3196 # string
3197 print CF " 'binddn' => '$ldap_binddn[$count]'";
3198 if ( $ldap_bindpw[$count] ) {
3199 print CF ",\n";
3200 # string
3201 print CF " 'bindpw' => '$ldap_bindpw[$count]'";
3202 }
3203 }
3204 if ( $ldap_protocol[$count] ) {
3205 print CF ",\n";
3206 # integer
3207 print CF " 'protocol' => $ldap_protocol[$count]";
3208 }
3209 print CF "\n";
3210 print CF ");\n";
3211 print CF "\n";
3212 }
3213
3214 # string
3215 print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
3216 # string
3217 print CF "\$addrbook_table = '$addrbook_table';\n\n";
3218 # string
3219 print CF "\$prefs_dsn = '$prefs_dsn';\n";
3220 # string
3221 print CF "\$prefs_table = '$prefs_table';\n";
3222 # string
3223 print CF "\$prefs_user_field = '$prefs_user_field';\n";
3224 # string
3225 print CF "\$prefs_key_field = '$prefs_key_field';\n";
3226 # string
3227 print CF "\$prefs_val_field = '$prefs_val_field';\n\n";
3228 # string
3229 print CF "\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
3230 # string
3231 print CF "\$addrbook_global_table = '$addrbook_global_table';\n";
3232 # boolean
3233 print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n\n";
3234 # boolean
3235 print CF "\$addrbook_global_listing = $addrbook_global_listing;\n\n";
3236 # boolean
3237 print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
3238
3239 # string
3240 print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
3241 # string
3242 print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
3243 # boolean
3244 print CF "\$use_imap_tls = $use_imap_tls;\n";
3245 # boolean
3246 print CF "\$use_smtp_tls = $use_smtp_tls;\n";
3247 # string
3248 print CF "\$session_name = '$session_name';\n";
3249 # string
3250 print CF "\$allow_advanced_search = '$allow_advanced_search';\n";
3251
3252 print CF "\n";
3253
3254 # boolean
3255 print CF "\$advanced_tree = $advanced_tree;\n";
3256 print CF "\n";
3257 # boolean
3258 print CF "\$oldway = $oldway;\n";
3259 print CF "\n";
3260 # boolean
3261 print CF "\$use_icons = $use_icons;\n";
3262 print CF "\n";
3263 # boolean
3264 print CF "\$use_php_recode = $use_php_recode;\n";
3265 print CF "\n";
3266 # boolean
3267 print CF "\$use_php_iconv = $use_php_iconv;\n";
3268 print CF "\n";
3269
3270 print CF "\@include SM_PATH . 'config/config_local.php';\n";
3271
3272 print CF "\n/**\n";
3273 print CF " * Make sure there are no characters after the PHP closing\n";
3274 print CF " * tag below (including newline characters and whitespace).\n";
3275 print CF " * Otherwise, that character will cause the headers to be\n";
3276 print CF " * sent and regular output to begin, which will majorly screw\n";
3277 print CF " * things up when we try to send more headers later.\n";
3278 print CF " */\n";
3279 print CF "?>";
3280
3281 close CF;
3282
3283 print "Data saved in config.php\n";
3284 } else {
3285 print "Error saving config.php: $!\n";
3286 }
3287 }
3288
3289 sub set_defaults {
3290 clear_screen();
3291 print $WHT. "SquirrelMail Configuration : " . $NRM;
3292 if ( $config == 1 ) { print "Read: config.php"; }
3293 elsif ( $config == 2 ) { print "Read: config_default.php"; }
3294 print "\n";
3295 print "---------------------------------------------------------\n";
3296
3297 print "While we have been building SquirrelMail, we have discovered some\n";
3298 print "preferences that work better with some servers that don't work so\n";
3299 print "well with others. If you select your IMAP server, this option will\n";
3300 print "set some pre-defined settings for that server.\n";
3301 print "\n";
3302 print "Please note that you will still need to go through and make sure\n";
3303 print "everything is correct. This does not change everything. There are\n";
3304 print "only a few settings that this will change.\n";
3305 print "\n";
3306
3307 $continue = 0;
3308 while ( $continue != 1 ) {
3309 print "Please select your IMAP server:\n";
3310 print " cyrus = Cyrus IMAP server\n";
3311 print " uw = University of Washington's IMAP server\n";
3312 print " exchange = Microsoft Exchange IMAP server\n";
3313 print " courier = Courier IMAP server\n";
3314 print " macosx = Mac OS X Mailserver\n";
3315 print " mercury32 = Mercury/32\n";
3316 print " quit = Do not change anything\n";
3317 print "Command >> ";
3318 $server = <STDIN>;
3319 $server =~ s/[\r|\n]//g;
3320
3321 print "\n";
3322 if ( $server eq "cyrus" ) {
3323 $imap_server_type = "cyrus";
3324 $default_folder_prefix = "";
3325 $trash_folder = "INBOX.Trash";
3326 $sent_folder = "INBOX.Sent";
3327 $draft_folder = "INBOX.Drafts";
3328 $show_prefix_option = false;
3329 $default_sub_of_inbox = true;
3330 $show_contain_subfolders_option = false;
3331 $optional_delimiter = ".";
3332 $disp_default_folder_prefix = "<none>";
3333 $force_username_lowercase = false;
3334
3335 $continue = 1;
3336 } elsif ( $server eq "uw" ) {
3337 $imap_server_type = "uw";
3338 $default_folder_prefix = "mail/";
3339 $trash_folder = "Trash";
3340 $sent_folder = "Sent";
3341 $draft_folder = "Drafts";
3342 $show_prefix_option = true;
3343 $default_sub_of_inbox = false;
3344 $show_contain_subfolders_option = true;
3345 $optional_delimiter = "/";
3346 $disp_default_folder_prefix = $default_folder_prefix;
3347 $delete_folder = true;
3348 $force_username_lowercase = true;
3349
3350 $continue = 1;
3351 } elsif ( $server eq "exchange" ) {
3352 $imap_server_type = "exchange";
3353 $default_folder_prefix = "";
3354 $default_sub_of_inbox = true;
3355 $trash_folder = "INBOX/Deleted Items";
3356 $sent_folder = "INBOX/Sent Items";
3357 $drafts_folder = "INBOX/Drafts";
3358 $show_prefix_option = false;
3359 $show_contain_subfolders_option = false;
3360 $optional_delimiter = "detect";
3361 $disp_default_folder_prefix = "<none>";
3362 $force_username_lowercase = true;
3363
3364 $continue = 1;
3365 } elsif ( $server eq "courier" ) {
3366 $imap_server_type = "courier";
3367 $default_folder_prefix = "INBOX.";
3368 $trash_folder = "Trash";
3369 $sent_folder = "Sent";
3370 $draft_folder = "Drafts";
3371 $show_prefix_option = false;
3372 $default_sub_of_inbox = false;
3373 $show_contain_subfolders_option = false;
3374 $optional_delimiter = ".";
3375 $disp_default_folder_prefix = $default_folder_prefix;
3376 $delete_folder = true;
3377 $force_username_lowercase = false;
3378
3379 $continue = 1;
3380 } elsif ( $server eq "macosx" ) {
3381 $imap_server_type = "macosx";
3382 $default_folder_prefix = "INBOX/";
3383 $trash_folder = "Trash";
3384 $sent_folder = "Sent";
3385 $draft_folder = "Drafts";
3386 $show_prefix_option = false;
3387 $default_sub_of_inbox = true;
3388 $show_contain_subfolders_option = false;
3389 $optional_delimiter = "detect";
3390 $allow_charset_search = false;
3391 $disp_default_folder_prefix = $default_folder_prefix;
3392
3393 $continue = 1;
3394 } elsif ( $server eq "mercury32" ) {
3395 $imap_server_type = "mercury32";
3396 $default_folder_prefix = "";
3397 $trash_folder = "INBOX.Trash";
3398 $sent_folder = "INBOX.Sent";
3399 $draft_folder = "INBOX.Drafts";
3400 $show_prefix_option = false;
3401 $default_sub_of_inbox = true;
3402 $show_contain_subfolders_option = true;
3403 $optional_delimiter = "detect";
3404 $delete_folder = true;
3405 $force_username_lowercase = true;
3406
3407 $continue = 1;
3408 } elsif ( $server eq "quit" ) {
3409 $continue = 1;
3410 } else {
3411 $disp_default_folder_prefix = $default_folder_prefix;
3412 print "Unrecognized server: $server\n";
3413 print "\n";
3414 }
3415
3416 print " imap_server_type = $imap_server_type\n";
3417 print " default_folder_prefix = $disp_default_folder_prefix\n";
3418 print " trash_folder = $trash_folder\n";
3419 print " sent_folder = $sent_folder\n";
3420 print " draft_folder = $draft_folder\n";
3421 print " show_prefix_option = $show_prefix_option\n";
3422 print " default_sub_of_inbox = $default_sub_of_inbox\n";
3423 print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3424 print " optional_delimiter = $optional_delimiter\n";
3425 print " delete_folder = $delete_folder\n";
3426 print " force_username_lowercase = $force_username_lowercase\n";
3427 }
3428 print "\nPress enter to continue...";
3429 $tmp = <STDIN>;
3430 }
3431
3432 # This subroutine corrects relative paths to ensure they
3433 # will work within the SM space. If the path falls within
3434 # the SM directory tree, the SM_PATH variable will be
3435 # prepended to the path, if not, then the path will be
3436 # converted to an absolute path, e.g.
3437 # '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
3438 # '../../someplace/data' --> '/absolute/path/someplace/data'
3439 # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
3440 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3441 # 'http://whatever/' --> 'http://whatever'
3442 # $some_var/path --> "$some_var/path"
3443 sub change_to_SM_path() {
3444 my ($old_path) = @_;
3445 my $new_path = '';
3446 my @rel_path;
3447 my @abs_path;
3448 my $subdir;
3449
3450 # If the path is absolute, don't bother.
3451 return "\'" . $old_path . "\'" if ( $old_path eq '');
3452 return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ );
3453 return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:\// );
3454 return $old_path if ( $old_path =~ /^\'(\/|http)/ );
3455 return $old_path if ( $old_path =~ /^\'\w:\// );
3456 return $old_path if ( $old_path =~ /^SM_PATH/);
3457
3458 if ( $old_path =~ /^\$/ ) {
3459 # check if it's a single var, or a $var/path combination
3460 # if it's $var/path, enclose in ""
3461 if ( $old_path =~ /\// ) {
3462 return '"'.$old_path.'"';
3463 }
3464 return $old_path;
3465 }
3466
3467 # Remove remaining '
3468 $old_path =~ s/\'//g;
3469
3470 # For relative paths, split on '../'
3471 @rel_path = split(/\.\.\//, $old_path);
3472
3473 if ( $#rel_path > 1 ) {
3474 # more than two levels away. Make it absolute.
3475 @abs_path = split(/\//, $dir);
3476
3477 # Lop off the relative pieces of the absolute path..
3478 for ( $i = 0; $i <= $#rel_path; $i++ ) {
3479 pop @abs_path;
3480 shift @rel_path;
3481 }
3482 push @abs_path, @rel_path;
3483 $new_path = "\'" . join('/', @abs_path) . "\'";
3484 } elsif ( $#rel_path > 0 ) {
3485 # it's within the SM tree, prepend SM_PATH
3486 $new_path = $old_path;
3487 $new_path =~ s/^\.\.\//SM_PATH . \'/;
3488 $new_path .= "\'";
3489 } else {
3490 # Last, it's a relative path without any leading '.'
3491 # Prepend SM_PATH and config, since the paths are
3492 # relative to the config directory
3493 $new_path = "SM_PATH . \'config/" . $old_path . "\'";
3494 }
3495 return $new_path;
3496 }
3497
3498
3499 # Change SM_PATH to admin-friendly version, e.g.:
3500 # SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
3501 # SM_PATH . 'config/some.php' --> 'some.php'
3502 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3503 # 'http://whatever/' --> 'http://whatever'
3504 sub change_to_rel_path() {
3505 my ($old_path) = @_;
3506 my $new_path = $old_path;
3507
3508 if ( $old_path =~ /^SM_PATH/ ) {
3509 $new_path =~ s/^SM_PATH . \'/\.\.\//;
3510 $new_path =~ s/\.\.\/config\///;
3511 }
3512
3513 return $new_path;
3514 }
3515
3516 sub detect_auth_support {
3517 # Attempts to auto-detect if a specific auth mechanism is supported.
3518 # Called by 'command112a' and 'command112b'
3519 # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3520
3521 # Misc setup
3522 use IO::Socket;
3523 my $service = shift;
3524 my $host = shift;
3525 my $mech = shift;
3526 # Sanity checks
3527 if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3528 # Error - wrong # of args
3529 print "BAD ARGS!\n";
3530 return undef;
3531 }
3532
3533 if ($service eq 'SMTP') {
3534 $cmd = "AUTH $mech\n";
3535 $logout = "QUIT\n";
3536 } elsif ($service eq 'IMAP') {
3537 $cmd = "A01 AUTHENTICATE $mech\n";
3538 $logout = "C01 LOGOUT\n";
3539 } else {
3540 # unknown service - whoops.
3541 return undef;
3542 }
3543
3544 # Get this show on the road
3545 my $sock=IO::Socket::INET->new($host);
3546 if (!defined($sock)) {
3547 # Connect failed
3548 return undef;
3549 }
3550 my $discard = <$sock>; # Server greeting/banner - who cares..
3551
3552 if ($service eq 'SMTP') {
3553 # Say hello first..
3554 print $sock "helo $domain\n";
3555 $discard = <$sock>; # Yeah yeah, you're happy to see me..
3556 }
3557 print $sock $cmd;
3558
3559 my $response = <$sock>;
3560 chomp($response);
3561 if (!defined($response)) {
3562 return undef;
3563 }
3564
3565 # So at this point, we have a response, and it is (hopefully) valid.
3566 if ($service eq 'SMTP') {
3567 if (($response =~ /^535/) or ($response =~/^502/)) {
3568 # Not supported
3569 close $sock;
3570 return 'NO';
3571 } elsif ($response =~ /^503/) {
3572 #Something went wrong
3573 return undef;
3574 }
3575 } elsif ($service eq 'IMAP') {
3576 if ($response =~ /^A01/) {
3577 # Not supported
3578 close $sock;
3579 return 'NO';
3580 }
3581 } else {
3582 # Unknown service - this shouldn't be able to happen.
3583 close $sock;
3584 return undef;
3585 }
3586
3587 # If it gets here, the mech is supported
3588 print $sock "*\n"; # Attempt to cancel authentication
3589 print $sock $logout; # Try to log out, but we don't really care if this fails
3590 close $sock;
3591 return 'YES';
3592 }
3593
3594 sub clear_screen() {
3595 if ( $^O =~ /^mswin/i) {
3596 system "cls";
3597 } else {
3598 system "clear";
3599 }
3600 }