本文整理汇总了PHP中PharData::decompressFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::decompressFiles方法的具体用法?PHP PharData::decompressFiles怎么用?PHP PharData::decompressFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PharData
的用法示例。
在下文中一共展示了PharData::decompressFiles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
public function action($parent)
{
$c = $parent->config;
$util = new Utility();
if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
$this->r = array('wrong path', 400);
return;
}
$path = $c['current_path'] . $_POST['path'];
$info = pathinfo($path);
$base_folder = $c['current_path'] . $util->fix_dirname($_POST['path']) . "/";
switch ($info['extension']) {
case "zip":
$zip = new \ZipArchive();
if ($zip->open($path) === true) {
//make all the folders
for ($i = 0; $i < $zip->numFiles; $i++) {
$OnlyFileName = $zip->getNameIndex($i);
$FullFileName = $zip->statIndex($i);
if (substr($FullFileName['name'], -1, 1) == "/") {
$util->create_folder($base_folder . $FullFileName['name']);
}
}
//unzip into the folders
for ($i = 0; $i < $zip->numFiles; $i++) {
$OnlyFileName = $zip->getNameIndex($i);
$FullFileName = $zip->statIndex($i);
if (!(substr($FullFileName['name'], -1, 1) == "/")) {
$fileinfo = pathinfo($OnlyFileName);
if (in_array(strtolower($fileinfo['extension']), $ext)) {
copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']);
}
}
}
$zip->close();
} else {
$this->r = array('Could not extract. File might be corrupt.', 500);
return;
}
break;
case "gz":
$p = new \PharData($path);
$p->decompress();
// creates files.tar
break;
case "tar":
// unarchive from the tar
$phar = new \PharData($path);
$phar->decompressFiles();
$files = array();
$util->check_files_extensions_on_phar($phar, $files, '', $ext);
$phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
break;
default:
$this->r = array('This extension is not supported. Valid: zip, gz, tar.', 400);
return;
break;
}
}
示例2: response
}
$zip->close();
} else {
response(trans('Zip_No_Extract'), 500)->send();
exit;
}
break;
case "gz":
$p = new PharData($path);
$p->decompress();
// creates files.tar
break;
case "tar":
// unarchive from the tar
$phar = new PharData($path);
$phar->decompressFiles();
$files = array();
check_files_extensions_on_phar($phar, $files, '', $ext);
$phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
break;
default:
response(trans('Zip_Invalid'), 400)->send();
exit;
}
break;
case 'media_preview':
$preview_file = $current_path . $_GET["file"];
$info = pathinfo($preview_file);
ob_start();
?>
<div id="jp_container_1" class="jp-video " style="margin:0 auto;">