diff --git a/common.php b/common.php index 365df3601..66c689206 100644 --- a/common.php +++ b/common.php @@ -226,16 +226,17 @@ function file_write($str, $file, $max_size = LOG_MAX_SIZE, $lock = true, $replac } clearstatcache(); if (bb_mkdir(dirname($file))) { - $fp = fopen($file, 'ab+'); - if ($lock) { - flock($fp, LOCK_EX); + if ($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 ($replace_content) { - ftruncate($fp, 0); - fseek($fp, 0, SEEK_SET); - } - $bytes_written = fwrite($fp, $str); - fclose($fp); } return $bytes_written; @@ -269,16 +270,6 @@ function clean_filename($fname) return str_replace($s, '_', str_compact($fname)); } -function bb_crc32($str) -{ - return (float)sprintf('%u', crc32($str)); -} - -function hexhex($value) -{ - return dechex(hexdec($value)); -} - /** * @param string $str * @return string