X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=functions%2Ffile_prefs.php;h=5ed99124d85beb1d3cdb3d68d27c78a30f7d0f0b;hb=6dc5eca489e0a529d9b6ac0316b7990701a0ec86;hp=ad596e662bcfe2ce5428701d03638025d38be8de;hpb=b94bfe13d33c8d6df9a98d5eba757ddbcbf9dd4a;p=squirrelmail.git diff --git a/functions/file_prefs.php b/functions/file_prefs.php index ad596e66..5ed99124 100644 --- a/functions/file_prefs.php +++ b/functions/file_prefs.php @@ -73,8 +73,8 @@ function cachePrefValues($data_dir, $username) { $prefs_cache[$key] = $value; } } - } - fclose($file); + } + fclose($file); $prefs_are_cached = TRUE; @@ -119,21 +119,20 @@ function savePrefValues($data_dir, $username) { } foreach ($prefs_cache as $Key => $Value) { if (isset($Value)) { - $tmpwrite = @fwrite($file, $Key . '=' . $Value . "\n"); - if ($tmpwrite == -1) { + if ( @fwrite($file, $Key . '=' . $Value . "\n") === FALSE ) { logout_error( sprintf( _("Preference file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp') ); exit; } } } fclose($file); - $tmpcopy = @copy($filename . '.tmp',$filename); - if ($tmpcopy == -1) { + if (! @copy($filename . '.tmp',$filename) ) { logout_error( sprintf( _("Preference file, %s, could not be copied from temporary file, %s. Contact your system administrator to resolve this issue."), $filename, $filename . '.tmp') ); exit; } @unlink($filename . '.tmp'); chmod($filename, 0600); + sqsession_register($prefs_cache , 'prefs_cache'); } /** @@ -183,7 +182,10 @@ function checkForPrefs($data_dir, $username, $filename = '') { /* Then, check if the file exists. */ if (!@file_exists($filename) ) { /* First, check the $data_dir for the default preference file. */ - $default_pref = $data_dir . '/default_pref'; + if(substr($data_dir,-1) != '/') { + $data_dir .= '/'; + } + $default_pref = $data_dir . 'default_pref'; /* If it is not there, check the internal data directory. */ if (!@file_exists($default_pref)) { @@ -224,13 +226,15 @@ function setSig($data_dir, $username, $number, $value) { logout_error( sprintf( _("Signature file, %s, could not be opened. Contact your system administrator to resolve this issue."), $filename . '.tmp') ); exit; } - $tmpwrite = @fwrite($file, $value); - if ($tmpwrite == -1) { + if ( @fwrite($file, $value) === FALSE ) { logout_error( sprintf( _("Signature file, %s, could not be written. Contact your system administrator to resolve this issue.") , $filename . '.tmp')); exit; } fclose($file); - @copy($filename . '.tmp',$filename); + if (! @copy($filename . '.tmp',$filename) ) { + logout_error( sprintf( _("Signature file, %s, could not be copied from temporary file, %s. Contact your system administrator to resolve this issue."), $filename, $filename . '.tmp') ); + exit; + } @unlink($filename . '.tmp'); chmod($filename, 0600);