Browse Source

Various fixes.
----------------------------------------------------------------------

thomppj 23 years ago
parent
commit
09e7797da5
4 changed files with 104 additions and 80 deletions
  1. 51 59
      config/conf.pl
  2. 14 8
      data/index.php
  3. 38 12
      functions/prefs.php
  4. 1 1
      plugins/sent_subfolders/setup.php

+ 51 - 59
config/conf.pl

@@ -1945,77 +1945,69 @@ sub set_defaults {
 
       print "\n";
       if ($server eq "cyrus") { 
-			$default_folder_prefix = "";
-			$trash_folder = "INBOX.Trash";
-			$sent_folder = "INBOX.Sent";
-			$draft_folder = "INBOX.Drafts";
-			$show_prefix_option = false;
-			$default_sub_of_inbox = true;
-			$show_contain_subfolders_option = false;
-			$imap_server_type = "cyrus";
-
-         print "         default_folder_prefix = none\n";
-         print "                  trash_folder = INBOX.Trash\n";
-         print "                   sent_folder = INBOX.Sent\n";
-         print "                  draft_folder = INBOX.Drafts\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";
+         $default_folder_prefix = "";
+         $trash_folder = "INBOX.Trash";
+         $sent_folder = "INBOX.Sent";
+         $draft_folder = "INBOX.Drafts";
+         $show_prefix_option = false;
+         $default_sub_of_inbox = true;
+         $show_contain_subfolders_option = false;
+         $imap_server_type = "cyrus";
+         $disp_default_folder_prefix = "<none>";
 
          $continue = 1;
       } elsif ($server eq "uw") {
-			$default_folder_prefix = "mail/";
-			$trash_folder = "Trash";
-			$sent_folder = "Sent";
-			$draft_folder = "Drafts";
-			$show_prefix_option = true;
-			$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 "                  draft_folder = Drafts\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";
-			
+         $default_folder_prefix = "mail/";
+         $trash_folder = "Trash";
+         $sent_folder = "Sent";
+         $draft_folder = "Drafts";
+         $show_prefix_option = true;
+         $default_sub_of_inbox = false;
+         $show_contain_subfolders_option = true;
+         $imap_server_type = "uw";
+         $disp_default_folder_prefix = $default_folder_prefix;
+
          $continue = 1;
       } elsif ($server eq "exchange") {
-			$default_folder_prefix = "";
-			$default_sub_of_inbox = true;
-			$trash_folder = "INBOX/Deleted Items";
-			$sent_folder = "INBOX/Sent Items";
-			$drafts_folder = "INBOX/Drafts";
-			$show_prefix_option = false;
-			$show_contain_subfolders_option = false;
-			$imap_server_type = "exchange";
-         
-         print "          default_folder_prefix = <none>\n";
-         print "           default_sub_of_inbox = true\n";
-         print "                   trash_folder = \"INBOX/Deleted Items\"\n";
-         print "                    sent_folder = \"INBOX/Sent Items\"\n";
-         print "                   draft_folder = \"INBOX/Drafts\"\n";
-         print "             show_prefix_option = false\n";
-         print " show_contain_subfolders_option = false\n";
-         print "               imap_server_type = exchange\n";
+         $default_folder_prefix = "";
+         $default_sub_of_inbox = true;
+         $trash_folder = "INBOX/Deleted Items";
+         $sent_folder = "INBOX/Sent Items";
+         $drafts_folder = "INBOX/Drafts";
+         $show_prefix_option = false;
+         $show_contain_subfolders_option = false;
+         $imap_server_type = "exchange";
+         $disp_default_folder_prefix = "<none>";
          
-			$continue = 1;
+         $continue = 1;
       } elsif ($server eq "courier") {
-			$imap_server_type = "courier";
+         $default_folder_prefix = "mail/";
+         $trash_folder = "Trash";
+         $sent_folder = "Sent";
+         $draft_folder = "Drafts";
+         $show_prefix_option = true;
+         $default_sub_of_inbox = false;
+         $show_contain_subfolders_option = true;
+         $imap_server_type = "courier";
+         $disp_default_folder_prefix = $default_folder_prefix;
 
-         print "   imap_server_type = courier\n";
-			
          $continue = 1;
-		} elsif ($server eq "quit") {
-			$continue = 1;
+      } elsif ($server eq "quit") {
+         $continue = 1;
       } else {
+         $disp_default_folder_prefix = $default_folder_prefix;
          print "Unrecognized server: $server\n";
-			print "\n";
+         print "\n";
       }
+
+      print "         default_folder_prefix = $disp_default_folder_prefix\n";
+      print "                  trash_folder = $trash_folder\n";
+      print "                   sent_folder = $sent_folder\n";
+      print "                  draft_folder = $draft_folder\n";
+      print "            show_prefix_option = $show_prefix_option\n";
+      print "          default_sub_of_inbox = $default_sub_of_inbox\n";
+      print "show_contain_subfolders_option = $show_contain_subfolders_option\n";
+      print "              imap_server_type = $imap_server_type\n";
    }   
    print "\nPress any key to continue...";
    $tmp = <STDIN>;

+ 14 - 8
data/index.php

@@ -1,14 +1,20 @@
 <?php
