X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=functions%2Fprefs.php;h=ed4c8de066d96271bfc76cd52cd6d39e4bd1b4e5;hp=93682733a1ebe49d7883d82287c22d2cd6961f07;hb=d88776e59f65aee9589aaf9b7712214d76a5afe3;hpb=d0747e266fbef3f6507ebe98dbef71b30c8fde5f diff --git a/functions/prefs.php b/functions/prefs.php index 93682733..ed4c8de0 100644 --- a/functions/prefs.php +++ b/functions/prefs.php @@ -1,80 +1,174 @@ -"; - 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($data_dir, $username) { - $filename = "$data_dir$username.pref"; - if (!file_exists($filename)) { - if (!copy("$data_dirdefault_pref", $filename)) { - echo "Error opening $filename"; - exit; - } - } - return; - } + } + } + + /* 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 + */ +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); +} + +/** + * FIXME: Undocumented function + */ +function checkForJavascript($reset = FALSE) +{ + global $data_dir, $username, $javascript_on, $javascript_setting; + + if ( !$reset && sqGetGlobalVar('javascript_on', $javascript_on, SQ_SESSION) ) + return $javascript_on; + + if ( $reset || !isset($javascript_setting) ) + $javascript_setting = getPref($data_dir, $username, 'javascript_setting', SMPREF_JS_AUTODETECT); + + if ( !sqGetGlobalVar('new_js_autodetect_results', $js_autodetect_results) && + !sqGetGlobalVar('js_autodetect_results', $js_autodetect_results) ) + $js_autodetect_results = SMPREF_JS_OFF; + + if ( $javascript_setting == SMPREF_JS_AUTODETECT ) + $javascript_on = $js_autodetect_results; + else + $javascript_on = $javascript_setting; + + sqsession_register($javascript_on, 'javascript_on'); + return $javascript_on; +} + ?> \ No newline at end of file