diff options
| author | Cassio de Campos <cassiopc@gmail.com> | 2017-10-24 09:52:02 +0000 |
|---|---|---|
| committer | Cassio de Campos <cassiopc@gmail.com> | 2017-10-24 09:52:02 +0000 |
| commit | 39af649d52ddb6da8f734841137412d2dcb5b7c8 (patch) | |
| tree | 488e109acffa5946cc4d70facfa1baef68cf0944 /src/globals.php | |
| parent | 9bca54deae072b4ff157b052352982ce0a700df6 (diff) | |
| download | boca-39af649d52ddb6da8f734841137412d2dcb5b7c8.tar.gz boca-39af649d52ddb6da8f734841137412d2dcb5b7c8.zip | |
bf and revert update
Diffstat (limited to 'src/globals.php')
| -rwxr-xr-x | src/globals.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/globals.php b/src/globals.php index eee3b72..9caf474 100755 --- a/src/globals.php +++ b/src/globals.php @@ -82,23 +82,45 @@ function fixbocadir($dir,$full=false) { } } function updatebocafile($dirboca, $dirz, $t) { - $ok = true; + $ok = 0; if(is_dir($dirz)) { $ds = DIRECTORY_SEPARATOR; if($ds=="") $ds = "/"; $d = @opendir($dirz); while (($file = @readdir($d)) !== false) { if($file != '.' && $file != '..') - if(updatebocafile($dirboca . $ds . $file, $dirz . $ds . $file, $t) === false) $ok=false; + $ok = $ok + updatebocafile($dirboca . $ds . $file, $dirz . $ds . $file, $t); } @closedir($d); @cleardir($dirz); } else { if(is_file($dirboca)) { copy($dirboca, $dirboca . '.' . $t . '.old'); - chmod($dirboca . '.' . $t . '.old', "0400"); + } else { + file_put_contents($dirboca . '.' . $t . '.old', ""); + } + @chmod($dirboca . '.' . $t . '.old', "0000"); + if(rename($dirz, $dirboca) === false) $ok=1; + } + return $ok; +} +function revertupdatebocafile($dirboca, $t) { + $ok = 0; + if(is_dir($dirboca)) { + $ds = DIRECTORY_SEPARATOR; + if($ds=="") $ds = "/"; + $d = @opendir($dirboca); + while (($file = @readdir($d)) !== false) { + if($file != '.' && $file != '..') + $ok = $ok + revertupdatebocafile($dirboca . $ds . $file, $t); + } + @closedir($d); + } else { + if(is_file($dirboca) && substr($dirboca, strlen($dirboca)-strlen('.' . $t . '.old')) == '.' . $t . '.old') { + @chmod($dirboca, "0600"); + if(@copy($dirboca, substr($dirboca, 0, strlen($dirboca)-strlen('.' . $t . '.old'))) === true) $ok=1; + @chmod($dirboca, "0000"); } - if(rename($dirz, $dirboca) === false) $ok=false; } return $ok; } |