Fixed broken file_write() function

This commit is contained in:
Roman Kelesidis 2023-01-23 20:26:05 +07:00
commit 4a65e1af02

View file

@ -248,10 +248,9 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
rename($file, $new_name);
}
}
if (file_exists($file) && $dir_created = bb_mkdir(dirname($file))) {
$fp = fopen($file, 'ab+');
}
if (isset($fp)) {
if (bb_mkdir(dirname($file))) {
if ($fp = fopen($file, 'ab+')) {
if ($lock) {
flock($fp, LOCK_EX);
}
@ -262,6 +261,7 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac
$bytes_written = fwrite($fp, $str);
fclose($fp);
}
}
return $bytes_written;
}