當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PharData::decompressFiles方法代碼示例

本文整理匯總了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;
     }
 }
開發者ID:Kingtreemonkey,項目名稱:FileManager,代碼行數:59,代碼來源:Extract.php

示例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;">
開發者ID:kipps,項目名稱:sri-lanka,代碼行數:31,代碼來源:ajax_calls.php


注:本文中的PharData::decompressFiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。