Minor improvements (#195)

* Minor improvements

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2023-06-24 22:10:14 +07:00 committed by GitHub
parent cbf0771e21
commit b63e125172
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 32 deletions

View File

@ -10,7 +10,7 @@
- Corrected translations [\#183](https://github.com/torrentpier/torrentpier-lts/pull/183) ([belomaxorka](https://github.com/belomaxorka))
- Fixed $bb_cfg['pm_days_keep'] [\#180](https://github.com/torrentpier/torrentpier-lts/pull/180) ([belomaxorka](https://github.com/belomaxorka))
- IP storage bugfix [\#177](https://github.com/torrentpier/torrentpier-lts/pull/177) ([belomaxorka](https://github.com/belomaxorka))
- Minor improvements [\#172](https://github.com/torrentpier/torrentpier-lts/pull/172), [\#175](https://github.com/torrentpier/torrentpier-lts/pull/175), [\#176](https://github.com/torrentpier/torrentpier-lts/pull/176), [\#178](https://github.com/torrentpier/torrentpier-lts/pull/178), [\#179](https://github.com/torrentpier/torrentpier-lts/pull/179), [\#181](https://github.com/torrentpier/torrentpier-lts/pull/181), [\#187](https://github.com/torrentpier/torrentpier-lts/pull/187), [\#192](https://github.com/torrentpier/torrentpier-lts/pull/192), [\#194](https://github.com/torrentpier/torrentpier-lts/pull/194) ([belomaxorka](https://github.com/belomaxorka))
- Minor improvements [\#172](https://github.com/torrentpier/torrentpier-lts/pull/172), [\#175](https://github.com/torrentpier/torrentpier-lts/pull/175), [\#176](https://github.com/torrentpier/torrentpier-lts/pull/176), [\#178](https://github.com/torrentpier/torrentpier-lts/pull/178), [\#179](https://github.com/torrentpier/torrentpier-lts/pull/179), [\#181](https://github.com/torrentpier/torrentpier-lts/pull/181), [\#187](https://github.com/torrentpier/torrentpier-lts/pull/187), [\#192](https://github.com/torrentpier/torrentpier-lts/pull/192), [\#194](https://github.com/torrentpier/torrentpier-lts/pull/194), [\#195](https://github.com/torrentpier/torrentpier-lts/pull/195) ([belomaxorka](https://github.com/belomaxorka))
- Fixed empty user search box [\#171](https://github.com/torrentpier/torrentpier-lts/pull/171) ([belomaxorka](https://github.com/belomaxorka))
- Added some placeholders for input fields [\#173](https://github.com/torrentpier/torrentpier-lts/pull/173) ([belomaxorka](https://github.com/belomaxorka))

View File

@ -199,47 +199,36 @@ function bb_log ($msg, $file_name)
function file_write ($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replace_content = false)
{
$bytes_written = false;
clearstatcache();
clearstatcache();
if ($max_size && @file_exists($file) && !is_dir($file) && (@filesize($file) >= $max_size))
if (($max_size && file_exists($file) && is_file($file)) && filesize($file) >= $max_size)
{
$old_name = $file; $ext = '';
if (preg_match('#^(.+)(\.[^\\\/]+)$#', $file, $matches))
{
$old_name = $matches[1]; $ext = $matches[2];
}
$new_name = $old_name .'_[old]_'. date('Y-m-d_H-i-s_') . getmypid() . $ext;
$file_parts = pathinfo($file);
$new_name = ($file_parts['dirname'] . '/' . $file_parts['filename'] . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . '.' . $file_parts['extension']);
clearstatcache();
if (@file_exists($file) && !is_dir($file) && (@filesize($file) >= $max_size) && !@file_exists($new_name))
if (!file_exists($new_name) && !is_file($new_name))
{
@rename($file, $new_name);
rename($file, $new_name);
}
}
clearstatcache();
if (!$fp = @fopen($file, 'ab'))
clearstatcache();
if (bb_mkdir(dirname($file)))
{
if ($dir_created = bb_mkdir(dirname($file)))
if ($fp = fopen($file, 'ab+'))
{
$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 ($fp)
{
if ($lock)
{
@flock($fp, LOCK_EX);
}
if ($replace_content)
{
@ftruncate($fp, 0);
@fseek($fp, 0, SEEK_SET);
}
$bytes_written = @fwrite($fp, $str);
@fclose($fp);
}
return $bytes_written;
}