diff --git a/common.php b/common.php index 7a636083..8cccd6f0 100644 --- a/common.php +++ b/common.php @@ -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))) diff --git a/library/ajax/manage_admin.php b/library/ajax/manage_admin.php index 844e4722..d2a83f38 100644 --- a/library/ajax/manage_admin.php +++ b/library/ajax/manage_admin.php @@ -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);