Revert "Fixed broken file_write() function"

This reverts commit 4a65e1af02.
This commit is contained in:
Roman Kelesidis 2023-03-09 16:24:32 +07:00
commit 6a4ee4e238

View file

@ -253,19 +253,19 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
rename($file, $new_name);
}
}
if (bb_mkdir(dirname($file))) {
if ($fp = fopen($file, 'ab+')) {
if ($lock) {
flock($fp, LOCK_EX);
}
if ($replace_content) {
ftruncate($fp, 0);
fseek($fp, 0, SEEK_SET);
}
$bytes_written = fwrite($fp, $str);
fclose($fp);
if (file_exists($file) && $dir_created = bb_mkdir(dirname($file))) {
$fp = fopen($file, 'ab+');
}
if (isset($fp)) {
if ($lock) {
flock($fp, LOCK_EX);
}
if ($replace_content) {
ftruncate($fp, 0);
fseek($fp, 0, SEEK_SET);
}
$bytes_written = fwrite($fp, $str);
fclose($fp);
}
return $bytes_written;