return the new vars!
[squirrelmail.git] / config / conf.pl
index 7e18dda637156694f0fe86846ff3ea112af66806..b981d6a4db3a7c443e72431818146d9082daecee 100755 (executable)
@@ -14,9 +14,9 @@ $conf_pl_version = "1.2.0";
 # Perl since at least 5.003_7, and nobody sane runs anything
 # before that, but just in case.
 ############################################################
-
+my $dir;
 if ( eval q{require "File/Basename.pm"} ) {
-    my $dir = File::Basename::dirname($0);
+    $dir = File::Basename::dirname($0);
     chdir($dir);
 }
 
@@ -31,6 +31,14 @@ if ( defined( $ENV{'PATH_INFO'} )
     exit;
     }
 
+############################################################
+# If we got here, use Cwd to get the full directory path
+# (the Basename stuff above will sometimes return '.' as
+# the base directory, which is not helpful here). 
+############################################################
+use Cwd;
+$dir = cwd();
+
 ############################################################              
 # First, lets read in the data already in there...
 ############################################################              
@@ -149,7 +157,7 @@ if ( -e "config.php" ) {
 # Read and parse the current configuration file
 # (either config.php or config_default.php).
 while ( $line = <FILE> ) {
-    $line =~ s/^\s+//;
+    $line =~ s/^\s+//; 
     $line =~ s/^\$//;
     $var = $line;
 
@@ -168,7 +176,7 @@ while ( $line = <FILE> ) {
             if ( -e "../themes" ) {
                 $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
             }
-            $theme_path[$sub] = $options[1];
+            $theme_path[$sub] = &change_to_rel_path($options[1]);
         } elsif ( $options[0] =~ /^theme\[[0-9]+\]\[['|"]NAME['|"]\]/ ) {
             $sub = $options[0];
             $sub =~ s/\]\[['|"]NAME['|"]\]//;
@@ -205,14 +213,14 @@ while ( $line = <FILE> ) {
                     $tmp =~ s/[\'|\"]\);\s*$//;
                     $charset = $tmp;
                 } elsif ( $tmp =~ /^\s*[\'|\"]port[\'|\"]/i ) {
-                    $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]//i;
-                    $tmp =~ s/[\'|\"],?\s*$//;
-                    $tmp =~ s/[\'|\"]\);\s*$//;
+                    $tmp =~ s/^\s*[\'|\"]port[\'|\"]\s*=>\s*[\'|\"]?//i;
+                    $tmp =~ s/[\'|\"]?,?\s*$//;
+                    $tmp =~ s/[\'|\"]?\);\s*$//;
                     $port = $tmp;
                 } elsif ( $tmp =~ /^\s*[\'|\"]maxrows[\'|\"]/i ) {
-                    $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]//i;
-                    $tmp =~ s/[\'|\"],?\s*$//;
-                    $tmp =~ s/[\'|\"]\);\s*$//;
+                    $tmp =~ s/^\s*[\'|\"]maxrows[\'|\"]\s*=>\s*[\'|\"]?//i;
+                    $tmp =~ s/[\'|\"]?,?\s*$//;
+                    $tmp =~ s/[\'|\"]?\);\s*$//;
                     $maxrows = $tmp;
                 } elsif ( $tmp =~ /^\s*[\'|\"]name[\'|\"]/i ) {
                     $tmp =~ s/^\s*[\'|\"]name[\'|\"]\s*=>\s*[\'|\"]//i;
@@ -227,6 +235,8 @@ while ( $line = <FILE> ) {
             $ldap_port[$sub]    = $port;
             $ldap_maxrows[$sub] = $maxrows;
             $ldap_charset[$sub] = $charset;
+        } elsif ( $options[0] =~ /^(data_dir|attachment_dir|theme_css|org_logo|signout_page)$/ ) {
+            ${ $options[0] } = &change_to_rel_path($options[1]);
         } else {
             ${ $options[0] } = $options[1];
         }
@@ -239,6 +249,9 @@ if ( $useSendmail ne "true" ) {
 if ( !$sendmail_path ) {
     $sendmail_path = "/usr/sbin/sendmail";
 }
+if ( !$pop_before_smtp ) {
+    $pop_before_smtp = "false";
+}
 if ( !$default_unseen_notify ) {
     $default_unseen_notify = 2;
 }
@@ -275,9 +288,21 @@ if ( !$default_use_mdn ) {
 if ( !$delete_folder ) {
     $delete_folder = "false";
 }
+if ( !$noselect_fix_enable ) {
+    $noselect_fix_enable = "false";
+}
 if ( !$frame_top ) {
     $frame_top = "_top";
 }
+
+if ( !$provider_uri ) {
+    $provider_uri = "http://www.squirrelmail.org/";
+}
+
+if ( !$provider_name ) {
+    $provider_name = "SquirrelMail";
+}
+
 if ( !$edit_identity ) {
     $edit_identity = "true";
 }
@@ -287,6 +312,18 @@ if ( !$edit_name ) {
 if ( !$allow_thread_sort ) {
     $allow_thread_sort = 'false';
 }
+if ( !$allow_server_sort ) {
+    $allow_server_sort = 'false';
+}
+if ( !$uid_support ) {
+    $uid_support = 'true';
+}
+if ( !$no_list_for_subscribe ) {
+    $no_list_for_subscribe = 'false';
+}
+if ( !$allow_charset_search ) {
+    $allow_charset_search = 'true';
+}
 if ( !$prefs_user_field ) {
     $prefs_user_field = 'user';
 }
@@ -355,6 +392,9 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         print "5.  Signout Page           : $WHT$signout_page$NRM\n";
         print "6.  Default Language       : $WHT$squirrelmail_default_language$NRM\n";
         print "7.  Top Frame              : $WHT$frame_top$NRM\n";
+        print "8.  Provider link          : $WHT$provider_uri$NRM\n";
+        print "9.  Provider name          : $WHT$provider_name$NRM\n";
+
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 2 ) {
@@ -375,10 +415,11 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             print "6.    SMTP Server        : $WHT$smtpServerAddress$NRM\n";
             print "7.    SMTP Port          : $WHT$smtpPort$NRM\n";
             print "8.    Authenticated SMTP : $WHT$use_authenticated_smtp$NRM\n";
+            print "9.    POP Before SMTP    : $WHT$pop_before_smtp$NRM\n";
         }
-        print "9.  Server               : $WHT$imap_server_type$NRM\n";
-        print "10. Invert Time          : $WHT$invert_time$NRM\n";
-        print "11. Delimiter            : $WHT$optional_delimiter$NRM\n";
+        print "10. Server               : $WHT$imap_server_type$NRM\n";
+        print "11. Invert Time          : $WHT$invert_time$NRM\n";
+        print "12. Delimiter            : $WHT$optional_delimiter$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 3 ) {
@@ -400,6 +441,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         print "15. Default Unseen Type           : $WHT$default_unseen_type$NRM\n";
         print "16. Auto Create Special Folders   : $WHT$auto_create_special$NRM\n";
         print "17. Don't move folders into Trash : $WHT$delete_folder$NRM\n";
+        print "18. Enable /NoSelect folder fix   : $WHT$noselect_fix_enable$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 4 ) {
@@ -415,9 +457,12 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         print "9.  Allow use of receipts     : $WHT$default_use_mdn$NRM\n";
         print "10. Allow editing of identity : $WHT$edit_identity$NRM\n";
         print "11. Allow server thread sort  : $WHT$allow_thread_sort$NRM\n";
+        print "12. Allow server-side sorting : $WHT$allow_server_sort$NRM\n";
         if ( lc($edit_identity) eq "false" ) {
-            print "12. Allow editing of name     : $WHT$edit_name$NRM\n";
+            print "13. Allow editing of name     : $WHT$edit_name$NRM\n";
         }
+        print "14. Allow server charset search : $WHT$allow_charset_search$NRM\n";
+        print "15. Enable UID support : $WHT$uid_support$NRM\n";
         print "\n";
         print "R   Return to Main Menu\n";
     } elsif ( $menu == 5 ) {
@@ -495,7 +540,6 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
         print "6.  Field for prefs key    : $WHT$prefs_key_field$NRM\n";
         print "7.  Field for prefs value  : $WHT$prefs_val_field$NRM\n";
         print "\n";
-        print "S   Save data\n";
         print "R   Return to Main Menu\n";
     }
     if ( $config_use_color == 1 ) {
@@ -554,6 +598,9 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 5 ) { $signout_page                  = command4(); }
             elsif ( $command == 6 ) { $squirrelmail_default_language = command5(); }
             elsif ( $command == 7 ) { $frame_top                     = command6(); }
+            elsif ( $command == 8 ) { $provider_uri                  = command7(); }
+            elsif ( $command == 9 ) { $provider_name                 = command8(); }
+
         } elsif ( $menu == 2 ) {
             if    ( $command == 1 )  { $domain                 = command11(); }
             elsif ( $command == 2 )  { $imapServerAddress      = command12(); }
@@ -563,9 +610,10 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 6 )  { $smtpServerAddress      = command16(); }
             elsif ( $command == 7 )  { $smtpPort               = command17(); }
             elsif ( $command == 8 )  { $use_authenticated_smtp = command18(); }
-            elsif ( $command == 9 )  { $imap_server_type       = command19(); }
-            elsif ( $command == 10 ) { $invert_time            = command110(); }
-            elsif ( $command == 11 ) { $optional_delimiter     = command111(); }
+            elsif ( $command == 9 )  { $pop_before_smtp        = command18a(); }
+            elsif ( $command == 10 ) { $imap_server_type       = command19(); }
+            elsif ( $command == 11 ) { $invert_time            = command110(); }
+            elsif ( $command == 12 ) { $optional_delimiter     = command111(); }
         } elsif ( $menu == 3 ) {
             if    ( $command == 1 )  { $default_folder_prefix          = command21(); }
             elsif ( $command == 2 )  { $show_prefix_option             = command22(); }
@@ -584,6 +632,7 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 15 ) { $default_unseen_type            = command213(); }
             elsif ( $command == 16 ) { $auto_create_special            = command214(); }
             elsif ( $command == 17 ) { $delete_folder                  = command215(); }
+            elsif ( $command == 18 ) { $noselect_fix_enable            = command216(); }
         } elsif ( $menu == 4 ) {
             if    ( $command == 1 )  { $default_charset          = command31(); }
             elsif ( $command == 2 )  { $data_dir                 = command33a(); }
@@ -596,7 +645,10 @@ while ( ( $command ne "q" ) && ( $command ne "Q" ) ) {
             elsif ( $command == 9 )  { $default_use_mdn          = command39(); }
             elsif ( $command == 10 ) { $edit_identity            = command310(); }
             elsif ( $command == 11 ) { $allow_thread_sort        = command312(); }
-            elsif ( $command == 12 ) { $edit_name                = command311(); }
+            elsif ( $command == 12 ) { $allow_server_sort        = command313(); }
+            elsif ( $command == 13 ) { $edit_name                = command311(); }
+            elsif ( $command == 14 ) { $allow_charset_search     = command314(); }
+            elsif ( $command == 15 ) { $uid_support              = command315(); }
         } elsif ( $menu == 5 ) {
             if ( $command == 1 ) { command41(); }
             elsif ( $command == 2 ) { $theme_css = command42(); }
@@ -634,6 +686,7 @@ sub command1 {
         $new_org_name = $org_name;
     } else {
         $new_org_name =~ s/[\r|\n]//g;
+       $new_org_name =~ s/\"/&quot;/g;
     }
     return $new_org_name;
 }
@@ -642,8 +695,10 @@ sub command1 {
 sub command2 {
     print "Your organization's logo is an image that will be displayed at\n";
     print "different times throughout SquirrelMail.  This is asking for the\n";
-    print "literal (/usr/local/squirrelmail/images/logo.jpg) or relative\n";
-    print "(../images/logo.jpg) path to your logo.\n";
+    print "literal (/usr/local/squirrelmail/images/logo.png) or relative\n";
+    print "(../images/logo.png) path to your logo.\n";
+    print "Relative paths to files outside the SquirrelMail distribution\n";
+    print "will be converted to their absolute path equivalents in config.php.\n";
     print "\n";
     print "[$WHT$org_logo$NRM]: $WHT";
     $new_org_logo = <STDIN>;
@@ -671,7 +726,9 @@ sub command2a {
         print "Height: [$WHT$org_logo_height$NRM]: $WHT";
         $new_org_logo_height = <STDIN>;
         $new_org_logo_height =~ tr/0-9//cd;  # only want digits!
-        $new_org_logo_height = $org_logo_height;
+        if( $new_org_logo_height eq '' ) {
+               $new_org_logo_height = $org_logo_height;
+       }
     } else {
         $new_org_logo_height = 0;
     }
@@ -690,6 +747,7 @@ sub command3 {
         $new_org_title = $org_title;
     } else {
         $new_org_title =~ s/[\r|\n]//g;
+       $new_org_title =~ s/\"/\'/g;
     }
     return $new_org_title;
 }
@@ -716,7 +774,7 @@ sub command4 {
 sub command5 {
     print "SquirrelMail attempts to set the language in many ways.  If it\n";
     print "can not figure it out in another way, it will default to this\n";
-    print "language.  Please use the two-letter code for the desired language.\n";
+    print "language.  Please use the code for the desired language.\n";
     print "\n";
     print "[$WHT$squirrelmail_default_language$NRM]: $WHT";
     $new_signout_page = <STDIN>;
@@ -746,11 +804,42 @@ sub command6 {
     return $new_frame_top;
 }
 
+# Default link to provider
+sub command7 {
+    print "Here you can set the link on the right of the page.\n";
+    print "The default is 'http://www.squirrelmail.org/'\n";
+    print "\n";
+    print "[$WHT$provider_uri$NRM]: $WHT";
+    $new_provider_uri = <STDIN>;
+    if ( $new_provider_uri eq "\n" ) {
+        $new_provider_uri = 'http://www.squirrelmail.org/';
+    } else {
+        $new_provider_uri =~ s/[\r|\n]//g;
+        $new_provider_uri =~ s/^\s+$//g;
+    }
+    return $new_provider_uri;
+}
+
+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 "\n";
+    print "[$WHT$provider_name$NRM]: $WHT";
+    $new_provider_name = <STDIN>;
+    if ( $new_provider_name eq "\n" ) {
+        $new_provider_name = 'SquirrelMail';
+    } else {
+        $new_provider_name =~ s/[\r|\n]//g;
+        $new_provider_name =~ s/^\s+$//g;
+    }
+    return $new_provider_name;
+}
+
 ####################################################################################
 
 # domain
 sub command11 {
-    print "The domain name is the suffix at the end of all email messages.  If\n";
+    print "The domain name is the suffix at the end of all email addresses.  If\n";
     print "for example, your email address is jdoe\@myorg.com, then your domain\n";
     print "would be myorg.com.\n";
     print "\n";
@@ -874,6 +963,23 @@ sub command18 {
     return $use_authenticated_smtp;
 }
 
+# pop before SMTP
+sub command18a {
+    print "Do you wish to use POP3 before SMTP?  Your server must\n";
+    print "support this in order for SquirrelMail to work with it.\n";
+
+    $YesNo = 'n';
+    $YesNo = 'y' if ( lc($pop_before_smtp) eq "true" );
+
+    print "Use pop before SMTP (y/n) [$WHT$YesNo$NRM]: $WHT";
+
+    $new_pop_before_smtp = <STDIN>;
+    $new_pop_before_smtp =~ tr/yn//cd;
+    return "true"  if ( $new_pop_before_smtp eq "y" );
+    return "false"  if ( $new_pop_before_smtp eq "n" );
+    return $pop_before_smtp;
+}
+
 # imap_server_type 
 sub command19 {
     print "Each IMAP server has its own quirks.  As much as we tried to stick\n";
@@ -886,6 +992,7 @@ sub command19 {
     print "    uw         = University of Washington's IMAP server\n";
     print "    exchange   = Microsoft Exchange IMAP server\n";
     print "    courier    = Courier IMAP server\n";
+    print "    macosx     = Mac OS X Mailserver\n";
     print "    other      = Not one of the above servers\n";
     print "[$WHT$imap_server_type$NRM]: $WHT";
     $new_imap_server_type = <STDIN>;
@@ -956,7 +1063,7 @@ sub command71 {
             $line =~ s/  /\&nbsp;\&nbsp;/g;
             $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
             $line =~ s/$/ /;
-            $line =~ s/\'/\\\'/g;
+            $line =~ s/\"/&quot;/g;
 
             $new_motd = $new_motd . $line;
         }
@@ -1044,12 +1151,13 @@ sub command21 {
         $new_default_folder_prefix = "";
     } else {
         # add the trailing delimiter only if we know what the server is.
-        if ($optional_delimiter and $optional_delimiter ne 'detect') {
-           $new_default_folder_prefix =~ s/${optional_delimiter}*$/$optional_delimiter/;
-        } elsif ($imap_server_type eq 'cyrus' or
-                 $imap_server_type eq 'courier') {
+        if (($imap_server_type eq 'cyrus' and
+                  $optional_delimiter eq 'detect') or
+                 ($imap_server_type eq 'courier' and
+                  $optional_delimiter eq 'detect')) {
            $new_default_folder_prefix =~ s/\.*$/\./;
-        } elsif ($imap_server_type eq 'uw') {
+        } elsif ($imap_server_type eq 'uw' and
+                 $optional_delimiter eq 'detect') {
            $new_default_folder_prefix =~ s/\/*$/\//;
         }
     }
@@ -1426,6 +1534,27 @@ sub command215 {
     return $delete_folder;
 }
 
+#noselect fix
+sub command216 {
+    print "Some IMAP server allow subfolders to exist even if the parent\n";
+    print "folders do not. This fixes some problems with the folder list\n";
+    print "when this is the case, causing the /NoSelect folders to be displayed\n";
+    print "\n";
+
+    if ( lc($noselect_fix_enable) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "enable noselect fix? (y/n) [$WHT$noselect_fix_enable$NRM]: $WHT";
+    $noselect_fix_enable = <STDIN>;
+    if ( ( $noselect_fix_enable =~ /^y\n/i ) || ( ( $noselect_fix_enable =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $noselect_fix_enable = "true";
+    } else {
+        $noselect_fix_enable = "false";
+    }
+    return $noselect_fix_enable;
+}
 ############# GENERAL OPTIONS #####################
 
 # Default Charset
@@ -1457,6 +1586,8 @@ sub command33a {
     print "are two examples:\n";
     print "  Absolute:    /usr/local/squirrelmail/data/\n";
     print "  Relative:    ../data/\n";
+    print "Relative paths to directories outside of the SquirrelMail distribution\n";
+    print "will be converted to their absolute path equivalents in config.php.\n";
     print "\n";
 
     print "[$WHT$data_dir$NRM]: $WHT";
@@ -1489,6 +1620,8 @@ sub command33b {
     print "      lying around there for too long.\n";
     print "  3.  It should probably be another directory than the data\n";
     print "      directory specified in option 3.\n";
+    print "Relative paths to directories outside of the SquirrelMail distribution\n";
+    print "will be converted to their absolute path equivalents in config.php.\n";
     print "\n";
 
     print "[$WHT$attachment_dir$NRM]: $WHT";
@@ -1676,6 +1809,7 @@ sub command311 {
 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 "\n";
 
     if ( lc($allow_thread_sort) eq "true" ) {
@@ -1693,6 +1827,66 @@ sub command312 {
     return $allow_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 "\n";
+
+    if ( lc($allow_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";
+    } else {
+        $allow_server_sort = "false";
+    }
+    return $allow_server_sort;
+}
+
+sub command314 {
+    print "This option allows you to choose if SM uses charset search\n";
+    print "Your IMAP server must support the SEARCH CHARSET command for this to work\n";
+    print "\n";
+
+    if ( lc($allow_charset_search) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Allow charset searching? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $allow_charset_search = <STDIN>;
+    if ( ( $allow_charset_search =~ /^y\n/i ) || ( ( $allow_charset_search =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $allow_charset_search = "true";
+    } else {
+        $allow_charset_search = "false";
+    }
+    return $allow_charset_search;
+}
+
+sub command315 {
+    print "This option allows you to enable unique identifier (UID) support.\n";
+    print "\n";
+
+    if ( lc($uid_support) eq "true" ) {
+        $default_value = "y";
+    } else {
+        $default_value = "n";
+    }
+    print "Enable Unique identifier (UID) support? (y/n) [$WHT$default_value$NRM]: $WHT";
+    $uid_support = <STDIN>;
+    if ( ( $uid_support =~ /^y\n/i ) || ( ( $uid_support =~ /^\n/ ) && ( $default_value eq "y" ) ) ) {
+        $uid_support = "true";
+    } else {
+        $uid_support = "false";
+    }
+    return $uid_support;
+}
+
+
 sub command41 {
     print "\nNow we will define the themes that you wish to use.  If you have added\n";
     print "a theme of your own, just follow the instructions (?) about how to add\n";
@@ -1843,6 +2037,9 @@ sub command42 {
     print "\n";
     print "To clear out an existing value, just type a space for the input.\n";
     print "\n";
+    print "Relative links to files outside the SquirrelMail distribution\n";
+    print "will be converted to their absolute path equivalents in config.php.\n";
+    print "\n";
     print "[$WHT$theme_css$NRM]: $WHT";
     $new_theme_css = <STDIN>;
 
@@ -2152,80 +2349,152 @@ sub save_data {
         if ($print_config_version) {
             print CF "\$config_version = '$print_config_version';\n";
         }
+       # integer
         print CF "\$config_use_color = $config_use_color;\n";
         print CF "\n";
-
+       
+       # string
         print CF "\$org_name      = \"$org_name\";\n";
-        print CF "\$org_logo      = '$org_logo';\n";
+        # string
+       print CF "\$org_logo      = " . &change_to_SM_path($org_logo) . ";\n";
         $org_logo_width |= 0;
         $org_logo_height |= 0;
-        print CF "\$org_logo_width  = $org_logo_width;\n";
-        print CF "\$org_logo_height = $org_logo_height;\n";
+       # string
+        print CF "\$org_logo_width  = '$org_logo_width';\n";
+        # string
+       print CF "\$org_logo_height = '$org_logo_height';\n";
+       # string that can contain variables.
         print CF "\$org_title     = \"$org_title\";\n";
-        print CF "\$signout_page  = '$signout_page';\n";
+       # string
+        print CF "\$signout_page  = " . &change_to_SM_path($signout_page) . ";\n";
+       # string
         print CF "\$frame_top     = '$frame_top';\n";
         print CF "\n";
 
-        print CF "\$motd = '$motd';\n";
+        print CF "\$provider_uri     = '$provider_uri';\n";
+        print CF "\n";
+
+        print CF "\$provider_name     = '$provider_name';\n";
         print CF "\n";
 
+       # string that can contain variables
+        print CF "\$motd = \"$motd\";\n";
+        print CF "\n";
+       
+       # string
         print CF "\$squirrelmail_default_language = '$squirrelmail_default_language';\n";
         print CF "\n";
 
+       # string
         print CF "\$domain                 = '$domain';\n";
+       # string
         print CF "\$imapServerAddress      = '$imapServerAddress';\n";
+       # integer
         print CF "\$imapPort               = $imapPort;\n";
+       # boolean
         print CF "\$useSendmail            = $useSendmail;\n";
+       # string
         print CF "\$smtpServerAddress      = '$smtpServerAddress';\n";
+       # integer
         print CF "\$smtpPort               = $smtpPort;\n";
+       # string
         print CF "\$sendmail_path          = '$sendmail_path';\n";
+       # boolean
         print CF "\$use_authenticated_smtp = $use_authenticated_smtp;\n";
+       # boolean
+        print CF "\$pop_before_smtp        = $pop_before_smtp;\n";
+       # string
         print CF "\$imap_server_type       = '$imap_server_type';\n";
+       # boolean
         print CF "\$invert_time            = $invert_time;\n";
+       # string
         print CF "\$optional_delimiter     = '$optional_delimiter';\n";
         print CF "\n";
 
+       # string
         print CF "\$default_folder_prefix          = '$default_folder_prefix';\n";
+       # string
         print CF "\$trash_folder                   = '$trash_folder';\n";
+       # string
         print CF "\$sent_folder                    = '$sent_folder';\n";
+       # string
         print CF "\$draft_folder                   = '$draft_folder';\n";
+       # boolean
         print CF "\$default_move_to_trash          = $default_move_to_trash;\n";
+       # boolean
         print CF "\$default_move_to_sent           = $default_move_to_sent;\n";
+       # boolean
         print CF "\$default_save_as_draft          = $default_save_as_draft;\n";
+       # boolean
         print CF "\$show_prefix_option             = $show_prefix_option;\n";
+       # boolean
         print CF "\$list_special_folders_first     = $list_special_folders_first;\n";
+       # boolean
         print CF "\$use_special_folder_color       = $use_special_folder_color;\n";
+       # boolean
         print CF "\$auto_expunge                   = $auto_expunge;\n";
+       # boolean
         print CF "\$default_sub_of_inbox           = $default_sub_of_inbox;\n";
+       # boolean
         print CF "\$show_contain_subfolders_option = $show_contain_subfolders_option;\n";
+       # integer
         print CF "\$default_unseen_notify          = $default_unseen_notify;\n";
+       # integer
         print CF "\$default_unseen_type            = $default_unseen_type;\n";
+       # boolean
         print CF "\$auto_create_special            = $auto_create_special;\n";
+       # boolean
         print CF "\$delete_folder                  = $delete_folder;\n";
+    # boolean
+        print CF "\$noselect_fix_enable            = $noselect_fix_enable;\n";
+
         print CF "\n";
 
+       # string
         print CF "\$default_charset          = '$default_charset';\n";
-        print CF "\$data_dir                 = '$data_dir';\n";
-        print CF "\$attachment_dir           = \"$attachment_dir\";\n";
+       # string
+        print CF "\$data_dir                 = " . &change_to_SM_path($data_dir) . ";\n";
+       # string that can contain a variable
+        print CF "\$attachment_dir           = " . &change_to_SM_path($attachment_dir) . ";\n";
+       # integer
         print CF "\$dir_hash_level           = $dir_hash_level;\n";
-        print CF "\$default_left_size        = $default_left_size;\n";
+       # string
+        print CF "\$default_left_size        = '$default_left_size';\n";
+       # boolean
         print CF "\$force_username_lowercase = $force_username_lowercase;\n";
+       # boolean
         print CF "\$default_use_priority     = $default_use_priority;\n";
+       # boolean
         print CF "\$hide_sm_attributions     = $hide_sm_attributions;\n";
+       # boolean
         print CF "\$default_use_mdn          = $default_use_mdn;\n";
+       # boolean
         print CF "\$edit_identity            = $edit_identity;\n";
+       # boolean
         print CF "\$edit_name                = $edit_name;\n";
+       # boolean
         print CF "\$allow_thread_sort        = $allow_thread_sort;\n";
+       # boolean
+        print CF "\$allow_server_sort        = $allow_server_sort;\n";
+        # boolean
+        print CF "\$allow_charset_search     = $allow_charset_search;\n";
+        # boolean
+        print CF "\$uid_support              = $uid_support;\n";
         print CF "\n";
-
+       
+       # all plugins are strings
         for ( $ct = 0 ; $ct <= $#plugins ; $ct++ ) {
             print CF "\$plugins[$ct] = '$plugins[$ct]';\n";
         }
         print CF "\n";
 
-        print CF "\$theme_css = '$theme_css';\n";
+       # strings
+        print CF "\$theme_css = " . &change_to_SM_path($theme_css) . ";\n";
+       if ( $theme_default eq '' ) { $theme_default = '0'; }
+        print CF "\$theme_default = $theme_default;\n";
+
         for ( $count = 0 ; $count <= $#theme_name ; $count++ ) {
-            print CF "\$theme[$count]['PATH'] = '$theme_path[$count]';\n";
+            print CF "\$theme[$count]['PATH'] = " . &change_to_SM_path($theme_path[$count]) . ";\n";
             print CF "\$theme[$count]['NAME'] = '$theme_name[$count]';\n";
         }
         print CF "\n";
@@ -2233,39 +2502,56 @@ sub save_data {
         if ( $default_use_javascript_addr_book ne "true" ) {
             $default_use_javascript_addr_book = "false";
         }
+
+       # boolean
         print CF "\$default_use_javascript_addr_book = $default_use_javascript_addr_book;\n";
         for ( $count = 0 ; $count <= $#ldap_host ; $count++ ) {
             print CF "\$ldap_server[$count] = array(\n";
+           # string
             print CF "    'host' => '$ldap_host[$count]',\n";
+           # string
             print CF "    'base' => '$ldap_base[$count]'";
             if ( $ldap_name[$count] ) {
                 print CF ",\n";
+               # string
                 print CF "    'name' => '$ldap_name[$count]'";
             }
             if ( $ldap_port[$count] ) {
                 print CF ",\n";
-                print CF "    'port' => '$ldap_port[$count]'";
+               # integer
+                print CF "    'port' => $ldap_port[$count]";
             }
             if ( $ldap_charset[$count] ) {
                 print CF ",\n";
+               # string
                 print CF "    'charset' => '$ldap_charset[$count]'";
             }
             if ( $ldap_maxrows[$count] ) {
                 print CF ",\n";
-                print CF "    'maxrows' => '$ldap_maxrows[$count]'";
+               # integer
+                print CF "    'maxrows' => $ldap_maxrows[$count]";
             }
             print CF "\n";
             print CF ");\n";
             print CF "\n";
         }
 
+       # string
         print CF "\$addrbook_dsn = '$addrbook_dsn';\n";
+       # string
         print CF "\$addrbook_table = '$addrbook_table';\n\n";
+       # string
         print CF "\$prefs_dsn = '$prefs_dsn';\n";
+       # string
         print CF "\$prefs_table = '$prefs_table';\n";
+       # string
         print CF "\$prefs_user_field = '$prefs_user_field';\n";
+       # string
         print CF "\$prefs_key_field = '$prefs_key_field';\n";
+       # string
         print CF "\$prefs_val_field = '$prefs_val_field';\n";
+       # boolean
+       print CF "\$no_list_for_subscribe = $no_list_for_subscribe;\n";
         print CF "\n";
 
         print CF "/**\n";
@@ -2310,6 +2596,7 @@ sub set_defaults {
         print "    uw         = University of Washington's IMAP server\n";
         print "    exchange   = Microsoft Exchange IMAP server\n";
         print "    courier    = Courier IMAP server\n";
+        print "    macosx     = Mac OS X Mailserver\n";
         print "    quit       = Do not change anything\n";
         print "Command >> ";
         $server = <STDIN>;
@@ -2367,6 +2654,20 @@ sub set_defaults {
             $optional_delimiter             = ".";
             $disp_default_folder_prefix     = $default_folder_prefix;
 
+            $continue = 1;
+        } elsif ( $server eq "macosx" ) {
+            $imap_server_type               = "macosx";
+            $default_folder_prefix          = "INBOX/";
+            $trash_folder                   = "Trash";
+            $sent_folder                    = "Sent";
+            $draft_folder                   = "Drafts";
+            $show_prefix_option             = false;
+            $default_sub_of_inbox           = true;
+            $show_contain_subfolders_option = false;
+            $optional_delimiter             = "detect";
+            $allow_charset_search           = false;
+            $disp_default_folder_prefix     = $default_folder_prefix;
+
             $continue = 1;
         } elsif ( $server eq "quit" ) {
             $continue = 1;
@@ -2389,3 +2690,68 @@ sub set_defaults {
     print "\nPress any key to continue...";
     $tmp = <STDIN>;
 }
+
+############################################################
+# This subroutine corrects relative paths to ensure they
+# will work within the SM space. If the path falls within
+# the SM directory tree, the SM_PATH variable will be 
+# prepended to the path, if not, then the path will be
+# converted to an absolute path.
+############################################################
+sub change_to_SM_path() {
+    my ($old_path) = @_;
+    my $new_path = '';
+    my @rel_path;
+    my @abs_path;
+    my $subdir;
+
+    # If the path is absolute, don't bother.
+    return "\'" . $old_path . "\'"  if ( $old_path eq '');
+    return "\'" . $old_path . "\'"  if ( $old_path =~ /^\// );
+    return $old_path                if ( $old_path =~ /^SM_PATH/ );
+
+    # For relative paths, split on '../'
+    @rel_path = split(/\.\.\//, $old_path);
+
+    if ( $#rel_path > 1 ) {
+        # more than two levels away. Make it absolute.
+        @abs_path = split(/\//, $dir);
+        foreach $subdir (@rel_path) {
+            if ($subdir eq '') {
+                pop @abs_path;
+            } else {
+                push @abs_path, $subdir;
+            }
+        }
+        foreach $subdir (@abs_path) {
+            $new_path .= $subdir . '/';
+        }
+    } elsif ( $#rel_path > 0 ) {
+        # it's within the SM tree, prepend SM_PATH
+        $new_path = $old_path;
+        $new_path =~ s/^\.\.\//SM_PATH . \'/;
+        $new_path .= '\'';
+    } else {
+        # Last, it's a relative path without any leading '.'
+        # Prepend SM_PATH  (no substitution required)
+        $new_path = "SM_PATH . \'" . $old_path . "\'";
+    }
+
+  return $new_path;
+}
+
+sub change_to_rel_path() {
+    my ($old_path) = @_;
+    my $new_path = '';
+
+    return $old_path if ( $old_path eq '');
+    return $old_path if ( $old_path =~ /^\// );
+    return $old_path if ( $old_path =~ /^\.\./ );
+
+    if ( $old_path =~ /^SM_PATH/ ) {
+        $new_path = $old_path;
+        $new_path =~ s/^SM_PATH . \'/\.\.\//;
+    }
+
+    return $new_path;
+}