mirror of
https://github.com/fsr/eseeva
synced 2025-04-28 17:38:31 +02:00
adds locking
This commit is contained in:
parent
897d70ca5c
commit
f0ac644d7e
2 changed files with 12 additions and 3 deletions
|
@ -9,8 +9,8 @@
|
|||
// and tutors.
|
||||
//============================================================================
|
||||
|
||||
define ("STUDENTLOGFILE", "logs/ESE2013_studentLog.txt");
|
||||
define ("TUTORLOGFILE", "logs/ESE2013_tutorLog.txt");
|
||||
define ("STUDENTLOGFILE", "logs/ESE_studentLog.txt");
|
||||
define ("TUTORLOGFILE", "logs/ESE_tutorLog.txt");
|
||||
|
||||
/**
|
||||
* Reads all question data out of a provided log file array that has been split by new lines.
|
||||
|
@ -178,6 +178,7 @@
|
|||
// otherwise read the file and split the string at each new line
|
||||
$fileData = fread($handle, $length);
|
||||
$lines = explode("\n", $fileData);
|
||||
fclose($handle);
|
||||
// begin parsing of the file, the beginning is the second line, because the
|
||||
// first should contains the disclaimer
|
||||
$index = 1;
|
||||
|
@ -231,7 +232,10 @@
|
|||
// each comment is escapd by a new line containing three tilde characters
|
||||
$fileData = $fileData . "\n" . $comment . "\n~~~";
|
||||
// write the generated data to the file and close it
|
||||
// use exclusive lock
|
||||
flock($handle, LOCK_EX);
|
||||
fwrite($handle, $fileData);
|
||||
flock($handle, LOCK_UN);
|
||||
fclose($handle);
|
||||
return true;
|
||||
}
|
||||
|
@ -301,4 +305,4 @@
|
|||
if (array_key_exists("comment", $formData) && trim($formData["comment"]) != "")
|
||||
array_push($commentData, $formData["comment"]);
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue