mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -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();
|
clearstatcache();
|
||||||
if (bb_mkdir(dirname($file))) {
|
if (bb_mkdir(dirname($file))) {
|
||||||
$fp = fopen($file, 'ab+');
|
if ($fp = fopen($file, 'ab+')) {
|
||||||
if ($lock) {
|
if ($lock) {
|
||||||
flock($fp, LOCK_EX);
|
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;
|
return $bytes_written;
|
||||||
|
@ -269,16 +270,6 @@ function clean_filename($fname)
|
||||||
return str_replace($s, '_', str_compact($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
|
* @param string $str
|
||||||
* @return string
|
* @return string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue