From: kink Date: Mon, 10 Mar 2003 23:56:12 +0000 (+0000) Subject: A better way to check for errors, and apply the previous fix to signature writes... X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=1d44a9374198d7e76e266f7da08a3ec85a1b8374 A better way to check for errors, and apply the previous fix to signature writes too. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@4638 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/functions/file_prefs.php b/functions/file_prefs.php index ad596e66..d80ba438 100644 --- a/functions/file_prefs.php +++ b/functions/file_prefs.php @@ -119,16 +119,14 @@ 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") ) { 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; } @@ -224,13 +222,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) ) { 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);