display disabled,TLS,STARTTLS instead of 0,1,2 in menu
[squirrelmail.git] / config / conf.pl
index d42be3db3f7387964f646f4f662464e0128357bb..7ad551e64a43511bb637b8051939d288273a11bb 100755 (executable)
@@ -286,6 +286,11 @@ while ( $line = <FILE> ) {
                     $tmp =~ s/[\'\"]?,?\s*$//;
                     $tmp =~ s/[\'\"]?\);\s*$//;
                     $listing = $tmp;
+                } elsif ( $tmp =~ /^\s*[\'\"]writeable[\'\"]/i ) {
+                    $tmp =~ s/^\s*[\'\"]writeable[\'\"]\s*=>\s*[\'\"]?//i;
+                    $tmp =~ s/[\'\"]?,?\s*$//;
+                    $tmp =~ s/[\'\"]?\);\s*$//;
+                    $writeable = $tmp;
                 } elsif ( $tmp =~ /^\s*[\'\"]search_tree[\'\"]/i ) {
                     $tmp =~ s/^\s*[\'\"]search_tree[\'\"]\s*=>\s*[\'\"]?//i;
                     $tmp =~ s/[\'\"]?,?\s*$//;
@@ -310,6 +315,7 @@ while ( $line = <FILE> ) {
             $ldap_protocol[$sub] = $protocol;
             $ldap_limit_scope[$sub] = $limit_scope;
             $ldap_listing[$sub] = $listing;
+            $ldap_writeable[$sub] = $writeable;
             $ldap_search_tree[$sub] = $search_tree;
             $ldap_starttls[$sub] = $starttls;
         } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
@@ -333,7 +339,6 @@ $force_username_lowercase = 'false'     if ( !$force_username_lowercase );
 $optional_delimiter = "detect"          if ( !$optional_delimiter );
 $auto_create_special = 'false'          if ( !$auto_create_special );
 $default_use_priority = 'true'          if ( !$default_use_priority );
-$hide_sm_attributions = 'false'         if ( !$hide_sm_attributions );
 $default_use_mdn = 'true'               if ( !$default_use_mdn );
 $delete_folder = 'false'                if ( !$delete_folder );
 $noselect_fix_enable = 'false'          if ( !$noselect_fix_enable );
@@ -342,8 +347,6 @@ $provider_uri = ''                      if ( !$provider_uri );
 $provider_name = ''                     if ( !$provider_name );
 $edit_identity = 'true'                 if ( !$edit_identity );
 $edit_name = 'true'                     if ( !$edit_name );
-$allow_thread_sort = 'false'            if ( !$allow_thread_sort );
-$allow_server_sort = 'false'            if ( !$allow_server_sort );
 $no_list_for_subscribe = 'false'        if ( !$no_list_for_subscribe );
 $allow_charset_search = 'true'          if ( !$allow_charset_search );
 $allow_advanced_search = 0              if ( !$allow_advanced_search) ;
@@ -354,6 +357,9 @@ $session_name = 'SQMSESSID'             if ( !$session_name );
 $skip_SM_header = 'false'               if ( !$skip_SM_header );
 $default_use_javascript_addr_book = 'false' if (! $default_use_javascript_addr_book);
 
+# since 1.2.0
+$hide_sm_attributions = 'false'         if ( !$hide_sm_attributions );
+
 # since 1.4.0
 $use_smtp_tls= 'false'                  if ( !$use_smtp_tls);
 $smtp_auth_mech = 'none'                if ( !$smtp_auth_mech );
@@ -366,7 +372,8 @@ $show_alternative_names = 'false'       if ( !$show_alternative_names );
 # implementation changes. options are provided by limit_languages plugin
 # $available_languages = 'all'            if ( !$available_languages );
 $aggressive_decoding = 'false'          if ( !$aggressive_decoding );
-$advanced_tree = 'false'                if ( !$advanced_tree );
+# available only in 1.5.0 and 1.5.1
+# $advanced_tree = 'false'                if ( !$advanced_tree );
 $use_php_recode = 'false'               if ( !$use_php_recode );
 $use_php_iconv = 'false'                if ( !$use_php_iconv );
 
@@ -410,6 +417,12 @@ $use_imap_tls = 0                      if ( $use_imap_tls eq 'false');
 $use_imap_tls = 1                      if ( $use_imap_tls eq 'true');
 $use_smtp_tls = 0                      if ( $use_smtp_tls eq 'false');
 $use_smtp_tls = 1                      if ( $use_smtp_tls eq 'true');
+# sorting options changed names and reversed values in 1.5.1
+$disable_thread_sort = 'false'         if ( !$disable_thread_sort );
+$disable_server_sort = 'false'         if ( !$disable_server_sort );
+
+# since 1.5.2
+$abook_file_line_length = 2048         if ( !$abook_file_line_length );
 
 if ( $ARGV[0] eq '--install-plugin' ) {
     print "Activating plugin " . $ARGV[1] . "\n";
@@ -495,7 +508,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
           print "4.  IMAP Server            : $WHT$imapServerAddress$NRM\n";
           print "5.  IMAP Port              : $WHT$imapPort$NRM\n";
           print "6.  Authentication type    : $WHT$imap_auth_mech$NRM\n";
-          print "7.  Secure IMAP (TLS)      : $WHT$use_imap_tls$NRM\n";
+          print "7.  Secure IMAP (TLS)      : $WHT" . display_use_tls($use_imap_tls) . "$NRM\n";
           print "8.  Server software        : $WHT$imap_server_type$NRM\n";
           print "9.  Delimiter              : $WHT$optional_delimiter$NRM\n";
           print "\n";
@@ -512,7 +525,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
             print "5.   SMTP Port             : $WHT$smtpPort$NRM\n";
             print "6.   POP before SMTP       : $WHT$pop_before_smtp$NRM\n";
             print "7.   SMTP Authentication   : $WHT$smtp_auth_mech$NRM\n";
-            print "8.   Secure SMTP (TLS)     : $WHT$use_smtp_tls$NRM\n";
+            print "8.   Secure SMTP (TLS)     : $WHT" . display_use_tls($use_smtp_tls) . "$NRM\n";
             print "9.   Header encryption key : $WHT$encode_header_key$NRM\n";
             print "\n";
           }
@@ -577,8 +590,8 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
         print "9.  Allow editing of identity   : $WHT$edit_identity$NRM\n";
         print "    Allow editing of name       : $WHT$edit_name$NRM\n";
         print "    Remove username from header : $WHT$hide_auth_header$NRM\n";
-        print "10. Allow server thread sort    : $WHT$allow_thread_sort$NRM\n";
-        print "11. Allow server-side sorting   : $WHT$allow_server_sort$NRM\n";
+        print "10. Disable server thread sort  : $WHT$disable_thread_sort$NRM\n";
+        print "11. Disable server-side sorting : $WHT$disable_server_sort$NRM\n";
         print "12. Allow server charset search : $WHT$allow_charset_search$NRM\n";
         print "13. Allow advanced search       : $WHT$allow_advanced_search$NRM\n";
         print "14. PHP session name            : $WHT$session_name$NRM\n";
@@ -611,6 +624,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
         print "3.  Global address book file                    : $WHT$abook_global_file$NRM\n";
         print "4.  Allow writing into global file address book : $WHT$abook_global_file_writeable$NRM\n";
         print "5.  Allow listing of global file address book   : $WHT$abook_global_file_listing$NRM\n";
+        print "6.  Allowed address book line length            : $WHT$abook_file_line_length$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 7 ) {
@@ -684,16 +698,15 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 11 ) {
     print $WHT. "Interface tweaks\n" . $NRM;
-    print "1.  Advanced tree                : $WHT$advanced_tree$NRM\n";
-    print "2.  Display html mails in iframe : $WHT$use_iframe$NRM\n";
-    print "3.  Use Icons                    : $WHT$use_icons$NRM\n";
+    print "1.  Display html mails in iframe : $WHT$use_iframe$NRM\n";
+    print "2.  Use Icons                    : $WHT$use_icons$NRM\n";
     print "\n";
     print $WHT. "PHP tweaks\n" . $NRM;
-    print "4.  Use php recode functions     : $WHT$use_php_recode$NRM\n";
-    print "5.  Use php iconv functions      : $WHT$use_php_iconv$NRM\n";
+    print "3.  Use php recode functions     : $WHT$use_php_recode$NRM\n";
+    print "4.  Use php iconv functions      : $WHT$use_php_iconv$NRM\n";
     print "\n";
     print $WHT. "Configuration tweaks\n" . $NRM;
-    print "6.  Allow remote configtest     : $WHT$allow_remote_configtest$NRM\n";
+    print "5.  Allow remote configtest     : $WHT$allow_remote_configtest$NRM\n";
     print "\n";
         print "R   Return to Main Menu\n";
     }
@@ -812,8 +825,8 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
             elsif ( $command == 7 )  { $hide_sm_attributions     = command38(); }
             elsif ( $command == 8 )  { $default_use_mdn          = command39(); }
             elsif ( $command == 9 )  { $edit_identity            = command310(); }
-            elsif ( $command == 10 ) { $allow_thread_sort        = command312(); }
-            elsif ( $command == 11 ) { $allow_server_sort        = command313(); }
+            elsif ( $command == 10 ) { $disable_thread_sort     = command312(); }
+            elsif ( $command == 11 ) { $disable_server_sort     = command313(); }
             elsif ( $command == 12 ) { $allow_charset_search     = command314(); }
             elsif ( $command == 13 ) { $allow_advanced_search    = command316(); }
             elsif ( $command == 14 ) { $session_name             = command317(); }
@@ -830,6 +843,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
             elsif ( $command == 3 ) { $abook_global_file=command63(); }
             elsif ( $command == 4 ) { command64(); }
             elsif ( $command == 5 ) { command65(); }
+            elsif ( $command == 6 ) { command_abook_file_line_length(); }
         } elsif ( $menu == 7 ) {
             if ( $command == 1 ) { $motd = command71(); }
         } elsif ( $menu == 8 ) {
@@ -853,12 +867,11 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) && ( $command ne ":q" ) ) {
             elsif ( $command == 4 ) { $aggressive_decoding           = commandA4(); }
             elsif ( $command == 5 ) { $lossy_encoding                = commandA5(); }
         } elsif ( $menu == 11 ) {
-            if    ( $command == 1 ) { $advanced_tree  = commandB1(); }
-            if    ( $command == 2 ) { $use_iframe     = commandB2(); }
-            elsif ( $command == 3 ) { $use_icons      = commandB3(); }
-            elsif ( $command == 4 ) { $use_php_recode = commandB4(); }
-            elsif ( $command == 5 ) { $use_php_iconv  = commandB5(); }
-            elsif ( $command == 6 ) { $allow_remote_configtest = commandB6(); }
+            if    ( $command == 1 ) { $use_iframe     = commandB2(); }
+            elsif ( $command == 2 ) { $use_icons      = commandB3(); }
+            elsif ( $command == 3 ) { $use_php_recode = commandB4(); }
+            elsif ( $command == 4 ) { $use_php_iconv  = commandB5(); }
+            elsif ( $command == 5 ) { $allow_remote_configtest = commandB6(); }
         }
     }
 }
@@ -1016,7 +1029,7 @@ sub command7 {
 
 sub command8 {
     print "Here you can set the name of the link on the right of the page.\n";
-    print "The default is 'SquirrelMail/'\n";
+    print "The default is 'SquirrelMail'\n";
     print "\n";
     print "[$WHT$provider_name$NRM]: $WHT";
     $new_provider_name = <STDIN>;
@@ -1025,6 +1038,7 @@ sub command8 {
     } else {
         $new_provider_name =~ s/[\r\n]//g;
         $new_provider_name =~ s/^\s+$//g;
+        $new_provider_name =~ s/\'/\\'/g;
     }
     return $new_provider_name;
 }
@@ -1466,6 +1480,19 @@ sub command_use_tls {
     return $default_val;
 }
 
+# This sub is used to display human readable text for 
+# $use_imap_tls and $use_smtp_tls values in conf.pl menu
+sub display_use_tls($) {
+    my $val = shift(@_);
+    my $ret = 'disabled';
+    if ($val eq '2') {
+        $ret = 'STARTTLS';
+    } elsif ($val eq '1') {
+        $ret = 'TLS';
+    }
+    return $ret;
+}
+
 # $encode_header_key
 sub command114{
     print "Encryption key allows to hide SquirrelMail Received: headers\n";
@@ -1630,7 +1657,11 @@ sub command23a {
     if ( $new_trash_folder eq "\n" ) {
         $new_trash_folder = $trash_folder;
     } else {
-        $new_trash_folder =~ s/[\r\n]//g;
+        if (check_imap_folder($new_trash_folder)) {
+            $new_trash_folder =~ s/[\r\n]//g;
+        } else {
+            $new_trash_folder = $trash_folder;
+        }
     }
     return $new_trash_folder;
 }
@@ -1651,7 +1682,11 @@ sub command23b {
     if ( $new_sent_folder eq "\n" ) {
         $new_sent_folder = $sent_folder;
     } else {
-        $new_sent_folder =~ s/[\r\n]//g;
+        if (check_imap_folder($new_sent_folder)) {
+            $new_sent_folder =~ s/[\r\n]//g;
+        } else {
+            $new_sent_folder = $sent_folder;
+        }
     }
     return $new_sent_folder;
 }
@@ -1673,7 +1708,11 @@ sub command23c {
     if ( $new_draft_folder eq "\n" ) {
         $new_draft_folder = $draft_folder;
     } else {
-        $new_draft_folder =~ s/[\r\n]//g;
+        if (check_imap_folder($new_draft_folder)) {
+            $new_draft_folder =~ s/[\r\n]//g;
+        } else {
+            $new_draft_folder = $draft_folder;
+        }
     }
     return $new_draft_folder;
 }
@@ -2278,44 +2317,51 @@ sub command311b {
 }
 
 sub command312 {
-    print "This option allows you to choose if users can use thread sorting\n";
-    print "Your IMAP server must support the THREAD command for this to work\n";
-    print "PHP versions later than 4.0.3 recommended\n";
+    print "This option allows you to disable server side thread sorting if your server \n";
+    print "declares THREAD support, but you don't want to provide threading options \n";
+    print "to end users or THREAD extension is broken or extension does not work with \n";
+    print "options used by SquirrelMail. Option is not used, if THREAD extension is \n";
+    print "not declared in IMAP CAPABILITY.\n";
     print "\n";
 
-    if ( lc($allow_thread_sort) eq 'true' ) {
+    if ( lc($disable_thread_sort) eq 'true' ) {
         $default_value = "y";
     } else {
         $default_value = "n";
     }
-    print "Allow server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
-    $allow_thread_sort = <STDIN>;
-    if ( ( $allow_thread_sort =~ /^y\n/i ) || ( ( $allow_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
-        $allow_thread_sort = 'true';
+    print "Disable server side thread sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $disable_thread_sort = <STDIN>;
+    if ( ( $disable_thread_sort =~ /^y\n/i ) || ( ( $disable_thread_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $disable_thread_sort = 'true';
     } else {
-        $allow_thread_sort = 'false';
+        $disable_thread_sort = 'false';
     }
-    return $allow_thread_sort;
+    return $disable_thread_sort;
 }
 
 sub command313 {
-    print "This option allows you to choose if SM uses server-side sorting\n";
-    print "Your IMAP server must support the SORT  command for this to work\n";
+    print "This option allows you to disable server side sorting if your server declares \n";
+    print "SORT support, but SORT extension is broken or does not work with options \n";
+    print "used by SquirrelMail. Option is not used, if SORT extension is not declared \n";
+    print "in IMAP CAPABILITY.\n";
+    print "\n";
+    print "It is strongly recommended to keep server side sorting enabled, if your ";
+    print "IMAP server supports it.";
     print "\n";
 
-    if ( lc($allow_server_sort) eq 'true' ) {
+    if ( lc($disable_server_sort) eq 'true' ) {
         $default_value = "y";
     } else {
         $default_value = "n";
     }
-    print "Allow server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
-    $allow_server_sort = <STDIN>;
-    if ( ( $allow_server_sort =~ /^y\n/i ) || ( ( $allow_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
-        $allow_server_sort = 'true';
+    print "Disable server-side sorting? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $disable_server_sort = <STDIN>;
+    if ( ( $disable_server_sort =~ /^y\n/i ) || ( ( $disable_server_sort =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $disable_server_sort = 'true';
     } else {
-        $allow_server_sort = 'false';
+        $disable_server_sort = 'false';
     }
-    return $allow_server_sort;
+    return $disable_server_sort;
 }
 
 sub command314 {
@@ -2880,6 +2926,8 @@ sub command_fontsets {
 
 sub command61 {
     print "You can now define different LDAP servers.\n";
+    print "Please ensure proper permissions for config.php when including\n";
+    print "sensitive passwords.\n\n";
     print "[ldap] command (?=help) > ";
     $input = <STDIN>;
     $input =~ s/[\r\n]//g;
@@ -2919,6 +2967,9 @@ sub command61 {
                 if ( $ldap_listing[$count] ) {
                     print "     listing: $ldap_listing[$count]\n";
                 }
+                if ( $ldap_writeable[$count] ) {
+                    print "   writeable: $ldap_writeable[$count]\n";
+                }
                 if ( $ldap_search_tree[$count] ) {
                     print " search_tree: $ldap_search_tree[$count]\n";
                 }
@@ -3038,7 +3089,6 @@ sub command61 {
               print "Number of displayed entries is limited by maxrows setting.\n";
               print "\n";
               print "Don't enable this option for public LDAP directories.\n";
-              print "This feature is experimental.\n";
               print "\n";
               print "Allow listing of LDAP directory? (y/N):";
               $name = <STDIN>;
@@ -3051,6 +3101,23 @@ sub command61 {
 
               print "\n";
 
+              print "You can control write access to LDAP address book here. This option can\n";
+              print "be useful if you run small LDAP server and want to provide writable\n";
+              print "shared address book stored in LDAP to users of webmail interface.\n";
+              print "\n";
+              print "Don't enable this option for public LDAP directories.\n";
+              print "\n";
+              print "Allow writing to LDAP directory? (y/N):";
+              $name = <STDIN>;
+              if ( $name =~ /^y\n/i ) {
+                $name = 'true';
+              } else {
+                $name = 'false';
+              }
+              $ldap_writeable[$sub] = $name;
+
+              print "\n";
+
               print "You can specify an additional search filter.\n";
               print "This could be something like \"(objectclass=posixAccount)\".\n";
               print "No filtering is performed by default. Press ENTER for default.\n";
@@ -3127,6 +3194,7 @@ sub command61 {
             @new_ldap_protocol = ();
             @new_ldap_limit_scope = ();
             @new_ldap_listing = ();
+            @new_ldap_writeable = ();
             @new_ldap_search_tree = ();
             @new_ldap_starttls = ();
 
@@ -3144,6 +3212,7 @@ sub command61 {
                     @new_ldap_protocol  = ( @new_ldap_protocol,  $ldap_protocol[$count] );
                     @new_ldap_limit_scope = ( @new_ldap_limit_scope,  $ldap_limit_scope[$count] );
                     @new_ldap_listing = ( @new_ldap_listing, $ldap_listing[$count] );
+                    @new_ldap_writeable = ( @new_ldap_writeable, $ldap_writeable[$count] );
                     @new_ldap_search_tree = ( @new_ldap_search_tree, $ldap_search_tree[$count] );
                     @new_ldap_starttls = ( @new_ldap_starttls, $ldap_starttls[$count] );
                 }
@@ -3161,6 +3230,7 @@ sub command61 {
             @ldap_protocol = @new_ldap_protocol;
             @ldap_limit_scope = @new_ldap_limit_scope;
             @ldap_listing = @new_ldap_listing;
+            @ldap_writeable = @new_ldap_writeable;
             @ldap_search_tree = @new_ldap_search_tree;
             @ldap_starttls = @new_ldap_starttls;
 
@@ -3270,14 +3340,47 @@ sub command65 {
     return $abook_global_file_listing;
 }
 
+# controls $abook_file_line_length setting
+sub command_abook_file_line_length {
+    print "This setting controls space allocated to file based address book records.\n";
+    print "End users will be unable to save address book entry, if total entry size \n";
+    print "(quoted address book fields + 4 delimiters + linefeed) exceeds allowed \n";
+    print "address book length size.\n";
+    print "\n";
+    print "Same setting is applied to personal and global file based address books.\n";
+    print "\n";
+    print "It is strongly recommended to keep default setting value. Change it only\n";
+    print "if you really want to store address book entries that are bigger than two\n";
+    print "kilobytes (2048).\n";
+    print "\n";
+
+    print "Enter allowed address book line length [$abook_file_line_length]: ";
+    my $tmp = <STDIN>;
+    $tmp = trim($tmp);
+    # value is not modified, if user hits Enter or enters space
+    if ($tmp ne '') {
+        # make sure that input is numeric
+        if ($tmp =~ /^\d+$/) {
+            $abook_file_line_length = $tmp;
+        } else {
+            print "If you want to change this setting, you must enter number.\n";
+            print "If you want to keep original setting - enter space.\n\n";
+            print "Press Enter to continue...";
+            $tmp = <STDIN>;
+        }
+    }
+}
+
 sub command91 {
     print "If you want to store your users address book details in a database then\n";
     print "you need to set this DSN to a valid value. The format for this is:\n";
     print "mysql://user:pass\@hostname/dbname\n";
     print "Where mysql can be one of the databases PHP supports, the most common\n";
-    print "of these are mysql, msql and pgsql\n";
+    print "of these are mysql, msql and pgsql.\n";
+    print "Please ensure proper permissions for config.php when including\n";
+    print "sensitive passwords.\n\n";
     print "If the DSN is left empty (hit space and then return) the database\n";
-    print "related code for address books will not be used\n";
+    print "related code for address books will not be used.\n";
     print "\n";
 
     if ( $addrbook_dsn eq "" ) {
@@ -3315,9 +3418,11 @@ sub command93 {
     print "you need to set this DSN to a valid value. The format for this is:\n";
     print "mysql://user:pass\@hostname/dbname\n";
     print "Where mysql can be one of the databases PHP supports, the most common\n";
-    print "of these are mysql, msql and pgsql\n";
+    print "of these are mysql, msql and pgsql.\n";
+    print "Please ensure proper permissions for config.php when including\n";
+    print "sensitive passwords.\n\n";
     print "If the DSN is left empty (hit space and then return) the database\n";
-    print "related code for address books will not be used\n";
+    print "related code for address books will not be used.\n";
     print "\n";
 
     if ( $prefs_dsn eq "" ) {
@@ -3418,9 +3523,11 @@ sub command98 {
     print "you need to set this DSN to a valid value. The format for this is:\n";
     print "mysql://user:pass\@hostname/dbname\n";
     print "Where mysql can be one of the databases PHP supports, the most common\n";
-    print "of these are mysql, msql and pgsql\n";
+    print "of these are mysql, msql and pgsql.\n";
+    print "Please ensure proper permissions for config.php when including\n";
+    print "sensitive passwords.\n\n";
     print "If the DSN is left empty (hit space and then return) the database\n";
-    print "related code for global SQL address book will not be used\n";
+    print "related code for global SQL address book will not be used.\n";
     print "\n";
 
     if ( $addrbook_global_dsn eq "" ) {
@@ -3514,7 +3621,7 @@ sub commandA2 {
     print "This option controls what character set is used when sending\n";
     print "mail and when sending HTML to the browser. Option works only\n";
     print "with US English (en_US) translation. Other translations use\n";
-    print "charsets that are set in functions/i18n.php.\n";
+    print "charsets that are set in translation settings.\n";
     print "\n";
 
     print "[$WHT$default_charset$NRM]: $WHT";
@@ -3594,28 +3701,6 @@ sub commandA5 {
     return $lossy_encoding;
 }
 
-
-# Advanced tree
-sub commandB1 {
-    print "Enable this option if you want to use DHTML based folder listing.\n";
-    print "Code is experimental, works only with some browsers and there might\n";
-    print "be some glitches.\n";
-    print "\n";
-
-    if ( lc($advanced_tree) eq 'true' ) {
-        $default_value = "y";
-    } else {
-        $default_value = "n";
-    }
-    print "Use advanced tree in folder listing? (y/n) [$WHT$default_value$NRM]: $WHT";
-    $advanced_tree = <STDIN>;
-    if ( ( $advanced_tree =~ /^y\n/i ) || ( ( $advanced_tree =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
-        $advanced_tree = 'true';
-    } else {
-        $advanced_tree = 'false';
-    }
-    return $advanced_tree;
-}
 # display html emails in iframe
 sub commandB2 {
     print "This option can enable html email rendering inside iframe.\n";
@@ -3886,9 +3971,9 @@ sub save_data {
         # boolean
         print CF "\$hide_auth_header         = $hide_auth_header;\n";
         # boolean
-        print CF "\$allow_thread_sort        = $allow_thread_sort;\n";
+        print CF "\$disable_thread_sort     = $disable_thread_sort;\n";
         # boolean
-        print CF "\$allow_server_sort        = $allow_server_sort;\n";
+        print CF "\$disable_server_sort     = $disable_server_sort;\n";
         # boolean
         print CF "\$allow_charset_search     = $allow_charset_search;\n";
         # integer
@@ -4004,6 +4089,11 @@ sub save_data {
                 # boolean
                 print CF "    'listing' => $ldap_listing[$count]";
             }
+           if ( $ldap_writeable[$count] ) {
+                print CF ",\n";
+                # boolean
+                print CF "    'writeable' => $ldap_writeable[$count]";
+            }
             if ( $ldap_search_tree[$count] ) {
                 print CF ",\n";
                 # integer
@@ -4053,6 +4143,8 @@ sub save_data {
         print CF "\$abook_global_file_writeable = $abook_global_file_writeable;\n\n";
         # boolean
         print CF "\$abook_global_file_listing = $abook_global_file_listing;\n\n";
+        # integer
+        print CF "\$abook_file_line_length = $abook_file_line_length;\n\n";
         # boolean
         print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
 
@@ -4069,9 +4161,6 @@ sub save_data {
 
         print CF "\n";
 
-        # boolean
-        print CF "\$advanced_tree = $advanced_tree;\n";
-        print CF "\n";
         # boolean
         print CF "\$use_iframe = $use_iframe;\n";
         print CF "\n";
@@ -4097,8 +4186,6 @@ sub save_data {
         print CF " * sent and regular output to begin, which will majorly screw\n";
         print CF " * things up when we try to send more headers later.\n";
         print CF " */\n";
-        print CF "?>";
-
         close CF;
 
         print "Data saved in config.php\n";
@@ -4161,6 +4248,9 @@ sub set_defaults {
             $disp_default_folder_prefix     = "<none>";
             $force_username_lowercase       = false;
 
+            # Delimiter might differ if unixhierarchysep is set to yes.
+            $message = "\nIf you have enabled unixhierarchysep, you must change delimiter and special folder names.\n";
+
             $continue = 1;
         } elsif ( $server eq "uw" ) {
             $imap_server_type               = "uw";
@@ -4491,3 +4581,30 @@ sub clear_screen() {
         system "clear";
     }
 }
+
+# checks IMAP mailbox name. Refuses to accept 8bit folders
+# returns 0 (folder name is not correct) or 1 (folder name is correct)
+sub check_imap_folder($) {
+    my $folder_name = shift(@_);
+    if ($folder_name =~ /[\x{80}-\x{FFFF}]/) {
+        # check for 8bit. Using iso-10646 range, because x80-xFF range does not match unicode chars
+        print "Folder name contains 8bit characters. Configuration utility requires\n";
+        print "UTF7-IMAP encoded folder names.\n";
+        print "Press any key to continue...";
+        my $tmp = <STDIN>;
+        return 0;
+    } elsif ($folder_name =~ /[&\*\%]/) {
+        # check for ampersand and list-wildcards
+        print "Folder name contains special UTF7-IMAP characters.\n";
+        print "Are you sure that folder name is correct? (yN): ";
+        my $tmp = <STDIN>;
+        $tmp = lc(trim($tmp));
+        if ($tmp =~ /^y$/) {
+            return 1;
+        } else {
+            return 0;
+        }
+    } else {
+        return 1;
+    }
+}