Create script to unzip archive files unzip.php

This commit is contained in:
Patrik Leifert
2024-02-29 22:00:45 +01:00
committed by GitHub
parent ea50fd66cb
commit 33d4edbd23

62
dist/public/unzip.php vendored Normal file
View File

@@ -0,0 +1,62 @@
<?php
$source = '../storage/vendor.zip';
$dest = '../vendor';
// $source2 = '../storage/vendor_public.zip';
// $dest2 = '../public/assets/vendor';
// Start measure
$starttime = microtime(true);
// Delete existing directory
// print "Removing existing directory...<br>";
// rrmdir($dest2);
// print "Extracting archive...<br>";
// $zip = new ZipArchive;
// Zip File Name
// if ($zip->open($source2) === TRUE) {
// Unzip Path
// $zip->extractTo($dest2);
// $zip->close();
// print 'Unzipped Process Successful!<br>';
// } else {
// print 'Unzipped Process failed<br>';
// }
// Delete existing directory
print "Removing existing directory...<br>";
rrmdir($dest);
print "Extracting archive...<br>";
$zip = new ZipArchive;
// Zip File Name
if ($zip->open($source) === TRUE) {
// Unzip Path
$zip->extractTo($dest);
$zip->close();
print 'Unzipped Process Successful!<br>';
} else {
print 'Unzipped Process failed<br>';
}
$endtime = microtime(true);
print "Executing this script took ".$endtime-$starttime." seconds!";
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir")
rrmdir($dir."/".$object);
else unlink ($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
print $dir."<br>";
}
}