Various fixes.
authorthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 23 Dec 2001 21:01:40 +0000 (21:01 +0000)
committerthomppj <thomppj@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 23 Dec 2001 21:01:40 +0000 (21:01 +0000)
----------------------------------------------------------------------

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@1893 7612ce4b-ef26-0410-bec9-ea0150e637f0

config/conf.pl
data/index.php
functions/prefs.php
plugins/sent_subfolders/setup.php

index b5a63cbf634b3f6d18113d3e93423cd062ba1055..7ef3064733c4ac08bbebfbdadd0e651f56883f90 100755 (executable)
@@ -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>;
index 9d9ed2ca6618c108a7fac708dc9415edd07d972a..b86832a0e18d6aeb8a1ce51ba011c2c5a26e4cef 100644 (file)
@@ -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? */
+
 ?>
index e71d4e0531d3ca9872372d3f207296f66925fe3d..d14d46a13d15775c0346d4e38defd14640060131 100644 (file)
@@ -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;
+            }
         }
     }
 
index 4e98bd0a2e2c2a9421a54826d4646ce298eb8136..9f20b11e310e9f7a249e2e4fefd330d8b9de26c6 100644 (file)
@@ -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');