X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fprefs.php;h=80de4f044de5a4a94115dcc0b7f75f65b10df4a5;hp=79cee53ebd825187f431ab9379e181b61329f396;hb=d9b8769ca92973a03c12a6bfffd44d5b6885d2be;hpb=96ba920bb2821a38dfa3d7554f7b3406d3464544 diff --git a/functions/prefs.php b/functions/prefs.php index 79cee53e..80de4f04 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -1,81 +1,136 @@ -"; - 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); + \ 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. */ + /* Note that the crc32() function result will be different on 32 and */ + /* 64 bit systems, thus the hack below. */ + $crc = crc32($username); + if ($crc & 0x80000000) { + $crc ^= 0xffffffff; + $crc += 1; + } + $hash = base_convert($crc, 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); +}