当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive::create方法代码示例

本文整理汇总了PHP中Archive::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::create方法的具体用法?PHP Archive::create怎么用?PHP Archive::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive的用法示例。


在下文中一共展示了Archive::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: create

 public function create($paths, $filename = FALSE)
 {
     $archive = new Archive('tar');
     foreach ($paths as $set) {
         $archive->add($set[0], $set[1]);
     }
     $gzfile = bzcompress($archive->create());
     if ($filename == FALSE) {
         return $gzfile;
     }
     if (substr($filename, -8) !== '.tar.bz2') {
         // Append tar extension
         $filename .= '.tar.bz2';
     }
     // Create the file in binary write mode
     $file = fopen($filename, 'wb');
     // Lock the file
     flock($file, LOCK_EX);
     // Write the tar file
     $return = fwrite($file, $gzfile);
     // Unlock the file
     flock($file, LOCK_UN);
     // Close the file
     fclose($file);
     return (bool) $return;
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:26,代码来源:Bzip.php

示例2: afterSaved

 public function afterSaved($payload)
 {
     unset($payload->attributes['created_at']);
     unset($payload->attributes['updated_at']);
     unset($payload->original['created_at']);
     unset($payload->original['updated_at']);
     if ($payload->attributes != $payload->original) {
         Archive::create(['token' => md5(time()), 'entity_id' => $payload->attributes['id'], 'entity_type' => get_class($payload), 'entity_data' => json_encode($payload->attributes)]);
         Log::info(get_class($payload) . ' #' . $payload->attributes['id'] . ' was archived');
     }
 }
开发者ID:YABhq,项目名称:Quarx,代码行数:11,代码来源:QuarxModel.php

示例3: creatingArchive

 public function creatingArchive()
 {
     $contents = array('lang/Object.class.php' => 'class Object { }', 'lang/Type.class.php' => 'class Type extends Object { }');
     $a = new Archive(new Stream());
     $a->open(ARCHIVE_CREATE);
     foreach ($contents as $filename => $bytes) {
         $a->addFileBytes($filename, NULL, NULL, $bytes);
     }
     $a->create();
     $this->assertEntries($a, $contents);
 }
开发者ID:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:ArchiveTest.class.php

示例4: list

    }
    list($type, $srcAbsHref, $mode, $width, $height) = check_keys(array("type", "href", "mode", "width", "height"));
    $thumb = new Thumb($h5ai);
    $thumbHref = $thumb->thumb($type, $srcAbsHref, $mode, $width, $height);
    if ($thumbHref === null) {
        json_fail(3, "thumbnail creation failed");
    }
    json_exit(array("absHref" => $thumbHref));
} else {
    if ($action === "archive") {
        json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
        list($execution, $format, $hrefs) = check_keys(array("execution", "format", "hrefs"));
        H5ai::req_once("/php/inc/Archive.php");
        $archive = new Archive($h5ai);
        $hrefs = explode(":", trim($hrefs));
        $target = $archive->create($execution, $format, $hrefs);
        if (!is_string($target)) {
            json_fail($target, "package creation failed");
        }
        json_exit(array("id" => basename($target), "size" => filesize($target)));
    } else {
        if ($action === "getarchive") {
            json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
            list($id, $as) = check_keys(array("id", "as"));
            json_fail(2, "file not found", !preg_match("/^h5ai-selection-/", $id));
            $target = H5ai::normalize_path(sys_get_temp_dir(), true) . $id;
            json_fail(3, "file not found", !file_exists($target));
            header("Content-Type: application/octet-stream");
            header("Content-Length: " . filesize($target));
            header("Content-Disposition: attachment; filename=\"{$as}\"");
            header("Connection: close");
开发者ID:nvdnkpr,项目名称:h5ai,代码行数:31,代码来源:api.php

示例5: apply

 public function apply()
 {
     $options = $this->app->get_options();
     list($action) = use_request_params(array("action"));
     if ($action === "get") {
         $response = array();
         if (array_key_exists("options", $_REQUEST)) {
             use_request_params("options");
             $response["options"] = $this->app->get_options();
         }
         if (array_key_exists("types", $_REQUEST)) {
             use_request_params("types");
             $response["types"] = $this->app->get_types();
         }
         if (array_key_exists("langs", $_REQUEST)) {
             use_request_params("langs");
             $response["langs"] = $this->app->get_l10n_list();
         }
         if (array_key_exists("l10n", $_REQUEST)) {
             list($iso_codes) = use_request_params("l10nCodes", "l10n");
             $iso_codes = explode(":", $iso_codes);
             $response["l10n"] = $this->app->get_l10n($iso_codes);
         }
         if (array_key_exists("checks", $_REQUEST)) {
             use_request_params("checks");
             $response["checks"] = $this->app->get_server_checks();
         }
         if (array_key_exists("server", $_REQUEST)) {
             use_request_params("server");
             $response["server"] = $this->app->get_server_details();
         }
         if (array_key_exists("custom", $_REQUEST)) {
             list($abs_href) = use_optional_request_params("customHref", "custom");
             $response["custom"] = $this->app->get_customizations($abs_href);
         }
         if (array_key_exists("entries", $_REQUEST)) {
             list($abs_href, $what) = use_optional_request_params("entriesHref", "entriesWhat", "entries");
             $what = is_numeric($what) ? intval($what, 10) : 1;
             $response["entries"] = $this->app->get_entries($abs_href, $what);
         }
         if (count($_REQUEST)) {
             $response["unused"] = $_REQUEST;
         }
         json_exit($response);
     } else {
         if ($action === "getThumbHref") {
             if (!$options["thumbnails"]["enabled"]) {
                 json_fail(1, "thumbnails disabled");
             }
             normalized_require_once("/server/php/inc/Thumb.php");
             if (!Thumb::is_supported()) {
                 json_fail(2, "thumbnails not supported");
             }
             list($type, $src_abs_href, $mode, $width, $height) = use_request_params(array("type", "href", "mode", "width", "height"));
             $thumb = new Thumb($this->app);
             $thumb_href = $thumb->thumb($type, $src_abs_href, $mode, $width, $height);
             if ($thumb_href === null) {
                 json_fail(3, "thumbnail creation failed");
             }
             json_exit(array("absHref" => $thumb_href));
         } else {
             if ($action === "createArchive") {
                 json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
                 list($execution, $format, $hrefs) = use_request_params(array("execution", "format", "hrefs"));
                 normalized_require_once("/server/php/inc/Archive.php");
                 $archive = new Archive($this->app);
                 $hrefs = explode(":", trim($hrefs));
                 $target = $archive->create($execution, $format, $hrefs);
                 if (!is_string($target)) {
                     json_fail($target, "package creation failed");
                 }
                 json_exit(array("id" => basename($target), "size" => filesize($target)));
             } else {
                 if ($action === "getArchive") {
                     json_fail(1, "downloads disabled", !$options["download"]["enabled"]);
                     list($id, $as) = use_request_params(array("id", "as"));
                     json_fail(2, "file not found", !preg_match("/^package-/", $id));
                     $target = $this->app->get_cache_abs_path() . "/" . $id;
                     json_fail(3, "file not found", !file_exists($target));
                     header("Content-Type: application/octet-stream");
                     header("Content-Length: " . filesize($target));
                     header("Content-Disposition: attachment; filename=\"{$as}\"");
                     header("Connection: close");
                     register_shutdown_function("delete_tempfile", $target);
                     readfile($target);
                 } else {
                     if ($action === "upload") {
                         list($href) = use_request_params(array("href"));
                         json_fail(1, "wrong HTTP method", strtolower($_SERVER["REQUEST_METHOD"]) !== "post");
                         json_fail(2, "something went wrong", !array_key_exists("userfile", $_FILES));
                         $userfile = $_FILES["userfile"];
                         json_fail(3, "something went wrong [" . $userfile["error"] . "]", $userfile["error"] !== 0);
                         json_fail(4, "folders not supported", file_get_contents($userfile["tmp_name"]) === "null");
                         $upload_dir = $this->app->get_abs_path($href);
                         $code = $this->app->get_http_code($href);
                         json_fail(5, "upload dir no h5ai folder or ignored", $code !== App::$MAGIC_SEQUENCE || $this->app->is_ignored($upload_dir));
                         $dest = $upload_dir . "/" . utf8_encode($userfile["name"]);
                         json_fail(6, "already exists", file_exists($dest));
                         json_fail(7, "can't move uploaded file", !move_uploaded_file($userfile["tmp_name"], $dest));
                         json_exit();
//.........这里部分代码省略.........
开发者ID:avidys,项目名称:camunda.org,代码行数:101,代码来源:Api.php


注:本文中的Archive::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。