diff --git a/common.php b/common.php index 8238b0005..92796a1ef 100644 --- a/common.php +++ b/common.php @@ -212,22 +212,19 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac { $bytes_written = false; - clearstatcache(); - if ($max_size && file_exists($file) && filesize($file) >= $max_size) { - $file_parts = pathinfo($file); - $new_name = ($file_parts['filename'] . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . '.' . $file_parts['extension']); - + $old_name = $file; + $ext = ''; + if (preg_match('#^(.+)(\.[^\\\/]+)$#', $file, $matches)) { + [$old_name, $ext] = $matches; + } + $new_name = $old_name . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . $ext; clearstatcache(); - if (!file_exists($new_name)) { rename($file, $new_name); } } - - clearstatcache(); - - if (!file_exists($file) && bb_mkdir(dirname($file))) { + if (!file_exists($file) && $dir_created = bb_mkdir(dirname($file))) { $fp = fopen($file, 'ab+'); } if (isset($fp)) { diff --git a/test_[old]_2023-05-29_12-43-14_8080.txt b/test_[old]_2023-05-29_12-43-14_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-14_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-15_8080.txt b/test_[old]_2023-05-29_12-43-15_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-15_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-16_8080.txt b/test_[old]_2023-05-29_12-43-16_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-16_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-17_8080.txt b/test_[old]_2023-05-29_12-43-17_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-17_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-18_8080.txt b/test_[old]_2023-05-29_12-43-18_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-18_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-19_8080.txt b/test_[old]_2023-05-29_12-43-19_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-19_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-20_8080.txt b/test_[old]_2023-05-29_12-43-20_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-20_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-21_8080.txt b/test_[old]_2023-05-29_12-43-21_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-21_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-22_8080.txt b/test_[old]_2023-05-29_12-43-22_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-22_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-23_8080.txt b/test_[old]_2023-05-29_12-43-23_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-23_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-24_8080.txt b/test_[old]_2023-05-29_12-43-24_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-24_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-25_8080.txt b/test_[old]_2023-05-29_12-43-25_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-25_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-26_8080.txt b/test_[old]_2023-05-29_12-43-26_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-26_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-27_8080.txt b/test_[old]_2023-05-29_12-43-27_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-27_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-28_8080.txt b/test_[old]_2023-05-29_12-43-28_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-28_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-29_8080.txt b/test_[old]_2023-05-29_12-43-29_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-29_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-30_8080.txt b/test_[old]_2023-05-29_12-43-30_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-30_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-31_8080.txt b/test_[old]_2023-05-29_12-43-31_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-31_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-32_8080.txt b/test_[old]_2023-05-29_12-43-32_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-32_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-33_8080.txt b/test_[old]_2023-05-29_12-43-33_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-33_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-34_8080.txt b/test_[old]_2023-05-29_12-43-34_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-34_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-35_8080.txt b/test_[old]_2023-05-29_12-43-35_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-35_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-36_8080.txt b/test_[old]_2023-05-29_12-43-36_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-36_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-37_8080.txt b/test_[old]_2023-05-29_12-43-37_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-37_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-38_8080.txt b/test_[old]_2023-05-29_12-43-38_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-38_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-39_8080.txt b/test_[old]_2023-05-29_12-43-39_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-39_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-40_8080.txt b/test_[old]_2023-05-29_12-43-40_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-40_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-41_8080.txt b/test_[old]_2023-05-29_12-43-41_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-41_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-42_8080.txt b/test_[old]_2023-05-29_12-43-42_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-42_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-43_8080.txt b/test_[old]_2023-05-29_12-43-43_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-43_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-44_8080.txt b/test_[old]_2023-05-29_12-43-44_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-44_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-45_8080.txt b/test_[old]_2023-05-29_12-43-45_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-45_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-46_8080.txt b/test_[old]_2023-05-29_12-43-46_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-46_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-47_8080.txt b/test_[old]_2023-05-29_12-43-47_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-47_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-48_8080.txt b/test_[old]_2023-05-29_12-43-48_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-48_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-49_8080.txt b/test_[old]_2023-05-29_12-43-49_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-49_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-50_8080.txt b/test_[old]_2023-05-29_12-43-50_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-50_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-51_8080.txt b/test_[old]_2023-05-29_12-43-51_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-51_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-52_8080.txt b/test_[old]_2023-05-29_12-43-52_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-52_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-53_8080.txt b/test_[old]_2023-05-29_12-43-53_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-53_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file diff --git a/test_[old]_2023-05-29_12-43-54_8080.txt b/test_[old]_2023-05-29_12-43-54_8080.txt deleted file mode 100644 index 52cfcc97f..000000000 --- a/test_[old]_2023-05-29_12-43-54_8080.txt +++ /dev/null @@ -1 +0,0 @@ -111111111111 \ No newline at end of file