+
 /**
- ** index.php
- **
- ** This file simply takes any attempt to view source files
- ** and sends those people to the login screen. At this
- ** point no attempt is made to see if the person is logged
- ** or not.
- **/
+ * index.php
+ *
+ * Copyright (c) 1999-2002 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This file simply takes any attempt to view source files and sends those
+ * people to the login screen. At this point no attempt is made to see if
+ * the person is logged or not.
+ *
+ * $Id$
+ */
 
 header("Location:../index.php");
 
-/** pretty impressive huh? **/
+/* pretty impressive huh? */
+
 ?>

+ 38 - 12
functions/prefs.php

@@ -30,13 +30,13 @@ function cachePrefValues($data_dir, $username) {
     /* Calculate the filename for the user's preference file */
     $filename = getHashedFile($username, $data_dir, "$username.pref");
 
-    /* A call to checkForPrefs here should take eliminate the need for
-    /* this to be called throughout the rest of the SquirrelMail code. 
+    /* A call to checkForPrefs here should take eliminate the need for */
+    /* this to be called throughout the rest of the SquirrelMail code. */
     checkForPrefs($data_dir, $username, $filename);
 
     /* Make sure that the preference file now DOES exist. */
     if (!file_exists($filename)) {
-        printf (_("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename);
+        echo sprintf (_("Preference file, %s, does not exist. Log out, and log back in to create a default preference file."), $filename) . "<br>\n";
         exit;
     }
 
@@ -146,13 +146,29 @@ function setPref($data_dir, $username, $string, $value) {
 function checkForPrefs($data_dir, $username, $filename = '') {
     /* First, make sure we have the filename. */
     if ($filename == '') {
-        $filename = getHashedFile($username, $data_dir, "$username.pref");
+        $filename = getHashedFile($username, $data_dir, '$username.pref');
     }
-    
+
     /* Then, check if the file exists. */
-    if (!file_exists($filename) ) {
-        if (!copy($data_dir . 'default_pref', $filename)) {
-            echo _("Error opening ") . $filename;
+    if (!@file_exists($filename) ) {
+        /* First, check the $data_dir for the default preference file. */
+        $default_pref = $data_dir . 'default_pref';
+
+        /* If it is not there, check the internal data directory. */
+        if (!@file_exists($default_pref)) {
+            $default_pref = '../data/default_pref';
+        }
+
+        /* Otherwise, report an error. */
+        if (!file_exists($default_pref)) {
+            echo _("Error opening ") . $default_pref . "<br>\n";
+            echo _("Default preference file not found!") . "<br>\n";
+            echo _("Please contact your system administrator and report this error.") . "<br>\n";
+            exit;
+        } else if (!@copy($default_pref, $filename)) {
+            echo _("Error opening ") . $default_pref . '<br>';
+            echo _("Could not create initial preference file!") . "<br>\n";
+            echo _("Please contact your system administrator and report this error.") . "<br>\n";
             exit;
         }
     }
@@ -203,9 +219,9 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) {
     $result = "$real_hash_dir/$datafile";
 
     /* Check for this file in the real hash directory. */
-    if ($hash_search && !file_exists($result)) {
+    if ($hash_search && !@file_exists($result)) {
         /* First check the base directory, the most common location. */
-        if (file_exists("$dir/$datafile")) {
+        if (@file_exists("$dir/$datafile")) {
             rename("$dir/$datafile", $result);
 
         /* Then check the full range of possible hash directories. */
@@ -228,6 +244,11 @@ function getHashedFile($username, $dir, $datafile, $hash_search = true) {
 function getHashedDir($username, $dir, $hash_dirs = '') {
     global $dir_hash_level;
 
+    /* Remove trailing slash from $dir if found */
+    if (substr($dir, -1) == '/') {
+        $dir = substr($dir, 0, strlen($dir) - 1);
+    }
+    
     /* If necessary, populate the hash dir variable. */
     if ($hash_dirs == '') {
         $hash_dirs = computeHashDirs($username);
@@ -237,8 +258,13 @@ function getHashedDir($username, $dir, $hash_dirs = '') {
     $real_hash_dir = $dir;
     for ($h = 0; $h < $dir_hash_level; ++$h) {
         $real_hash_dir .= '/' . $hash_dirs[$h];
-        if (!is_dir($real_hash_dir)) {
-            mkdir($real_hash_dir, 0770);
+        if (!@is_dir($real_hash_dir)) {
+            if (!@mkdir($real_hash_dir, 0770)) {
+                echo sprintf(_("Error creating directory %s."), $real_hash_dir) . '<br>';
+                echo _("Could not create hashed directory structure!") . "<br>\n";
+                echo _("Please contact your system administrator and report this error.") . "<br>\n";
+                exit;
+            }
         }
     }
 

+ 1 - 1
plugins/sent_subfolders/setup.php

@@ -148,7 +148,7 @@ function sent_subfolders_update_sentfolder() {
     global $sent_subfolders_base, $sent_subfolders_setting;
     global $username, $data_dir, $key, $imapServerAddress, $imapPort;
     global $use_sent_subfolders, $move_to_sent;
-
+    
     if ($use_sent_subfolders && $move_to_sent) {
         $year = date('Y');
         $month = date('m');