From 68ee788d32a1cb722f96d326c5280bfcee228d57 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 29 May 2023 16:45:46 +0700 Subject: [PATCH] Fixed broken file_write function (#736) --- common.php | 17 ++++++++++------- test_[old]_2023-05-29_12-43-14_8080.txt | 1 + test_[old]_2023-05-29_12-43-15_8080.txt | 1 + test_[old]_2023-05-29_12-43-16_8080.txt | 1 + test_[old]_2023-05-29_12-43-17_8080.txt | 1 + test_[old]_2023-05-29_12-43-18_8080.txt | 1 + test_[old]_2023-05-29_12-43-19_8080.txt | 1 + test_[old]_2023-05-29_12-43-20_8080.txt | 1 + test_[old]_2023-05-29_12-43-21_8080.txt | 1 + test_[old]_2023-05-29_12-43-22_8080.txt | 1 + test_[old]_2023-05-29_12-43-23_8080.txt | 1 + test_[old]_2023-05-29_12-43-24_8080.txt | 1 + test_[old]_2023-05-29_12-43-25_8080.txt | 1 + test_[old]_2023-05-29_12-43-26_8080.txt | 1 + test_[old]_2023-05-29_12-43-27_8080.txt | 1 + test_[old]_2023-05-29_12-43-28_8080.txt | 1 + test_[old]_2023-05-29_12-43-29_8080.txt | 1 + test_[old]_2023-05-29_12-43-30_8080.txt | 1 + test_[old]_2023-05-29_12-43-31_8080.txt | 1 + test_[old]_2023-05-29_12-43-32_8080.txt | 1 + test_[old]_2023-05-29_12-43-33_8080.txt | 1 + test_[old]_2023-05-29_12-43-34_8080.txt | 1 + test_[old]_2023-05-29_12-43-35_8080.txt | 1 + test_[old]_2023-05-29_12-43-36_8080.txt | 1 + test_[old]_2023-05-29_12-43-37_8080.txt | 1 + test_[old]_2023-05-29_12-43-38_8080.txt | 1 + test_[old]_2023-05-29_12-43-39_8080.txt | 1 + test_[old]_2023-05-29_12-43-40_8080.txt | 1 + test_[old]_2023-05-29_12-43-41_8080.txt | 1 + test_[old]_2023-05-29_12-43-42_8080.txt | 1 + test_[old]_2023-05-29_12-43-43_8080.txt | 1 + test_[old]_2023-05-29_12-43-44_8080.txt | 1 + test_[old]_2023-05-29_12-43-45_8080.txt | 1 + test_[old]_2023-05-29_12-43-46_8080.txt | 1 + test_[old]_2023-05-29_12-43-47_8080.txt | 1 + test_[old]_2023-05-29_12-43-48_8080.txt | 1 + test_[old]_2023-05-29_12-43-49_8080.txt | 1 + test_[old]_2023-05-29_12-43-50_8080.txt | 1 + test_[old]_2023-05-29_12-43-51_8080.txt | 1 + test_[old]_2023-05-29_12-43-52_8080.txt | 1 + test_[old]_2023-05-29_12-43-53_8080.txt | 1 + test_[old]_2023-05-29_12-43-54_8080.txt | 1 + 42 files changed, 51 insertions(+), 7 deletions(-) create mode 100644 test_[old]_2023-05-29_12-43-14_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-15_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-16_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-17_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-18_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-19_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-20_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-21_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-22_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-23_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-24_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-25_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-26_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-27_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-28_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-29_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-30_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-31_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-32_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-33_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-34_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-35_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-36_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-37_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-38_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-39_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-40_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-41_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-42_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-43_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-44_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-45_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-46_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-47_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-48_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-49_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-50_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-51_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-52_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-53_8080.txt create mode 100644 test_[old]_2023-05-29_12-43-54_8080.txt diff --git a/common.php b/common.php index 92796a1ef..8238b0005 100644 --- a/common.php +++ b/common.php @@ -212,19 +212,22 @@ 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) { - $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; + $file_parts = pathinfo($file); + $new_name = ($file_parts['filename'] . '_[old]_' . date('Y-m-d_H-i-s_') . getmypid() . '.' . $file_parts['extension']); + clearstatcache(); + if (!file_exists($new_name)) { rename($file, $new_name); } } - if (!file_exists($file) && $dir_created = bb_mkdir(dirname($file))) { + + clearstatcache(); + + if (!file_exists($file) && 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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-14_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-15_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-16_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-17_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-18_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-19_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-20_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-21_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-22_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-23_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-24_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-25_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-26_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-27_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-28_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-29_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-30_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-31_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-32_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-33_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-34_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-35_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-36_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-37_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-38_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-39_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-40_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-41_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-42_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-43_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-44_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-45_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-46_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-47_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-48_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-49_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-50_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-51_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-52_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-53_8080.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 000000000..52cfcc97f --- /dev/null +++ b/test_[old]_2023-05-29_12-43-54_8080.txt @@ -0,0 +1 @@ +111111111111 \ No newline at end of file