X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fprefs.php;h=c37748bd98fb3e70cc00cc4d522a68b67fc1cacf;hb=478e8b55a374012970ccb53c133ab5efdc182c56;hp=7253092b22cee9715f7cbead96013c28f90e86c3;hpb=99259b46a0b1cc7c2b094f5b1c2830444faf7120;p=squirrelmail.git
diff --git a/functions/prefs.php b/functions/prefs.php
index 7253092b..c37748bd 100644
--- a/functions/prefs.php
+++ b/functions/prefs.php
@@ -1,75 +1,126 @@
-
- /**
- ** prefs.php
- **
- ** This contains functions for manipulating user preferences
- **/
-
- /** returns the value for $string **/
- function getPref($username, $string) {
- $filename = "../data/$username.pref";
- $file = fopen($filename, "r");
-
- /** read in all the preferences **/
- for ($i=0; !feof($file); $i++) {
- $pref = fgets($file, 1024);
- if (substr($pref, 0, strpos($pref, "=")) == $string) {
- fclose($file);
- return substr($pref, strpos($pref, "=")+1);
- }
- }
- fclose($file);
- return "";
- }
-
- /** sets the pref, $string, to $set_to **/
- function setPref($username, $string, $set_to) {
- $filename = "../data/$username.pref";
- $found = false;
- if (!file_exists($filename)) {
- echo "Preference file, $filename, does not exist. Log out, and log back in to create a default preference file.
";
- exit;
- }
- $file = fopen($filename, "r");
-
- /** read in all the preferences **/
- for ($i=0; !feof($file); $i++) {
- $pref[$i] = fgets($file, 1024);
- if (substr($pref[$i], 0, strpos($pref[$i], "=")) == $string) {
- $found = true;
- $pos = $i;
- }
- }
- fclose($file);
-
- $file = fopen($filename, "w");
- if ($found == true) {
- for ($i=0; $i < count($pref); $i++) {
- if ($i == $pos) {
- fwrite($file, "$string=$set_to\n", 1024);
- } else {
- fwrite($file, "$pref[$i]", 1024);
+' .
+ _("Could not create hashed directory structure!") . "
\n" .
+ _("Please contact your system administrator and report this error.") . "
\n";
+ exit;
}
- }
- } else {
- for ($i=0; $i < count($pref); $i++) {
- fwrite($file, "$pref[$i]", 1024);
- }
- fwrite($file, "$string=$set_to\n", 1024);
- }
-
- fclose($file);
- }
-
- /** This checks if there is a pref file, if there isn't, it will create it. **/
- function checkForPrefs($username) {
- $filename = "../data/$username.pref";
- if (!file_exists($filename)) {
- if (!copy("../data/default_pref", $filename)) {
- echo "Error opening $filename";
- exit;
- }
- }
- return;
- }
-?>
\ No newline at end of file
+ }
+ }
+
+ /* And return that directory. */
+ return ($real_hash_dir);
+}
+
+function computeHashDirs($username) {
+ /* Compute the hash for this user and extract the hash directories. */
+ $hash = base_convert(crc32($username), 10, 16);
+ $hash_dirs = array();
+ for ($h = 0; $h < 4; ++ $h) {
+ $hash_dirs[] = substr($hash, $h, 1);
+ }
+
+ /* Return our array of hash directories. */
+ return ($hash_dirs);
+}
+
+?>