forked from aaroneiche/do-want
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.php
executable file
·45 lines (33 loc) · 1000 Bytes
/
update.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
40
41
42
43
44
45
<body style="font-family:arial">
<?php
//This is an update test file.
function copyUpdateFiles($fileArray,$zipArchive){
foreach($fileArray as $file){
if(!isset($file['name'])){
copyUpdateFiles($file,$zipArchive);
}else{
$fileChecksum = md5_file($file['path'].$file['name']);
if($fileChecksum == $file['checksum']){
print $file['name']." is up-to-date.<br/>";
}else{
print $file['name']." <b>Should be updated.</b> ";
$result = $zipArchive->extractTo($file['path'], $file['name']);
if($result){
print $file['name']." copied and replaced.<br/>";
}else{
print "Copy failed<br/>";
}
}
}
}
}
$zip = new ZipArchive;
$res = $zip->open("uploads/update.zip");
if($res == true){
$manifestLocation = $zip->locateName("manifest.json");
$manifestFile = $zip->getFromIndex($manifestLocation);
$manifest = json_decode($manifestFile,true);
copyUpdateFiles($manifest,$zip);
}
?>
</body>