Create compress.zip.php

This commit is contained in:
Namhyeon Go 2019-10-13 01:20:49 +09:00 committed by GitHub
parent fb5a711b2e
commit 773c98b9a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

31
helper/compress.zip.php Normal file
View File

@ -0,0 +1,31 @@
<?php
// @date 2019-10-13
// @author Go Namhyeon <gnh1201@gmail.com>
if(!check_function_exists("unzip")) {
function unzip($src, $dst, $options=array()) {
$flag = false;
$method = get_value_in_array("method", $options, "ZipArchive");
switch($method) {
case "ZipArchive":
$handle = new ZipArchive;
$res = $handle->open($src);
if ($res === TRUE) {
$zip->extractTo($dst);
$zip->close();
$flag = true;
}
break;
case "unzip":
if(loadHelper("exectool")) {
exec_command(sprintf("unzip -d '%s' '%s'", make_safe_argument($src), make_safe_argument($dst)));
$flag = true;
}
break;
}
return $flag;
}
}