X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Fprefs.php;h=3f8f9974792ec217208a9e75896fd68adcb651bb;hb=3e6ee6cac3f0661ac3d2ffc516bb5d3be5f8f14f;hp=51265242727e4a4ea47d8116e99fc08fc8ab47d3;hpb=3021b626f1e78d9e02ddc0fd6cf6606b0dca1c77;p=squirrelmail.git diff --git a/functions/prefs.php b/functions/prefs.php index 51265242..3f8f9974 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -1,80 +1,128 @@ -"; - 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); +} + +/** + * Helper function for getHashDir which does the actual hash calculation. + * + * @param string username the username to calculate the hash dir for + * @return array a list of hash dirs for this username + * @since 1.2.0 + */ +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); +}