squirrelmail-webmail  1.4.22
About: SquirrelMail is a standards-based webmail package with strong MIME support, address books, and folder manipulation (written in PHP4).
  Fossies Dox: squirrelmail-webmail-1.4.22.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

conf.pl
Go to the documentation of this file.
1 #!/usr/bin/env perl
2 # conf.pl
3 #
4 # Copyright (c) 1999-2011 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: conf.pl 14111 2011-05-03 07:46:46Z pdontthink $
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  # Make sure that file is readable
50  if (! -r "config.php") {
51  clear_screen();
52  print "WARNING:\n";
53  print "The file \"config/config.php\" was found, but you don't\n";
54  print "have rights to read it.\n";
55  print "\n";
56  print "Press enter to continue";
57  $ctu = <STDIN>;
58  exit;
59  }
60  open( FILE, "config.php" );
61  while ( $line = <FILE> ) {
62  $line =~ s/^\s+//;
63  $line =~ s/^\$//;
64  $var = $line;
65 
66  $var =~ s/=/EQUALS/;
67  if ( $var =~ /^([a-z]|[A-Z])/ ) {
68  @o = split ( /\s*EQUALS\s*/, $var );
69  if ( $o[0] eq "config_version" ) {
70  $o[1] =~ s/[\n|\r]//g;
71  $o[1] =~ s/[\'|\"];\s*$//;
72  $o[1] =~ s/;$//;
73  $o[1] =~ s/^[\'|\"]//;
74 
75  $config_version = $o[1];
76  close(FILE);
77  }
78  }
79  }
80  close(FILE);
81 
82  if ( $config_version ne $conf_pl_version ) {
83  clear_screen();
84  print "WARNING:\n";
85  print " The file \"config/config.php\" was found, but it is for\n";
86  print " an older version of SquirrelMail. It is possible to still\n";
87  print " read the defaults from this file but be warned that many\n";
88  print " preferences change between versions. It is recommended that\n";
89  print " you start with a clean config.php for each upgrade that you\n";
90  print " do. To do this, just move config/config.php out of the way.\n";
91  print "\n";
92  print "Continue loading with the old config.php [y/N]? ";
93  $ctu = <STDIN>;
94 
95  if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
96  exit;
97  }
98 
99  print "\nDo you want me to stop warning you [y/N]? ";
100  $ctu = <STDIN>;
101  if ( $ctu =~ /^y\n/i ) {
102  $print_config_version = $conf_pl_version;
103  } else {
104  $print_config_version = $config_version;
105  }
106  } else {
107  $print_config_version = $config_version;
108  }
109 
110  $config = 1;
111  open( FILE, "config.php" );
112 } elsif ( -e "config_default.php" ) {
113  open( FILE, "config_default.php" );
114  while ( $line = <FILE> ) {
115  $line =~ s/^\s+//;
116  $line =~ s/^\$//;
117  $var = $line;
118 
119  $var =~ s/=/EQUALS/;
120  if ( $var =~ /^([a-z]|[A-Z])/ ) {
121  @o = split ( /\s*EQUALS\s*/, $var );
122  if ( $o[0] eq "config_version" ) {
123  $o[1] =~ s/[\n|\r]//g;
124  $o[1] =~ s/[\'|\"];\s*$//;
125  $o[1] =~ s/;$//;
126  $o[1] =~ s/^[\'|\"]//;
127 
128  $config_version = $o[1];
129  close(FILE);
130  }
131  }
132  }
133  close(FILE);
134 
135  if ( $config_version ne $conf_pl_version ) {
136  clear_screen();
137  print "WARNING:\n";
138  print " You are trying to use a 'config_default.php' from an older\n";
139  print " version of SquirrelMail. This is HIGHLY unrecommended. You\n";
140  print " should get the 'config_default.php' that matches the version\n";
141  print " of SquirrelMail that you are running. You can get this from\n";
142  print " the SquirrelMail web page by going to the following URL:\n";
143  print " http://squirrelmail.org.\n";
144  print "\n";
145  print "Continue loading with old config_default.php (a bad idea) [y/N]? ";
146  $ctu = <STDIN>;
147 
148  if ( ( $ctu !~ /^y\n/i ) || ( $ctu =~ /^\n/ ) ) {
149  exit;
150  }
151 
152  print "\nDo you want me to stop warning you [y/N]? ";
153  $ctu = <STDIN>;
154  if ( $ctu =~ /^y\n/i ) {
155  $print_config_version = $conf_pl_version;
156  } else {
157  $print_config_version = $config_version;
158  }
159  } else {
160  $print_config_version = $config_version;
161  }
162  $config = 2;
163  open( FILE, "config_default.php" );
164 } else {
165  print "No configuration file found. Please get config_default.php\n";
166  print "or config.php before running this again. This program needs\n";
167  print "a default config file to get default values.\n";
168  exit;
169 }
170 
171 # Read and parse the current configuration file
172 # (either config.php or config_default.php).
173 while ( $line = <FILE> ) {
174  $line =~ s/^\s+//;
175  $line =~ s/^\$//;
176  $var = $line;
177 
178  $var =~ s/=/EQUALS/;
179  if ( $var =~ /^([a-z]|[A-Z])/ ) {
180  @options = split ( /\s*EQUALS\s*/, $var );
181  $options[1] =~ s/[\n|\r]//g;
182  $options[1] =~ s/[\'|\"];\s*$//;
183  $options[1] =~ s/;$//;
184  $options[1] =~ s/^[\'|\"]//;
185  # de-escape escaped strings
186  $options[1] =~ s/\\'/'/g;
187  $options[1] =~ s/\\\\/\\/g;
188 
189  if ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]PATH['|"]\]/ ) {
190  $sub = $options[0];
191  $sub =~ s/\]\[['|"]PATH['|"]\]//;
192  $sub =~ s/.*\[//;
193  if ( -e "../themes" ) {
194  $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
195  }
196  $theme_path[$sub] = &change_to_rel_path($options[1]);
197  } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
198  $sub = $options[0];
199  $sub =~ s/\]\[['|"]NAME['|"]\]//;
200  $sub =~ s/.*\[//;
201  $theme_name[$sub] = $options[1];
202  } elsif ( $options[0] =~ /^plugins\[[0-9]+\]/ ) {
203  $sub = $options[0];
204  $sub =~ s/\]//;
205  $sub =~ s/^plugins\[//;
206  $plugins[$sub] = $options[1];
207  } elsif ( $options[0] =~ /^ldap_server\[[0-9]+\]/ ) {
208  $sub = $options[0];
209  $sub =~ s/\]//;
210  $sub =~ s/^ldap_server\[//;
211  $continue = 0;
212  while ( ( $tmp = <FILE> ) && ( $continue != 1 ) ) {
213  if ( $tmp =~ /\);\s*$/ ) {
214  $continue = 1;
215  }
216 
217  if ( $tmp =~ /^\s*[\'|\"]host[\'|\"]/i ) {
218  $tmp =~ s/^\s*[\'|\"]host[\'|\"]\s*=>\s*[\'|\"]//i;
219  $tmp =~ s/[\'|\"],?\s*$//;
220  $tmp =~ s/[\'|\"]\);\s*$//;
221  $host = $tmp;
222  } elsif ( $tmp =~ /^\s*[\'|\"]base[\'|\"]/i ) {
223  $tmp =~ s/^\s*[\'|\"]base[\'|\"]\s*=>\s*[\'|\"]//i;
224  $tmp =~ s/[\'|\"],?\s*$//;
225  $tmp =~ s/[\'|\"]\);\s*$//;
226  $base = $tmp;
227  } elsif ( $tmp =~ /^\s*[\'|\"]charset[\'|\"]/i ) {
228  $tmp =~ s/^\s*[\'|\"]charset[\'|\"]\s*=>\s*[\'|\"]//i;
229  $tmp =~ s/[\'|\"],?\s*$//;
230  $tmp =~ s/[\'|\"]\);\s*$//;
231  $charset = $tmp;
232  } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
233  $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
234  $tmp =~ s/[\'|\"]?,?\s*$//;
235  $tmp =~ s/[\'|\"]?\);\s*$//;
236  $port = $tmp;
237  } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
238  $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
239  $tmp =~ s/[\'|\"]?,?\s*$//;
240  $tmp =~ s/[\'|\"]?\);\s*$//;
241  $maxrows = $tmp;
242  } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
243  $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
244  $tmp =~ s/[\'|\"],?\s*$//;
245  $tmp =~ s/[\'|\"]\);\s*$//;
246  $name = $tmp;
247  } elsif ( $tmp =~ /^\s*[\'|\"]binddn[\'|\"]/i ) {
248  $tmp =~ s/^\s*[\'|\"]binddn[\'|\"]\s*=>\s*[\'|\"]//i;
249  $tmp =~ s/[\'|\"],?\s*$//;
250  $tmp =~ s/[\'|\"]\);\s*$//;
251  $binddn = $tmp;
252  } elsif ( $tmp =~ /^\s*[\'|\"]bindpw[\'|\"]/i ) {
253  $tmp =~ s/^\s*[\'|\"]bindpw[\'|\"]\s*=>\s*[\'|\"]//i;
254  $tmp =~ s/[\'|\"],?\s*$//;
255  $tmp =~ s/[\'|\"]\);\s*$//;
256  $bindpw = $tmp;
257  } elsif ( $tmp =~ /^\s*[\'|\"]protocol[\'|\"]/i ) {
258  $tmp =~ s/^\s*[\'|\"]protocol[\'|\"]\s*=>\s*[\'|\"]?//i;
259  $tmp =~ s/[\'|\"]?,?\s*$//;
260  $tmp =~ s/[\'|\"]?\);\s*$//;
261  $protocol = $tmp;
262  }
263  }
264  $ldap_host[$sub] = $host;
265  $ldap_base[$sub] = $base;
266  $ldap_name[$sub] = $name;
267  $ldap_port[$sub] = $port;
268  $ldap_maxrows[$sub] = $maxrows;
269  $ldap_charset[$sub] = $charset;
270  $ldap_binddn[$sub] = $binddn;
271  $ldap_bindpw[$sub] = $bindpw;
272  $ldap_protocol[$sub] = $protocol;
273  } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
274  ${ $options[0] } = &change_to_rel_path($options[1]);
275  } else {
276  ${ $options[0] } = $options[1];
277  }
278  }
279 }
280 close FILE;
281 
282 # Default values used when option is missing
283 $useSendmail = "false" if ( lc($useSendmail) ne "true" );
284 $sendmail_path = "/usr/sbin/sendmail" if ( !$sendmail_path );
285 $pop_before_smtp = "false" if ( !$pop_before_smtp ) ;
286 $pop_before_smtp_host = '' if ( !$pop_before_smtp_host ) ;
287 $default_unseen_notify = 2 if ( !$default_unseen_notify );
288 $default_unseen_type = 1 if ( !$default_unseen_type );
289 $config_use_color = 0 if ( !$config_use_color );
290 $invert_time = "false" if ( !$invert_time );
291 $force_username_lowercase = "false" if ( !$force_username_lowercase );
292 $optional_delimiter = "detect" if ( !$optional_delimiter );
293 $auto_create_special = "false" if ( !$auto_create_special );
294 $default_use_priority = "true" if ( !$default_use_priority );
295 $hide_sm_attributions = "false" if ( !$hide_sm_attributions );
296 $default_use_mdn = "true" if ( !$default_use_mdn );
297 $delete_folder = "false" if ( !$delete_folder );
298 $noselect_fix_enable = "false" if ( !$noselect_fix_enable );
299 $frame_top = "_top" if ( !$frame_top );
300 
301 $provider_uri = "http://squirrelmail.org/" if ( !$provider_uri );
302 $provider_name = "SquirrelMail" if ( !$provider_name );
303 
304 $edit_identity = "true" if ( !$edit_identity );
305 $edit_name = "true" if ( !$edit_name );
306 $allow_thread_sort = 'false' if ( !$allow_thread_sort ) ;
307 $allow_server_sort = 'false' if ( !$allow_server_sort );
308 $uid_support = 'true' if ( !$uid_support );
309 $no_list_for_subscribe = 'false' if ( !$no_list_for_subscribe );
310 $allow_charset_search = 'true' if ( !$allow_charset_search );
311 
312 $prefs_user_field = 'user' if ( !$prefs_user_field );
313 $prefs_key_field = 'prefkey' if ( !$prefs_key_field );
314 $prefs_val_field = 'prefval' if ( !$prefs_val_field );
315 
316 $use_smtp_tls= 'false' if ( !$use_smtp_tls);
317 $smtp_auth_mech = 'none' if ( !$smtp_auth_mech );
318 
319 $use_imap_tls = 'false' if ( !$use_imap_tls );
320 $imap_auth_mech = 'login' if ( !$imap_auth_mech );
321 
322 $session_name = 'SQMSESSID' if (!$session_name );
323 
324 $default_use_javascript_addr_book = 'false' if (! $default_use_javascript_addr_book);
325 
326 # Added in 1.4.4
327 $lossy_encoding = 'false' if ( !$lossy_encoding );
328 $addrbook_global_dsn = '' if ( !$addrbook_global_dsn );
329 $addrbook_global_table = 'global_abook' if ( !$addrbook_global_table );
330 $addrbook_global_writeable = 'false' if ( !$addrbook_global_writeable );
331 $addrbook_global_listing = 'false' if ( !$addrbook_global_listing );
332 $abook_global_file = '' if ( !$abook_global_file);
333 $abook_global_file_writeable = 'false' if ( !$abook_global_file_writeable);
334 
335 # Added in 1.4.5
336 $hide_auth_header = "false" if ( !$hide_auth_header );
337 $encode_header_key = '' if ( !$encode_header_key );
338 
339 # Added in 1.4.8
340 $config_location_base = '' if ( !$config_location_base );
341 # add qmail-inject test here for backwards compatibility
342 if ( !$sendmail_args && $sendmail_path =~ /qmail-inject/ ) {
343  $sendmail_args = '';
344 } elsif ( !$sendmail_args ) {
345  $sendmail_args = '-i -t';
346 }
347 
348 # Added in 1.4.11
349 $smtp_sitewide_user = '' if ( !$smtp_sitewide_user );
350 $smtp_sitewide_pass = '' if ( !$smtp_sitewide_pass );
351 
352 # Added in 1.4.9
353 $abook_global_file_listing = 'true' if ( !$abook_global_file_listing );
354 $abook_file_line_length = 2048 if ( !$abook_file_line_length );
355 
356 # Added in 1.4.16
357 $only_secure_cookies = 'true' if ( !$only_secure_cookies );
358 
359 # Added in 1.4.20RC1
360 $disable_security_tokens = 'false' if ( !$disable_security_tokens );
361 $check_referrer = '' if ( !$check_referrer );
362 
363 if ( $ARGV[0] eq '--install-plugin' ) {
364  print "Activating plugin " . $ARGV[1] . "\n";
365  if ( -d "../plugins/" . $ARGV[1]) {
366  push @plugins, $ARGV[1];
367  save_data();
368  exit(0);
369  } else {
370  print "No such plugin.\n";
371  exit(1);
372  }
373 } elsif ( $ARGV[0] eq '--remove-plugin' ) {
374  print "Removing plugin " . $ARGV[1] . "\n";
375  foreach $plugin (@plugins) {
376  if ( $plugin ne $ARGV[1] ) {
377  push @newplugins, $plugin;
378  }
379  }
380  @plugins = @newplugins;
381  save_data();
382  exit(0);
383 }
384 
385 
386 
387 ####################################################################################
388 
389 # used in multiple places, define once
390 $list_supported_imap_servers =
391  " bincimap = Binc IMAP server\n" .
392  " courier = Courier IMAP server\n" .
393  " cyrus = Cyrus IMAP server\n" .
394  " dovecot = Dovecot Secure IMAP server\n" .
395  " exchange = Microsoft Exchange IMAP server\n" .
396  " hmailserver = hMailServer\n" .
397  " macosx = Mac OS X Mailserver\n" .
398  " mercury32 = Mercury/32\n" .
399  " uw = University of Washington's IMAP server\n" .
400  " gmail = IMAP access to Google mail (Gmail) accounts\n";
401 
402 #####################################################################################
403 if ( $config_use_color == 1 ) {
404  $WHT = "\x1B[1m";
405  $NRM = "\x1B[0m";
406 } else {
407  $WHT = "";
408  $NRM = "";
409  $config_use_color = 2;
410 }
411 
412 while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
413  clear_screen();
414  print $WHT. "SquirrelMail Configuration : " . $NRM;
415  if ( $config == 1 ) { print "Read: config.php"; }
416  elsif ( $config == 2 ) { print "Read: config_default.php"; }
417  print " ($print_config_version)\n";
418  print "---------------------------------------------------------\n";
419 
420  if ( $menu == 0 ) {
421  print $WHT. "Main Menu --\n" . $NRM;
422  print "1. Organization Preferences\n";
423  print "2. Server Settings\n";
424  print "3. Folder Defaults\n";
425  print "4. General Options\n";
426  print "5. Themes\n";
427  print "6. Address Books\n";
428  print "7. Message of the Day (MOTD)\n";
429  print "8. Plugins\n";
430  print "9. Database\n";
431  print "10. Languages\n";
432  print "\n";
433  print "D. Set pre-defined settings for specific IMAP servers\n";
434  print "\n";
435  } elsif ( $menu == 1 ) {
436  print $WHT. "Organization Preferences\n" . $NRM;
437  print "1. Organization Name : $WHT$org_name$NRM\n";
438  print "2. Organization Logo : $WHT$org_logo$NRM\n";
439  print "3. Org. Logo Width/Height : $WHT($org_logo_width/$org_logo_height)$NRM\n";
440  print "4. Organization Title : $WHT$org_title$NRM\n";
441  print "5. Signout Page : $WHT$signout_page$NRM\n";
442  print "6. Top Frame : $WHT$frame_top$NRM\n";
443  print "7. Provider link : $WHT$provider_uri$NRM\n";
444  print "8. Provider name : $WHT$provider_name$NRM\n";
445 
446  print "\n";
447  print "R Return to Main Menu\n";
448  } elsif ( $menu == 2 ) {
449  print $WHT. "Server Settings\n\n" . $NRM;
450  print $WHT . "General" . $NRM . "\n";
451  print "-------\n";
452  print "1. Domain : $WHT$domain$NRM\n";
453  print "2. Invert Time : $WHT$invert_time$NRM\n";
454  print "3. Sendmail or SMTP : $WHT";
455  if ( lc($useSendmail) eq "true" ) {
456  print "Sendmail";
457  } else {
458  print "SMTP";
459  }
460  print "$NRM\n";
461  print "\n";
462 
463  if ( $show_imap_settings ) {
464  print $WHT . "IMAP Settings". $NRM . "\n--------------\n";
465  print "4. IMAP Server : $WHT$imapServerAddress$NRM\n";
466  print "5. IMAP Port : $WHT$imapPort$NRM\n";
467  print "6. Authentication type : $WHT$imap_auth_mech$NRM\n";
468  print "7. Secure IMAP (TLS) : $WHT$use_imap_tls$NRM\n";
469  print "8. Server software : $WHT$imap_server_type$NRM\n";
470  print "9. Delimiter : $WHT$optional_delimiter$NRM\n";
471  print "\n";
472  } elsif ( $show_smtp_settings ) {
473  if ( lc($useSendmail) eq "true" ) {
474  print $WHT . "Sendmail" . $NRM . "\n--------\n";
475  print "4. Sendmail Path : $WHT$sendmail_path$NRM\n";
476  print "5. Sendmail arguments : $WHT$sendmail_args$NRM\n";
477  print "6. Header encryption key : $WHT$encode_header_key$NRM\n";
478  print "\n";
479  } else {
480  print $WHT . "SMTP Settings" . $NRM . "\n-------------\n";
481  print "4. SMTP Server : $WHT$smtpServerAddress$NRM\n";
482  print "5. SMTP Port : $WHT$smtpPort$NRM\n";
483  print "6. POP before SMTP : $WHT$pop_before_smtp$NRM\n";
484  print "7. SMTP Authentication : $WHT$smtp_auth_mech" . display_smtp_sitewide_userpass() . "$NRM\n";
485  print "8. Secure SMTP (TLS) : $WHT$use_smtp_tls$NRM\n";
486  print "9. Header encryption key : $WHT$encode_header_key$NRM\n";
487  print "\n";
488  }
489  }
490 
491  if ($show_imap_settings == 0) {
492  print "A. Update IMAP Settings : ";
493  print "$WHT$imapServerAddress$NRM:";
494  print "$WHT$imapPort$NRM ";
495  print "($WHT$imap_server_type$NRM)\n";
496  }
497  if ($show_smtp_settings == 0) {
498  if ( lc($useSendmail) eq "true" ) {
499  print "B. Change Sendmail Config : $WHT$sendmail_path$NRM\n";
500  } else {
501  print "B. Update SMTP Settings : ";
502  print "$WHT$smtpServerAddress$NRM:";
503  print "$WHT$smtpPort$NRM\n";
504  }
505  }
506  if ( $show_smtp_settings || $show_imap_settings )
507  {
508  print "H. Hide " .
509  ($show_imap_settings ? "IMAP Server" :
510  (lc($useSendmail) eq "true") ? "Sendmail" : "SMTP") . " Settings\n";
511  }
512 
513  print "\n";
514  print "R Return to Main Menu\n";
515  } elsif ( $menu == 3 ) {
516  print $WHT. "Folder Defaults\n" . $NRM;
517  print "1. Default Folder Prefix : $WHT$default_folder_prefix$NRM\n";
518  print "2. Show Folder Prefix Option : $WHT$show_prefix_option$NRM\n";
519  print "3. Trash Folder : $WHT$trash_folder$NRM\n";
520  print "4. Sent Folder : $WHT$sent_folder$NRM\n";
521  print "5. Drafts Folder : $WHT$draft_folder$NRM\n";
522  print "6. By default, move to trash : $WHT$default_move_to_trash$NRM\n";
523  print "7. By default, save sent messages : $WHT$default_move_to_sent$NRM\n";
524  print "8. By default, save as draft : $WHT$default_save_as_draft$NRM\n";
525  print "9. List Special Folders First : $WHT$list_special_folders_first$NRM\n";
526  print "10. Show Special Folders Color : $WHT$use_special_folder_color$NRM\n";
527  print "11. Auto Expunge : $WHT$auto_expunge$NRM\n";
528  print "12. Default Sub. of INBOX : $WHT$default_sub_of_inbox$NRM\n";
529  print "13. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
530  print "14. Default Unseen Notify : $WHT$default_unseen_notify$NRM\n";
531  print "15. Default Unseen Type : $WHT$default_unseen_type$NRM\n";
532  print "16. Auto Create Special Folders : $WHT$auto_create_special$NRM\n";
533  print "17. Folder Delete Bypasses Trash : $WHT$delete_folder$NRM\n";
534  print "18. Enable /NoSelect folder fix : $WHT$noselect_fix_enable$NRM\n";
535  print "\n";
536  print "R Return to Main Menu\n";
537  } elsif ( $menu == 4 ) {
538  print $WHT. "General Options\n" . $NRM;
539  print "1. Data Directory : $WHT$data_dir$NRM\n";
540  print "2. Attachment Directory : $WHT$attachment_dir$NRM\n";
541  print "3. Directory Hash Level : $WHT$dir_hash_level$NRM\n";
542  print "4. Default Left Size : $WHT$default_left_size$NRM\n";
543  print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n";
544  print "6. Allow use of priority : $WHT$default_use_priority$NRM\n";
545  print "7. Hide SM attributions : $WHT$hide_sm_attributions$NRM\n";
546  print "8. Allow use of receipts : $WHT$default_use_mdn$NRM\n";
547  print "9. Allow editing of identity : $WHT$edit_identity$NRM\n";
548  print " Allow editing of name : $WHT$edit_name$NRM\n";
549  print " Remove username from header : $WHT$hide_auth_header$NRM\n";
550  print "10. Allow server thread sort : $WHT$allow_thread_sort$NRM\n";
551  print "11. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
552  print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
553  print "13. Enable UID support : $WHT$uid_support$NRM\n";
554  print "14. PHP session name : $WHT$session_name$NRM\n";
555  print "15. Location base : $WHT$config_location_base$NRM\n";
556  print "16. Only secure cookies if poss. : $WHT$only_secure_cookies$NRM\n";
557  print "17. Disable secure forms : $WHT$disable_security_tokens$NRM\n";
558  print "18. Page referal requirement : $WHT$check_referrer$NRM\n";
559  print "\n";
560  print "R Return to Main Menu\n";
561  } elsif ( $menu == 5 ) {
562  print $WHT. "Themes\n" . $NRM;
563  print "1. Change Themes\n";
564  for ( $count = 0 ; $count <= $#theme_name/2 ; $count++ ) {
565  $temp_name = $theme_name[$count*2];
566  printf " %s%*s %s\n", $temp_name,
567  40 - length($temp_name), " ",
568  $theme_name[($count*2)+1];
569  }
570  print "2. CSS File : $WHT$theme_css$NRM\n";
571  print "\n";
572  print "R Return to Main Menu\n";
573  } elsif ( $menu == 6 ) {
574  print $WHT. "Address Books\n" . $NRM;
575  print "1. Change LDAP Servers\n";
576  for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
577  print " > $ldap_host[$count]\n";
578  }
579  print "2. Use Javascript Address Book Search : $WHT$default_use_javascript_addr_book$NRM\n";
580  print "3. Global file address book : $WHT$abook_global_file$NRM\n";
581  print "4. Allow writing into global file address book : $WHT$abook_global_file_writeable$NRM\n";
582  print "5. Allow listing of global file address book : $WHT$abook_global_file_listing$NRM\n";
583  print "6. Allowed address book line length : $WHT$abook_file_line_length$NRM\n";
584  print "\n";
585  print "R Return to Main Menu\n";
586  } elsif ( $menu == 7 ) {
587  print $WHT. "Message of the Day (MOTD)\n" . $NRM;
588  print "\n$motd\n";
589  print "\n";
590  print "1 Edit the MOTD\n";
591  print "\n";
592  print "R Return to Main Menu\n";
593  } elsif ( $menu == 8 ) {
594  print $WHT. "Plugins\n" . $NRM;
595  print " Installed Plugins\n";
596  $num = 0;
597  for ( $count = 0 ; $count <= $#plugins ; $count++ ) {
598  $num = $count + 1;
599  print " $num. $plugins[$count]\n";
600  }
601  print "\n Available Plugins:\n";
602  opendir( DIR, "../plugins" );
603  @files = sort(readdir(DIR));
604  $pos = 0;
605  @unused_plugins = ();
606  for ( $i = 0 ; $i <= $#files ; $i++ ) {
607  if ( -d "../plugins/" . $files[$i] && $files[$i] !~ /^\./ && $files[$i] ne "CVS" ) {
608  $match = 0;
609  for ( $k = 0 ; $k <= $#plugins ; $k++ ) {
610  if ( $plugins[$k] eq $files[$i] ) {
611  $match = 1;
612  }
613  }
614  if ( $match == 0 ) {
615  $unused_plugins[$pos] = $files[$i];
616  $pos++;
617  }
618  }
619  }
620 
621  for ( $i = 0 ; $i <= $#unused_plugins ; $i++ ) {
622  $num = $num + 1;
623  print " $num. $unused_plugins[$i]\n";
624  }
625  closedir DIR;
626 
627  print "\n";
628  print "R Return to Main Menu\n";
629  } elsif ( $menu == 9 ) {
630  print $WHT. "Database\n" . $NRM;
631  print "1. DSN for Address Book : $WHT$addrbook_dsn$NRM\n";
632  print "2. Table for Address Book : $WHT$addrbook_table$NRM\n";
633  print "\n";
634  print "3. DSN for Preferences : $WHT$prefs_dsn$NRM\n";
635  print "4. Table for Preferences : $WHT$prefs_table$NRM\n";
636  print "5. Field for username : $WHT$prefs_user_field$NRM\n";
637  print "6. Field for prefs key : $WHT$prefs_key_field$NRM\n";
638  print "7. Field for prefs value : $WHT$prefs_val_field$NRM\n";
639  print "\n";
640  print "8. DSN for Global Address Book : $WHT$addrbook_global_dsn$NRM\n";
641  print "9. Table for Global Address Book : $WHT$addrbook_global_table$NRM\n";
642  print "10. Allow writing into Global Address Book : $WHT$addrbook_global_writeable$NRM\n";
643  print "11. Allow listing of Global Address Book : $WHT$addrbook_global_listing$NRM\n";
644  print "\n";
645  print "R Return to Main Menu\n";
646  } elsif ( $menu == 10 ) {
647  print $WHT. "Language preferences\n" . $NRM;
648  print "1. Default Language : $WHT$squirrelmail_default_language$NRM\n";
649  print "2. Default Charset : $WHT$default_charset$NRM\n";
650  print "3. Enable lossy encoding : $WHT$lossy_encoding$NRM\n";
651  print "\n";
652  print "R Return to Main Menu\n";
653  }
654  if ( $config_use_color == 1 ) {
655  print "C Turn color off\n";
656  } else {
657  print "C Turn color on\n";
658  }
659  print "S Save data\n";
660  print "Q Quit\n";
661 
662  print "\n";
663  print "Command >> " . $WHT;
664  $command = <STDIN>;
665  $command =~ s/[\n|\r]//g;
666  $command =~ tr/A-Z/a-z/;
667  print "$NRM\n";
668 
669  # Read the commands they entered.
670  if ( $command eq "r" ) {
671  $menu = 0;
672  } elsif ( $command eq "s" ) {
673  save_data();
674  print "Press enter to continue...";
675  $tmp = <STDIN>;
676  $saved = 1;
677  } elsif ( ( $command eq "q" ) && ( $saved == 0 ) ) {
678  print "You have not saved your data.\n";
679  print "Save? [" . $WHT . "Y" . $NRM . "/n]: ";
680  $save = <STDIN>;
681  if ( ( $save =~ /^y/i ) || ( $save =~ /^\s*$/ ) ) {
682  save_data();
683  }
684  } elsif ( $command eq "c" ) {
685  if ( $config_use_color == 1 ) {
686  $config_use_color = 2;
687  $WHT = "";
688  $NRM = "";
689  } else {
690  $config_use_color = 1;
691  $WHT = "\x1B[1m";
692  $NRM = "\x1B[0m";
693  }
694  } elsif ( $command eq "d" && $menu == 0 ) {
695  set_defaults();
696  } else {
697  $saved = 0;
698  if ( $menu == 0 ) {
699  if ( ( $command > 0 ) && ( $command < 11 ) ) {
700  $menu = $command;
701  }
702  } elsif ( $menu == 1 ) {
703  if ( $command == 1 ) { $org_name = command1(); }
704  elsif ( $command == 2 ) { $org_logo = command2(); }
705  elsif ( $command == 3 ) { ($org_logo_width,$org_logo_height) = command3(); }
706  elsif ( $command == 4 ) { $org_title = command4(); }
707  elsif ( $command == 5 ) { $signout_page = command5(); }
708  elsif ( $command == 6 ) { $frame_top = command6(); }
709  elsif ( $command == 7 ) { $provider_uri = command7(); }
710  elsif ( $command == 8 ) { $provider_name = command8(); }
711 
712  } elsif ( $menu == 2 ) {
713  if ( $command eq "a" ) { $show_imap_settings = 1; $show_smtp_settings = 0; }
714  elsif ( $command eq "b" ) { $show_imap_settings = 0; $show_smtp_settings = 1; }
715  elsif ( $command eq "h" ) { $show_imap_settings = 0; $show_smtp_settings = 0; }
716  elsif ( $command <= 3 ) {
717  if ( $command == 1 ) { $domain = command11(); }
718  elsif ( $command == 2 ) { $invert_time = command110(); }
719  elsif ( $command == 3 ) { $useSendmail = command14(); }
720  $show_imap_settings = 0; $show_smtp_settings = 0;
721  } elsif ( $show_imap_settings ) {
722  if ( $command == 4 ) { $imapServerAddress = command12(); }
723  elsif ( $command == 5 ) { $imapPort = command13(); }
724  elsif ( $command == 6 ) { $imap_auth_mech = command112a(); }
725  elsif ( $command == 7 ) { $use_imap_tls = command113("IMAP",$use_imap_tls); }
726  elsif ( $command == 8 ) { $imap_server_type = command19(); }
727  elsif ( $command == 9 ) { $optional_delimiter = command111(); }
728  } elsif ( $show_smtp_settings && lc($useSendmail) eq "true" ) {
729  if ( $command == 4 ) { $sendmail_path = command15(); }
730  elsif ( $command == 5 ) { $sendmail_args = command_sendmail_args(); }
731  elsif ( $command == 6 ) { $encode_header_key = command114(); }
732  } elsif ( $show_smtp_settings ) {
733  if ( $command == 4 ) { $smtpServerAddress = command16(); }
734  elsif ( $command == 5 ) { $smtpPort = command17(); }
735  elsif ( $command == 6 ) { $pop_before_smtp = command18a(); }
736  elsif ( $command == 7 ) { $smtp_auth_mech = command112b(); }
737  elsif ( $command == 8 ) { $use_smtp_tls = command113("SMTP",$use_smtp_tls); }
738  elsif ( $command == 9 ) { $encode_header_key = command114(); }
739  }
740  } elsif ( $menu == 3 ) {
741  if ( $command == 1 ) { $default_folder_prefix = command21(); }
742  elsif ( $command == 2 ) { $show_prefix_option = command22(); }
743  elsif ( $command == 3 ) { $trash_folder = command23a(); }
744  elsif ( $command == 4 ) { $sent_folder = command23b(); }
745  elsif ( $command == 5 ) { $draft_folder = command23c(); }
746  elsif ( $command == 6 ) { $default_move_to_trash = command24a(); }
747  elsif ( $command == 7 ) { $default_move_to_sent = command24b(); }
748  elsif ( $command == 8 ) { $default_save_as_draft = command24c(); }
749  elsif ( $command == 9 ) { $list_special_folders_first = command27(); }
750  elsif ( $command == 10 ) { $use_special_folder_color = command28(); }
751  elsif ( $command == 11 ) { $auto_expunge = command29(); }
752  elsif ( $command == 12 ) { $default_sub_of_inbox = command210(); }
753  elsif ( $command == 13 ) { $show_contain_subfolders_option = command211(); }
754  elsif ( $command == 14 ) { $default_unseen_notify = command212(); }
755  elsif ( $command == 15 ) { $default_unseen_type = command213(); }
756  elsif ( $command == 16 ) { $auto_create_special = command214(); }
757  elsif ( $command == 17 ) { $delete_folder = command215(); }
758  elsif ( $command == 18 ) { $noselect_fix_enable = command216(); }
759  } elsif ( $menu == 4 ) {
760  if ( $command == 1 ) { $data_dir = command31(); }
761  elsif ( $command == 2 ) { $attachment_dir = command32(); }
762  elsif ( $command == 3 ) { $dir_hash_level = command33(); }
763  elsif ( $command == 4 ) { $default_left_size = command34(); }
764  elsif ( $command == 5 ) { $force_username_lowercase = command35(); }
765  elsif ( $command == 6 ) { $default_use_priority = command36(); }
766  elsif ( $command == 7 ) { $hide_sm_attributions = command37(); }
767  elsif ( $command == 8 ) { $default_use_mdn = command38(); }
768  elsif ( $command == 9 ) { $edit_identity = command39(); }
769  elsif ( $command == 10 ) { $allow_thread_sort = command310(); }
770  elsif ( $command == 11 ) { $allow_server_sort = command311(); }
771  elsif ( $command == 12 ) { $allow_charset_search = command312(); }
772  elsif ( $command == 13 ) { $uid_support = command313(); }
773  elsif ( $command == 14 ) { $session_name = command314(); }
774  elsif ( $command == 15 ) { $config_location_base = command_config_location_base(); }
775  elsif ( $command == 16 ) { $only_secure_cookies = command316(); }
776  elsif ( $command == 17 ) { $disable_security_tokens = command317(); }
777  elsif ( $command == 18 ) { $check_referrer = command318(); }
778  } elsif ( $menu == 5 ) {
779  if ( $command == 1 ) { command41(); }
780  elsif ( $command == 2 ) { $theme_css = command42(); }
781  } elsif ( $menu == 6 ) {
782  if ( $command == 1 ) { command61(); }
783  elsif ( $command == 2 ) { command62(); }
784  elsif ( $command == 3 ) { $abook_global_file=command63(); }
785  elsif ( $command == 4 ) { command64(); }
786  elsif ( $command == 5 ) { command_abook_global_file_listing(); }
787  elsif ( $command == 6 ) { command_abook_file_line_length(); }
788  } elsif ( $menu == 7 ) {
789  if ( $command == 1 ) { $motd = command71(); }
790  } elsif ( $menu == 8 ) {
791  if ( $command =~ /^[0-9]+/ ) { @plugins = command81(); }
792  } elsif ( $menu == 9 ) {
793  if ( $command == 1 ) { $addrbook_dsn = command91(); }
794  elsif ( $command == 2 ) { $addrbook_table = command92(); }
795  elsif ( $command == 3 ) { $prefs_dsn = command93(); }
796  elsif ( $command == 4 ) { $prefs_table = command94(); }
797  elsif ( $command == 5 ) { $prefs_user_field = command95(); }
798  elsif ( $command == 6 ) { $prefs_key_field = command96(); }
799  elsif ( $command == 7 ) { $prefs_val_field = command97(); }
800  elsif ( $command == 8 ) { $addrbook_global_dsn = command98(); }
801  elsif ( $command == 9 ) { $addrbook_global_table = command99(); }
802  elsif ( $command == 10 ) { $addrbook_global_writeable = command910(); }
803  elsif ( $command == 11 ) { $addrbook_global_listing = command911(); }
804  } elsif ( $menu == 10 ) {
805  if ( $command == 1 ) { $squirrelmail_default_language = commandA1(); }
806  elsif ( $command == 2 ) { $default_charset = commandA2(); }
807  elsif ( $command == 3 ) { $lossy_encoding = commandA3(); }
808  }
809  }
810 }
811 
812 # we exit here
813 print "\nExiting conf.pl.\n".
814  "You might want to test your configuration by browsing to\n".
815  "http://your-squirrelmail-location/src/configtest.php\n".
816  "Happy SquirrelMailing!\n\n";
817 
818 
819 ####################################################################################
820 #### Organization preferences ####
821 # org_name
822 sub command1 {
823  print "We have tried to make the name SquirrelMail as transparent as\n";
824  print "possible. If you set up an organization name, most places where\n";
825  print "SquirrelMail would take credit will be credited to your organization.\n";
826  print "\n";
827  print "If your Organization Name includes a '\$', please precede it with a \\. \n";
828  print "Other '\$' will be considered the beginning of a variable that\n";
829  print "must be defined before the \$org_name is printed.\n";
830  print "\$version, for example, is included by default, and will print the\n";
831  print "string representing the current SquirrelMail version.\n";
832  print "\n";
833  print "[$WHT$org_name$NRM]: $WHT";
834  $new_org_name = <STDIN>;
835  if ( $new_org_name eq "\n" ) {
836  $new_org_name = $org_name;
837  } else {
838  $new_org_name =~ s/[\r|\n]//g;
839  $new_org_name =~ s/\"/&quot;/g;
840  }
841  return $new_org_name;
842 }
843 
844 # org_logo
845 sub command2 {
846  print "Your organization's logo is an image that will be displayed at\n";
847  print "different times throughout SquirrelMail. ";
848  print "\n";
849  print "Please be aware of the following: \n";
850  print " - Relative URLs are relative to the config dir\n";
851  print " to use the default logo, use ../images/sm_logo.png\n";
852  print " - To specify a logo defined outside the SquirrelMail source tree\n";
853  print " use the absolute URL the webserver would use to include the file\n";
854  print " e.g. http://example.com/images/mylogo.gif or /images/mylogo.jpg\n";
855  print "\n";
856  print "[$WHT$org_logo$NRM]: $WHT";
857  $new_org_logo = <STDIN>;
858  if ( $new_org_logo eq "\n" ) {
859  $new_org_logo = $org_logo;
860  } else {
861  $new_org_logo =~ s/[\r|\n]//g;
862  }
863  return $new_org_logo;
864 }
865 
866 # org_logo_width
867 sub command3 {
868  print "Your organization's logo is an image that will be displayed at\n";
869  print "different times throughout SquirrelMail. Width\n";
870  print "and Height of your logo image. Use '0' to disable.\n";
871  print "\n";
872  print "Width: [$WHT$org_logo_width$NRM]: $WHT";
873  $new_org_logo_width = <STDIN>;
874  $new_org_logo_width =~ tr/0-9//cd; # only want digits!
875  if ( $new_org_logo_width eq '' ) {
876  $new_org_logo_width = $org_logo_width;
877  }
878  if ( $new_org_logo_width > 0 ) {
879  print "Height: [$WHT$org_logo_height$NRM]: $WHT";
880  $new_org_logo_height = <STDIN>;
881  $new_org_logo_height =~ tr/0-9//cd; # only want digits!
882  if( $new_org_logo_height eq '' ) {
883  $new_org_logo_height = $org_logo_height;
884  }
885  } else {
886  $new_org_logo_height = 0;
887  }
888  return ($new_org_logo_width, $new_org_logo_height);
889 }
890 
891 # org_title
892 sub command4 {
893  print "A title is what is displayed at the top of the browser window in\n";
894  print "the titlebar. Usually this will end up looking something like:\n";
895  print "\"Netscape: $org_title\"\n";
896  print "\n";
897  print "If your Organization Title includes a '\$', please precede it with a \\. \n";
898  print "Other '\$' will be considered the beginning of a variable that\n";
899  print "must be defined before the \$org_title is printed.\n";
900  print "\$version, for example, is included by default, and will print the\n";
901  print "string representing the current SquirrelMail version.\n";
902  print "\n";
903  print "[$WHT$org_title$NRM]: $WHT";
904  $new_org_title = <STDIN>;
905  if ( $new_org_title eq "\n" ) {
906  $new_org_title = $org_title;
907  } else {
908  $new_org_title =~ s/[\r|\n]//g;
909  $new_org_title =~ s/\"/\'/g;
910  }
911  return $new_org_title;
912 }
913 
914 # signout_page
915 sub command5 {
916  print "When users click the Sign Out button they will be logged out and\n";
917  print "then sent to signout_page. If signout_page is left empty,\n";
918  print "(hit space and then return) they will be taken, as normal,\n";
919  print "to the default and rather sparse SquirrelMail signout page.\n";
920  print "\n";
921  print "[$WHT$signout_page$NRM]: $WHT";
922  $new_signout_page = <STDIN>;
923  if ( $new_signout_page eq "\n" ) {
924  $new_signout_page = $signout_page;
925  } else {
926  $new_signout_page =~ s/[\r|\n]//g;
927  $new_signout_page =~ s/^\s+$//g;
928  }
929  return $new_signout_page;
930 }
931 
932 # Default top frame
933 sub command6 {
934  print "SquirrelMail defaults to using the whole of the browser window.\n";
935  print "This allows you to keep it within a specified frame. The default\n";
936  print "is '_top'\n";
937  print "\n";
938  print "[$WHT$frame_top$NRM]: $WHT";
939  $new_frame_top = <STDIN>;
940  if ( $new_frame_top eq "\n" ) {
941  $new_frame_top = '_top';
942  } else {
943  $new_frame_top =~ s/[\r|\n]//g;
944  $new_frame_top =~ s/^\s+$//g;
945  }
946  return $new_frame_top;
947 }
948 
949 # Default link to provider
950 sub command7 {
951  print "Here you can set the link on the right of the page.\n";
952  print "The default is 'http://squirrelmail.org/'\n";
953  print "\n";
954  print "[$WHT$provider_uri$NRM]: $WHT";
955  $new_provider_uri = <STDIN>;
956  if ( $new_provider_uri eq "\n" ) {
957  $new_provider_uri = 'http://squirrelmail.org/';
958  } else {
959  $new_provider_uri =~ s/[\r|\n]//g;
960  $new_provider_uri =~ s/^\s+$//g;
961  }
962  return $new_provider_uri;
963 }
964 
965 sub command8 {
966  print "Here you can set the name of the link on the right of the page.\n";
967  print "The default is 'SquirrelMail'\n";
968  print "\n";
969  print "[$WHT$provider_name$NRM]: $WHT";
970  $new_provider_name = <STDIN>;
971  if ( $new_provider_name eq "\n" ) {
972  $new_provider_name = 'SquirrelMail';
973  } else {
974  $new_provider_name =~ s/[\r|\n]//g;
975  $new_provider_name =~ s/^\s+$//g;
976  $new_provider_name =~ s/\'/\\'/g;
977  }
978  return $new_provider_name;
979 }
980 
981 ####################################################################################
982 #### Server settings ####
983 # domain
984 sub command11 {
985  print "The domain name is the suffix at the end of all email addresses. If\n";
986  print "for example, your email address is jdoe\@example.com, then your domain\n";
987  print "would be example.com.\n";
988  print "\n";
989  print "[$WHT$domain$NRM]: $WHT";
990  $new_domain = <STDIN>;
991  if ( $new_domain eq "\n" ) {
992  $new_domain = $domain;
993  } else {
994  $new_domain =~ s/\s//g;
995  }
996  return $new_domain;
997 }
998 
999 # imapServerAddress
1000 sub command12 {
1001  print "This is the hostname where your IMAP server can be contacted.\n";
1002  print "[$WHT$imapServerAddress$NRM]: $WHT";
1003  $new_imapServerAddress = <STDIN>;
1004  if ( $new_imapServerAddress eq "\n" ) {
1005  $new_imapServerAddress = $imapServerAddress;
1006  } else {
1007  $new_imapServerAddress =~ s/[\r|\n]//g;
1008  }
1009  return $new_imapServerAddress;
1010 }
1011 
1012 # imapPort
1013 sub command13 {
1014  print "This is the port that your IMAP server is on. Usually this is 143.\n";
1015  print "[$WHT$imapPort$NRM]: $WHT";
1016  $new_imapPort = <STDIN>;
1017  if ( $new_imapPort eq "\n" ) {
1018  $new_imapPort = $imapPort;
1019  } else {
1020  $new_imapPort =~ s/[\r|\n]//g;
1021  }
1022  return $new_imapPort;
1023 }
1024 
1025 # useSendmail
1026 sub command14 {
1027  print "You now need to choose the method that you will use for sending\n";
1028  print "messages in SquirrelMail. You can either connect to an SMTP server\n";
1029  print "or use sendmail directly.\n";
1030  if ( lc($useSendmail) eq "true" ) {
1031  $default_value = "1";
1032  } else {
1033  $default_value = "2";
1034  }
1035  print "\n";
1036  print " 1. Sendmail\n";
1037  print " 2. SMTP\n";
1038  print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
1039  $use_sendmail = <STDIN>;
1040  if ( ( $use_sendmail =~ /^1\n/i )
1041  || ( ( $use_sendmail =~ /^\n/ ) && ( $default_value eq "1" ) ) ) {
1042  $useSendmail = "true";
1043  } else {
1044  $useSendmail = "false";
1045  }
1046  return $useSendmail;
1047 }
1048 
1049 # sendmail_path
1050 sub command15 {
1051  print "Specify where the sendmail executable is located. Usually /usr/sbin/sendmail\n";
1052  print "[$WHT$sendmail_path$NRM]: $WHT";
1053  $new_sendmail_path = <STDIN>;
1054  if ( $new_sendmail_path eq "\n" ) {
1055  $new_sendmail_path = $sendmail_path;
1056  } else {
1057  $new_sendmail_path =~ s/[\r|\n]//g;
1058  }
1059  return $new_sendmail_path;
1060 }
1061 
1062 # Extra sendmail arguments
1063 sub command_sendmail_args {
1064  print "Specify additional sendmail program arguments.\n";
1065  print "\n";
1066  print "Make sure that arguments are supported by your sendmail program. -f argument \n";
1067  print "is added automatically by SquirrelMail scripts. Variable defaults to standard\n";
1068  print "/usr/sbin/sendmail arguments. If you use qmail-inject, nbsmtp or any other \n";
1069  print "sendmail wrapper, which does not support -i and -t arguments, set variable to\n";
1070  print "empty string or use arguments suitable for your mailer.\n";
1071  print "\n";
1072  print "[$WHT$sendmail_args$NRM]: $WHT";
1073  $new_sendmail_args = <STDIN>;
1074  if ( $new_sendmail_args eq "\n" ) {
1075  $new_sendmail_args = $sendmail_args;
1076  } else {
1077  # strip linefeeds and crs.
1078  $new_sendmail_args =~ s/[\r\n]//g;
1079  }
1080  return trim($new_sendmail_args);
1081 }
1082 
1083 # smtpServerAddress
1084 sub command16 {
1085  print "This is the hostname of your SMTP server.\n";
1086  print "[$WHT$smtpServerAddress$NRM]: $WHT";
1087  $new_smtpServerAddress = <STDIN>;
1088  if ( $new_smtpServerAddress eq "\n" ) {
1089  $new_smtpServerAddress = $smtpServerAddress;
1090  } else {
1091  $new_smtpServerAddress =~ s/[\r|\n]//g;
1092  }
1093  return $new_smtpServerAddress;
1094 }
1095 
1096 # smtpPort
1097 sub command17 {
1098  print "This is the port to connect to for SMTP. Usually 25.\n";
1099  print "[$WHT$smtpPort$NRM]: $WHT";
1100  $new_smtpPort = <STDIN>;
1101  if ( $new_smtpPort eq "\n" ) {
1102  $new_smtpPort = $smtpPort;
1103  } else {
1104  $new_smtpPort =~ s/[\r|\n]//g;
1105  }
1106  return $new_smtpPort;
1107 }
1108 
1109 # authenticated server
1110 sub command18 {
1111  return;
1112  # This sub disabled by tassium - it has been replaced with smtp_auth_mech
1113  print "Do you wish to use an authenticated SMTP server? Your server must\n";
1114  print "support this in order for SquirrelMail to work with it. We implemented\n";
1115  print "it according to RFC 2554.\n";
1116 
1117  $YesNo = 'n';
1118  $YesNo = 'y' if ( lc($use_authenticated_smtp) eq "true" );
1119 
1120  print "Use authenticated SMTP server (y/n) [$WHT$YesNo$NRM]: $WHT";
1121 
1122  $new_use_authenticated_smtp = <STDIN>;
1123  $new_use_authenticated_smtp =~ tr/yn//cd;
1124  return "true" if ( $new_use_authenticated_smtp eq "y" );
1125  return "false" if ( $new_use_authenticated_smtp eq "n" );
1126  return $use_authenticated_smtp;
1127 }
1128 
1129 # pop before SMTP
1130 sub command18a {
1131  print "Do you wish to use POP3 before SMTP? Your server must\n";
1132  print "support this in order for SquirrelMail to work with it.\n";
1133 
1134  $YesNo = 'n';
1135  $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
1136 
1137  print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
1138 
1139  $new_pop_before_smtp = <STDIN>;
1140  $new_pop_before_smtp =~ tr/yn//cd;
1141  if ( $new_pop_before_smtp eq "y" ) {
1142  $new_pop_before_smtp = "true";
1143  } elsif ( $new_pop_before_smtp eq "n" ) {
1144  $new_pop_before_smtp = "false";
1145  } else {
1146  $new_pop_before_smtp = $pop_before_smtp;
1147  }
1148 
1149  # if using POP before SMTP, allow setting of custom POP server address
1150  if ($new_pop_before_smtp eq "true") {
1151  print "$NRM\nIf the address of the POP server is not the same as\n";
1152  print "your SMTP server, you may specify it here. Leave blank (to\n";
1153  print "clear this, enter only spaces) to use the same address as\n";
1154  print "your SMTP server.\n";
1155  print "POP before SMTP server address [$WHT$pop_before_smtp_host$NRM]: $WHT";
1156 
1157  $new_pop_before_smtp_host = <STDIN>;
1158  if ( $new_pop_before_smtp_host eq "\n" ) {
1159  $new_pop_before_smtp_host = $pop_before_smtp_host;
1160  } elsif ($new_pop_before_smtp_host =~ /^\s+$/) {
1161  $new_pop_before_smtp_host = '';
1162  } else {
1163  $new_pop_before_smtp_host =~ s/[\r|\n]//g;
1164  }
1165  $pop_before_smtp_host = $new_pop_before_smtp_host;
1166  }
1167 
1168  return $new_pop_before_smtp;
1169 }
1170 
1171 # imap_server_type
1172 sub command19 {
1173  print "Each IMAP server has its own quirks. As much as we tried to stick\n";
1174  print "to standards, it doesn't help much if the IMAP server doesn't follow\n";
1175  print "the same principles. We have made some work-arounds for some of\n";
1176  print "these servers. If you would like to use them, please select your\n";
1177  print "IMAP server. If you do not wish to use these work-arounds, you can\n";
1178  print "set this to \"other\", and none will be used.\n";
1179  print $list_supported_imap_servers;
1180  print " other = Not one of the above servers\n";
1181  print "[$WHT$imap_server_type$NRM]: $WHT";
1182  $new_imap_server_type = <STDIN>;
1183 
1184  if ( $new_imap_server_type eq "\n" ) {
1185  $new_imap_server_type = $imap_server_type;
1186  } else {
1187  $new_imap_server_type =~ s/[\r|\n]//g;
1188  }
1189  return $new_imap_server_type;
1190 }
1191 
1192 # invert_time
1193 sub command110 {
1194  print "Sometimes the date of messages sent is messed up (off by a few hours\n";
1195  print "on some machines). Typically this happens if the system doesn't support\n";
1196  print "tm_gmtoff. It will happen only if your time zone is \"negative\".\n";
1197  print "This most often occurs on Solaris 7 machines in the United States.\n";
1198  print "By default, this is off. It should be kept off unless problems surface\n";
1199  print "about the time that messages are sent.\n";
1200  print " no = Do NOT fix time -- almost always correct\n";
1201  print " yes = Fix the time for this system\n";
1202 
1203  $YesNo = 'n';
1204  $YesNo = 'y' if ( lc($invert_time) eq "true" );
1205 
1206  print "Fix the time for this system (y/n) [$WHT$YesNo$NRM]: $WHT";
1207 
1208  $new_invert_time = <STDIN>;
1209  $new_invert_time =~ tr/yn//cd;
1210  return "true" if ( $new_invert_time eq "y" );
1211  return "false" if ( $new_invert_time eq "n" );
1212  return $invert_time;
1213 }
1214 
1215 sub command111 {
1216  print "This is the delimiter that your IMAP server uses to distinguish between\n";
1217  print "folders. For example, Cyrus uses '.' as the delimiter and a complete\n";
1218  print "folder would look like 'INBOX.Friends.Bob', while UW uses '/' and would\n";
1219  print "look like 'INBOX/Friends/Bob'. Normally this should be left at 'detect'\n";
1220  print "but if you are sure you know what delimiter your server uses, you can\n";
1221  print "specify it here.\n";
1222  print "\nTo have it autodetect the delimiter, set it to 'detect'.\n\n";
1223  print "[$WHT$optional_delimiter$NRM]: $WHT";
1224  $new_optional_delimiter = <STDIN>;
1225 
1226  if ( $new_optional_delimiter eq "\n" ) {
1227  $new_optional_delimiter = $optional_delimiter;
1228  } else {
1229  $new_optional_delimiter =~ s/[\r|\n]//g;
1230  }
1231  return $new_optional_delimiter;
1232 }
1233 # IMAP authentication type
1234 # Possible values: login, cram-md5, digest-md5
1235 # Now offers to detect supported mechs, assuming server & port are set correctly
1236 
1237 sub command112a {
1238  if ($use_imap_tls =~ /^true\b/i) {
1239  print "Auto-detection of login methods is unavailable when using TLS.\n";
1240  } else {
1241  print "If you have already set the hostname and port number, I can try to\n";
1242  print "detect the mechanisms your IMAP server supports.\n";
1243  print "I will try to detect CRAM-MD5 and DIGEST-MD5 support. I can't test\n";
1244  print "for \"login\" without knowing a username and password.\n";
1245  print "Auto-detecting is optional - you can safely say \"n\" here.\n";
1246  print "\nTry to detect supported mechanisms? [y/N]: ";
1247  $inval=<STDIN>;
1248  chomp($inval);
1249  if ($inval =~ /^y\b/i) {
1250  # Yes, let's try to detect.
1251  print "Trying to detect IMAP capabilities...\n";
1252  my $host = $imapServerAddress . ':'. $imapPort;
1253  print "CRAM-MD5:\t";
1254  my $tmp = detect_auth_support('IMAP',$host,'CRAM-MD5');
1255  if (defined($tmp)) {
1256  if ($tmp eq 'YES') {
1257  print "$WHT SUPPORTED$NRM\n";
1258  } else {
1259  print "$WHT NOT SUPPORTED$NRM\n";
1260  }
1261  } else {
1262  print $WHT . " ERROR DETECTING$NRM\n";
1263  }
1264 
1265  print "DIGEST-MD5:\t";
1266  $tmp = detect_auth_support('IMAP',$host,'DIGEST-MD5');
1267  if (defined($tmp)) {
1268  if ($tmp eq 'YES') {
1269  print "$WHT SUPPORTED$NRM\n";
1270  } else {
1271  print "$WHT NOT SUPPORTED$NRM\n";
1272  }
1273  } else {
1274  print $WHT . " ERROR DETECTING$NRM\n";
1275  }
1276 
1277  }
1278  }
1279  print "\nWhat authentication mechanism do you want to use for IMAP connections?\n\n";
1280  print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1281  print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext methods.\n";
1282  print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1283  print "\n*** YOUR IMAP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n";
1284  print "If you don't understand or are unsure, you probably want \"login\"\n\n";
1285  print "login, cram-md5, or digest-md5 [$WHT$imap_auth_mech$NRM]: $WHT";
1286  $inval=<STDIN>;
1287  chomp($inval);
1288  if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) || ($inval =~ /^login\b/i)) {
1289  return lc($inval);
1290  } else {
1291  # user entered garbage or default value so nothing needs to be set
1292  return $imap_auth_mech;
1293  }
1294 }
1295 
1296 
1297 # SMTP authentication type
1298 # Possible choices: none, login, plain, cram-md5, digest-md5
1299 sub command112b {
1300  if ($use_smtp_tls =~ /^true\b/i) {
1301  print "Auto-detection of login methods is unavailable when using TLS.\n";
1302  } elsif (eval ("use IO::Socket; 1")) {
1303  print "If you have already set the hostname and port number, I can try to\n";
1304  print "automatically detect the mechanisms your SMTP server supports.\n";
1305  print "Auto-detection is *optional* - you can safely say \"n\" here.\n";
1306  print "\nTry to detect auth mechanisms? [y/N]: ";
1307  $inval=<STDIN>;
1308  chomp($inval);
1309  if ($inval =~ /^y\b/i) {
1310  # Yes, let's try to detect.
1311  print "Trying to detect supported methods (SMTP)...\n";
1312 
1313  # Special case!
1314  # Check none by trying to relay to junk@microsoft.com
1315  $host = $smtpServerAddress . ':' . $smtpPort;
1316  my $sock = IO::Socket::INET->new($host);
1317  print "Testing none:\t\t$WHT";
1318  if (!defined($sock)) {
1319  print " ERROR TESTING\n";
1320  close $sock;
1321  } else {
1322  $got = <$sock>; # Discard greeting
1323  print $sock "HELO $domain\r\n";
1324  $got = <$sock>; # Discard
1325  print $sock "MAIL FROM:<tester\@squirrelmail.org>\r\n";
1326  $got = <$sock>; # Discard
1327  print $sock "RCPT TO:<junk\@microsoft.com>\r\n";
1328  $got = <$sock>; # This is the important line
1329  if ($got =~ /^250\b/) { # SMTP will relay without auth
1330  print "SUPPORTED$NRM\n";
1331  } else {
1332  print "NOT SUPPORTED$NRM\n";
1333  }
1334  print $sock "RSET\r\n";
1335  print $sock "QUIT\r\n";
1336  close $sock;
1337  }
1338  # Try login (SquirrelMail default)
1339  print "Testing login:\t\t";
1340  $tmp=detect_auth_support('SMTP',$host,'LOGIN');
1341  if (defined($tmp)) {
1342  if ($tmp eq 'YES') {
1343  print $WHT . "SUPPORTED$NRM\n";
1344  } else {
1345  print $WHT . "NOT SUPPORTED$NRM\n";
1346  }
1347  } else {
1348  print $WHT . "ERROR DETECTING$NRM\n";
1349  }
1350 
1351  # Try plain
1352  print "Testing plain:\t\t";
1353  $tmp=detect_auth_support('SMTP',$host,'PLAIN');
1354  if (defined($tmp)) {
1355  if ($tmp eq 'YES') {
1356  print $WHT . "SUPPORTED$NRM\n";
1357  } else {
1358  print $WHT . "NOT SUPPORTED$NRM\n";
1359  }
1360  } else {
1361  print $WHT . "ERROR DETECTING$NRM\n";
1362  }
1363 
1364  # Try CRAM-MD5
1365  print "Testing CRAM-MD5:\t";
1366  $tmp=detect_auth_support('SMTP',$host,'CRAM-MD5');
1367  if (defined($tmp)) {
1368  if ($tmp eq 'YES') {
1369  print $WHT . "SUPPORTED$NRM\n";
1370  } else {
1371  print $WHT . "NOT SUPPORTED$NRM\n";
1372  }
1373  } else {
1374  print $WHT . "ERROR DETECTING$NRM\n";
1375  }
1376 
1377 
1378  print "Testing DIGEST-MD5:\t";
1379  $tmp=detect_auth_support('SMTP',$host,'DIGEST-MD5');
1380  if (defined($tmp)) {
1381  if ($tmp eq 'YES') {
1382  print $WHT . "SUPPORTED$NRM\n";
1383  } else {
1384  print $WHT . "NOT SUPPORTED$NRM\n";
1385  }
1386  } else {
1387  print $WHT . "ERROR DETECTING$NRM\n";
1388  }
1389  }
1390  }
1391  print "\nWhat authentication mechanism do you want to use for SMTP connections?\n";
1392  print $WHT . "none" . $NRM . " - Your SMTP server does not require authorization.\n";
1393  print $WHT . "login" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1394  print $WHT . "plain" . $NRM . " - Plaintext. If you can do better, you probably should.\n";
1395  print $WHT . "cram-md5" . $NRM . " - Slightly better than plaintext.\n";
1396  print $WHT . "digest-md5" . $NRM . " - Privacy protection - better than cram-md5.\n";
1397  print $WHT . "\n*** YOUR SMTP SERVER MUST SUPPORT THE MECHANISM YOU CHOOSE HERE ***\n" . $NRM;
1398  print "If you don't understand or are unsure, you probably want \"none\"\n\n";
1399  print "none, login, plain, cram-md5, or digest-md5 [$WHT$smtp_auth_mech$NRM]: $WHT";
1400  $inval=<STDIN>;
1401  chomp($inval);
1402  if ($inval =~ /^none\b/i) {
1403  # SMTP doesn't necessarily require logins
1404  $smtp_sitewide_user = '';
1405  $smtp_sitewide_pass = '';
1406  return "none";
1407  }
1408  if ( ($inval =~ /^cram-md5\b/i) || ($inval =~ /^digest-md5\b/i) ||
1409  ($inval =~ /^login\b/i) || ($inval =~ /^plain\b/i)) {
1410  command_smtp_sitewide_userpass($inval);
1411  return lc($inval);
1412  } elsif (trim($inval) eq '') {
1413  command_smtp_sitewide_userpass($smtp_auth_mech);
1414  return $smtp_auth_mech;
1415  } else {
1416  # user entered garbage
1417  return $smtp_auth_mech;
1418  }
1419 }
1420 
1421 sub command_smtp_sitewide_userpass($) {
1422  # get first function argument
1423  my $auth_mech = shift(@_);
1424  my $default, $tmp;
1425  $auth_mech = lc(trim($auth_mech));
1426  if ($auth_mech eq 'none') {
1427  return;
1428  }
1429  print "SMTP authentication uses IMAP username and password by default.\n";
1430  print "\n";
1431  print "Would you like to use other login and password for all SquirrelMail \n";
1432  print "SMTP connections?";
1433  if ($smtp_sitewide_user ne '') {
1434  $default = 'y';
1435  print " [Y/n]:";
1436  } else {
1437  $default = 'n';
1438  print " [y/N]:";
1439  }
1440  $tmp=<STDIN>;
1441  $tmp = trim($tmp);
1442 
1443  if ($tmp eq '') {
1444  $tmp = $default;
1445  } else {
1446  $tmp = lc($tmp);
1447  }
1448 
1449  if ($tmp eq 'n') {
1450  $smtp_sitewide_user = '';
1451  $smtp_sitewide_pass = '';
1452  } elsif ($tmp eq 'y') {
1453  print "Enter username [$smtp_sitewide_user]:";
1454  my $new_user = <STDIN>;
1455  $new_user = trim($new_user);
1456  if ($new_user ne '') {
1457  $smtp_sitewide_user = $new_user;
1458  }
1459  if ($smtp_sitewide_user ne '') {
1460  print "If you don't enter any password, current sitewide password will be used.\n";
1461  print "If you enter space, password will be set to empty string.\n";
1462  print "Enter password:";
1463  my $new_pass = <STDIN>;
1464  if ($new_pass ne "\n") {
1465  $smtp_sitewide_pass = trim($new_pass);
1466  }
1467  } else {
1468  print "Invalid input. You must set username used for SMTP authentication.\n";
1469  print "Press enter to continue\n";
1470  $tmp = <STDIN>;
1471  }
1472  } else {
1473  print "Invalid input\n";
1474  print "Press enter to continue\n";
1475  $tmp = <STDIN>;
1476  }
1477 }
1478 
1479 # Sub adds information about SMTP authentication type to menu
1480 sub display_smtp_sitewide_userpass() {
1481  my $ret = '';
1482  if ($smtp_auth_mech ne 'none') {
1483  if ($smtp_sitewide_user ne '') {
1484  $ret = ' (with custom username and password)';
1485  } else {
1486  $ret = ' (with IMAP username and password)';
1487  }
1488  }
1489  return $ret;
1490 }
1491 
1492 
1493 # TLS
1494 # This sub is reused for IMAP and SMTP
1495 # Args: service name, default value
1496 sub command113 {
1497  my($default_val,$service,$inval);
1498  $service=$_[0];
1499  $default_val=$_[1];
1500  print "TLS (Transport Layer Security) encrypts the traffic between server and client.\n";
1501  print "If you're familiar with SSL, you get the idea.\n";
1502  print "To use this feature, your " . $service . " server must offer TLS\n";
1503  print "capability, plus PHP 4.3.x with OpenSSL support.\n";
1504  print "Note that the 'STARTTLS' command is not supported; the server must\n";
1505  print "have a dedicated port listening for TLS connections.\n";
1506  print "\nIf your " . $service . " server is localhost, you can safely disable this.\n";
1507  print "If it is remote, you may wish to seriously consider enabling this.\n";
1508  print "Enable TLS (y/n) [$WHT";
1509  if ($default_val eq "true") {
1510  print "y";
1511  } else {
1512  print "n";
1513  }
1514  print "$NRM]: $WHT";
1515  $inval=<STDIN>;
1516  $inval =~ tr/yn//cd;
1517  return "true" if ( $inval eq "y" );
1518  return "false" if ( $inval eq "n" );
1519  return $default_val;
1520 }
1521 
1522 # $encode_header_key
1523 sub command114{
1524  print "This encryption key allows the hiding of SquirrelMail Received:\n";
1525  print "headers in outbound messages. SquirrelMail uses the encryption\n";
1526  print "key to encode the username, remote address, and proxied address\n";
1527  print "and then stores that encoded information in X-Squirrel-* headers.\n";
1528  print "\n";
1529  print "Warning: the encryption function used to accomplish this is not\n";
1530  print "bulletproof. When used with a static encryption key as it is here,\n";
1531  print "it provides only minimal security and the encoded user information\n";
1532  print "in the X-Squirrel-* headers can be decoded quickly by a skilled\n";
1533  print "attacker.\n";
1534  print "\n";
1535  print "When you need to inspect an email sent from your system with the\n";
1536  print "X-Squirrel-* headers, you can decode the user information therein\n";
1537  print "by using the decrypt_headers.php script found in the SquirrelMail\n";
1538  print "contrib/ directory. You'll need the encryption key that you\n";
1539  print "defined here when doing so.\n";
1540  print "\n";
1541  print "Enter encryption key: ";
1542  $new_encode_header_key = <STDIN>;
1543  if ( $new_encode_header_key eq "\n" ) {
1544  $new_encode_header_key = $encode_header_key;
1545  } else {
1546  $new_encode_header_key =~ s/[\r\n]//g;
1547  }
1548  return $new_encode_header_key;
1549 }
1550 
1551 ####################################################################################
1552 #### MOTD ####
1553 sub command71 {
1554  print "\nYou can now create the welcome message that is displayed\n";
1555  print "every time a user logs on. You can use HTML or just plain\n";
1556  print
1557 "text. If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
1558 
1559  $new_motd = "";
1560  do {
1561  print "] ";
1562  $line = <STDIN>;
1563  $line =~ s/[\r|\n]//g;
1564  if ( $line ne "@" ) {
1565  $line =~ s/ /\&nbsp;\&nbsp;/g;
1566  $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
1567  $line =~ s/$/ /;
1568  $line =~ s/\"/\\\"/g;
1569 
1570  $new_motd = $new_motd . $line;
1571  }
1572  } while ( $line ne "@" );
1573  return $new_motd;
1574 }
1575 
1576 ####################################################################################
1577 #### PLUGINS ####
1578 sub command81 {
1579  $command =~ s/[\s|\n|\r]*//g;
1580  if ( $command > 0 ) {
1581  $command = $command - 1;
1582  if ( $command <= $#plugins ) {
1583  @newplugins = ();
1584  $ct = 0;
1585  while ( $ct <= $#plugins ) {
1586  if ( $ct != $command ) {
1587  @newplugins = ( @newplugins, $plugins[$ct] );
1588  }
1589  $ct++;
1590  }
1591  @plugins = @newplugins;
1592  } elsif ( $command <= $#plugins + $#unused_plugins + 1 ) {
1593  $num = $command - $#plugins - 1;
1594  @newplugins = @plugins;
1595  $ct = 0;
1596  while ( $ct <= $#unused_plugins ) {
1597  if ( $ct == $num ) {
1598  @newplugins = ( @newplugins, $unused_plugins[$ct] );
1599  }
1600  $ct++;
1601  }
1602  @plugins = @newplugins;
1603  }
1604  }
1605  return @plugins;
1606 }
1607 
1608 ####################################################################################
1609 #### FOLDERS #####
1610 # default_folder_prefix
1611 sub command21 {
1612  print "Some IMAP servers (UW, for example) store mail and folders in\n";
1613  print "your user space in a separate subdirectory. This is where you\n";
1614  print "specify what that directory is.\n";
1615  print "\n";
1616  print "EXAMPLE: mail/";
1617  print "\n";
1618  print "NOTE: If you use Cyrus, or some server that would not use this\n";
1619  print " option, you must set this to 'none'.\n";
1620  print "\n";
1621  print "[$WHT$default_folder_prefix$NRM]: $WHT";
1622  $new_default_folder_prefix = <STDIN>;
1623 
1624  if ( $new_default_folder_prefix eq "\n" ) {
1625  $new_default_folder_prefix = $default_folder_prefix;
1626  } else {
1627  $new_default_folder_prefix =~ s/[\r\n]//g;
1628  }
1629  if ( ( $new_default_folder_prefix =~ /^\s*$/ ) || ( $new_default_folder_prefix =~ m/^none$/i ) ) {
1630  $new_default_folder_prefix = "";
1631  } else {
1632  # add the trailing delimiter only if we know what the server is.
1633  if (($imap_server_type eq 'cyrus' and
1634  $optional_delimiter eq 'detect') or
1635  ($imap_server_type eq 'courier' and
1636  $optional_delimiter eq 'detect')) {
1637  $new_default_folder_prefix =~ s/\.*$/\./;
1638  } elsif ($imap_server_type eq 'uw' and
1639  $optional_delimiter eq 'detect') {
1640  $new_default_folder_prefix =~ s/\/*$/\//;
1641  }
1642  }
1643  return $new_default_folder_prefix;
1644 }
1645 
1646 # Show Folder Prefix
1647 sub command22 {
1648  print "It is possible to set up the default folder prefix as a user\n";
1649  print "specific option, where each user can specify what their mail\n";
1650  print "folder is. If you set this to false, they will never see the\n";
1651  print "option, but if it is true, this option will appear in the\n";
1652  print "'options' section.\n";
1653  print "\n";
1654  print "NOTE: You set the default folder prefix in option '1' of this\n";
1655  print " section. That will be the default if the user doesn't\n";
1656  print " specify anything different.\n";
1657  print "\n";
1658 
1659  if ( lc($show_prefix_option) eq "true" ) {
1660  $default_value = "y";
1661  } else {
1662  $default_value = "n";
1663  }
1664  print "\n";
1665  print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1666  $new_show = <STDIN>;
1667  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1668  $show_prefix_option = "true";
1669  } else {
1670  $show_prefix_option = "false";
1671  }
1672  return $show_prefix_option;
1673 }
1674 
1675 # Trash Folder
1676 sub command23a {
1677  print "You can now specify where the default trash folder is located.\n";
1678  print "On servers where you do not want this, you can set it to anything\n";
1679  print "and set option 6 to false.\n";
1680  print "\n";
1681  print "This is relative to where the rest of your email is kept. You do\n";
1682  print "not need to worry about their mail directory. If this folder\n";
1683  print "would be ~/mail/trash on the filesystem, you only need to specify\n";
1684  print "that this is 'trash', and be sure to put 'mail/' in option 1.\n";
1685  print "\n";
1686 
1687  print "[$WHT$trash_folder$NRM]: $WHT";
1688  $new_trash_folder = <STDIN>;
1689  if ( $new_trash_folder eq "\n" ) {
1690  $new_trash_folder = $trash_folder;
1691  } else {
1692  if (check_imap_folder($new_trash_folder)) {
1693  $new_trash_folder =~ s/[\r|\n]//g;
1694  } else {
1695  $new_trash_folder = $trash_folder;
1696  }
1697  }
1698  return $new_trash_folder;
1699 }
1700 
1701 # Sent Folder
1702 sub command23b {
1703  print "This is where messages that are sent will be stored. SquirrelMail\n";
1704  print "by default puts a copy of all outgoing messages in this folder.\n";
1705  print "\n";
1706  print "This is relative to where the rest of your email is kept. You do\n";
1707  print "not need to worry about their mail directory. If this folder\n";
1708  print "would be ~/mail/sent on the filesystem, you only need to specify\n";
1709  print "that this is 'sent', and be sure to put 'mail/' in option 1.\n";
1710  print "\n";
1711 
1712  print "[$WHT$sent_folder$NRM]: $WHT";
1713  $new_sent_folder = <STDIN>;
1714  if ( $new_sent_folder eq "\n" ) {
1715  $new_sent_folder = $sent_folder;
1716  } else {
1717  if (check_imap_folder($new_sent_folder)) {
1718  $new_sent_folder =~ s/[\r|\n]//g;
1719  } else {
1720  $new_sent_folder = $sent_folder;
1721  }
1722  }
1723  return $new_sent_folder;
1724 }
1725 
1726 # Draft Folder
1727 sub command23c {
1728  print "You can now specify where the default draft folder is located.\n";
1729  print "On servers where you do not want this, you can set it to anything\n";
1730  print "and set option 9 to false.\n";
1731  print "\n";
1732  print "This is relative to where the rest of your email is kept. You do\n";
1733  print "not need to worry about their mail directory. If this folder\n";
1734  print "would be ~/mail/drafts on the filesystem, you only need to specify\n";
1735  print "that this is 'drafts', and be sure to put 'mail/' in option 1.\n";
1736  print "\n";
1737 
1738  print "[$WHT$draft_folder$NRM]: $WHT";
1739  $new_draft_folder = <STDIN>;
1740  if ( $new_draft_folder eq "\n" ) {
1741  $new_draft_folder = $draft_folder;
1742  } else {
1743  if (check_imap_folder($new_draft_folder)) {
1744  $new_draft_folder =~ s/[\r|\n]//g;
1745  } else {
1746  $new_draft_folder = $draft_folder;
1747  }
1748  }
1749  return $new_draft_folder;
1750 }
1751 
1752 # default move to trash
1753 sub command24a {
1754  print "By default, should messages get moved to the trash folder? You\n";
1755  print "can specify the default trash folder in option 3. If this is set\n";
1756  print "to false, messages will get deleted immediately without moving\n";
1757  print "to the trash folder.\n";
1758  print "\n";
1759  print "Trash folder is currently: $trash_folder\n";
1760  print "\n";
1761 
1762  if ( lc($default_move_to_trash) eq "true" ) {
1763  $default_value = "y";
1764  } else {
1765  $default_value = "n";
1766  }
1767  print "By default, move to trash (y/n) [$WHT$default_value$NRM]: $WHT";
1768  $new_show = <STDIN>;
1769  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1770  $default_move_to_trash = "true";
1771  } else {
1772  $default_move_to_trash = "false";
1773  }
1774  return $default_move_to_trash;
1775 }
1776 
1777 # default move to sent (save sent messages)
1778 sub command24b {
1779  print "By default, should copies of outgoing messages get saved in the\n";
1780  print "sent folder? You can specify the default sent folder in option 4.\n";
1781  print "If this is set to false, messages will get sent and no copy will\n";
1782  print "be made.\n";
1783  print "\n";
1784  print "Sent folder is currently: $sent_folder\n";
1785  print "\n";
1786 
1787  if ( lc($default_move_to_sent) eq "true" ) {
1788  $default_value = "y";
1789  } else {
1790  $default_value = "n";
1791  }
1792  print "By default, save sent messages (y/n) [$WHT$default_value$NRM]: $WHT";
1793  $new_show = <STDIN>;
1794  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1795  $default_move_to_sent = "true";
1796  } else {
1797  $default_move_to_sent = "false";
1798  }
1799  return $default_move_to_sent;
1800 }
1801 
1802 # default save as draft
1803 sub command24c {
1804  print "By default, should the save to draft option be shown? You can\n";
1805  print "specify the default drafts folder in option 5. If this is set\n";
1806  print "to false, users will not be shown the save to draft option.\n";
1807  print "\n";
1808  print "Drafts folder is currently: $draft_folder\n";
1809  print "\n";
1810 
1811  if ( lc($default_save_as_draft) eq "true" ) {
1812  $default_value = "y";
1813  } else {
1814  $default_value = "n";
1815  }
1816  print "By default, save as draft (y/n) [$WHT$default_value$NRM]: $WHT";
1817  $new_show = <STDIN>;
1818  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1819  $default_save_as_draft = "true";
1820  } else {
1821  $default_save_as_draft = "false";
1822  }
1823  return $default_save_as_draft;
1824 }
1825 
1826 # List special folders first
1827 sub command27 {
1828  print "SquirrelMail has what we call 'special folders' that are not\n";
1829  print "manipulated and viewed like normal folders. Some examples of\n";
1830  print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1831  print "Simply asks if you want these folders listed first in the folder\n";
1832  print "listing.\n";
1833  print "\n";
1834 
1835  if ( lc($list_special_folders_first) eq "true" ) {
1836  $default_value = "y";
1837  } else {
1838  $default_value = "n";
1839  }
1840  print "\n";
1841  print "List first (y/n) [$WHT$default_value$NRM]: $WHT";
1842  $new_show = <STDIN>;
1843  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1844  $list_special_folders_first = "true";
1845  } else {
1846  $list_special_folders_first = "false";
1847  }
1848  return $list_special_folders_first;
1849 }
1850 
1851 # Show special folders color
1852 sub command28 {
1853  print "SquirrelMail has what we call 'special folders' that are not\n";
1854  print "manipulated and viewed like normal folders. Some examples of\n";
1855  print "these folders would be INBOX, Trash, Sent, etc. This option\n";
1856  print "wants to know if we should display special folders in a\n";
1857  print "color than the other folders.\n";
1858  print "\n";
1859 
1860  if ( lc($use_special_folder_color) eq "true" ) {
1861  $default_value = "y";
1862  } else {
1863  $default_value = "n";
1864  }
1865  print "\n";
1866  print "Show color (y/n) [$WHT$default_value$NRM]: $WHT";
1867  $new_show = <STDIN>;
1868  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1869  $use_special_folder_color = "true";
1870  } else {
1871  $use_special_folder_color = "false";
1872  }
1873  return $use_special_folder_color;
1874 }
1875 
1876 # Auto expunge
1877 sub command29 {
1878  print "The way that IMAP handles deleting messages is as follows. You\n";
1879  print "mark the message as deleted, and then to 'really' delete it, you\n";
1880  print "expunge it. This option asks if you want to just have messages\n";
1881  print "marked as deleted, or if you want SquirrelMail to expunge the \n";
1882  print "messages too.\n";
1883  print "\n";
1884 
1885  if ( lc($auto_expunge) eq "true" ) {
1886  $default_value = "y";
1887  } else {
1888  $default_value = "n";
1889  }
1890  print "Auto expunge (y/n) [$WHT$default_value$NRM]: $WHT";
1891  $new_show = <STDIN>;
1892  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1893  $auto_expunge = "true";
1894  } else {
1895  $auto_expunge = "false";
1896  }
1897  return $auto_expunge;
1898 }
1899 
1900 # Default sub of inbox
1901 sub command210 {
1902  print "Some IMAP servers have all folders as subfolders of INBOX.\n";
1903  print "This can cause some confusion in folder creation for users when\n";
1904  print "they try to create folders and don't put it as a subfolder of INBOX\n";
1905  print "and get permission errors. This option asks if you want folders\n";
1906  print "to be subfolders of INBOX by default.\n";
1907  print "\n";
1908 
1909  if ( lc($default_sub_of_inbox) eq "true" ) {
1910  $default_value = "y";
1911  } else {
1912  $default_value = "n";
1913  }
1914  print "Default sub of INBOX (y/n) [$WHT$default_value$NRM]: $WHT";
1915  $new_show = <STDIN>;
1916  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1917  $default_sub_of_inbox = "true";
1918  } else {
1919  $default_sub_of_inbox = "false";
1920  }
1921  return $default_sub_of_inbox;
1922 }
1923 
1924 # Show contain subfolder option
1925 sub command211 {
1926  print "Some IMAP servers (UW) make it so that there are two types of\n";
1927  print "folders. Those that contain messages, and those that contain\n";
1928  print "subfolders. If this is the case for your server, set this to\n";
1929  print "true, and it will ask the user whether the folder they are\n";
1930  print "creating contains subfolders or messages.\n";
1931  print "\n";
1932 
1933  if ( lc($show_contain_subfolders_option) eq "true" ) {
1934  $default_value = "y";
1935  } else {
1936  $default_value = "n";
1937  }
1938  print "Show option (y/n) [$WHT$default_value$NRM]: $WHT";
1939  $new_show = <STDIN>;
1940  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
1941  $show_contain_subfolders_option = "true";
1942  } else {
1943  $show_contain_subfolders_option = "false";
1944  }
1945  return $show_contain_subfolders_option;
1946 }
1947 
1948 # Default Unseen Notify
1949 sub command212 {
1950  print "This option specifies where the users will receive notification\n";
1951  print "about unseen messages by default. This is of course an option that\n";
1952  print "can be changed on a user level.\n";
1953  print " 1 = No notification\n";
1954  print " 2 = Only on the INBOX\n";
1955  print " 3 = On all folders\n";
1956  print "\n";
1957 
1958  print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
1959  $new_show = <STDIN>;
1960  if ( $new_show =~ /^[1|2|3]\n/i ) {
1961  $default_unseen_notify = $new_show;
1962  }
1963  $default_unseen_notify =~ s/[\r|\n]//g;
1964  return $default_unseen_notify;
1965 }
1966 
1967 # Default Unseen Type
1968 sub command213 {
1969  print "Here you can define the default way that unseen messages will be displayed\n";
1970  print "to the user in the folder listing on the left side.\n";
1971  print " 1 = Only unseen messages (4)\n";
1972  print " 2 = Unseen and Total messages (4/27)\n";
1973  print "\n";
1974 
1975  print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
1976  $new_show = <STDIN>;
1977  if ( $new_show =~ /^[1|2]\n/i ) {
1978  $default_unseen_type = $new_show;
1979  }
1980  $default_unseen_type =~ s/[\r|\n]//g;
1981  return $default_unseen_type;
1982 }
1983 
1984 # Auto create special folders
1985 sub command214 {
1986  print "Would you like the Sent, Trash, and Drafts folders to be created\n";
1987  print "automatically print for you when a user logs in? If the user\n";
1988  print "accidentally deletes their special folders, this option will\n";
1989  print "automatically create it again for them.\n";
1990  print "\n";
1991 
1992  if ( lc($auto_create_special) eq "true" ) {
1993  $default_value = "y";
1994  } else {
1995  $default_value = "n";
1996  }
1997  print "Auto create special folders? (y/n) [$WHT$default_value$NRM]: $WHT";
1998  $new_show = <STDIN>;
1999  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2000  $auto_create_special = "true";
2001  } else {
2002  $auto_create_special = "false";
2003  }
2004  return $auto_create_special;
2005 }
2006 
2007 # Automatically delete folders
2008 sub command215 {
2009  if ( $imap_server_type eq "uw" ) {
2010  print "UW IMAP servers will not allow folders containing";
2011  print "mail to also contain folders.\n";
2012  print "Deleting folders will bypass the trash folder and";
2013  print "be immediately deleted\n\n";
2014  print "If this is not the correct value for your server,\n";
2015  print "please use option D on the Main Menu to configure your server correctly.\n\n";
2016  print "Press enter to continue...\n";
2017  $new_delete = <STDIN>;
2018  $delete_folder = "true";
2019  } else {
2020  print "Should folders selected for deletion bypass the Trash folder?\n\n";
2021  if ( lc($delete_folder) eq "true" ) {
2022  $default_value = "y";
2023  } else {
2024  $default_value = "n";
2025  }
2026  print "Auto delete folders? (y/n) [$WHT$default_value$NRM]: $WHT";
2027  $new_delete = <STDIN>;
2028  if ( ( $new_delete =~ /^y\n/i ) || ( ( $new_delete =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2029  $delete_folder = "true";
2030  } else {
2031  $delete_folder = "false";
2032  }
2033  }
2034  return $delete_folder;
2035 }
2036 
2037 #noselect fix
2038 sub command216 {
2039  print "Some IMAP servers allow subfolders to exist even if the parent\n";
2040  print "folders do not. This fixes some problems with the folder list\n";
2041  print "when this is the case, causing the /NoSelect folders to be displayed\n";
2042  print "\n";
2043 
2044  if ( lc($noselect_fix_enable) eq "true" ) {
2045  $default_value = "y";
2046  } else {
2047  $default_value = "n";
2048  }
2049  print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
2050  $noselect_fix_enable = <STDIN>;
2051  if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2052  $noselect_fix_enable = "true";
2053  } else {
2054  $noselect_fix_enable = "false";
2055  }
2056  return $noselect_fix_enable;
2057 }
2058 
2059 ####################################################################################
2060 #### GENERAL OPTIONS ####
2061 # Data directory
2062 sub command31 {
2063  print "Specify the location for your data directory.\n";
2064  print "The path name can be absolute or relative (to the config directory).\n";
2065  print "You probably need to create this directory yourself. Here are two examples:\n";
2066  print " Absolute: /var/local/squirrelmail/data/\n";
2067  print " Relative: ../data/\n";
2068  print "Relative paths to directories outside of the SquirrelMail distribution\n";
2069  print "will be converted to their absolute path equivalents in config.php.\n\n";
2070  print "Note: There are potential security risks with having a writable directory\n";
2071  print "under the web server's root directory (ex: /home/httpd/html).\n";
2072  print "For this reason, it is recommended to put the data directory\n";
2073  print "in an alternate location of your choice. \n";
2074  print "\n";
2075 
2076  print "[$WHT$data_dir$NRM]: $WHT";
2077  $new_data_dir = <STDIN>;
2078  if ( $new_data_dir eq "\n" ) {
2079  $new_data_dir = $data_dir;
2080  } else {
2081  $new_data_dir =~ s/[\r|\n]//g;
2082  }
2083  if ( $new_data_dir =~ /^\s*$/ ) {
2084  $new_data_dir = "";
2085  } else {
2086  $new_data_dir =~ s/\/*$//g;
2087  $new_data_dir =~ s/$/\//g;
2088  }
2089  return $new_data_dir;
2090 }
2091 
2092 # Attachment directory
2093 sub command32 {
2094  print "Path to directory used for storing attachments while a mail is\n";
2095  print "being sent. The path name can be absolute or relative (to the config directory).\n";
2096  print "It doesn't matter. Here are two examples:\n";
2097  print " Absolute: /var/spool/squirrelmail/attach/\n";
2098  print " Relative: ../attach/\n";
2099  print "Relative paths to directories outside of the SquirrelMail distribution\n";
2100  print "will be converted to their absolute path equivalents in config.php.\n\n";
2101  print "Note: There are a few security considerations regarding this\n";
2102  print "directory:\n";
2103  print " 1. It should have the permission 733 (rwx-wx-wx) to make it\n";
2104  print " impossible for a random person with access to the webserver\n";
2105  print " to list files in this directory. Confidential data might\n";
2106  print " be laying around in there.\n";
2107  print " Depending on your user:group assignments, 730 (rwx-wx---)\n";
2108  print " may be possible, and more secure (e.g. root:apache)\n";
2109  print " 2. Since the webserver is not able to list the files in the\n";
2110  print " content is also impossible for the webserver to delete files\n";
2111  print " lying around there for too long.\n";
2112  print " 3. It should probably be another directory than the data\n";
2113  print " directory specified in option 3.\n";
2114  print "\n";
2115 
2116  print "[$WHT$attachment_dir$NRM]: $WHT";
2117  $new_attachment_dir = <STDIN>;
2118  if ( $new_attachment_dir eq "\n" ) {
2119  $new_attachment_dir = $attachment_dir;
2120  } else {
2121  $new_attachment_dir =~ s/[\r|\n]//g;
2122  }
2123  if ( $new_attachment_dir =~ /^\s*$/ ) {
2124  $new_attachment_dir = "";
2125  } else {
2126  $new_attachment_dir =~ s/\/*$//g;
2127  $new_attachment_dir =~ s/$/\//g;
2128  }
2129  return $new_attachment_dir;
2130 }
2131 
2132 sub command33 {
2133  print "The directory hash level setting allows you to configure the level\n";
2134  print "of hashing that Squirremail employs in your data and attachment\n";
2135  print "directories. This value must be an integer ranging from 0 to 4.\n";
2136  print "When this value is set to 0, Squirrelmail will simply store all\n";
2137  print "files as normal in the data and attachment directories. However,\n";
2138  print "when set to a value from 1 to 4, a simple hashing scheme will be\n";
2139  print "used to organize the files in this directory. In short, the crc32\n";
2140  print "value for a username will be computed. Then, up to the first 4\n";
2141  print "digits of the hash, as set by this configuration value, will be\n";
2142  print "used to directory hash the files for that user in the data and\n";
2143  print "attachment directory. This allows for better performance on\n";
2144  print "servers with larger numbers of users.\n";
2145  print "\n";
2146 
2147  print "[$WHT$dir_hash_level$NRM]: $WHT";
2148  $new_dir_hash_level = <STDIN>;
2149  if ( $new_dir_hash_level eq "\n" ) {
2150  $new_dir_hash_level = $dir_hash_level;
2151  } else {
2152  $new_dir_hash_level =~ s/[\r|\n]//g;
2153  }
2154  if ( ( int($new_dir_hash_level) < 0 )
2155  || ( int($new_dir_hash_level) > 4 )
2156  || !( int($new_dir_hash_level) eq $new_dir_hash_level ) ) {
2157  print "Invalid Directory Hash Level.\n";
2158  print "Value must be an integer ranging from 0 to 4\n";
2159  print "Hit enter to continue.\n";
2160  $enter_key = <STDIN>;
2161 
2162  $new_dir_hash_level = $dir_hash_level;
2163  }
2164 
2165  return $new_dir_hash_level;
2166 }
2167 
2168 sub command34 {
2169  print "This is the default size (in pixels) of the left folder list.\n";
2170  print "Default is 150, but you can set it to whatever you wish. This\n";
2171  print "is a user preference, so this will only show up as their default.\n";
2172  print "\n";
2173  print "[$WHT$default_left_size$NRM]: $WHT";
2174  $new_default_left_size = <STDIN>;
2175  if ( $new_default_left_size eq "\n" ) {
2176  $new_default_left_size = $default_left_size;
2177  } else {
2178  $new_default_left_size =~ s/[\r|\n]//g;
2179  }
2180  return $new_default_left_size;
2181 }
2182 
2183 sub command35 {
2184  print "Some IMAP servers only have lowercase letters in the usernames\n";
2185  print "but they still allow people with uppercase to log in. This\n";
2186  print "causes a problem with the user's preference files. This option\n";
2187  print "transparently changes all usernames to lowercase.";
2188  print "\n";
2189 
2190  if ( lc($force_username_lowercase) eq "true" ) {
2191  $default_value = "y";
2192  } else {
2193  $default_value = "n";
2194  }
2195  print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT";
2196  $new_show = <STDIN>;
2197  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2198  return "true";
2199  }
2200  return "false";
2201 }
2202 
2203 sub command36 {
2204  print "";
2205  print "\n";
2206 
2207  if ( lc($default_use_priority) eq "true" ) {
2208  $default_value = "y";
2209  } else {
2210  $default_value = "n";
2211  }
2212 
2213  print "Allow users to specify priority of outgoing mail (y/n) [$WHT$default_value$NRM]: $WHT";
2214  $new_show = <STDIN>;
2215  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2216  return "true";
2217  }
2218  return "false";
2219 }
2220 
2221 sub command37 {
2222  print "";
2223  print "\n";
2224 
2225  if ( lc($default_hide_attribution) eq "true" ) {
2226  $default_value = "y";
2227  } else {
2228  $default_value = "n";
2229  }
2230 
2231  print "Hide SM attributions (y/n) [$WHT$default_value$NRM]: $WHT";
2232  $new_show = <STDIN>;
2233  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2234  return "true";
2235  }
2236  return "false";
2237 }
2238 
2239 sub command38 {
2240  print "";
2241  print "\n";
2242 
2243  if ( lc($default_use_mdn) eq "true" ) {
2244  $default_value = "y";
2245  } else {
2246  $default_value = "n";
2247  }
2248 
2249  print "Enable support for read/delivery receipt support (y/n) [$WHT$default_value$NRM]: $WHT";
2250  $new_show = <STDIN>;
2251  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2252  return "true";
2253  }
2254  return "false";
2255 }
2256 
2257 sub command39 {
2258  print "In loosely managed environments, you may want to allow users\n";
2259  print "to edit their full name and email address. In strictly managed\n";
2260  print "environments, you may want to force users to use the name\n";
2261  print "and email address assigned to them.\n";
2262  print "\n";
2263  print "'y' - allow a user to edit their full name and email address,\n";
2264  print "'n' - users must use the assigned values.\n";
2265  print "\n";
2266 
2267  if ( lc($edit_identity) eq "true" ) {
2268  $default_value = "y";
2269  } else {
2270  $default_value = "n";
2271  }
2272  print "Allow editing of user's identity? (y/n) [$WHT$default_value$NRM]: $WHT";
2273  $new_edit = <STDIN>;
2274  if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2275  $edit_identity = "true";
2276  $edit_name = "true";
2277  $hide_auth_header = "false";
2278  } else {
2279  $edit_identity = "false";
2280  $edit_name = command39a();
2281  $hide_auth_header = command39b();
2282  }
2283  return $edit_identity;
2284 }
2285 
2286 sub command39a {
2287  print $NRM;
2288  print "\nAs a follow-up, this option allows you to choose if the user\n";
2289  print "can edit their full name even when you don't want them to\n";
2290  print "change their username\n";
2291  print "\n";
2292 
2293  if ( lc($edit_name) eq "true" ) {
2294  $default_value = "y";
2295  } else {
2296  $default_value = "n";
2297  }
2298  print "Allow editing of the users full name? (y/n) [$WHT$default_value$NRM]: $WHT";
2299  $new_edit = <STDIN>;
2300  if ( ( $new_edit =~ /^y\n/i ) || ( ( $new_edit =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2301  $edit_name = "true";
2302  } else {
2303  $edit_name = "false";
2304  }
2305  return $edit_name;
2306 }
2307 
2308 sub command39b {
2309  print $NRM;
2310  print "\nSquirrelMail adds username information to every outgoing\n";
2311  print "email in order to prevent possible sender forging when\n";
2312  print "users are allowed to change their email and/or full name.\n";
2313  print "\n";
2314  print "You can remove user information from this header (y) if you\n";
2315  print "think that it violates privacy or security.\n";
2316  print "\n";
2317  print "Note: SquirrelMail will refuse to remove that information\n";
2318  print "from the email headers if users are allowed to change their\n";
2319  print "identities, regardless of what you have set here.\n";
2320  print "\n";
2321  print "Note: If you have defined a header encryption key in your SMTP\n";
2322  print "or Sendmail settings (see the \"Server Settings\" option page),\n";
2323  print "this setting is ignored because all user information in outgoing\n";
2324  print "messages is encoded.\n";
2325  print "\n";
2326 
2327  if ( lc($hide_auth_header) eq "true" ) {
2328  $default_value = "y";
2329  } else {
2330  $default_value = "n";
2331  }
2332  print "Remove username from email headers? (y/n) [$WHT$default_value$NRM]: $WHT";
2333  $new_header = <STDIN>;
2334  if ( ( $new_header =~ /^y\n/i ) || ( ( $new_header =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2335  $hide_auth_header = "true";
2336  } else {
2337  $hide_auth_header = "false";
2338  }
2339  return $edit_name;
2340 }
2341 
2342 sub command310 {
2343  print "This option allows you to choose if users can use thread sorting.\n";
2344  print "Your IMAP server must support the THREAD command for this to work.\n";
2345  print "\n";
2346 
2347  if ( lc($allow_thread_sort) eq "true" ) {
2348  $default_value = "y";
2349  } else {
2350  $default_value = "n";
2351  }
2352  print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2353  $allow_thread_sort = <STDIN>;
2354  if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2355  $allow_thread_sort = "true";
2356  } else {
2357  $allow_thread_sort = "false";
2358  }
2359  return $allow_thread_sort;
2360 }
2361 
2362 sub command311 {
2363  print "This option allows you to choose if SM uses server-side sorting\n";
2364  print "Your IMAP server must support the SORT command for this to work\n";
2365  print "\n";
2366 
2367  if ( lc($allow_server_sort) eq "true" ) {
2368  $default_value = "y";
2369  } else {
2370  $default_value = "n";
2371  }
2372  print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
2373  $allow_server_sort = <STDIN>;
2374  if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2375  $allow_server_sort = "true";
2376  } else {
2377  $allow_server_sort = "false";
2378  }
2379  return $allow_server_sort;
2380 }
2381 
2382 sub command312 {
2383  print "This option allows you to choose if SM uses charset search\n";
2384  print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
2385  print "\n";
2386 
2387  if ( lc($allow_charset_search) eq "true" ) {
2388  $default_value = "y";
2389  } else {
2390  $default_value = "n";
2391  }
2392  print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
2393  $allow_charset_search = <STDIN>;
2394  if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2395  $allow_charset_search = "true";
2396  } else {
2397  $allow_charset_search = "false";
2398  }
2399  return $allow_charset_search;
2400 }
2401 
2402 sub command313 {
2403  print "This option allows you to enable unique identifier (UID) support.\n";
2404  print "\n";
2405 
2406  if ( lc($uid_support) eq "true" ) {
2407  $default_value = "y";
2408  } else {
2409  $default_value = "n";
2410  }
2411  print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
2412  $uid_support = <STDIN>;
2413  if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2414  $uid_support = "true";
2415  } else {
2416  $uid_support = "false";
2417  }
2418  return $uid_support;
2419 }
2420 
2421 sub command314 {
2422  print "This option allows you to change the name of the PHP session used\n";
2423  print "by SquirrelMail. Unless you know what you are doing, you probably\n";
2424  print "don't need or want to change this from the default of SQMSESSID.\n";
2425  print "[$WHT$session_name$NRM]: $WHT";
2426  $new_session_name = <STDIN>;
2427  chomp($new_session_name);
2428  if ( $new_session_name eq "" ) {
2429  $new_session_name = $session_name;
2430  }
2431  return $new_session_name;
2432 }
2433 
2434 # set the location base for redirects (since 1.4.8)
2435 sub command_config_location_base {
2436  print "Here you can set the base part of the SquirrelMail URL.\n";
2437  print "It is normally autodetected but if that fails, use this\n";
2438  print "option to override.\n";
2439  print "It should contain only the protocol and hostname/port parts\n";
2440  print "of the URL; the full path will be appended automatically.\n\n";
2441  print "Examples:\nhttp://webmail.example.org\nhttp://webmail.example.com:8080\nhttps://webmail.example.com:6691\n\n";
2442  print "Do not add any path elements.\n";
2443 
2444  print "URL base? [" .$WHT."autodetect$NRM]: $WHT";
2445  $new_config_location_base = <STDIN>;
2446  chomp($new_config_location_base);
2447  $config_location_base = $new_config_location_base;
2448 
2449  return $config_location_base;
2450 }
2451 
2452 
2453 # only_secure_cookies (since 1.4.16)
2454 sub command316 {
2455  print "This option allows you to specify that if a user session is initiated\n";
2456  print "under a secure (HTTPS, SSL-encrypted) connection, the cookies given to\n";
2457  print "the browser will ONLY be transmitted via a secure connection henceforth.\n\n";
2458  print "Generally this is a Good Thing, and should NOT be disabled. However,\n";
2459  print "if you intend to use the Secure Login or Show SSL Link plugins to\n";
2460  print "encrypt the user login, but not the rest of the SquirrelMail session,\n";
2461  print "this can be turned off. Think twice before doing so.\n";
2462  print "\n";
2463 
2464  if ( lc($only_secure_cookies) eq 'true' ) {
2465  $default_value = "y";
2466  } else {
2467  $default_value = "n";
2468  }
2469  print "Transmit cookies only on secure connection when available? (y/n) [$WHT$default_value$NRM]: $WHT";
2470  $only_secure_cookies = <STDIN>;
2471  if ( ( $only_secure_cookies =~ /^y\n/i ) || ( ( $only_secure_cookies =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2472  $only_secure_cookies = 'true';
2473  } else {
2474  $only_secure_cookies = 'false';
2475  }
2476  return $only_secure_cookies;
2477 }
2478 
2479 
2480 
2481 # disable_security_tokens (since 1.4.20RC1)
2482 sub command317 {
2483  print "This option allows you to turn off the security checks in the forms\n";
2484  print "that SquirrelMail generates. It is NOT RECOMMENDED that you disable\n";
2485  print "this feature - otherwise, your users may be exposed to phishing and\n";
2486  print "other attacks.\n";
2487  print "Unless you know what you are doing, you should leave this set to \"NO\".\n";
2488  print "\n";
2489 
2490  if ( lc($disable_security_tokens) eq 'true' ) {
2491  $default_value = "y";
2492  } else {
2493  $default_value = "n";
2494  }
2495  print "Disable secure forms? (y/n) [$WHT$default_value$NRM]: $WHT";
2496  $disable_security_tokens = <STDIN>;
2497  if ( ( $disable_security_tokens =~ /^y\n/i ) || ( ( $disable_security_tokens =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2498  $disable_security_tokens = 'true';
2499  } else {
2500  $disable_security_tokens = 'false';
2501  }
2502  return $disable_security_tokens;
2503 }
2504 
2505 
2506 
2507 # check_referrer (since 1.4.20RC1)
2508 sub command318 {
2509  print "This option allows you to enable referal checks for all page requests\n";
2510  print "made to SquirrelMail. This can help ensure that page requests came\n";
2511  print "from the same server and not from an attacker's site (usually the\n";
2512  print "result of a XSS or phishing attack). To enable referal checking,\n";
2513  print "this setting can be set to the domain where your SquirrelMail is\n";
2514  print "being hosted (usually the same as the Domain setting under Server\n";
2515  print "Settings). For example, it could be \"example.com\", or if you\n";
2516  print "use a plugin (such as Login Manager) to host SquirrelMail on more\n";
2517  print "than one domain, you can set this to \"###DOMAIN###\" to tell it\n";
2518  print "to use the current domain.\n";
2519  print "\n";
2520  print "However, in some cases (where proxy servers are in use, etc.), the\n";
2521  print "domain might be different.\n";
2522  print "\n";
2523  print "NOTE that referal checks are not foolproof - they can be spoofed by\n";
2524  print "browsers, and some browsers intentionally don't send referal\n";
2525  print "information (in which case, the check is silently bypassed)\n";
2526  print "\n";
2527 
2528  print "Referal requirement? [$WHT$check_referrer$NRM]: $WHT";
2529  $new_check_referrer = <STDIN>;
2530  chomp($new_check_referrer);
2531  $check_referrer = $new_check_referrer;
2532 
2533  return $check_referrer;
2534 }
2535 
2536 
2537 
2538 ####################################################################################
2539 #### THEMES ####
2540 sub command41 {
2541  print "\nDefine the themes that you wish to use. If you have added ";
2542  print "a theme of your own, just follow the instructions (?) about how to add ";
2543  print "them. You can also change the default theme.\n";
2544  print "[theme] command (?=help) > ";
2545  $input = <STDIN>;
2546  $input =~ s/[\r|\n]//g;
2547  while ( $input ne "d" ) {
2548  if ( $input =~ /^\s*l\s*/i ) {
2549  $count = 0;
2550  while ( $count <= $#theme_name ) {
2551  if ( $count == $theme_default ) {
2552  print " *";
2553  } else {
2554  print " ";
2555  }
2556  if ( $count < 10 ) {
2557  print " ";
2558  }
2559  $name = $theme_name[$count];
2560  $num_spaces = 35 - length($name);
2561  for ( $i = 0 ; $i < $num_spaces ; $i++ ) {
2562  $name = $name . " ";
2563  }
2564 
2565  print " $count. $name";
2566  print "($theme_path[$count])\n";
2567 
2568  $count++;
2569  }
2570  } elsif ( $input =~ /^\s*m\s*[0-9]+/i ) {
2571  $old_def = $theme_default;
2572  $theme_default = $input;
2573  $theme_default =~ s/^\s*m\s*//;
2574  if ( ( $theme_default > $#theme_name ) || ( $theme_default < 0 ) ) {
2575  print "Cannot set default theme to $theme_default. That theme does not exist.\n";
2576  $theme_default = $old_def;
2577  }
2578  } elsif ( $input =~ /^\s*\+/ ) {
2579  print "What is the name of this theme: ";
2580  $name = <STDIN>;
2581  $name =~ s/[\r|\n]//g;
2582  $theme_name[ $#theme_name + 1 ] = $name;
2583  print "Be sure to put ../themes/ before the filename.\n";
2584  print "What file is this stored in (ex: ../themes/default_theme.php): ";
2585  $name = <STDIN>;
2586  $name =~ s/[\r|\n]//g;
2587  $theme_path[ $#theme_path + 1 ] = $name;
2588  } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2589  if ( $input =~ /[0-9]+\s*$/ ) {
2590  $rem_num = $input;
2591  $rem_num =~ s/^\s*-\s*//g;
2592  $rem_num =~ s/\s*$//;
2593  } else {
2594  $rem_num = $#theme_name;
2595  }
2596  if ( $rem_num == $theme_default ) {
2597  print "You cannot remove the default theme!\n";
2598  } else {
2599  $count = 0;
2600  @new_theme_name = ();
2601  @new_theme_path = ();
2602  while ( $count <= $#theme_name ) {
2603  if ( $count != $rem_num ) {
2604  @new_theme_name = ( @new_theme_name, $theme_name[$count] );
2605  @new_theme_path = ( @new_theme_path, $theme_path[$count] );
2606  }
2607  $count++;
2608  }
2609  @theme_name = @new_theme_name;
2610  @theme_path = @new_theme_path;
2611  if ( $theme_default > $rem_num ) {
2612  $theme_default--;
2613  }
2614  }
2615  } elsif ( $input =~ /^\s*t\s*/i ) {
2616  print "\nStarting detection...\n\n";
2617 
2618  opendir( DIR, "../themes" );
2619  @files = grep { /\.php$/i } sort(readdir(DIR));
2620  $cnt = 0;
2621  while ( $cnt <= $#files ) {
2622  $filename = "../themes/" . $files[$cnt];
2623  if ( $filename ne "../themes/index.php" ) {
2624  $found = 0;
2625  for ( $x = 0 ; $x <= $#theme_path ; $x++ ) {
2626  if ( $theme_path[$x] eq $filename ) {
2627  $found = 1;
2628  }
2629  }
2630  if ( $found != 1 ) {
2631  print "** Found theme: $filename\n";
2632  $def = $files[$cnt];
2633  $def =~ s/_/ /g;
2634  $def =~ s/\.php//g;
2635  $def = lc($def);
2636  #$def =~ s/(^\w+)/ucfirst $1/eg;
2637  #$def =~ s/(\s+)(\w+)/$1 . ucfirst $2/eg;
2638  $def =~ s/(^\w+)|(\s+)(\w+)/ucfirst $1 . $2 . ucfirst $3/eg;
2639  print " What is its name? [$def]: ";
2640  $nm = <STDIN>;
2641  $nm =~ s/^\s+|\s+$|[\n|\r]//g;
2642  if ( $nm eq '' ) { $nm = $def; }
2643  $theme_name[ $#theme_name + 1 ] = $nm;
2644  $theme_path[ $#theme_path + 1 ] = $filename;
2645  }
2646  }
2647  $cnt++;
2648  }
2649  print "\n";
2650  for ( $cnt = 0 ; $cnt <= $#theme_path ; $cnt++ ) {
2651  $filename = $theme_path[$cnt];
2652  if ( !( -e $filename ) ) {
2653  print " Removing $filename (file not found)\n";
2654  $offset = 0;
2655  @new_theme_name = ();
2656  @new_theme_path = ();
2657  for ( $x = 0 ; $x < $#theme_path ; $x++ ) {
2658  if ( $theme_path[$x] eq $filename ) {
2659  $offset = 1;
2660  }
2661  if ( $offset == 1 ) {
2662  $new_theme_name[$x] = $theme_name[ $x + 1 ];
2663  $new_theme_path[$x] = $theme_path[ $x + 1 ];
2664  } else {
2665  $new_theme_name[$x] = $theme_name[$x];
2666  $new_theme_path[$x] = $theme_path[$x];
2667  }
2668  }
2669  @theme_name = @new_theme_name;
2670  @theme_path = @new_theme_path;
2671  }
2672  }
2673  print "\nDetection complete!\n\n";
2674 
2675  closedir DIR;
2676  } elsif ( $input =~ /^\s*\?\s*/ ) {
2677  print ".-------------------------.\n";
2678  print "| t (detect themes) |\n";
2679  print "| + (add theme) |\n";
2680  print "| - N (remove theme) |\n";
2681  print "| m N (mark default) |\n";
2682  print "| l (list themes) |\n";
2683  print "| d (done) |\n";
2684  print "`-------------------------'\n";
2685  }
2686  print "[theme] command (?=help) > ";
2687  $input = <STDIN>;
2688  $input =~ s/[\r|\n]//g;
2689  }
2690 }
2691 
2692 # Theme - CSS file
2693 sub command42 {
2694  print "You may specify a cascading style-sheet (CSS) file to be included\n";
2695  print "on each html page generated by SquirrelMail. The CSS file is useful\n";
2696  print "for specifying a site-wide font. If you're not familiar with CSS\n";
2697  print "files, leave this blank.\n";
2698  print "\n";
2699  print "To clear out an existing value, just type a space for the input.\n";
2700  print "\n";
2701  print "Please be aware of the following: \n";
2702  print " - Relative URLs are relative to the config dir\n";
2703  print " to use the themes directory, use ../themes/css/newdefault.css\n";
2704  print " - To specify a css file defined outside the SquirrelMail source tree\n";
2705  print " use the absolute URL the webserver would use to include the file\n";
2706  print " e.g. http://example.com/css/mystyle.css or /css/mystyle.css\n";
2707  print "\n";
2708  print "[$WHT$theme_css$NRM]: $WHT";
2709  $new_theme_css = <STDIN>;
2710 
2711  if ( $new_theme_css eq "\n" ) {
2712  $new_theme_css = $theme_css;
2713  } else {
2714  $new_theme_css =~ s/[\r|\n]//g;
2715  }
2716  $new_theme_css =~ s/^\s*//;
2717  return $new_theme_css;
2718 }
2719 ####################################################################################
2720 #### Address books ####
2721 # LDAP
2722 sub command61 {
2723  print "You can now define different LDAP servers.\n";
2724  print "Please ensure proper permissions for config.php when including\n";
2725  print "sensitive passwords.\n\n";
2726  print "[ldap] command (?=help) > ";
2727  $input = <STDIN>;
2728  $input =~ s/[\r|\n]//g;
2729  while ( $input ne "d" ) {
2730  if ( $input =~ /^\s*l\s*/i ) {
2731  $count = 0;
2732  while ( $count <= $#ldap_host ) {
2733  print "$count. $ldap_host[$count]\n";
2734  print " base: $ldap_base[$count]\n";
2735  if ( $ldap_charset[$count] ) {
2736  print " charset: $ldap_charset[$count]\n";
2737  }
2738  if ( $ldap_port[$count] ) {
2739  print " port: $ldap_port[$count]\n";
2740  }
2741  if ( $ldap_name[$count] ) {
2742  print " name: $ldap_name[$count]\n";
2743  }
2744  if ( $ldap_maxrows[$count] ) {
2745  print " maxrows: $ldap_maxrows[$count]\n";
2746  }
2747  if ( $ldap_binddn[$count] ) {
2748  print " binddn: $ldap_binddn[$count]\n";
2749  if ( $ldap_bindpw[$count] ) {
2750  print " bindpw: $ldap_bindpw[$count]\n";
2751  }
2752  }
2753  if ( $ldap_protocol[$count] ) {
2754  print " protocol: $ldap_protocol[$count]\n";
2755  }
2756 
2757  print "\n";
2758  $count++;
2759  }
2760  } elsif ( $input =~ /^\s*\+/ ) {
2761  $sub = $#ldap_host + 1;
2762 
2763  print "First, we need to have the hostname or the IP address where\n";
2764  print "this LDAP server resides. Example: ldap.bigfoot.com\n";
2765  print "\n";
2766  print "You can use any URI compatible with your LDAP library. ldaps\n";
2767  print "and ldapi URIs can be used to create secure LDAP connections.\n";
2768  print "hostname: ";
2769  $name = <STDIN>;
2770  $name =~ s/[\r|\n]//g;
2771  $ldap_host[$sub] = $name;
2772 
2773  print "\n";
2774 
2775  print "Next, we need the server root (base dn). For this, an empty\n";
2776  print "string is allowed.\n";
2777  print "Example: ou=member_directory,o=netcenter.com\n";
2778  print "base: ";
2779  $name = <STDIN>;
2780  $name =~ s/[\r|\n]//g;
2781  $ldap_base[$sub] = $name;
2782 
2783  print "\n";
2784 
2785  print "This is the TCP/IP port number for the LDAP server. Default\n";
2786  print "port is 389. This is optional. Press ENTER for default.\n";
2787  print "port: ";
2788  $name = <STDIN>;
2789  $name =~ s/[\r|\n]//g;
2790  $ldap_port[$sub] = $name;
2791 
2792  print "\n";
2793 
2794  print "This is the charset for the server. Default is utf-8. This\n";
2795  print "is also optional. Press ENTER for default.\n";
2796  print "charset: ";
2797  $name = <STDIN>;
2798  $name =~ s/[\r|\n]//g;
2799  $ldap_charset[$sub] = $name;
2800 
2801  print "\n";
2802 
2803  print "This is the name for the server, used to tag the results of\n";
2804  print "the search. Default it \"LDAP: hostname\". Press ENTER for default\n";
2805  print "name: ";
2806  $name = <STDIN>;
2807  $name =~ s/[\r|\n]//g;
2808  $ldap_name[$sub] = $name;
2809 
2810  print "\n";
2811 
2812  print "You can specify the maximum number of rows in the search result.\n";
2813  print "Default is unlimited. Press ENTER for default.\n";
2814  print "maxrows: ";
2815  $name = <STDIN>;
2816  $name =~ s/[\r|\n]//g;
2817  $ldap_maxrows[$sub] = $name;
2818 
2819  print "\n";
2820 
2821  print "If your LDAP server does not like anonymous logins, you can specify bind DN.\n";
2822  print "Default is none, anonymous bind. Press ENTER for default.\n";
2823  print "binddn: ";
2824  $name = <STDIN>;
2825  $name =~ s/[\r|\n]//g;
2826  $ldap_binddn[$sub] = $name;
2827 
2828  print "\n";
2829 
2830  if ( $ldap_binddn[$sub] ne '' ) {
2831 
2832  print "Now, please specify password for that DN.\n";
2833  print "bindpw: ";
2834  $name = <STDIN>;
2835  $name =~ s/[\r|\n]//g;
2836  $ldap_bindpw[$sub] = $name;
2837 
2838  print "\n";
2839  }
2840 
2841  print "You can specify bind protocol version here.\n";
2842  print "Default protocol version depends on your php ldap settings.\n";
2843  print "Press ENTER for default.\n";
2844  print "protocol: ";
2845  $name = <STDIN>;
2846  $name =~ s/[\r|\n]//g;
2847  $ldap_protocol[$sub] = $name;
2848 
2849  print "\n";
2850 
2851  } elsif ( $input =~ /^\s*-\s*[0-9]?/ ) {
2852  if ( $input =~ /[0-9]+\s*$/ ) {
2853  $rem_num = $input;
2854  $rem_num =~ s/^\s*-\s*//g;
2855  $rem_num =~ s/\s*$//;
2856  } else {
2857  $rem_num = $#ldap_host;
2858  }
2859  $count = 0;
2860  @new_ldap_host = ();
2861  @new_ldap_base = ();
2862  @new_ldap_port = ();
2863  @new_ldap_name = ();
2864  @new_ldap_charset = ();
2865  @new_ldap_maxrows = ();
2866  @new_ldap_bindpw = ();
2867  @new_ldap_binddn = ();
2868  @new_ldap_protocol = ();
2869 
2870  while ( $count <= $#ldap_host ) {
2871  if ( $count != $rem_num ) {
2872  @new_ldap_host = ( @new_ldap_host, $ldap_host[$count] );
2873  @new_ldap_base = ( @new_ldap_base, $ldap_base[$count] );
2874  @new_ldap_port = ( @new_ldap_port, $ldap_port[$count] );
2875  @new_ldap_name = ( @new_ldap_name, $ldap_name[$count] );
2876  @new_ldap_charset = ( @new_ldap_charset, $ldap_charset[$count] );
2877  @new_ldap_maxrows = ( @new_ldap_maxrows, $ldap_maxrows[$count] );
2878  @new_ldap_binddn = ( @new_ldap_binddn, $ldap_binddn[$count] );
2879  @new_ldap_bindpw = ( @new_ldap_bindpw, $ldap_bindpw[$count] );
2880  @new_ldap_protocol = ( @new_ldap_protocol, $ldap_protocol[$count] );
2881  }
2882  $count++;
2883  }
2884  @ldap_host = @new_ldap_host;
2885  @ldap_base = @new_ldap_base;
2886  @ldap_port = @new_ldap_port;
2887  @ldap_name = @new_ldap_name;
2888  @ldap_charset = @new_ldap_charset;
2889  @ldap_maxrows = @new_ldap_maxrows;
2890  @ldap_binddn = @new_ldap_binddn;
2891  @ldap_bindpw = @new_ldap_bindpw;
2892  @ldap_protocol = @new_ldap_protocol;
2893  } elsif ( $input =~ /^\s*\?\s*/ ) {
2894  print ".-------------------------.\n";
2895  print "| + (add host) |\n";
2896  print "| - N (remove host) |\n";
2897  print "| l (list hosts) |\n";
2898  print "| d (done) |\n";
2899  print "`-------------------------'\n";
2900  }
2901  print "[ldap] command (?=help) > ";
2902  $input = <STDIN>;
2903  $input =~ s/[\r|\n]//g;
2904  }
2905 }
2906 
2907 # Javascript or html address book
2908 sub command62 {
2909  print "Some of our developers have come up with very good javascript interface\n";
2910  print "for searching through address books, however, our original goals said\n";
2911  print "that we would be 100% HTML. In order to make it possible to use their\n";
2912  print "interface, and yet stick with our goals, we have also written a plain\n";
2913  print "HTML version of the search. Here, you can choose which version to use.\n";
2914  print "\n";
2915  print "This is just the default value. It is also a user option that each\n";
2916  print "user can configure individually\n";
2917  print "\n";
2918 
2919  if ( lc($default_use_javascript_addr_book) eq "true" ) {
2920  $default_value = "y";
2921  } else {
2923  $default_value = "n";
2924  }
2925  print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
2926  $new_show = <STDIN>;
2927  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2929  } else {
2931  }
2933 }
2934 
2935 # global filebased address book
2936 sub command63 {
2937  print "If you want to use global file address book, then you\n";
2938  print "must set this option to a valid value. If option does\n";
2939  print "not have path elements, system assumes that file is\n";
2940  print "stored in data directory. If relative path is set, it is\n";
2941  print "relative to main squirrelmail directory. If value is empty,\n";
2942  print "address book is not enabled.\n";
2943  print "\n";
2944 
2945  print "[$WHT$abook_global_file$NRM]: $WHT";
2946  $new_abook_global_file = <STDIN>;
2947  if ( $new_abook_global_file eq "\n" ) {
2948  $new_abook_global_file = $abook_global_file;
2949  } else {
2950  $new_abook_global_file =~ s/[\r\n]//g;
2951  }
2952  return $new_abook_global_file;
2953 }
2954 
2955 # writing into global filebased abook control
2956 sub command64 {
2957  print "This setting controls writing into global file address\n";
2958  print "book options. Address book file must be writeable by\n";
2959  print "webserver's user, if you want to enable this option.\n";
2960  print "\n";
2961 
2962  if ( lc($abook_global_file_writeable) eq 'true' ) {
2963  $default_value = "y";
2964  } else {
2965  $abook_global_file_writeable = 'false';
2966  $default_value = "n";
2967  }
2968  print "Allow writing into global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
2969  $new_show = <STDIN>;
2970  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2972  } else {
2973  $abook_global_file_writeable = 'false';
2974  }
2976 }
2977 
2978 # listing of global filebased abook control
2979 sub command_abook_global_file_listing {
2980  print "This setting controls listing of global file address book.\n";
2981  print "\n";
2982 
2983  if ( lc($abook_global_file_listing) eq 'true' ) {
2984  $default_value = "y";
2985  } else {
2986  $abook_global_file_listing = 'false';
2987  $default_value = "n";
2988  }
2989  print "Allow listing of global file address book (y/n) [$WHT$default_value$NRM]: $WHT";
2990  $new_show = <STDIN>;
2991  if ( ( $new_show =~ /^y\n/i ) || ( ( $new_show =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
2992  $abook_global_file_listing = 'true';
2993  } else {
2994  $abook_global_file_listing = 'false';
2995  }
2997 }
2998 
2999 # controls $abook_file_line_length setting
3000 sub command_abook_file_line_length {
3001  print "This setting controls space allocated to file based address book records.\n";
3002  print "End users will be unable to save address book entry, if total entry size \n";
3003  print "(quoted address book fields + 4 delimiters + linefeed) exceeds allowed \n";
3004  print "address book length size.\n";
3005  print "\n";
3006  print "Same setting is applied to personal and global file based address books.\n";
3007  print "\n";
3008  print "It is strongly recommended to keep default setting value. Change it only\n";
3009  print "if you really want to store address book entries that are bigger than two\n";
3010  print "kilobytes (2048).\n";
3011  print "\n";
3012 
3013  print "Enter allowed address book line length [$abook_file_line_length]: ";
3014  my $tmp = <STDIN>;
3015  $tmp = trim($tmp);
3016  # value is not modified, if user hits Enter or enters space
3017  if ($tmp ne '') {
3018  # make sure that input is numeric
3019  if ($tmp =~ /^\d+$/) {
3020  $abook_file_line_length = $tmp;
3021  } else {
3022  print "If you want to change this setting, you must enter number.\n";
3023  print "If you want to keep original setting - enter space.\n\n";
3024  print "Press Enter to continue...";
3025  $tmp = <STDIN>;
3026  }
3027  }
3028 }
3029 
3030 ####################################################################################
3031 #### Database ####
3032 sub command91 {
3033  print "If you want to store your users address book details in a database then\n";
3034  print "you need to set this DSN to a valid value. The format for this is:\n";
3035  print "mysql://user:pass\@hostname/dbname\n";
3036  print "Where mysql can be one of the databases PHP supports, the most common\n";
3037  print "of these are mysql, msql and pgsql.\n";
3038  print "Please ensure proper permissions for config.php when including\n";
3039  print "sensitive passwords.\n\n";
3040  print "If the DSN is left empty (hit space and then return) the database\n";
3041  print "related code for address books will not be used.\n";
3042  print "\n";
3043 
3044  if ( $addrbook_dsn eq "" ) {
3045  $default_value = "Disabled";
3046  } else {
3047  $default_value = $addrbook_dsn;
3048  }
3049  print "[$WHT$addrbook_dsn$NRM]: $WHT";
3050  $new_dsn = <STDIN>;
3051  if ( $new_dsn eq "\n" ) {
3052  $new_dsn = "";
3053  } else {
3054  $new_dsn =~ s/[\r|\n]//g;
3055  $new_dsn =~ s/^\s+$//g;
3056  }
3057  return $new_dsn;
3058 }
3059 
3060 sub command92 {
3061  print "This is the name of the table you want to store the address book\n";
3062  print "data in, it defaults to 'address'\n";
3063  print "\n";
3064  print "[$WHT$addrbook_table$NRM]: $WHT";
3065  $new_table = <STDIN>;
3066  if ( $new_table eq "\n" ) {
3067  $new_table = $addrbook_table;
3068  } else {
3069  $new_table =~ s/[\r|\n]//g;
3070  }
3071  return $new_table;
3072 }
3073 
3074 sub command93 {
3075  print "If you want to store your users preferences in a database then\n";
3076  print "you need to set this DSN to a valid value. The format for this is:\n";
3077  print "mysql://user:pass\@hostname/dbname\n";
3078  print "Where mysql can be one of the databases PHP supports, the most common\n";
3079  print "of these are mysql, msql and pgsql.\n";
3080  print "Please ensure proper permissions for config.php when including\n";
3081  print "sensitive passwords.\n\n";
3082  print "If the DSN is left empty (hit space and then return) the database\n";
3083  print "related code for address books will not be used.\n";
3084  print "\n";
3085 
3086  if ( $prefs_dsn eq "" ) {
3087  $default_value = "Disabled";
3088  } else {
3089  $default_value = $prefs_dsn;
3090  }
3091  print "[$WHT$prefs_dsn$NRM]: $WHT";
3092  $new_dsn = <STDIN>;
3093  if ( $new_dsn eq "\n" ) {
3094  $new_dsn = "";
3095  } else {
3096  $new_dsn =~ s/[\r|\n]//g;
3097  $new_dsn =~ s/^\s+$//g;
3098  }
3099  return $new_dsn;
3100 }
3101 
3102 sub command94 {
3103  print "This is the name of the table you want to store the preferences\n";
3104  print "data in, it defaults to 'userprefs'\n";
3105  print "\n";
3106  print "[$WHT$prefs_table$NRM]: $WHT";
3107  $new_table = <STDIN>;
3108  if ( $new_table eq "\n" ) {
3109  $new_table = $prefs_table;
3110  } else {
3111  $new_table =~ s/[\r|\n]//g;
3112  }
3113  return $new_table;
3114 }
3115 
3116 sub command95 {
3117  print "This is the name of the field in which you want to store the\n";
3118  print "username of the person the prefs are for. It defaults to 'user'\n";
3119  print "\n";
3120  print "[$WHT$prefs_user_field$NRM]: $WHT";
3121  $new_field = <STDIN>;
3122  if ( $new_field eq "\n" ) {
3123  $new_field = $prefs_user_field;
3124  } else {
3125  $new_field =~ s/[\r|\n]//g;
3126  }
3127  return $new_field;
3128 }
3129 
3130 sub command96 {
3131  print "This is the name of the field in which you want to store the\n";
3132  print "preferences keyword. It defaults to 'prefkey'\n";
3133  print "\n";
3134  print "[$WHT$prefs_key_field$NRM]: $WHT";
3135  $new_field = <STDIN>;
3136  if ( $new_field eq "\n" ) {
3137  $new_field = $prefs_key_field;
3138  } else {
3139  $new_field =~ s/[\r|\n]//g;
3140  }
3141  return $new_field;
3142 }
3143 
3144 sub command97 {
3145  print "This is the name of the field in which you want to store the\n";
3146  print "preferences value. It defaults to 'prefval'\n";
3147  print "\n";
3148  print "[$WHT$prefs_val_field$NRM]: $WHT";
3149  $new_field = <STDIN>;
3150  if ( $new_field eq "\n" ) {
3151  $new_field = $prefs_val_field;
3152  } else {
3153  $new_field =~ s/[\r|\n]//g;
3154  }
3155  return $new_field;
3156 }
3157 
3158 sub command98 {
3159  print "If you want to store your global address book in a database then\n";
3160  print "you need to set this DSN to a valid value. The format for this is:\n";
3161  print "mysql://user:pass\@hostname/dbname\n";
3162  print "Where mysql can be one of the databases PHP supports, the most common\n";
3163  print "of these are mysql, msql and pgsql.\n";
3164  print "Please ensure proper permissions for config.php when including\n";
3165  print "sensitive passwords.\n\n";
3166  print "If the DSN is left empty (hit space and then return) the database\n";
3167  print "related code for global SQL address book will not be used.\n";
3168  print "\n";
3169 
3170  if ( $addrbook_global_dsn eq "" ) {
3171  $default_value = "Disabled";
3172  } else {
3173  $default_value = $addrbook_global_dsn;
3174  }
3175  print "[$WHT$addrbook_global_dsn$NRM]: $WHT";
3176  $new_dsn = <STDIN>;
3177  if ( $new_dsn eq "\n" ) {
3178  $new_dsn = "";
3179  } else {
3180  $new_dsn =~ s/[\r\n]//g;
3181  $new_dsn =~ s/^\s+$//g;
3182  }
3183  return $new_dsn;
3184 }
3185 
3186 sub command99 {
3187  print "This is the name of the table you want to store the global address book\n";
3188  print "data in. Default table name is 'global_abook'. Address book uses same\n";
3189  print "database format as personal address book.\n";
3190  print "\n";
3191  print "[$WHT$addrbook_global_table$NRM]: $WHT";
3192  $new_table = <STDIN>;
3193  if ( $new_table eq "\n" ) {
3194  $new_table = $addrbook_global_table;
3195  } else {
3196  $new_table =~ s/[\r\n]//g;
3197  }
3198  return $new_table;
3199 }
3200 
3201 sub command910 {
3202  print "This option controls users\' ability to add or modify records stored \n";
3203  print "in global address book\n";
3204 
3205  if ( lc($addrbook_global_writeable) eq 'true' ) {
3206  $default_value = "y";
3207  } else {
3208  $default_value = "n";
3209  }
3210  print "Allow writing into global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
3211  $addrbook_global_writeable = <STDIN>;
3212  if ( ( $addrbook_global_writeable =~ /^y\n/i ) || ( ( $addrbook_global_writeable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3213  $addrbook_global_writeable = 'true';
3214  } else {
3215  $addrbook_global_writeable = 'false';
3216  }
3218 }
3219 
3220 sub command911 {
3221  print "Enable this option if you want to see listing of addresses stored \n";
3222  print "in global address book\n";
3223 
3224  if ( lc($addrbook_global_listing) eq 'true' ) {
3225  $default_value = "y";
3226  } else {
3227  $default_value = "n";
3228  }
3229  print "Allow listing of global address book? (y/n) [$WHT$default_value$NRM]: $WHT";
3230  $addrbook_global_listing = <STDIN>;
3231  if ( ( $addrbook_global_listing =~ /^y\n/i ) || ( ( $addrbook_global_listing =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3232  $addrbook_global_listing = 'true';
3233  } else {
3234  $addrbook_global_listing = 'false';
3235  }
3236  return $addrbook_global_listing;
3237 }
3238 
3239 
3240 ####################################################################################
3241 #### Languages ####
3242 # Default language
3243 sub commandA1 {
3244  print "SquirrelMail attempts to set the language in many ways. If it\n";
3245  print "can not figure it out in another way, it will default to this\n";
3246  print "language. Please use the code for the desired language.\n";
3247  print "\n";
3248  print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
3249  $new_language = <STDIN>;
3250  if ( $new_language eq "\n" ) {
3251  $new_language = $squirrelmail_default_language;
3252  } else {
3253  $new_language =~ s/[\r|\n]//g;
3254  $new_language =~ s/^\s+$//g;
3255  }
3256  return $new_language;
3257 }
3258 
3259 # Default Charset
3260 sub commandA2 {
3261  print "This option controls what character set is used when sending\n";
3262  print "mail and when sending HTML to the browser.\n";
3263  print "\n";
3264  print "This option is used only when default language is 'en_US'.\n";
3265  print "\n";
3266 
3267  print "[$WHT$default_charset$NRM]: $WHT";
3268  $new_default_charset = <STDIN>;
3269  if ( $new_default_charset eq "\n" ) {
3270  $new_default_charset = $default_charset;
3271  } else {
3272  $new_default_charset =~ s/[\r|\n]//g;
3273  }
3274  return $new_default_charset;
3275 }
3276 
3277 # Lossy encoding
3278 sub commandA3 {
3279  print "Enable this option if you want to allow lossy charset encoding in message\n";
3280  print "composition pages. This option allows charset conversions when output\n";
3281  print "charset does not support all symbols used in original charset. Symbols\n";
3282  print "unsupported by output charset will be replaced with question marks.\n";
3283  print "\n";
3284 
3285  if ( lc($lossy_encoding) eq 'true' ) {
3286  $default_value = "y";
3287  } else {
3288  $default_value = "n";
3289  }
3290  print "Enable lossy encoding? (y/n) [$WHT$default_value$NRM]: $WHT";
3291  $lossy_encoding = <STDIN>;
3292  if ( ( $lossy_encoding =~ /^y\n/i ) || ( ( $lossy_encoding =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
3293  $lossy_encoding = 'true';
3294  } else {
3295  $lossy_encoding = 'false';
3296  }
3297  return $lossy_encoding;
3298 }
3299 
3300 #### End of menu functions
3301 ####################################################################################
3302 
3303 sub save_data {
3304  $tab = " ";
3305  if ( open( CF, ">config.php" ) ) {
3306  print CF "<?php\n";
3307  print CF "\n";
3308 
3309  print CF "/**\n";
3310  print CF " * SquirrelMail Configuration File\n";
3311  print CF " * Created using the configure script, conf.pl\n";
3312  print CF " */\n";
3313  print CF "\n";
3314  print CF "global \$version;\n";
3315 
3316  if ($print_config_version) {
3317  print CF "\$config_version = '$print_config_version';\n";
3318  }
3319  # integer
3320  print CF "\$config_use_color = $config_use_color;\n";
3321  print CF "\n";
3322 
3323  # string
3324  print CF "\$org_name = \"$org_name\";\n";
3325  # string
3326  print CF "\$org_logo = " . &change_to_SM_path($org_logo) . ";\n";
3327  $org_logo_width |= 0;
3328  $org_logo_height |= 0;
3329  # string
3330  print CF "\$org_logo_width = '$org_logo_width';\n";
3331  # string
3332  print CF "\$org_logo_height = '$org_logo_height';\n";
3333  # string that can contain variables.
3334  print CF "\$org_title = \"$org_title\";\n";
3335  # string
3336  print CF "\$signout_page = " . &change_to_SM_path($signout_page) . ";\n";
3337  # string
3338  print CF "\$frame_top = '$frame_top';\n";
3339  print CF "\n";
3340 
3341  print CF "\$provider_uri = '$provider_uri';\n";
3342  print CF "\n";
3343 
3344  print CF "\$provider_name = '$provider_name';\n";
3345  print CF "\n";
3346 
3347  # string that can contain variables
3348  print CF "\$motd = \"$motd\";\n";
3349  print CF "\n";
3350 
3351  # Language preferences
3352  # string
3353  print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
3354  # string
3355  print CF "\$default_charset = '$default_charset';\n";
3356  # boolean
3357  print CF "\$lossy_encoding = $lossy_encoding;\n";
3358  print CF "\n";
3359 
3360  # Server settings
3361  # string
3362  print CF "\$domain = '$domain';\n";
3363  # string
3364  print CF "\$imapServerAddress = '$imapServerAddress';\n";
3365  # integer
3366  print CF "\$imapPort = $imapPort;\n";
3367  # boolean
3368  print CF "\$useSendmail = $useSendmail;\n";
3369  # string
3370  print CF "\$smtpServerAddress = '$smtpServerAddress';\n";
3371  # integer
3372  print CF "\$smtpPort = $smtpPort;\n";
3373  # string
3374  print CF "\$sendmail_path = '$sendmail_path';\n";
3375  # string
3376  print CF "\$sendmail_args = '$sendmail_args';\n";
3377  # boolean
3378 # print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
3379  # boolean
3380  print CF "\$pop_before_smtp = $pop_before_smtp;\n";
3381  # string
3382  print CF "\$pop_before_smtp_host = '$pop_before_smtp_host';\n";
3383  # string
3384  print CF "\$imap_server_type = '$imap_server_type';\n";
3385  # boolean
3386  print CF "\$invert_time = $invert_time;\n";
3387  # string
3388  print CF "\$optional_delimiter = '$optional_delimiter';\n";
3389  # string
3390  print CF "\$encode_header_key = '$encode_header_key';\n";
3391  print CF "\n";
3392 
3393  # string
3394  print CF "\$default_folder_prefix = '$default_folder_prefix';\n";
3395  # string
3396  print CF "\$trash_folder = '$trash_folder';\n";
3397  # string
3398  print CF "\$sent_folder = '$sent_folder';\n";
3399  # string
3400  print CF "\$draft_folder = '$draft_folder';\n";
3401  # boolean
3402  print CF "\$default_move_to_trash = $default_move_to_trash;\n";
3403  # boolean
3404  print CF "\$default_move_to_sent = $default_move_to_sent;\n";
3405  # boolean
3406  print CF "\$default_save_as_draft = $default_save_as_draft;\n";
3407  # boolean
3408  print CF "\$show_prefix_option = $show_prefix_option;\n";
3409  # boolean
3410  print CF "\$list_special_folders_first = $list_special_folders_first;\n";
3411  # boolean
3412  print CF "\$use_special_folder_color = $use_special_folder_color;\n";
3413  # boolean
3414  print CF "\$auto_expunge = $auto_expunge;\n";
3415  # boolean
3416  print CF "\$default_sub_of_inbox = $default_sub_of_inbox;\n";
3417  # boolean
3418  print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
3419  # integer
3420  print CF "\$default_unseen_notify = $default_unseen_notify;\n";
3421  # integer
3422  print CF "\$default_unseen_type = $default_unseen_type;\n";
3423  # boolean
3424  print CF "\$auto_create_special = $auto_create_special;\n";
3425  # boolean
3426  print CF "\$delete_folder = $delete_folder;\n";
3427  # boolean
3428  print CF "\$noselect_fix_enable = $noselect_fix_enable;\n";
3429 
3430  print CF "\n";
3431 
3432  # General options
3433  # string
3434  print CF "\$data_dir = " . &change_to_SM_path($data_dir) . ";\n";
3435  # string that can contain a variable
3436  print CF "\$attachment_dir = " . &change_to_SM_path($attachment_dir) . ";\n";
3437  # integer
3438  print CF "\$dir_hash_level = $dir_hash_level;\n";
3439  # string
3440  print CF "\$default_left_size = '$default_left_size';\n";
3441  # boolean
3442  print CF "\$force_username_lowercase = $force_username_lowercase;\n";
3443  # boolean
3444  print CF "\$default_use_priority = $default_use_priority;\n";
3445  # boolean
3446  print CF "\$hide_sm_attributions = $hide_sm_attributions;\n";
3447  # boolean
3448  print CF "\$default_use_mdn = $default_use_mdn;\n";
3449  # boolean
3450  print CF "\$edit_identity = $edit_identity;\n";
3451  # boolean
3452  print CF "\$edit_name = $edit_name;\n";
3453  # boolean
3454  print CF "\$hide_auth_header = $hide_auth_header;\n";
3455  # boolean
3456  print CF "\$allow_thread_sort = $allow_thread_sort;\n";
3457  # boolean
3458  print CF "\$allow_server_sort = $allow_server_sort;\n";
3459  # boolean
3460  print CF "\$allow_charset_search = $allow_charset_search;\n";
3461  # boolean
3462  print CF "\$uid_support = $uid_support;\n";
3463  print CF "\n";
3464 
3465  # all plugins are strings
3466  for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
3467  print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
3468  }
3469  print CF "\n";
3470 
3471  # strings
3472  print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
3473  if ( $theme_default eq '' ) { $theme_default = '0'; }
3474  print CF "\$theme_default = $theme_default;\n";
3475 
3476  for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
3477  print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
3478  # escape theme name so it can contain single quotes.
3479  $esc_name = $theme_name[$count];
3480  $esc_name =~ s/\\/\\\\/g;
3481  $esc_name =~ s/'/\\'/g;
3482  print CF "\$theme[$count]['NAME'] = '$esc_name';\n";
3483  }
3484  print CF "\n";
3485 
3486  ## Address books
3487  # boolean
3488  print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
3489  for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
3490  print CF "\$ldap_server[$count] = array(\n";
3491  # string
3492  print CF " 'host' => '$ldap_host[$count]',\n";
3493  # string
3494  print CF " 'base' => '$ldap_base[$count]'";
3495  if ( $ldap_name[$count] ) {
3496  print CF ",\n";
3497  # string
3498  print CF " 'name' => '$ldap_name[$count]'";
3499  }
3500  if ( $ldap_port[$count] ) {
3501  print CF ",\n";
3502  # integer
3503  print CF " 'port' => $ldap_port[$count]";
3504  }
3505  if ( $ldap_charset[$count] ) {
3506  print CF ",\n";
3507  # string
3508  print CF " 'charset' => '$ldap_charset[$count]'";
3509  }
3510  if ( $ldap_maxrows[$count] ) {
3511  print CF ",\n";
3512  # integer
3513  print CF " 'maxrows' => $ldap_maxrows[$count]";
3514  }
3515  if ( $ldap_binddn[$count] ) {
3516  print CF ",\n";
3517  # string
3518  print CF " 'binddn' => '$ldap_binddn[$count]'";
3519  if ( $ldap_bindpw[$count] ) {
3520  print CF ",\n";
3521  # string
3522  print CF " 'bindpw' => '$ldap_bindpw[$count]'";
3523  }
3524  }
3525  if ( $ldap_protocol[$count] ) {
3526  print CF ",\n";
3527  # integer
3528  print CF " 'protocol' => $ldap_protocol[$count]";
3529  }
3530  print CF "\n";
3531  print CF ");\n";
3532  print CF "\n";
3533  }
3534 
3535  # Global file based address book
3536  # string
3537  print CF "\$abook_global_file = '$abook_global_file';\n";
3538  # boolean
3539  print CF "\$abook_global_file_writeable = $abook_global_file_writeable;\n";
3540  # boolean
3541  print CF "\$abook_global_file_listing = $abook_global_file_listing;\n";
3542  # integer
3543  print CF "\$abook_file_line_length = $abook_file_line_length;\n\n";
3544 
3545  ## Database
3546  # string
3547  print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
3548  # string
3549  print CF "\$addrbook_table = '$addrbook_table';\n\n";
3550  # string
3551  print CF "\$prefs_dsn = '$prefs_dsn';\n";
3552  # string
3553  print CF "\$prefs_table = '$prefs_table';\n";
3554  # string
3555  print CF "\$prefs_user_field = '$prefs_user_field';\n";
3556  # string
3557  print CF "\$prefs_key_field = '$prefs_key_field';\n";
3558  # string
3559  print CF "\$prefs_val_field = '$prefs_val_field';\n";
3560  # string
3561  print CF "\$addrbook_global_dsn = '$addrbook_global_dsn';\n";
3562  # string
3563  print CF "\$addrbook_global_table = '$addrbook_global_table';\n";
3564  # boolean
3565  print CF "\$addrbook_global_writeable = $addrbook_global_writeable;\n";
3566  # boolean
3567  print CF "\$addrbook_global_listing = $addrbook_global_listing;\n\n";
3568  # boolean
3569  print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
3570 
3571  # string
3572  print CF "\$smtp_auth_mech = '$smtp_auth_mech';\n";
3573  print CF "\$imap_auth_mech = '$imap_auth_mech';\n";
3574  print CF "\$smtp_sitewide_user = '" . quote_single($smtp_sitewide_user) . "';\n";
3575  print CF "\$smtp_sitewide_pass = '" . quote_single($smtp_sitewide_pass) . "';\n";
3576  # boolean
3577  print CF "\$use_imap_tls = $use_imap_tls;\n";
3578  print CF "\$use_smtp_tls = $use_smtp_tls;\n";
3579 
3580  print CF "\$session_name = '$session_name';\n";
3581 
3582  # boolean
3583  print CF "\$only_secure_cookies = $only_secure_cookies;\n";
3584  print CF "\$disable_security_tokens = $disable_security_tokens;\n";
3585 
3586  # string
3587  print CF "\$check_referrer = '$check_referrer';\n";
3588 
3589  print CF "\n";
3590  print CF "\$config_location_base = '$config_location_base';\n";
3591 
3592  print CF "\n";
3593  print CF "\@include SM_PATH . 'config/config_local.php';\n";
3594 
3595  print CF "\n";
3596  close CF;
3597 
3598  print "Data saved in config.php\n";
3599  } else {
3600  print "Error saving config.php: $!\n";
3601  }
3602 }
3603 
3604 sub set_defaults {
3605  clear_screen();
3606  print $WHT. "SquirrelMail Configuration : " . $NRM;
3607  if ( $config == 1 ) { print "Read: config.php"; }
3608  elsif ( $config == 2 ) { print "Read: config_default.php"; }
3609  print "\n";
3610  print "---------------------------------------------------------\n";
3611 
3612  print "While we have been building SquirrelMail, we have discovered some\n";
3613  print "preferences that work better with some servers that don't work so\n";
3614  print "well with others. If you select your IMAP server, this option will\n";
3615  print "set some pre-defined settings for that server.\n";
3616  print "\n";
3617  print "Please note that you will still need to go through and make sure\n";
3618  print "everything is correct. This does not change everything. There are\n";
3619  print "only a few settings that this will change.\n";
3620  print "\n";
3621 
3622  $continue = 0;
3623  while ( $continue != 1 ) {
3624  print "Please select your IMAP server:\n";
3625  print $list_supported_imap_servers;
3626  print "\n";
3627  print " quit = Do not change anything\n";
3628  print "Command >> ";
3629  $server = <STDIN>;
3630  $server =~ s/[\r|\n]//g;
3631 
3632  # variable is used to display additional messages.
3633  $message = "";
3634 
3635  print "\n";
3636  if ( $server eq "cyrus" ) {
3637  $imap_server_type = "cyrus";
3639  $trash_folder = "INBOX.Trash";
3640  $sent_folder = "INBOX.Sent";
3641  $draft_folder = "INBOX.Drafts";
3642  $show_prefix_option = false;
3643  $default_sub_of_inbox = true;
3645  $optional_delimiter = ".";
3646  $disp_default_folder_prefix = "<none>";
3647 
3648  $continue = 1;
3649  } elsif ( $server eq "uw" ) {
3650  $imap_server_type = "uw";
3651  $default_folder_prefix = "mail/";
3652  $trash_folder = "Trash";
3653  $sent_folder = "Sent";
3654  $draft_folder = "Drafts";
3655  $show_prefix_option = true;
3656  $default_sub_of_inbox = false;
3658  $optional_delimiter = "/";
3659  $disp_default_folder_prefix = $default_folder_prefix;
3660  $delete_folder = true;
3661 
3662  $continue = 1;
3663  } elsif ( $server eq "exchange" ) {
3664  $imap_server_type = "exchange";
3666  $default_sub_of_inbox = true;
3667  $trash_folder = "INBOX/Deleted Items";
3668  $sent_folder = "INBOX/Sent Items";
3669  $drafts_folder = "INBOX/Drafts";
3670  $show_prefix_option = false;
3672  $optional_delimiter = "detect";
3673  $disp_default_folder_prefix = "<none>";
3674 
3675  $continue = 1;
3676  } elsif ( $server eq "courier" ) {
3677  $imap_server_type = "courier";
3678  $default_folder_prefix = "INBOX.";
3679  $trash_folder = "Trash";
3680  $sent_folder = "Sent";
3681  $draft_folder = "Drafts";
3682  $show_prefix_option = false;
3683  $default_sub_of_inbox = true;
3685  $optional_delimiter = ".";
3686  $disp_default_folder_prefix = $default_folder_prefix;
3687  $delete_folder = true;
3688 
3689  $continue = 1;
3690  } elsif ( $server eq "macosx" ) {
3691  $imap_server_type = "macosx";
3692  $default_folder_prefix = "INBOX/";
3693  $trash_folder = "Trash";
3694  $sent_folder = "Sent";
3695  $draft_folder = "Drafts";
3696  $show_prefix_option = false;
3697  $default_sub_of_inbox = true;
3699  $optional_delimiter = "detect";
3700  $allow_charset_search = false;
3701  $disp_default_folder_prefix = $default_folder_prefix;
3702 
3703  $continue = 1;
3704  } elsif ( $server eq "hmailserver" ) {
3705  $imap_server_type = "hmailserver";
3707  $trash_folder = "INBOX.Trash";
3708  $sent_folder = "INBOX.Sent";
3709  $draft_folder = "INBOX.Drafts";
3710  $show_prefix_option = false;
3711  $default_sub_of_inbox = true;
3713  $optional_delimiter = "detect";
3714  $allow_charset_search = false;
3715  $disp_default_folder_prefix = $default_folder_prefix;
3716  $delete_folder = false;
3717  $force_username_lowercase = false;
3718 
3719  $continue = 1;
3720  } elsif ( $server eq "mercury32" ) {
3721  $imap_server_type = "mercury32";
3723  $trash_folder = "Trash";
3724  $sent_folder = "Sent";
3725  $draft_folder = "Drafts";
3726  $show_prefix_option = false;
3727  $default_sub_of_inbox = true;
3729  $optional_delimiter = "detect";
3730  $delete_folder = true;
3732 
3733  $continue = 1;
3734  } elsif ( $server eq "dovecot" ) {
3735  $imap_server_type = "dovecot";
3737  $trash_folder = "Trash";
3738  $sent_folder = "Sent";
3739  $draft_folder = "Drafts";
3740  $show_prefix_option = false;
3741  $default_sub_of_inbox = false;
3743  $delete_folder = false;
3745  $optional_delimiter = "detect";
3746  $disp_default_folder_prefix = "<none>";
3747 
3748  $continue = 1;
3749  } elsif ( $server eq "bincimap" ) {
3750  $imap_server_type = "bincimap";
3751  $default_folder_prefix = "INBOX/";
3752  $trash_folder = "Trash";
3753  $sent_folder = "Sent";
3754  $draft_folder = "Drafts";
3755  $show_prefix_option = false;
3756  $default_sub_of_inbox = false;
3758  $delete_folder = true;
3759  $force_username_lowercase = false;
3760  $optional_delimiter = "detect";
3761  $disp_default_folder_prefix = $default_folder_prefix;
3762 
3763  # Default folder prefix depends on used depot.
3764  $message = "\nIf you use IMAPdir depot, you must set default folder prefix to empty string.\n";
3765 
3766  $continue = 1;
3767  } elsif ( $server eq "gmail" ) {
3768  $imap_server_type = "gmail";
3770  $trash_folder = "[Gmail]/Trash";
3771  $default_move_to_trash = true;
3772  $sent_folder = "[Gmail]/Sent Mail";
3773  $draft_folder = "[Gmail]/Drafts";
3774  $auto_create_special = false;
3775  $show_prefix_option = false;
3776  $default_sub_of_inbox = false;
3778  $delete_folder = true;
3779  $force_username_lowercase = false;
3780  $optional_delimiter = "/";
3781  $disp_default_folder_prefix = "<none>";
3782  $domain = "gmail.com";
3783  $imapServerAddress = "imap.gmail.com";
3784  $imapPort = 993;
3785  $use_imap_tls = true;
3786  $imap_auth_mech = "login";
3787  $smtpServerAddress = "smtp.gmail.com";
3788  $smtpPort = 465;
3789  $pop_before_smtp = false;
3790  $useSendmail = false;
3791  $use_smtp_tls = true;
3792  $smtp_auth_mech = "login";
3793  $continue = 1;
3794 
3795  # Gmail changes system folder names (Drafts, Sent, Trash) out
3796  # from under you when the user changes language settings
3797  $message = "\nNOTE! When a user changes languages in Gmail's interface, the\n"
3798  . "Drafts, Sent and Trash folder names are changed to localized\n"
3799  . "versions thereof. To see those folders correctly in SquirrelMail,\n"
3800  . "the user should change the SquirrelMail language to match.\n"
3801  . "Moreover, SquirrelMail then needs to be told what folders to use\n"
3802  . "for Drafts, Sent and Trash in Options --> Folder Preferences.\n"
3803  . "These default settings will only correctly find the Sent, Trash\n"
3804  . "and Drafts folders if both Gmail and SquirrelMail languages are\n"
3805  . "set to English.\n\n"
3806  . "Also note that in some regions (Europe?), the default folder\n"
3807  . "names (see main menu selection 3. Folder Defaults) are different\n"
3808  . "(they may need to have the prefix \"[Google Mail]\" instead of\n"
3809  . "\"[Gmail]\") and \"Trash\" may be called \"Bin\" instead.\n";
3810 
3811  } elsif ( $server eq "quit" ) {
3812  $continue = 1;
3813  } else {
3814  $disp_default_folder_prefix = $default_folder_prefix;
3815  print "Unrecognized server: $server\n";
3816  print "\n";
3817  }
3818 
3819  print " imap_server_type = $imap_server_type\n";
3820  print " default_folder_prefix = $disp_default_folder_prefix\n";
3821  print " trash_folder = $trash_folder\n";
3822  print " sent_folder = $sent_folder\n";
3823  print " draft_folder = $draft_folder\n";
3824  print " show_prefix_option = $show_prefix_option\n";
3825  print " default_sub_of_inbox = $default_sub_of_inbox\n";
3826  print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
3827  print " optional_delimiter = $optional_delimiter\n";
3828  print " delete_folder = $delete_folder\n";
3829 
3830  print "$message";
3831  }
3832  print "\nPress enter to continue...";
3833  $tmp = <STDIN>;
3834 }
3835 
3836 # This subroutine corrects relative paths to ensure they
3837 # will work within the SM space. If the path falls within
3838 # the SM directory tree, the SM_PATH variable will be
3839 # prepended to the path, if not, then the path will be
3840 # converted to an absolute path, e.g.
3841 # '../images/logo.gif' --> SM_PATH . 'images/logo.gif'
3842 # '../../someplace/data' --> '/absolute/path/someplace/data'
3843 # 'images/logo.gif' --> SM_PATH . 'config/images/logo.gif'
3844 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3845 # 'C:\absolute\path\logo.gif' --> 'C:\absolute\path\logo.gif'
3846 # 'http://whatever/' --> 'http://whatever'
3847 # $some_var/path --> "$some_var/path"
3848 sub change_to_SM_path() {
3849  my ($old_path) = @_;
3850  my $new_path = '';
3851  my @rel_path;
3852  my @abs_path;
3853  my $subdir;
3854 
3855  # If the path is absolute, don't bother.
3856  return "\'" . $old_path . "\'" if ( $old_path eq '');
3857  return "\'" . $old_path . "\'" if ( $old_path =~ /^(\/|http)/ );
3858  return "\'" . $old_path . "\'" if ( $old_path =~ /^\w:(\\|\/)/ );
3859  return $old_path if ( $old_path =~ /^\'(\/|http)/ );
3860  return $old_path if ( $old_path =~ /^\'\w:\// );
3861  return $old_path if ( $old_path =~ /^SM_PATH/);
3862 
3863  if ( $old_path =~ /^\$/ ) {
3864  # check if it's a single var, or a $var/path combination
3865  # if it's $var/path, enclose in ""
3866  if ( $old_path =~ /\// ) {
3867  return '"'.$old_path.'"';
3868  }
3869  return $old_path;
3870  }
3871 
3872  # Remove remaining '
3873  $old_path =~ s/\'//g;
3874 
3875  # For relative paths, split on '../'
3876  @rel_path = split(/\.\.\//, $old_path);
3877 
3878  if ( $#rel_path > 1 ) {
3879  # more than two levels away. Make it absolute.
3880  @abs_path = split(/\//, $dir);
3881 
3882  # Lop off the relative pieces of the absolute path..
3883  for ( $i = 0; $i <= $#rel_path; $i++ ) {
3884  pop @abs_path;
3885  shift @rel_path;
3886  }
3887  push @abs_path, @rel_path;
3888  $new_path = "\'" . join('/', @abs_path) . "\'";
3889  } elsif ( $#rel_path > 0 ) {
3890  # it's within the SM tree, prepend SM_PATH
3891  $new_path = $old_path;
3892  $new_path =~ s/^\.\.\//SM_PATH . \'/;
3893  $new_path .= "\'";
3894  } else {
3895  # Last, it's a relative path without any leading '.'
3896  # Prepend SM_PATH and config, since the paths are
3897  # relative to the config directory
3898  $new_path = "SM_PATH . \'config/" . $old_path . "\'";
3899  }
3900  return $new_path;
3901 }
3902 
3903 
3904 # Change SM_PATH to admin-friendly version, e.g.:
3905 # SM_PATH . 'images/logo.gif' --> '../images/logo.gif'
3906 # SM_PATH . 'config/some.php' --> 'some.php'
3907 # '/absolute/path/logo.gif' --> '/absolute/path/logo.gif'
3908 # 'http://whatever/' --> 'http://whatever'
3909 sub change_to_rel_path() {
3910  my ($old_path) = @_;
3911  my $new_path = $old_path;
3912 
3913  if ( $old_path =~ /^SM_PATH/ ) {
3914  $new_path =~ s/^SM_PATH . \'/\.\.\//;
3915  $new_path =~ s/\.\.\/config\///;
3916  }
3917 
3918  return $new_path;
3919 }
3920 
3921 # Attempts to auto-detect if a specific auth mechanism is supported.
3922 # Called by 'command112a' and 'command112b'
3923 # ARGS: service-name (IMAP or SMTP), host:port, mech-name (ie. CRAM-MD5)
3924 sub detect_auth_support {
3925  # Try loading IO::Socket
3926  unless (eval("use IO::Socket; 1")) {
3927  print "Perl IO::Socket module is not available.";
3928  return undef;
3929  }
3930 
3931  # Misc setup
3932  my $service = shift;
3933  my $host = shift;
3934  my $mech = shift;
3935  # Sanity checks
3936  if ((!defined($service)) or (!defined($host)) or (!defined($mech))) {
3937  # Error - wrong # of args
3938  print "BAD ARGS!\n";
3939  return undef;
3940  }
3941 
3942  if ($service eq 'SMTP') {
3943  $cmd = "AUTH $mech\r\n";
3944  $logout = "QUIT\r\n";
3945  } elsif ($service eq 'IMAP') {
3946  $cmd = "A01 AUTHENTICATE $mech\n";
3947  $logout = "C01 LOGOUT\n";
3948  } else {
3949  # unknown service - whoops.
3950  return undef;
3951  }
3952 
3953  # Get this show on the road
3954  my $sock=IO::Socket::INET->new($host);
3955  if (!defined($sock)) {
3956  # Connect failed
3957  return undef;
3958  }
3959  my $discard = <$sock>; # Server greeting/banner - who cares..
3960 
3961  if ($service eq 'SMTP') {
3962  # Say hello first..
3963  print $sock "HELO $domain\r\n";
3964  $discard = <$sock>; # Yeah yeah, you're happy to see me..
3965  }
3966  print $sock $cmd;
3967 
3968  my $response = <$sock>;
3969  chomp($response);
3970  if (!defined($response)) {
3971  return undef;
3972  }
3973 
3974  # So at this point, we have a response, and it is (hopefully) valid.
3975  if ($service eq 'SMTP') {
3976  if (!($response =~ /^334/)) {
3977  # Not supported
3978  print $sock $logout;
3979  close $sock;
3980  return 'NO';
3981  }
3982  } elsif ($service eq 'IMAP') {
3983  if ($response =~ /^A01/) {
3984  # Not supported
3985  close $sock;
3986  return 'NO';
3987  }
3988  } else {
3989  # Unknown service - this shouldn't be able to happen.
3990  close $sock;
3991  return undef;
3992  }
3993 
3994  # If it gets here, the mech is supported
3995  print $sock "*\n"; # Attempt to cancel authentication
3996  print $sock $logout; # Try to log out, but we don't really care if this fails
3997  close $sock;
3998  return 'YES';
3999 }
4000 
4001 sub clear_screen() {
4002  if ( $^O =~ /^mswin/i) {
4003  system "cls";
4004  } else {
4005  system "clear";
4006  }
4007 }
4008 
4009 # Quotes safely strings containing single quote
4010 sub quote_single($) {
4011  my $string = shift(@_);
4012  $string =~ s/\'/\\'/g;
4013  return $string;
4014 }
4015 
4016 # trims whitespace
4017 # Example code from O'Reilly Perl Cookbook
4018 sub trim {
4019  my @out = @_;
4020  for (@out) {
4021  s/^\s+//;
4022  s/\s+$//;
4023  }
4024  return wantarray ? @out : $out[0];
4025 }
4026 
4027 
4028 # checks IMAP mailbox name. Detect 8bit input and special characters
4029 # returns 0 (folder name is not correct) or 1 (folder name is correct)
4030 sub check_imap_folder($) {
4031  my $folder_name = shift(@_);
4032 
4033  if ($folder_name =~ /[\x80-\xFFFF]/) {
4034  print "Folder name contains 8bit characters. Configuration utility requires\n";
4035  print "UTF7-IMAP encoded folder names.\n";
4036  print "Press enter to continue...";
4037  my $tmp = <STDIN>;
4038  return 0;
4039  } elsif ($folder_name =~ /[&\*\%]/) {
4040  # check for ampersand and list-wildcards
4041  print "Folder name contains special UTF7-IMAP characters.\n";
4042  print "Are you sure that folder name is correct? (yN): ";
4043  my $tmp = <STDIN>;
4044  $tmp = lc(trim($tmp));
4045  if ($tmp =~ /^y$/) {
4046  return 1;
4047  } else {
4048  return 0;
4049  }
4050  } else {
4051  return 1;
4052  }
4053 }
$smtp_sitewide_user
$smtp_sitewide_user
Definition: config_default.php:267
$encode_header_key
$encode_header_key
Definition: config_default.php:170
$default_use_javascript_addr_book
$default_use_javascript_addr_book
Definition: config_default.php:886
$ret
$ret
Definition: webmail.php:172
$useSendmail
$useSendmail
Definition: config_default.php:140
$org_logo_width
$org_logo_width
Definition: config_default.php:47
$sendmail_path
$sendmail_path
Definition: config_default.php:180
files
if(empty($variables_order)) do_err('Your variables_order setting seems to be empty. Make sure it is undefined in any PHP ini files htaccess files
Definition: configtest.php:152
$cnt
$cnt
Definition: options_identities.php:86
$default_use_mdn
$default_use_mdn
Definition: config_default.php:575
$count
$count
Definition: message_details_bottom.php:97
$frame_top
$frame_top
Definition: config_default.php:84
change_to_rel_path
change_to_rel_path($old_path)
Definition: options.php:156
$imapServerAddress
$imapServerAddress
Definition: config_default.php:202
$abook_global_file
$abook_global_file
Definition: config_default.php:893
problem
if(empty($gpc_order)) do_err('Your gpc_order setting seems to be empty. Make sure it is undefined in any PHP ini files htaccess etc and not specifically set to an empty value or SquirrelMail may not correctly G P C Your gpc_order setting is insufficient for SquirrelMail to function It needs to be set to but you have it set to session pcre Required PHP extensions enable_dl safe_mode mb_internal_encoding mbstring func_overload You have enabled mbstring overloading It can cause problems with SquirrelMail scripts that rely on single byte string functions register_globals register_globals off You have enabled PHP register_globals Running PHP installation with< tt > magic_quotes_gpc</tt > or< tt > magic_quotes_sybase</tt > in your PHP configuration We recommend all those settings to be off SquirrelMail may work with them but when experiencing stray backslashes in your mail or other strange it may be advisable to turn them off short_open_tag You have configured PHP not to allow short but if you experience problems with PHP code being displayed in some of the pages and changing setting to on solves the problem
Definition: configtest.php:250
$draft_folder
$draft_folder
Definition: config_default.php:396
$num
else $num
Definition: options_order.php:37
$theme_css
$theme_css
Definition: config_default.php:696
$imap_auth_mech
$imap_auth_mech
Definition: config_default.php:285
$edit_identity
$edit_identity
Definition: config_default.php:588
on
if(empty($gpc_order)) do_err('Your gpc_order setting seems to be empty. Make sure it is undefined in any PHP ini files htaccess etc and not specifically set to an empty value or SquirrelMail may not function correctly G P C Your gpc_order setting is insufficient for SquirrelMail to function It needs to be set to but you have it set to session pcre Required PHP extensions enable_dl safe_mode mb_internal_encoding mbstring func_overload You have enabled mbstring overloading It can cause problems with SquirrelMail scripts that rely on single byte string functions register_globals register_globals off You have enabled PHP register_globals Running PHP installation with< tt > magic_quotes_gpc</tt > or< tt > magic_quotes_sybase</tt > in your PHP configuration We recommend all those settings to be off SquirrelMail may work with them on
Definition: configtest.php:223
$squirrelmail_default_language
$squirrelmail_default_language
Definition: config_default.php:1012
$data_dir
$data_dir
Definition: config_default.php:499
$prefs_table
$prefs_table
Definition: config_default.php:971
$imap_server_type
$imap_server_type
Definition: config_default.php:231
$default_move_to_sent
$default_move_to_sent
Definition: config_default.php:392
$default_save_as_draft
$default_save_as_draft
Definition: config_default.php:393
$prefs_key_field
$prefs_key_field
Definition: config_default.php:972
$pop_before_smtp_host
$pop_before_smtp_host
Definition: config_default.php:321
$trash_folder
$trash_folder
Definition: config_default.php:394
$use_imap_tls
$use_imap_tls
Definition: config_default.php:240
$auto_create_special
$auto_create_special
Definition: config_default.php:416
$sendmail_args
$sendmail_args
Definition: config_default.php:194
$plugins
global $plugins
Definition: plugin.php:196
$show_prefix_option
$show_prefix_option
Definition: config_default.php:352
$provider_name
$provider_name
Definition: config_default.php:95
if
if(! defined( 'SM_PATH')) define( 'SM_PATH'
Definition: mime.class.php:16
plugins
$org_title
$org_title
Definition: config_default.php:61
$folder_name
$folder_name
Definition: folders_create.php:48
$hide_auth_header
$hide_auth_header
Definition: config_default.php:605
$uid_support
$uid_support
Definition: config_default.php:643
POP3
Definition: class.POP3.php:21
$message
$message
Definition: download.php:54
$signout_page
$signout_page
Definition: config_default.php:74
$prefs_user_field
$prefs_user_field
Definition: config_default.php:973
$default_unseen_notify
$default_unseen_notify
Definition: config_default.php:464
$addrbook_table
$addrbook_table
Definition: config_default.php:966
$prefs_dsn
$prefs_dsn
Definition: config_default.php:970
$org_name
$org_name
Definition: config_default.php:35
$smtpPort
$smtpPort
Definition: config_default.php:151
for
for( $i=0, $num=count( $filters);$i< $num;$i++)
Definition: options.php:234
$addrbook_dsn
$addrbook_dsn
Definition: config_default.php:965
$abook_global_file_writeable
$abook_global_file_writeable
Definition: config_default.php:900
$addrbook_global_table
$addrbook_global_table
Definition: config_default.php:988
$sent_folder
$sent_folder
Definition: config_default.php:395
$invert_time
$invert_time
Definition: config_default.php:129
$noselect_fix_enable
$noselect_fix_enable
Definition: config_default.php:474
$attachment_dir
$attachment_dir
Definition: config_default.php:517
$provider_uri
$provider_uri
Definition: config_default.php:106
$abook_global_file_listing
$abook_global_file_listing
Definition: config_default.php:907
$list_special_folders_first
$list_special_folders_first
Definition: config_default.php:424
$use_smtp_tls
$use_smtp_tls
Definition: config_default.php:249
$allow_thread_sort
$allow_thread_sort
Definition: config_default.php:615
$addrbook_global_writeable
$addrbook_global_writeable
Definition: config_default.php:994
$abook_file_line_length
$abook_file_line_length
Definition: config_default.php:925
$default_use_priority
$default_use_priority
Definition: config_default.php:558
$optional_delimiter
$optional_delimiter
Definition: config_default.php:300
squirrelmail
$smtpServerAddress
$smtpServerAddress
Definition: config_default.php:146
$allow_charset_search
$allow_charset_search
Definition: config_default.php:635
$edit_name
$edit_name
Definition: config_default.php:589
$theme_default
$theme_default
Definition: config_default.php:695
$prefs_val_field
$prefs_val_field
Definition: config_default.php:974
$filename
if(isset($override_type0)) if(isset($override_type1)) $filename
Definition: download.php:97
exit
exit
Definition: help.php:128
SM_PATH
const SM_PATH
Definition: decrypt_headers.php:16
$pop_before_smtp
$pop_before_smtp
Definition: config_default.php:309
_
_($str)
Definition: gettext.php:160
$default_charset
$default_charset
Definition: config_default.php:1027
$lossy_encoding
$lossy_encoding
Definition: config_default.php:1038
$config_location_base
$config_location_base
Definition: config_default.php:675
$force_username_lowercase
$force_username_lowercase
Definition: config_default.php:550
$delete_folder
$delete_folder
Definition: config_default.php:398
$allow_server_sort
$allow_server_sort
Definition: config_default.php:625
$smtp_auth_mech
$smtp_auth_mech
Definition: config_default.php:257
$default_move_to_trash
$default_move_to_trash
Definition: config_default.php:391
$show_contain_subfolders_option
$show_contain_subfolders_option
Definition: config_default.php:449
$smtp_sitewide_pass
$smtp_sitewide_pass
Definition: config_default.php:277
$imapPort
$imapPort
Definition: config_default.php:210
Message
Definition: Message.class.php:27
$session_name
$session_name
Definition: config_default.php:651
plugin
if(empty($gpc_order)) do_err('Your gpc_order setting seems to be empty. Make sure it is undefined in any PHP ini files htaccess etc and not specifically set to an empty value or SquirrelMail may not correctly G P C Your gpc_order setting is insufficient for SquirrelMail to function It needs to be set to but you have it set to session pcre Required PHP extensions enable_dl safe_mode mb_internal_encoding mbstring func_overload You have enabled mbstring overloading It can cause problems with SquirrelMail scripts that rely on single byte string functions register_globals register_globals off You have enabled PHP register_globals Running PHP installation with< tt > magic_quotes_gpc</tt > or< tt > magic_quotes_sybase</tt > in your PHP configuration We recommend all those settings to be off SquirrelMail may work with them but when experiencing stray backslashes in your mail or other strange it may be advisable to turn them off short_open_tag You have configured PHP not to allow short but if you experience problems with PHP code being displayed in some of the pages and changing setting to on solves the please file a bug report against the failing plugin The correct contact information is most likely to be found in the plugin documentation plugins You have enabled the< i ></i > plugin
Definition: configtest.php:250
$default_sub_of_inbox
$default_sub_of_inbox
Definition: config_default.php:433
$use_special_folder_color
$use_special_folder_color
Definition: config_default.php:407
$dir_hash_level
$dir_hash_level
Definition: config_default.php:530
$hide_sm_attributions
$hide_sm_attributions
Definition: config_default.php:567
$default_unseen_type
$default_unseen_type
Definition: config_default.php:465
Language
Definition: Language.class.php:24
$addrbook_global_dsn
$addrbook_global_dsn
Definition: config_default.php:982
$default_folder_prefix
$default_folder_prefix
Definition: config_default.php:342
$domain
$domain
Definition: config_default.php:118
$org_logo_height
$org_logo_height
Definition: config_default.php:53
$motd
$motd
Definition: config_default.php:933
$org_logo
$org_logo
Definition: config_default.php:41
n
print< br >< center >< b > IMAP server information</b ></center >< br > n
Definition: options.php:72
$default_left_size
$default_left_size
Definition: config_default.php:539
$addrbook_global_listing
$addrbook_global_listing
Definition: config_default.php:1000
$auto_expunge
$auto_expunge
Definition: config_default.php:397