Skip to content

Commit

Permalink
Minor fixes (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
belomaxorka committed Apr 1, 2023
1 parent da382c3 commit 584cf67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion library/ajax/manage_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

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);
Expand Down

0 comments on commit 584cf67

Please sign in to comment.