updated install
[squirrelmail.git] / functions / prefs.php
index 1f6891bd663ef2c85d22e1027f1cbad39651491b..51265242727e4a4ea47d8116e99fc08fc8ab47d3 100644 (file)
@@ -8,6 +8,11 @@
    /** returns the value for $string **/
    function getPref($username, $string) {
       $filename = "../data/$username.pref";
+      if (!file_exists($filename)) {
+         echo "Preference file \"$filename\" not found.  Exiting abnormally";
+         exit;
+      }
+
       $file = fopen($filename, "r");
 
       /** read in all the preferences **/
@@ -15,7 +20,7 @@
          $pref = fgets($file, 1024);
          if (substr($pref, 0, strpos($pref, "=")) == $string) {
             fclose($file);
-            return substr($pref, strpos($pref, "=")+1);
+            return trim(substr($pref, strpos($pref, "=")+1));
          }
       }
       fclose($file);
@@ -63,9 +68,9 @@
 
    /** This checks if there is a pref file, if there isn't, it will create it. **/
    function checkForPrefs($username) {
-      $filename = "../data/default_pref";
+      $filename = "../data/$username.pref";
       if (!file_exists($filename)) {
-         if (!copy("../config/default.pref", $filename)) {
+         if (!copy("../data/default_pref", $filename)) {
             echo "Error opening $filename";
             exit;
          }