forked from oraoto/pib
-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathinit.php
39 lines (30 loc) · 820 Bytes
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php // {"autorun":true, "persist":false, "single-expression": false, "render-as": "html"}
$stdErr = fopen('php://stderr', 'w');
set_error_handler(function(...$args) use($stdErr, &$errors){
fwrite($stdErr, print_r($args,1));
});
$pathFile = '/config/restore-path.tmp';
$docroot = file_get_contents($pathFile);
// rmdir($docroot);
if(!file_exists($docroot))
{
mkdir($docroot, 0777, true);
}
$zip = new ZipArchive;
if($zip->open('/persist/restore.zip', ZipArchive::RDONLY) === TRUE)
{
$total = $zip->count();
$percent = 0;
for($i = 0; $i < $total; $i++)
{
$zip->extractTo($docroot, $zip->getNameIndex($i));
$newPercent = ((1+$i) / $total);
if($newPercent - $percent >= 0.01)
{
print $newPercent . PHP_EOL;
$percent = $newPercent;
}
}
unlink($pathFile);
unlink('/persist/restore.zip');
}