Minor fixes (#103)

This commit is contained in:
Roman Kelesidis 2023-04-01 12:36:18 +07:00 committed by GitHub
parent da382c3520
commit 584cf6784b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -192,7 +192,9 @@ function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $repla
{
$bytes_written = false;
if ($max_size && @filesize($file) >= $max_size)
clearstatcache();
if ($max_size && @file_exists($file) && !is_dir($file) && (@filesize($file) >= $max_size))
{
$old_name = $file; $ext = '';
if (preg_match('#^(.+)(\.[^\\\/]+)$#', $file, $matches))
@ -201,11 +203,14 @@ function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $repla
}
$new_name = $old_name .'_[old]_'. date('Y-m-d_H-i-s_') . getmypid() . $ext;
clearstatcache();
if (@file_exists($file) && @filesize($file) >= $max_size && !@file_exists($new_name))
if (@file_exists($file) && !is_dir($file) && (@filesize($file) >= $max_size) && !@file_exists($new_name))
{
@rename($file, $new_name);
}
}
clearstatcache();
if (!$fp = @fopen($file, 'ab'))
{
if ($dir_created = bb_mkdir(dirname($file)))

View File

@ -59,7 +59,7 @@ switch ($mode)
if (!is_file($bb_cfg['sphinx_config_path'].".log"))
{
file_put_contents($bb_cfg['sphinx_config_path'].".log", "####Logger from dimka3210.####".date("H:i:s", TIMENOW)."##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
file_put_contents($bb_cfg['sphinx_config_path'].".log", "##############################".date("H:i:s", TIMENOW)."##############################\r\n\r\n\r\n\r\n", FILE_APPEND);
}
file_put_contents($bb_cfg['sphinx_config_path'].".log", "##############################".date("H:i:s", TIMENOW)."##############################\r\n", FILE_APPEND);