mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Fixed broken file_write() function
This commit is contained in:
parent
78ba737cd3
commit
4a65e1af02
1 changed files with 12 additions and 12 deletions
24
common.php
24
common.php
|
@ -248,19 +248,19 @@ 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 ($lock) {
|
||||
flock($fp, LOCK_EX);
|
||||
|
||||
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 ($replace_content) {
|
||||
ftruncate($fp, 0);
|
||||
fseek($fp, 0, SEEK_SET);
|
||||
}
|
||||
$bytes_written = fwrite($fp, $str);
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
return $bytes_written;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue