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


PHP tar::toTarStream方法代码示例

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


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

示例1: procShopToolUserSkinExport

        /**
         * user skin export
         * @return Object
         */
        public function procShopToolUserSkinExport(){
            if(!$this->module_srl) return new Object('-1','msg_invalid_request');

            $oShopModel = $this->model;
            $skin_path = FileHandler::getRealPath($oShopModel->getShopPath($this->module_srl));

            $tar_list = FileHandler::readDir($skin_path,'/(\.css|\.html|\.htm|\.js)$/');

            $img_list = FileHandler::readDir($skin_path."img",'/(\.png|\.jpeg|\.jpg|\.gif|\.swf)$/');
            for($i=0,$c=count($img_list);$i<$c;$i++) $tar_list[] = 'img/' . $img_list[$i];

            $userimages_list = FileHandler::readDir($skin_path."user_images",'/(\.png|\.jpeg|\.jpg|\.gif|\.swf)$/');
            for($i=0,$c=count($userimages_list);$i<$c;$i++) $tar_list[] = 'user_images/' . $userimages_list[$i];

            require_once(_XE_PATH_.'libs/tar.class.php');
            chdir($skin_path);
            $tar = new tar();

            $replace_path = getNumberingPath($this->module_srl,3);
            foreach($tar_list as $key => $file) $tar->addFile($file,$replace_path,'__SHOP_SKIN_PATH__');

            $stream = $tar->toTarStream();
            $filename = 'ShopUserSkin_' . date('YmdHis') . '.tar';
            header("Cache-Control: ");
            header("Pragma: ");
            header("Content-Type: application/x-compressed");
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
            header('Content-Disposition: attachment; filename="'. $filename .'"');
            header("Content-Transfer-Encoding: binary\n");
            echo $stream;

            Context::close();
            exit();
         }
开发者ID:haegyung,项目名称:xe-module-shop,代码行数:38,代码来源:shop.controller.php

示例2: procLayoutAdminUserLayoutExport

 /**
  * export user layout
  * @return void
  */
 function procLayoutAdminUserLayoutExport()
 {
     $layout_srl = Context::get('layout_srl');
     if (!$layout_srl) {
         return new Object('-1', 'msg_invalid_request');
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     $oLayoutModel = getModel('layout');
     // Copy files to temp path
     $file_path = $oLayoutModel->getUserLayoutPath($layout_srl);
     $target_path = $oLayoutModel->getUserLayoutPath(0);
     FileHandler::copyDir($file_path, $target_path);
     // replace path and ini config
     $ini_config = $oLayoutModel->getUserLayoutIniConfig(0);
     $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
     unset($file_list[2]);
     foreach ($file_list as $file) {
         if (strncasecmp('images', $file, 6) === 0) {
             continue;
         }
         // replace path
         $file = $target_path . $file;
         $content = FileHandler::readFile($file);
         $pattern = '/(http:\\/\\/[^ ]+)?(\\.\\/)?' . str_replace('/', '\\/', str_replace('./', '', $file_path)) . '/';
         if (basename($file) == 'faceoff.css' || basename($file) == 'layout.css') {
             $content = preg_replace($pattern, '../', $content);
         } else {
             $content = preg_replace($pattern, './', $content);
         }
         // replace ini config
         foreach ($ini_config as $key => $value) {
             $content = str_replace('{$layout_info->faceoff_ini_config[\'' . $key . '\']}', $value, $content);
         }
         FileHandler::writeFile($file, $content);
     }
     // make info.xml
     $info_file = $target_path . 'conf/info.xml';
     FileHandler::copyFile('./modules/layout/faceoff/conf/info.xml', $info_file);
     $content = FileHandler::readFile($info_file);
     $content = str_replace('type="faceoff"', '', $content);
     FileHandler::writeFile($info_file, $content);
     $file_list[] = 'conf/info.xml';
     // make css file
     $css_file = $target_path . 'css/layout.css';
     FileHandler::copyFile('./modules/layout/faceoff/css/layout.css', $css_file);
     $content = FileHandler::readFile('./modules/layout/tpl/css/widget.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     $content = FileHandler::readFile($target_path . 'faceoff.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     $content = FileHandler::readFile($target_path . 'layout.css');
     FileHandler::writeFile($css_file, "\n" . $content, 'a');
     // css load
     $content = FileHandler::readFile($target_path . 'layout.html');
     $content = "<load target=\"css/layout.css\" />\n" . $content;
     FileHandler::writeFile($target_path . 'layout.html', $content);
     unset($file_list[3]);
     unset($file_list[1]);
     $file_list[] = 'css/layout.css';
     // Compress the files
     $tar = new tar();
     $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath(0));
     chdir($user_layout_path);
     foreach ($file_list as $key => $file) {
         $tar->addFile($file);
     }
     $stream = $tar->toTarStream();
     $filename = 'faceoff_' . date('YmdHis') . '.tar';
     header("Cache-Control: ");
     header("Pragma: ");
     header("Content-Type: application/x-compressed");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     //            header("Content-Length: " .strlen($stream)); ?? why??
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header("Content-Transfer-Encoding: binary\n");
     echo $stream;
     // Close Context and then exit
     Context::close();
     // delete temp path
     FileHandler::removeDir($target_path);
     exit;
 }
开发者ID:ddmshu,项目名称:xe-core,代码行数:85,代码来源:layout.admin.controller.php

示例3: procLayoutAdminUserLayoutExport

 /**
  * @brief faceoff export
  *
  **/
 function procLayoutAdminUserLayoutExport()
 {
     $layout_srl = Context::get('layout_srl');
     if (!$layout_srl) {
         return new Object('-1', 'msg_invalid_request');
     }
     require_once _XE_PATH_ . 'libs/tar.class.php';
     // 압축할 파일 목록을 가져온다
     $oLayoutModel =& getModel('layout');
     $file_list = $oLayoutModel->getUserLayoutFileList($layout_srl);
     // 압축을 한다.
     $tar = new tar();
     $user_layout_path = FileHandler::getRealPath($oLayoutModel->getUserLayoutPath($layout_srl));
     chdir($user_layout_path);
     $replace_path = getNumberingPath($layout_srl, 3);
     foreach ($file_list as $key => $file) {
         $tar->addFile($file, $replace_path, '__LAYOUT_PATH__');
     }
     $stream = $tar->toTarStream();
     $filename = 'faceoff_' . date('YmdHis') . '.tar';
     header("Cache-Control: ");
     header("Pragma: ");
     header("Content-Type: application/x-compressed");
     header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
     //            header("Content-Length: " .strlen($stream)); ?? why??
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     header("Content-Transfer-Encoding: binary\n");
     echo $stream;
     // Context를 강제로 닫고 종료한다.
     Context::close();
     exit;
 }
开发者ID:hottaro,项目名称:xpressengine,代码行数:36,代码来源:layout.admin.controller.php


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