Update Wrappers.php

This commit is contained in:
Squidly271
2024-05-18 09:43:28 -04:00
committed by GitHub
parent f5e5ae2d28
commit 8d4c007226

View File

@@ -22,6 +22,25 @@ $_proxy_ = '__';
$_arrow_ = '»';
// Wrapper functions
function file_put_contents_atomic($filename,$data, $flags = 0, $context = null) {
while (true) {
$suffix = rand();
if ( ! is_file("$filename$suffix") )
break;
}
$renResult = false;
$copyResult = @copy($filename,"$filename$suffix");
if ( $copyResult ) {
if (file_put_contents("$filename$suffix",$data,$flags,$context) === strlen($data))
$renResult = @rename("$filename$suffix",$filename);
}
if ( (! $copyResult || ! $renResult) ) {
my_logger("File_put_contents_atomic failed to write / rename $filename");
@unlink("$filename$suffix");
return false;
}
return strlen($data);
}
function parse_plugin_cfg($plugin, $sections=false, $scanner=INI_SCANNER_NORMAL) {
global $docroot;
$ram = "$docroot/plugins/$plugin/default.cfg";