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