made the sendmail/smtp option more clear
[squirrelmail.git] / config / conf.pl
index 8d792876df29c351086964a9a3808fe6cfc7a378..ea7dcd07453317347794352ecc90eee7e9ee6299 100755 (executable)
 #!/usr/bin/perl
 # conf.pl
-# Written March 26, 2000
-# Luke Ehresman (lehresma@css.tayloru.edu)
+# Luke Ehresman (luke@squirrelmail.org)
 #
 # A simple configure script to configure squirrelmail
 ############################################################              
 $WHT = "\x1B[37;1m";
 $NRM = "\x1B[0m";
+$conf_pl_version = "x51";
 
 ############################################################              
 # First, lets read in the data already in there...
 ############################################################              
 if ( -e "config.php") {
+   open (FILE, "config.php");
+   while ($line = <FILE>) {
+      if ($line =~ /^\s+\$/) {
+         $line =~ s/^\s+\$//;
+         $var = $line;
+      
+         $var =~ s/=/EQUALS/;
+         if ($var =~ /^([a-z]|[A-Z])/) {
+            @o = split(/\s*EQUALS\s*/, $var);
+            if ($o[0] eq "config_version") {
+               $o[1] =~ s/[\n|\r]//g;
+               $o[1] =~ s/\";\s*$//;
+               $o[1] =~ s/;$//;
+               $o[1] =~ s/^"//;
+
+               $config_version = $o[1];
+               close (FILE);
+            }
+         }
+      }   
+   }
+   close (FILE);
+
+   if ($config_version ne $conf_pl_version) {
+      system "clear";
+      print $WHT."WARNING:\n".$NRM;
+      print "  The file \"config/config.php\" was found, but it is for an older version of\n";
+      print "  SquirrelMail.  It is possible to still read the defaults from this file\n";
+      print "  but be warned that many preferences change between versions.  It is\n";
+      print "  recommended that you start with a clean config.php for each upgrade that\n";
+      print "  you do.  To do this, just move config/config.php out of the way.\n\n";
+      print "Continue loading with the old config.php [y/n]? ";
+      $ctu = <STDIN>;
+      if (($ctu =~ /^n\n/i) || ($ctu =~ /^\n/)) {
+         exit;
+      }
+
+      print "\nDo you want me to stop warning you [y/n]? ";
+      $ctu = <STDIN>;
+      if ($ctu =~ /^y\n/i) {
+         $print_config_version = $conf_pl_version;
+      } else {
+         $print_config_version = $config_version;
+      }
+   } else {
+      $print_config_version = $config_version;
+   } 
+
    $config = 1;
    open (FILE, "config.php");
 } elsif (-e "config_default.php") {
+   open (FILE, "config_default.php");
+   while ($line = <FILE>) {
+      if ($line =~ /^\s+\$/) {
+         $line =~ s/^\s+\$//;
+         $var = $line;
+      
+         $var =~ s/=/EQUALS/;
+         if ($var =~ /^([a-z]|[A-Z])/) {
+            @o = split(/\s*EQUALS\s*/, $var);
+            if ($o[0] eq "config_version") {
+               $o[1] =~ s/[\n|\r]//g;
+               $o[1] =~ s/\";\s*$//;
+               $o[1] =~ s/;$//;
+               $o[1] =~ s/^"//;
+
+               $config_version = $o[1];
+               close (FILE);
+            }
+         }
+      }   
+   }
+   close (FILE);
+
+   if ($config_version ne $conf_pl_version) {
+      system "clear";
+      print $WHT."WARNING:\n".$NRM;
+      print "  You are trying to use a \"config_default.php\" from an older version of\n";
+      print "  SquirrelMail.  This is HIGHLY unrecommended.  You should get the\n";
+      print "  \"config_default.php\" that matches the version of SquirrelMail that you\n";
+      print "  are running.  You can get this from the SquirrelMail web page by going\n";
+      print "  to:  http://www.squirrelmail.org.\n\n";
+      print "Continue loading with the old config_default.php (not a good idea) [y/n]? ";
+      $ctu = <STDIN>;
+      if (($ctu =~ /^n\n/i) || ($ctu =~ /^\n/)) {
+         exit;
+      }
+
+      print "\nDo you want me to stop warning you [y/n]? ";
+      $ctu = <STDIN>;
+      if ($ctu =~ /^y\n/i) {
+         $print_config_version = $conf_pl_version;
+      } else {
+         $print_config_version = $config_version;
+      }
+   } else {
+      $print_config_version = $config_version;
+   }
    $config = 2;
    open (FILE, "config_default.php");
 } else {
@@ -32,26 +127,36 @@ while ($line = <FILE>) {
       $line =~ s/^\s+\$//;
       $var = $line;
       
+      $var =~ s/=/EQUALS/;
       if ($var =~ /^([a-z]|[A-Z])/) {
-         @options = split(/\s*=\s*/, $var);
+         @options = split(/\s*EQUALS\s*/, $var);
          $options[1] =~ s/[\n|\r]//g;
-         $options[1] =~ s/^"//g;
-         $options[1] =~ s/;.*$//g;
-         $options[1] =~ s/"$//g;
+         $options[1] =~ s/\";\s*$//;
+         $options[1] =~ s/;$//;
+         $options[1] =~ s/^"//;
 
          if ($options[0] =~ /^theme\[[0-9]+\]\["PATH"\]/) {
             $sub = $options[0];
             $sub =~ s/\]\["PATH"\]//;
-            $sub = substr ($sub, @sub-1, 1);
+            $sub =~ s/.*\[//; 
+            if (-e "../themes") {
+               $options[1] =~ s/^\.\.\/config/\.\.\/themes/;
+            }   
             $theme_path[$sub] = $options[1];
          } elsif ($options[0] =~ /^theme\[[0-9]+\]\["NAME"\]/) {
             $sub = $options[0];
             $sub =~ s/\]\["NAME"\]//;
-            $sub = substr ($sub, @sub-1, 1);
+            $sub =~ s/.*\[//; 
             $theme_name[$sub] = $options[1];
+         } elsif ($options[0] =~ /^plugins\[[0-9]+\]/) {
+            $sub = $options[0];
+            $sub =~ s/\]//; 
+            $sub =~ s/^plugins\[//;
+            $plugins[$sub] = $options[1];
          } elsif ($options[0] =~ /^ldap_server\[[0-9]+\]/) {
             $sub = $options[0];
-            $sub = substr ($sub, length($sub)-2, 1);
+            $sub =~ s/\]//; 
+            $sub =~ s/^ldap_server\[//;
             $continue = 0;
             while (($tmp = <FILE>) && ($continue != 1)) {
                if ($tmp =~ /\);\s*$/) {
@@ -108,17 +213,24 @@ if ($useSendmail ne "true") {
 if (!$sendmail_path) {
    $sendmail_path = "/usr/sbin/sendmail";
 }
+if (!$default_unseen_notify) {
+   $default_unseen_notify = 2;
+}
+if (!$default_unseen_type) {
+   $default_unseen_type = 1;
+}
 
 #####################################################################################
 
 while (($command ne "q") && ($command ne "Q")) {
    system "clear";
-   if ($menu == 0) {
-      print $WHT."SquirrelMail Configuration : ".$NRM;
-      if ($config == 1) { print "Read: config.php"; }
-      elsif ($config == 2) { print "Read: config_default.php"; }
-      print "\n";
+   print $WHT."SquirrelMail Configuration : ".$NRM;
+   if ($config == 1) { print "Read: config.php"; }
+   elsif ($config == 2) { print "Read: config_default.php"; }
+   print "\n";
+   print "---------------------------------------------------------\n";
 
+   if ($menu == 0) {
       print $WHT."Main Menu --\n".$NRM;
       print "1.  Organization Preferences\n";
       print "2.  Server Settings\n";
@@ -127,6 +239,7 @@ while (($command ne "q") && ($command ne "Q")) {
       print "5.  Themes\n";
       print "6.  Address Books (LDAP)\n";
       print "7.  Message of the Day (MOTD)\n";
+      print "8.  Plugins\n";
       print "\n";
       print "D.  Set pre-defined settings for specific IMAP servers\n";
       print "\n";
@@ -142,7 +255,13 @@ while (($command ne "q") && ($command ne "Q")) {
       print "1.  Domain               : $WHT$domain$NRM\n";
       print "2.  IMAP Server          : $WHT$imapServerAddress$NRM\n";
       print "3.  IMAP Port            : $WHT$imapPort$NRM\n";
-      print "4.  Use Sendmail         : $WHT$useSendmail$NRM\n";
+      print "4.  Use Sendmail/SMTP    : $WHT";
+      if ($useSendmail eq "true") {
+         print "Sendmail";
+      } else {
+         print "SMTP";
+      }
+      print "$NRM\n";
       if ($useSendmail eq "true") {
          print "5.    Sendmail Path      : $WHT$sendmail_path$NRM\n";
       } else {
@@ -165,15 +284,16 @@ while (($command ne "q") && ($command ne "Q")) {
       print "9.  Auto Expunge               : $WHT$auto_expunge$NRM\n";
       print "10. Default Sub. of INBOX      : $WHT$default_sub_of_inbox$NRM\n";
       print "11. Show 'Contain Sub.' Option : $WHT$show_contain_subfolders_option$NRM\n";
+      print "12. Default Unseen Notify      : $WHT$default_unseen_notify$NRM\n";
+      print "13. Default Unseen Type        : $WHT$default_unseen_type$NRM\n";
       print "\n";
       print "R   Return to Main Menu\n";
    } elsif ($menu == 4) {
       print $WHT."General Options\n".$NRM;
       print "1.  Default Charset      : $WHT$default_charset$NRM\n";
-      print "2.  Auto Forward         : $WHT$auto_forward$NRM\n";
-      print "3.  Data Directory       : $WHT$data_dir$NRM\n";
-      print "4.  Attachment Directory : $WHT$attachment_dir$NRM\n";
-      print "5.  Default Left Size    : $WHT$default_left_size$NRM\n";
+      print "2.  Data Directory       : $WHT$data_dir$NRM\n";
+      print "3.  Attachment Directory : $WHT$attachment_dir$NRM\n";
+      print "4.  Default Left Size    : $WHT$default_left_size$NRM\n";
       print "\n";
       print "R   Return to Main Menu\n";
    } elsif ($menu == 5) {
@@ -200,6 +320,14 @@ while (($command ne "q") && ($command ne "Q")) {
       print "1   Edit the MOTD\n";
       print "\n";
       print "R   Return to Main Menu\n";
+   } elsif ($menu == 8) {
+      print $WHT."Plugins\n".$NRM;
+      print "1   Change Plugins\n";
+      for ($count = 0; $count <= $#plugins; $count++) {
+         print "    >  $plugins[$count]\n";
+      }
+      print "\n";
+      print "R   Return to Main Menu\n";
    }
    print "S   Save data\n";
    print "Q   Quit\n";
@@ -231,7 +359,7 @@ while (($command ne "q") && ($command ne "Q")) {
    } else {
       $saved = 0;
       if ($menu == 0) {
-         if (($command > 0) && ($command < 8)) {
+         if (($command > 0) && ($command < 9)) {
             $menu = $command;
          }
       } elsif ($menu == 1) {
@@ -259,12 +387,13 @@ while (($command ne "q") && ($command ne "Q")) {
          elsif ($command == 9) { $auto_expunge                   = command29 (); }
          elsif ($command == 10){ $default_sub_of_inbox           = command210(); }
          elsif ($command == 11){ $show_contain_subfolders_option = command211(); }
+         elsif ($command == 12){ $default_unseen_notify          = command212(); }
+         elsif ($command == 13){ $default_unseen_type            = command213(); }
       } elsif ($menu == 4) {
          if    ($command == 1) { $default_charset    = command31 (); }
-         elsif ($command == 2) { $auto_forward       = command32 (); }
-         elsif ($command == 3) { $data_dir           = command33 (); }
-         elsif ($command == 4) { $attachment_dir     = command34 (); }
-         elsif ($command == 5) { $default_left_size  = command35 (); }
+         elsif ($command == 2) { $data_dir           = command33 (); }
+         elsif ($command == 3) { $attachment_dir     = command34 (); }
+         elsif ($command == 4) { $default_left_size  = command35 (); }
       } elsif ($menu == 5) {
          if ($command == 1) { 
             command41 (); 
@@ -273,7 +402,9 @@ while (($command ne "q") && ($command ne "Q")) {
          if    ($command == 1) { command61(); }
          elsif ($command == 2) { command62(); }
       } elsif ($menu == 7) {
-         if    ($command == 1) { $motd = command71 (); $motd =~ s/"/\\"/g;}
+         if    ($command == 1) { $motd             = command71(); }
+      } elsif ($menu == 8) {
+         if    ($command == 1) { $plugins = command81(); }
       }
    }   
 }
@@ -380,14 +511,16 @@ sub command14 {
    print "messages in SquirrelMail.  You can either connect to an SMTP server\n";
    print "or use sendmail directly.\n";
    if ($useSendmail eq "true") {
-      $default_value = "y";
+      $default_value = "1";
    } else {
-      $default_value = "n";
+      $default_value = "2";
    }
    print "\n";
-   print "Use Sendmail (y/n) [$WHT$default_value$NRM]: $WHT";
+   print "  1.  Sendmail\n";
+   print "  2.  SMTP\n";
+   print "Your choice [1/2] [$WHT$default_value$NRM]: $WHT";
    $use_sendmail = <STDIN>;
-   if (($use_sendmail =~ /^y\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "y"))) {
+   if (($use_sendmail =~ /^1\n/i) || (($use_sendmail =~ /^\n/) && ($default_value eq "1"))) {
       $useSendmail = "true";
    } else {
       $useSendmail = "false";
@@ -462,19 +595,96 @@ sub command18 {
 sub command71 {
    print "\nYou can now create the welcome message that is displayed\n";
    print "every time a user logs on.  You can use HTML or just plain\n";
-   print "text.\n\n(Type @ on a blank line to exit)\n";
+   print "text.  If you do not wish to have one, just make it blank.\n\n(Type @ on a blank line to exit)\n";
+   
+   $new_motd = "";
    do {
       print "] ";
       $line = <STDIN>;
       $line =~ s/[\r|\n]//g;
-      $line =~ s/  /\&nbsp;\&nbsp;/g;
       if ($line ne "@") {
+         $line =~ s/  /\&nbsp;\&nbsp;/g;
+         $line =~ s/\t/\&nbsp;\&nbsp;\&nbsp;\&nbsp;/g;
+         $line =~ s/$/ /;
+         $line =~ s/\"/\\\"/g;
+
          $new_motd = $new_motd . $line;
       }
    } while ($line ne "@");
    return $new_motd;
 }
 
+################# PLUGINS ###################
+
+sub command81 {
+   print "\nThis is where you can define plugins.  The plugin must already exist in the\n";
+   print "plugins/ directory in order to add them here.  A plugin name is the name of the\n";
+   print "directory that it resides in.  For example, if you have a plugin in the directory\n";
+   print "plugins/myplug, the name is \"myplug\".\n\n";
+   print "[plugins] command (?=help) > ";
+   $input = <STDIN>;
+   $input =~ s/[\r|\n]//g;
+   while ($input ne "d") {
+      if ($input =~ /^\s*l\s*/i) {
+         $count = 0;
+         while ($count <= $#plugins) {
+            print " $count.  $plugins[$count]\n";
+            $count++;
+         }
+         print "\n";
+      } elsif ($input =~ /^\s*\+/) {
+         print "What is the name of this plugin: ";
+         $name = <STDIN>;
+         $name =~ s/[\r|\n]//g;
+
+         if (-e "../plugins/$name") {
+            $exists = 0;
+            for ($m=0; $m <= $#plugins; $m++) {
+               if ($plugins[$m] eq $name) {
+                  $exists = 1;
+               }
+            }
+            if ($exists == 1) {
+               print "\nThat plugin already exists in the list!\n";
+            } else {
+               $plugins[$#plugins+1] = $name;
+            }   
+            print "\n";
+         } else {
+            print "\nThat plugin does not exist in the plugins/ directory!\n\n";
+         }
+      } elsif ($input =~ /^\s*-\s*[0-9]?/) {
+         if ($input =~ /[0-9]+\s*$/) {
+            $rem_num = $input;
+            $rem_num =~ s/^\s*-\s*//g;
+            $rem_num =~ s/\s*$//;
+         } else {
+            $rem_num = $#plugins;
+         }
+            
+         $count = 0;
+         @new_plugins = ();
+         while ($count <= $#plugins) {
+            if ($count != $rem_num) {
+               @new_plugins = (@new_plugins, $plugins[$count]);
+            }
+            $count++;
+         }
+         @plugins = @new_plugins;
+      } elsif ($input =~ /^\s*\?\s*/) {
+         print ".-------------------------.\n";
+         print "| +          (add plugin) |\n";
+         print "| - N     (remove plugin) |\n";
+         print "| l        (list plugins) |\n";
+         print "| d                (done) |\n";
+         print "`-------------------------'\n";
+      }
+      print "[plugins] command (?=help) > ";
+      $input = <STDIN>;
+      $input =~ s/[\r|\n]//g;
+   }
+}   
+
 ################# FOLDERS ###################
 
 # default_folder_prefix
@@ -605,8 +815,7 @@ sub command25 {
 sub command26 {
    print "By default, should messages get moved to the sent folder?  You\n";
    print "can specify the default sent folder in option 4.  If this is set\n";
-   print "to false, messages will get deleted immediately without moving\n";
-   print "to the sent folder.\n";
+   print "to false, messages will get sent an no copy will be made.\n";
    print "\n";
    print "Trash folder is currently: $sent_folder\n";
    print "\n";
@@ -748,6 +957,43 @@ sub command211 {
    return $show_contain_subfolders_option;
 }
 
+# Default Unseen Notify 
+sub command212 {
+   print "This option specifies where the users will receive notification\n";
+   print "about unseen messages by default.  This is of course an option that\n";
+   print "can be changed on a user level.\n";
+   print "  1 = No notification\n";
+   print "  2 = Only on the INBOX\n";
+   print "  3 = On all folders\n";
+   print "\n";
+   
+   print "Which one should be default (1,2,3)? [$WHT$default_unseen_notify$NRM]: $WHT";
+   $new_show = <STDIN>;
+   if ($new_show =~ /^[1|2|3]\n/i) {
+      $default_unseen_notify = $new_show;
+   }
+   $default_unseen_notify =~ s/[\r|\n]//g;
+   return $default_unseen_notify;
+}
+
+# Default Unseen Type 
+sub command213 {
+   print "Here you can define the default way that unseen messages will be displayed\n";
+   print "to the user in the folder listing on the left side.\n";
+   print "  1 = Only unseen messages   (4)\n";
+   print "  2 = Unseen and Total messages  (4/27)\n";
+   print "\n";
+   
+   print "Which one should be default (1,2)? [$WHT$default_unseen_type$NRM]: $WHT";
+   $new_show = <STDIN>;
+   if ($new_show =~ /^[1|2]\n/i) {
+      $default_unseen_type = $new_show;
+   }
+   $default_unseen_type =~ s/[\r|\n]//g;
+   return $default_unseen_type;
+}
+
+
 ############# GENERAL OPTIONS #####################
 
 # Default Charset
@@ -769,32 +1015,6 @@ sub command31 {
    return $new_default_charset;
 }
 
-# Auto Forward
-sub command32 {
-   print "There are some places that we will automatically forward the user\n";
-   print "rather than display pointless messages like 'Message sent!' or\n";
-   print "stuff like that.  Use this or not?\n";
-   print "\n";
-   print "NOTE:  This is not working currently as we are trying to find a\n";
-   print "       better way to handle this.  This option really doesn't do\n";
-   print "       much.\n";
-   print "\n";
-   
-   if ($auto_forward eq "true") {
-      $default_value = "y";
-   } else {
-      $default_value = "n";
-   }
-   print "Auto forward (y/n) [$WHT$default_value$NRM]: $WHT";
-   $new_show = <STDIN>;
-   if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
-      $auto_forward = "true";
-   } else {
-      $auto_forward = "false";
-   }
-   return $auto_forward;
-}
-
 # Data directory
 sub command33 {
    print "It is a possible security hole to have a writable directory\n";
@@ -912,8 +1132,8 @@ sub command41 {
          $name = <STDIN>;
          $name =~ s/[\r|\n]//g;
          $theme_name[$#theme_name+1] = $name;
-         print "Be sure to put ../config/ before the filename.\n";
-         print "What file is this stored in (ex: ../config/default_theme.php): ";
+         print "Be sure to put ../themes/ before the filename.\n";
+         print "What file is this stored in (ex: ../themes/default_theme.php): ";
          $name = <STDIN>;
          $name =~ s/[\r|\n]//g;
          $theme_path[$#theme_path+1] = $name;
@@ -944,8 +1164,60 @@ sub command41 {
                $theme_default--;
             }   
          }
+      } elsif ($input =~ /^\s*t\s*/i) {
+         print "\nStarting detection...\n\n";
+         
+         opendir(DIR, "../themes");
+         @files = grep { /\.php$/i } readdir(DIR);
+         $cnt = 0;
+         while ($cnt <= $#files) {
+            $filename = "../themes/" . $files[$cnt];
+            $found = 0;
+            for ($x=0; $x <= $#theme_path; $x++) {
+               if ($theme_path[$x] eq $filename) {
+                  $found = 1;
+               }
+            }
+            if ($found != 1) {
+               print "** Found theme: $filename\n";
+               print "   What is its name? ";
+               $nm = <STDIN>;
+               $nm =~ s/[\n|\r]//g;
+               $theme_name[$#theme_name+1] = $nm;
+               $theme_path[$#theme_path+1] = $filename;
+            }
+            $cnt++;
+         }
+         print "\n";
+         for ($cnt=0; $cnt <= $#theme_path; $cnt++) {
+            $filename = $theme_path[$cnt];
+            if (! (-e $filename)) {
+               print "  Removing $filename (file not found)\n";
+               $offset = 0;
+               @new_theme_name = ();
+               @new_theme_path = ();
+               for ($x=0; $x < $#theme_path; $x++) {
+                  if ($theme_path[$x] eq $filename) {
+                     $offset = 1;
+                  }
+                  if ($offset == 1) {
+                     $new_theme_name[$x] = $theme_name[$x+1];
+                     $new_theme_path[$x] = $theme_path[$x+1];
+                  } else {
+                     $new_theme_name[$x] = $theme_name[$x];
+                     $new_theme_path[$x] = $theme_path[$x];
+                  }
+               }
+               @theme_name = @new_theme_name;
+               @theme_path = @new_theme_path;
+            }
+         }
+         print "\nDetection complete!\n\n";
+         
+         closedir DIR;  
       } elsif ($input =~ /^\s*\?\s*/) {
          print ".-------------------------.\n";
+         print "| t       (detect themes) |\n";
          print "| +           (add theme) |\n";
          print "| - N      (remove theme) |\n";
          print "| m N      (mark default) |\n";
@@ -1091,12 +1363,11 @@ sub command61 {
 }   
 
 sub command62 {
-   print "Although our project goals stated that we would stay 100% HTML with\n";
-   print "no javascript, some of our developers have developed a wonderful\n";
-   print "javascript interface for searching for email addresses in your address\n";
-   print "books.  In order to stick with our project goals, and without having\n";
-   print "to refuse their work, we also developed an HTML version of address\n";
-   print "book searching.\n";
+   print "Some of our developers have come up with very good javascript interface\n";
+   print "for searching through address books, however, our original goals said\n";
+   print "that we would be 100% HTML.  In order to make it possible to use their\n";
+   print "interface, and yet stick with our goals, we have also written a plain\n";
+   print "HTML version of the search.  Here, you can choose which version to use.\n";
    print "\n";
    print "This is just the default value.  It is also a user option that each\n";
    print "user can configure individually\n";
@@ -1108,7 +1379,7 @@ sub command62 {
       $default_use_javascript_addr_book = "false";
       $default_value = "n";
    }
-   print "Use javascript version (y/n) [$WHT$default_value$NRM]: $WHT";
+   print "Use javascript version by default (y/n) [$WHT$default_value$NRM]: $WHT";
    $new_show = <STDIN>;
    if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) {
       $default_use_javascript_addr_book = "true";
@@ -1122,9 +1393,14 @@ sub command62 {
 sub save_data {
    open (FILE, ">config.php");
 
-   print FILE "<?\n\t/** SquirrelMail configuration\n";
+   print FILE "<?php\n\t/** SquirrelMail configuration\n";
    print FILE "\t ** Created using the configure script, conf.pl\n\t **/\n\n";
 
+   if ($print_config_version) {
+      print FILE "\t\$config_version = \"$print_config_version\";\n";
+      print FILE "\n";
+   }
+   
    print FILE "\t\$org_name   = \"$org_name\";\n";
    print FILE "\t\$org_logo   = \"$org_logo\";\n";
    print FILE "\t\$org_title  = \"$org_title\";\n";
@@ -1153,16 +1429,23 @@ sub save_data {
    print FILE "\t\$auto_expunge                     =  $auto_expunge;\n";
    print FILE "\t\$default_sub_of_inbox             =  $default_sub_of_inbox;\n";
    print FILE "\t\$show_contain_subfolders_option   =  $show_contain_subfolders_option;\n";
+   print FILE "\t\$default_unseen_notify            =  $default_unseen_notify;\n";
+   print FILE "\t\$default_unseen_type              =  $default_unseen_type;\n";
    print FILE "\n";
 
    print FILE "\t\$default_charset   = \"$default_charset\";\n";
-   print FILE "\t\$auto_forward      =  $auto_forward;\n";
    print FILE "\t\$data_dir          = \"$data_dir\";\n";
    print FILE "\t\$attachment_dir    = \"$attachment_dir\";\n";
    print FILE "\t\$default_left_size =  $default_left_size;\n";
 
    print FILE "\n";
 
+   for ($count=0; $count <= $#plugins; $count++) {
+      print FILE "\t\$plugins[$count] = \"$plugins[$count]\";\n";
+   }
+   
+   print FILE "\n";
+
    for ($count=0; $count <= $#theme_name; $count++) {
       print FILE "\t\$theme[$count][\"PATH\"] = \"$theme_path[$count]\";\n";
       print FILE "\t\$theme[$count][\"NAME\"] = \"$theme_name[$count]\";\n";
@@ -1193,7 +1476,6 @@ sub save_data {
       print FILE ");\n\n";
    }
 
-   print FILE "\n";
    print FILE "\t\$motd = \"$motd\";\n";
 
    print FILE "?>\n";
@@ -1202,6 +1484,12 @@ sub save_data {
 
 sub set_defaults {
    system "clear";
+   print $WHT."SquirrelMail Configuration : ".$NRM;
+   if ($config == 1) { print "Read: config.php"; }
+   elsif ($config == 2) { print "Read: config_default.php"; }
+   print "\n";
+   print "---------------------------------------------------------\n";
+
    print "While we have been building SquirrelMail, we have discovered some\n";
    print "preferences that work better with some servers that don't work so\n";
    print "well with others.  If you select your IMAP server, this option will\n";
@@ -1209,7 +1497,7 @@ sub set_defaults {
    print "\n";
    print "Please note that you will still need to go through and make sure\n";
    print "everything is correct.  This does not change everything.  There are\n";
-   print "only a few settings that thils will change.\n";
+   print "only a few settings that this will change.\n";
    print "\n";
 
    $continue = 0;
@@ -1224,8 +1512,9 @@ sub set_defaults {
       $server = <STDIN>;
       $server =~ s/[\r|\n]//g;
 
-      if      ($server eq "cyrus") { 
-                       $default_folder_prefix = "";
+      print "\n";
+      if ($server eq "cyrus") { 
+                       $default_folder_prefix = "INBOX";
                        $trash_folder = "INBOX.Trash";
                        $sent_folder = "INBOX.Sent";
                        $show_prefix_option = false;
@@ -1233,6 +1522,14 @@ sub set_defaults {
                        $show_contain_subfolders_option = false;
                        $imap_server_type = "cyrus";
 
+         print "         default_folder_prefix = INBOX\n";
+         print "                  trash_folder = INBOX.Trash\n";
+         print "                   sent_folder = INBOX.Sent\n";
+         print "            show_prefix_option = false\n";
+         print "          default_sub_of_inbox = true\n";
+         print "show_contain_subfolders_option = false\n";
+         print "              imap_server_type = cyrus\n";
+
          $continue = 1;
       } elsif ($server eq "uw") {
                        $default_folder_prefix = "mail/";
@@ -1242,6 +1539,14 @@ sub set_defaults {
                        $default_sub_of_inbox = false;
                        $show_contain_subfolders_option = true;
                        $imap_server_type = "uw";
+
+         print "         default_folder_prefix = mail/\n";
+         print "                  trash_folder = Trash\n";
+         print "                   sent_folder = Sent\n";
+         print "            show_prefix_option = true\n";
+         print "          default_sub_of_inbox = false\n";
+         print "show_contain_subfolders_option = true\n";
+         print "              imap_server_type = uw\n";
                        
          $continue = 1;
       } elsif ($server eq "exchange") {
@@ -1251,12 +1556,21 @@ sub set_defaults {
                        $sent_folder = "INBOX/Sent Items";
                        $show_prefix_option = false;
                        $show_contain_subfolders_option = false;
-                       
                        $imap_server_type = "exchange";
          
+         print "          default_folder_prefix = INBOX/\n";
+         print "           default_sub_of_inbox = true\n";
+         print "                   trash_folder = \"INBOX/Deleted Items\"\n";
+         print "                    sent_folder = \"INBOX/Sent Items\"\n";
+         print "             show_prefix_option = false\n";
+         print " show_contain_subfolders_option = false\n";
+         print "               imap_server_type = exchange\n";
+         
                        $continue = 1;
       } elsif ($server eq "courier") {
                        $imap_server_type = "courier";
+
+         print "   imap_server_type = courier\n";
                        
          $continue = 1;
                } elsif ($server eq "quit") {
@@ -1266,4 +1580,6 @@ sub set_defaults {
                        print "\n";
       }
    }   
+   print "\nPress any key to continue...";
+   $tmp = <STDIN>;
 }