mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Minor improvements (#769)
This commit is contained in:
parent
18d21d6a49
commit
2c1cb6d703
1 changed files with 10 additions and 19 deletions
29
common.php
29
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue