mirror of
https://github.com/fsr/eseeva
synced 2025-01-19 00:11:41 +01:00
fixes truncation aat write access
This commit is contained in:
parent
3637b0c7b9
commit
db9faaf3d9
2 changed files with 6 additions and 2 deletions
|
@ -109,7 +109,7 @@
|
||||||
{
|
{
|
||||||
if (!isset($fileName) || !isset($keyData))
|
if (!isset($fileName) || !isset($keyData))
|
||||||
return false;
|
return false;
|
||||||
$handle = fopen($fileName, 'w+');
|
$handle = fopen($fileName, 'c');
|
||||||
if ($handle == null)
|
if ($handle == null)
|
||||||
return false;
|
return false;
|
||||||
// debug code
|
// debug code
|
||||||
|
@ -122,7 +122,9 @@
|
||||||
|
|
||||||
//use exclusive lock for writing
|
//use exclusive lock for writing
|
||||||
flock($handle, LOCK_EX);
|
flock($handle, LOCK_EX);
|
||||||
|
ftruncate($handle, 0);
|
||||||
$res = fwrite($handle, $data);
|
$res = fwrite($handle, $data);
|
||||||
|
fflush($handle);
|
||||||
flock($handle, LOCK_UN);
|
flock($handle, LOCK_UN);
|
||||||
// debug Code
|
// debug Code
|
||||||
//if ($res == false)
|
//if ($res == false)
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
*/
|
*/
|
||||||
function WriteLogFile($fileName, &$questionData, &$tutorData, &$commentData)
|
function WriteLogFile($fileName, &$questionData, &$tutorData, &$commentData)
|
||||||
{
|
{
|
||||||
$handle = fopen($fileName, 'w');
|
$handle = fopen($fileName, 'c');
|
||||||
if (!$handle)
|
if (!$handle)
|
||||||
return false;
|
return false;
|
||||||
// write disclaimer and question data block identifier
|
// write disclaimer and question data block identifier
|
||||||
|
@ -234,7 +234,9 @@
|
||||||
// write the generated data to the file and close it
|
// write the generated data to the file and close it
|
||||||
// use exclusive lock
|
// use exclusive lock
|
||||||
flock($handle, LOCK_EX);
|
flock($handle, LOCK_EX);
|
||||||
|
ftruncate($handle, 0);
|
||||||
fwrite($handle, $fileData);
|
fwrite($handle, $fileData);
|
||||||
|
fflush($handle);
|
||||||
flock($handle, LOCK_UN);
|
flock($handle, LOCK_UN);
|
||||||
fclose($handle);
|
fclose($handle);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in a new issue