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


PHP File_Archive::read方法代码示例

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


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

示例1: packTheme

 /**
  * Creates a .zip file of the theme in themes/ directory
  *
  * @access  public
  * @param   string  $theme      Name of the theme
  * @param   string  $srcDir     Source directory
  * @param   string  $destDir    Target directory
  * @param   bool    $copy_example_to_repository  If copy example.png too or not
  * @return  bool    Returns true if:
  *                    - Theme exists
  *                    - Theme exists and could be packed
  *                  Returns false if:
  *                    - Theme doesn't exist
  *                    - Theme doesn't exists and couldn't be packed
  */
 function packTheme($theme, $srcDir, $destDir, $copy_example_to_repository = true)
 {
     $themeSrc = $srcDir . '/' . $theme;
     if (!is_dir($themeSrc)) {
         return new Jaws_Error(_t('TMS_ERROR_THEME_DOES_NOT_EXISTS', $theme));
     }
     if (!Jaws_Utils::is_writable($destDir)) {
         return new Jaws_Error(_t('GLOBAL_ERROR_FAILED_DIRECTORY_UNWRITABLE', $destDir), $this->gadget->name);
     }
     $themeDest = $destDir . '/' . $theme . '.zip';
     //If file exists.. delete it
     if (file_exists($themeDest)) {
         @unlink($themeDest);
     }
     require_once PEAR_PATH . 'File/Archive.php';
     $reader = File_Archive::read($themeSrc, $theme);
     $innerWriter = File_Archive::toFiles();
     $writer = File_Archive::toArchive($themeDest, $innerWriter);
     $res = File_Archive::extract($reader, $writer);
     if (PEAR::isError($res)) {
         return new Jaws_Error(_t('TMS_ERROR_COULD_NOT_PACK_THEME'));
     }
     Jaws_Utils::chmod($themeDest);
     if ($copy_example_to_repository) {
         //Copy image to repository/images
         if (file_exists($srcDir . '/example.png')) {
             @copy($srcDir . '/example.png', JAWS_DATA . "themes/repository/Resources/images/{$theme}.png");
             Jaws_Utils::chmod(JAWS_DATA . 'themes/repository/Resources/images/' . $theme . '.png');
         }
     }
     return $themeDest;
 }
开发者ID:juniortux,项目名称:jaws,代码行数:47,代码来源:Themes.php

示例2: Backup

 /**
  * Returns downloadable backup file
  *
  * @access  public
  * @return void
  */
 function Backup()
 {
     $this->gadget->CheckPermission('Backup');
     $tmpDir = sys_get_temp_dir();
     $domain = preg_replace("/^(www.)|(:{$_SERVER['SERVER_PORT']})\$|[^a-z0-9\\-\\.]/", '', strtolower($_SERVER['HTTP_HOST']));
     $nameArchive = $domain . '-' . date('Y-m-d') . '.tar.gz';
     $pathArchive = $tmpDir . DIRECTORY_SEPARATOR . $nameArchive;
     //Dump database data
     $dbFileName = 'dbdump.xml';
     $dbFilePath = $tmpDir . DIRECTORY_SEPARATOR . $dbFileName;
     Jaws_DB::getInstance()->Dump($dbFilePath);
     $files = array();
     require_once PEAR_PATH . 'File/Archive.php';
     $files[] = File_Archive::read(JAWS_DATA);
     $files[] = File_Archive::read($dbFilePath, $dbFileName);
     File_Archive::extract($files, File_Archive::toArchive($pathArchive, File_Archive::toFiles()));
     Jaws_Utils::Delete($dbFilePath);
     // browser must download file from server instead of cache
     header("Expires: 0");
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // force download dialog
     header("Content-Type: application/force-download");
     // set data type, size and filename
     header("Content-Disposition: attachment; filename=\"{$nameArchive}\"");
     header("Content-Transfer-Encoding: binary");
     header('Content-Length: ' . @filesize($pathArchive));
     @readfile($pathArchive);
     Jaws_Utils::Delete($pathArchive);
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:36,代码来源:Backup.php

示例3: saveChanges

 function saveChanges()
 {
     global $CONFIG;
     $_REQUEST->setType('uncompress', 'any');
     if (isset($_FILES['uFiles']) && $this->may($USER, EDIT)) {
         $u = false;
         $ue = false;
         $extensions = $CONFIG->Files->filter;
         foreach ($_FILES['uFiles']['error'] as $i => $e) {
             $parts = explode('.', $_FILES['uFiles']['name'][$i]);
             $extension = array_pop($parts);
             if ($e == UPLOAD_ERR_NO_FILE) {
                 continue;
             }
             $newPath = $this->that->path . '/' . $_FILES['uFiles']['name'][$i];
             if ($e == UPLOAD_ERR_OK) {
                 if ($_REQUEST['uncompress'] && in_array(strtolower(strrchr($_FILES['uFiles']['name'][$i], '.')), array('.tar', '.gz', '.tgz', '.bz2', '.tbz', '.zip', '.ar', '.deb'))) {
                     $tmpfile = $_FILES['uFiles']['tmp_name'][$i] . $_FILES['uFiles']['name'][$i];
                     rename($_FILES['uFiles']['tmp_name'][$i], $tmpfile);
                     $u = true;
                     require_once "File/Archive.php";
                     error_reporting(E_ALL);
                     $curdir = getcwd();
                     chdir($this->path);
                     //FIXME: FIXME!
                     if (@File_Archive::extract(File_Archive::filter(File_Archive::predExtension($extensions), File_Archive::read($tmpfile . '/*')), File_Archive::toFiles()) == null) {
                         $ue = true;
                     } else {
                         Flash::queue(__('Extraction failed'));
                     }
                     chdir($curdir);
                 } elseif (!in_array(strtolower($extension), $extensions)) {
                     Flash::queue(__('Invalid format:') . ' ' . $_FILES['uFiles']['name'][$i], 'warning');
                     continue;
                 } else {
                     $u = (bool) @move_uploaded_file($_FILES['uFiles']['tmp_name'][$i], $newPath);
                 }
             }
             if (!$u) {
                 Flash::queue(__('Upload of file') . ' "' . $_FILES['uFiles']['name'][$i] . '" ' . __('failed') . ' (' . ($e ? $e : __('Check permissions')) . ')', 'warning');
             }
         }
         if ($u) {
             $this->loadStructure(true);
             Flash::queue(__('Your file(s) were uploaded'));
             return true;
         }
         if ($ue) {
             $this->loadStructure(true);
             Flash::queue(__('Your file(s) were uploaded and extracted'));
             return true;
         }
         return false;
     }
 }
开发者ID:jonatanolofsson,项目名称:solidba.se,代码行数:55,代码来源:Upload.php

示例4: validate

 /**
  * validate実行
  *
  * @param   mixed   $attributes チェックする値
  * @param   string  $errStr     エラー文字列
  * @param   array   $params     オプション引数
  * @return  string  エラー文字列(エラーの場合)
  * @access  public
  */
 function validate($attributes, $errStr, $params)
 {
     $this->_cabinet = $attributes["cabinet"];
     $file = $attributes["file"];
     $container =& DIContainerFactory::getContainer();
     $commonMain =& $container->getComponent("commonMain");
     $this->_fileAction =& $commonMain->registerClass(WEBAPP_DIR . '/components/file/Action.class.php', "File_Action", "fileAction");
     $this->_fileView =& $commonMain->registerClass(WEBAPP_DIR . '/components/file/View.class.php', "File_View", "fileView");
     $this->_uploadsView =& $container->getComponent("uploadsView");
     $file_path = "cabinet/" . strtolower(session_id()) . timezone_date();
     if (file_exists(FILEUPLOADS_DIR . $file_path)) {
         $result = $this->_fileAction->delDir(FILEUPLOADS_DIR . $file_path);
         if ($result === false) {
             return $errStr;
         }
     }
     mkdir(FILEUPLOADS_DIR . $file_path, octdec(_UPLOAD_FOLDER_MODE));
     $request =& $container->getComponent("Request");
     $request->setParameter("file_path", $file_path);
     $result = $this->_uploadsView->getUploadById($file["upload_id"]);
     if ($result === false) {
         return $errStr;
     }
     $upload = $result[0];
     File_Archive::extract(File_Archive::read(FILEUPLOADS_DIR . $upload["file_path"] . $upload["physical_file_name"] . "/"), $dest = FILEUPLOADS_DIR . $file_path);
     $configView =& $container->getComponent("configView");
     $config = $configView->getConfigByConfname(_SYS_CONF_MODID, "allow_extension");
     if (!isset($config["conf_value"])) {
         return $errStr;
     }
     $this->_allow_extension = $config["conf_value"];
     $cabinetView =& $container->getComponent("cabinetView");
     $used_size = $cabinetView->getUsedSize();
     if ($used_size === false) {
         return $errStr;
     }
     $total_size = $used_size;
     $result = $this->_check(FILEUPLOADS_DIR . $file_path, $total_size);
     if ($result !== true) {
         $this->_fileAction->delDir(FILEUPLOADS_DIR . $file_path);
         return $result;
     }
     $decompress_size = $this->_fileView->getSize(FILEUPLOADS_DIR . $file_path);
     if ($this->_cabinet["cabinet_max_size"] != 0 && $this->_cabinet["cabinet_max_size"] < $used_size + $decompress_size) {
         $this->_fileAction->delDir(FILEUPLOADS_DIR . $file_path);
         $suffix_compresssize = $this->_fileView->formatSize($used_size + $decompress_size);
         $suffix_maxsize = $this->_fileView->formatSize($this->_cabinet["cabinet_max_size"]);
         return sprintf(CABINET_ERROR_DECOMPRESS_MAX_SIZE, $suffix_compresssize, $suffix_maxsize);
     }
     $result = $cabinetView->checkCapacitySize($decompress_size);
     if ($result !== true) {
         $this->_fileAction->delDir(FILEUPLOADS_DIR . $file_path);
         return $result;
     }
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:64,代码来源:Validator_FileDecompress.class.php

示例5: UnpackFiles

 /**
  * Check if input (an array of $_FILES) are .tar or .zip files, if they
  * are then these get unpacked and returns an managed as $_FILES (returning
  * an array with the same structure $_FILES uses and move pics to /tmp)
  *
  * @access  public
  * @param   array   $files   $_FILES
  * @return  array   $_FILES format
  */
 function UnpackFiles($files)
 {
     if (!is_array($files)) {
         return array();
     }
     $cleanFiles = array();
     $tmpDir = sys_get_temp_dir();
     $counter = 1;
     require_once PEAR_PATH . 'File/Archive.php';
     foreach ($files as $key => $file) {
         if (empty($file['tmp_name'])) {
             continue;
         }
         $ext = strrchr($file['name'], '.');
         switch ($ext) {
             case '.gz':
                 $ext = '.tgz';
                 break;
             case '.bz2':
             case '.bzip2':
                 $ext = '.tbz';
                 break;
         }
         $ext = strtolower(ltrim($ext, '.'));
         if (File_Archive::isKnownExtension($ext)) {
             $tmpArchiveName = $tmpDir . DIRECTORY_SEPARATOR . $file['name'];
             if (!move_uploaded_file($file['tmp_name'], $tmpArchiveName)) {
                 continue;
             }
             $reader = File_Archive::read($tmpArchiveName);
             $source = File_Archive::readArchive($ext, $reader);
             if (!PEAR::isError($source)) {
                 while ($source->next()) {
                     $destFile = $tmpDir . DIRECTORY_SEPARATOR . basename($source->getFilename());
                     $sourceFile = $tmpArchiveName . '/' . $source->getFilename();
                     $extract = File_Archive::extract($sourceFile, $tmpDir);
                     if (PEAR::IsError($extract)) {
                         continue;
                     }
                     $cleanFiles['photo' . $counter] = array('name' => basename($source->getFilename()), 'type' => $source->getMime(), 'tmp_name' => $destFile, 'size' => @filesize($destFile), 'error' => 0);
                     $counter++;
                 }
             }
         } else {
             $cleanFiles['photo' . $counter] = $file;
             $counter++;
         }
     }
     return $cleanFiles;
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:59,代码来源:Upload.php

示例6: Export

 /**
  * Export language
  *
  * @access  public
  * @return  void
  */
 function Export()
 {
     $lang = jaws()->request->fetch('lang', 'get');
     require_once PEAR_PATH . 'File/Archive.php';
     $tmpDir = sys_get_temp_dir();
     $tmpFileName = "{$lang}.tar";
     $tmpArchiveName = $tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
     $writerObj = File_Archive::toFiles();
     $src = File_Archive::read(JAWS_DATA . "languages/{$lang}", $lang);
     $dst = File_Archive::toArchive($tmpArchiveName, $writerObj);
     $res = File_Archive::extract($src, $dst);
     if (!PEAR::isError($res)) {
         return Jaws_Utils::Download($tmpArchiveName, $tmpFileName);
     }
     Jaws_Header::Referrer();
 }
开发者ID:Dulciane,项目名称:jaws,代码行数:22,代码来源:Export.php

示例7: _unzipFile

 /**
  * _unzipFile
  *
  * @return	bool
  **/
 public function _unzipFile()
 {
     // local file name
     $downloadDirPath = realpath($this->Xupdate->params['temp_path']);
     $downloadFilePath = $this->Xupdate->params['temp_path'] . '/' . $this->target_key . '.zip';
     $exploredDirPath = realpath($downloadDirPath . '/' . $this->target_key);
     if (empty($downloadFilePath)) {
         $this->_set_error_log('getDownloadFilePath not found error in: ' . $this->_getDownloadFilePath());
         return false;
     }
     if (!chdir($exploredDirPath)) {
         $this->_set_error_log('chdir error in: ' . $exploredDirPath);
         return false;
         //chdir error
     }
     File_Archive::extract(File_Archive::read($downloadFilePath . '/'), File_Archive::appender($exploredDirPath));
     return true;
 }
开发者ID:nao-pon,项目名称:xupdate,代码行数:23,代码来源:FtpCommonFileArchive.class.php

示例8: _decompression

 function _decompression($name, &$fileUpload)
 {
     $container =& DIContainerFactory::getContainer();
     $actionChain =& $container->getComponent("ActionChain");
     $session =& $container->getComponent("Session");
     $file_extra =& $container->getComponent("File");
     $commonMain =& $container->getComponent("commonMain");
     $fileAction =& $commonMain->registerClass(WEBAPP_DIR . '/components/file/Action.class.php', "File_Action", "fileAction");
     $action_name = $actionChain->getCurActionName();
     $pathList = explode("_", $action_name);
     $cur_sess_id = $session->getID();
     require_once "File/Archive.php";
     //
     // テンポラリーディレクトリ作成
     //
     if (!file_exists(FILEUPLOADS_DIR . $pathList[0])) {
         mkdir(FILEUPLOADS_DIR . $pathList[0], octdec(_UPLOAD_FOLDER_MODE));
     }
     $file_path = $pathList[0] . "/" . strtolower($cur_sess_id);
     if (file_exists(FILEUPLOADS_DIR . $file_path)) {
         $result = $fileAction->delDir(FILEUPLOADS_DIR . $file_path);
         if ($result === false) {
             return false;
         }
     }
     mkdir(FILEUPLOADS_DIR . $file_path, octdec(_UPLOAD_FOLDER_MODE));
     //
     // 圧縮ファイル取得
     //
     $files = $file_extra->getParameterRef($name);
     $file_name = FILEUPLOADS_DIR . $file_path . "/" . $files['name'];
     //
     // TODO:cabinetの場合、圧縮ファイルをFileクラスに登録したものを解凍しないといけないため
     // $fileUpload->moveで移動してしまうとエラーとなる。
     //
     $fileUpload->move(0, $file_name);
     //
     // 圧縮ファイル解凍
     //
     File_Archive::extract(File_Archive::read($file_name . "/"), $dest = FILEUPLOADS_DIR . $file_path);
     //
     // 圧縮ファイル削除
     //
     $fileAction->delDir($file_name);
     //
     // 解凍したファイルをアップロードファイルとしてセット
     //
     $commonMain =& $container->getComponent("commonMain");
     $uploadsAction =& $commonMain->registerClass(WEBAPP_DIR . '/components/uploads/Action.class.php', "Uploads_Action", "uploadsAction");
     $uploadsAction->setFileByPath(FILEUPLOADS_DIR . $file_path, $name);
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:51,代码来源:Filter_FileUpload.class.php

示例9: _testReadArchive

 function _testReadArchive()
 {
     $source = File_Archive::readArchive('tar', File_Archive::read('up.tar'));
     while ($source->next()) {
         echo $source->getFilename() . "\n";
     }
 }
开发者ID:andychang88,项目名称:jianzhanseo.com,代码行数:7,代码来源:test.php

示例10: getRestoreArray

 /**
  * バックアップXMLファイル->リストア配列変換処理
  *
  * @access  public
  */
 function getRestoreArray($upload_id, $backup_page_id, $module_id, $temporary_file_path)
 {
     set_time_limit(BACKUP_TIME_LIMIT);
     // メモリ最大サイズ設定
     ini_set('memory_limit', -1);
     $errorList =& $this->_actionChain->getCurErrorList();
     //if($backup_page_id == 0 || $upload_id == 0) {
     //	// フルバックアップをリストアしようとしている
     //	$errorList->add("backup", BACKUP_FAILURE_RESTORE);
     //	return false;
     //}
     //$uploads = $this->_db->selectExecute("uploads", array("upload_id" => $upload_id, "room_id" => $backup_page_id, "module_id" => $module_id));
     $uploads = $this->_db->selectExecute("uploads", array("upload_id" => $upload_id, "module_id" => $module_id));
     if ($uploads === false || !isset($uploads[0]) || count($uploads) > 1) {
         return false;
     }
     $uploads_file_path = FILEUPLOADS_DIR . "backup/" . $uploads[0]['physical_file_name'];
     if (!file_exists($uploads_file_path)) {
         // バックアップファイルなし
         $errorList->add("backup", BACKUP_NONE_RESTORE);
         return false;
     }
     if (file_exists($temporary_file_path)) {
         // 現在、同じバックアップファイル-リストア中
         // エラーとする
         $errorList->add("backup", BACKUP_RESTORING);
         return false;
     }
     if (!mkdir($temporary_file_path, 0777)) {
         $errorList->add("backup", BACKUP_RESTORE_ERROR);
         return false;
     }
     //
     // 解凍
     //
     File_Archive::extract(File_Archive::read($uploads_file_path . "/"), File_Archive::appender($temporary_file_path));
     if (!file_exists($temporary_file_path . BACKUP_ROOM_XML_FILE_NAME)) {
         // XMLファイルなし
         $this->_fileAction->delDir($temporary_file_path);
         $errorList->add("backup", BACKUP_FAILURE_RESTORE);
         return false;
     }
     // PHP 4 > 4.3.0, PHP 5
     $xml = file_get_contents($temporary_file_path . BACKUP_ROOM_XML_FILE_NAME);
     if ($xml === false) {
         $this->_fileAction->delDir($temporary_file_path);
         $errorList->add("backup", BACKUP_RESTORE_ERROR);
         return false;
     }
     if (!file_exists($temporary_file_path . BACKUP_ROOM_XML_INI_NAME)) {
         // XML INIファイルなし
         $this->_fileAction->delDir($temporary_file_path);
         $errorList->add("backup", BACKUP_FAILURE_RESTORE);
         return false;
     }
     $xml_ini = file_get_contents($temporary_file_path . BACKUP_ROOM_XML_INI_NAME);
     if ($xml_ini === false) {
         $this->_fileAction->delDir($temporary_file_path);
         $errorList->add("backup", BACKUP_RESTORE_ERROR);
         return false;
     }
     $unserializer =& new XML_Unserializer();
     //
     // 複合化チェック
     //
     $result = $unserializer->unserialize($xml_ini);
     if ($result !== true) {
         $this->_fileAction->delDir($temporary_file_path);
         $errorList->add("backup", BACKUP_FAILURE_UNSERIALIZE);
         return false;
     }
     $data_ini = $unserializer->getUnserializedData();
     // 共有設定されているかどうか
     if ($data_ini["host_field"] == BASE_URL . INDEX_FILE_NAME) {
         // 自サイトならば、無条件でOK
         $self_flag = true;
     } else {
         $self_flag = false;
         // サイトテーブルにあり、commons_flagが立っているものを許す
         $data_ini["host_field"] = preg_replace("/" . preg_quote(INDEX_FILE_NAME, "/") . "\$/i", "", $data_ini["host_field"]);
         $where_params = array("url" => $data_ini["host_field"], "commons_flag" => _ON);
         // 有効期限がいついつの公開鍵を取得
         $other_site = $this->_db->selectExecute("sites", $where_params, null, 1);
         if ($other_site === false) {
             $this->_fileAction->delDir($temporary_file_path);
             $errorList->add("backup", BACKUP_RESTORE_ERROR);
             return false;
         }
         if (!isset($other_site[0])) {
             // 共有設定されていない
             $this->_fileAction->delDir($temporary_file_path);
             $errorList->add("backup", BACKUP_RESTORE_COMMONS_ERROR);
             return false;
         }
     }
//.........这里部分代码省略.........
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:101,代码来源:Restore.class.php

示例11: removeDuplicatesFromSource

 /**
  * Remove duplicates from a source, keeping the most recent one (or the one that has highest pos in
  * the archive if the files have same date or no date specified)
  *
  * @param File_Archive_Reader a reader that may contain duplicates
  */
 function removeDuplicatesFromSource(&$toConvert, $URL = null)
 {
     $source =& File_Archive::_convertToReader($toConvert);
     if (PEAR::isError($source)) {
         return $source;
     }
     if ($URL !== null && substr($URL, -1) != '/') {
         $URL .= '/';
     }
     if ($source === null) {
         $source = File_Archive::read($URL);
     }
     require_once dirname(__FILE__) . "/Archive/Predicate/Duplicate.php";
     $pred = new File_Archive_Predicate_Duplicate($source);
     $source->close();
     return File_Archive::removeFromSource($pred, $source, null);
 }
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:23,代码来源:Archive.php

示例12: archive_items

/**
 * Zip & TarGzip Functions
 */
function archive_items($dir)
{
    if (($GLOBALS["permissions"] & 01) != 01) {
        show_error($GLOBALS["error_msg"]["accessfunc"]);
    }
    if (!$GLOBALS["zip"] && !$GLOBALS["tgz"]) {
        show_error($GLOBALS["error_msg"]["miscnofunc"]);
    }
    $allowed_types = array('zip', 'tgz', 'tbz', 'tar');
    $actionURL = str_replace("index2.php", "index3.php", make_link("arch", $dir, NULL));
    // If we have something to archive, let's do it now
    if (isset($GLOBALS['__POST']["name"])) {
        $saveToDir = $GLOBALS['__POST']['saveToDir'];
        if (!file_exists(get_abs_dir($saveToDir))) {
            echo nx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
            echo nx_alertBox('The Save-To Directory you have specified does not exist.');
            die('The Save-To Directory you have specified does not exist.');
        }
        if (!is_writable(get_abs_dir($saveToDir))) {
            echo nx_scriptTag('', '$(\'loadingindicator\').style.display=\'none\';');
            echo nx_alertBox('Please specify a writable directory to save the archive to.');
            die('Please specify a writable directory to save the archive to.');
        }
        require_once _QUIXPLORER_PATH . '/libraries/Archive.php';
        if (!in_array(strtolower($GLOBALS['__POST']["type"]), $allowed_types)) {
            echo 'Unknown Archive Format: ' . htmlspecialchars($GLOBALS['__POST']["type"]);
            nx_exit();
        }
        while (@ob_end_clean()) {
        }
        header('Status: 200 OK');
        echo '<?xml version="1.0" ?>' . "\n";
        $files_per_step = 2500;
        $cnt = count($GLOBALS['__POST']["selitems"]);
        $abs_dir = get_abs_dir($dir);
        $name = basename(stripslashes($GLOBALS['__POST']["name"]));
        if ($name == "") {
            show_error($GLOBALS["error_msg"]["miscnoname"]);
        }
        $download = JArrayHelper::getValue($_REQUEST, 'download', "n");
        $startfrom = JArrayHelper::getValue($_REQUEST, 'startfrom', 0);
        $archive_name = get_abs_item($saveToDir, $name);
        $fileinfo = pathinfo($archive_name);
        if (empty($fileinfo['extension'])) {
            $archive_name .= "." . $GLOBALS['__POST']["type"];
            $fileinfo['extension'] = $GLOBALS['__POST']["type"];
        }
        foreach ($allowed_types as $ext) {
            if ($GLOBALS['__POST']["type"] == $ext && @$fileinfo['extension'] != $ext) {
                $archive_name .= "." . $ext;
            }
        }
        for ($i = 0; $i < $cnt; $i++) {
            $selitem = stripslashes($GLOBALS['__POST']["selitems"][$i]);
            if (is_dir($abs_dir . "/" . $selitem)) {
                $items = JFolder::files($abs_dir . "/" . $selitem, '.', true, true);
                foreach ($items as $item) {
                    if (is_dir($item) || !is_readable($item) || $item == $archive_name) {
                        continue;
                    }
                    $v_list[] = $item;
                }
            } else {
                $v_list[] = $abs_dir . "/" . $selitem;
            }
        }
        $cnt_filelist = count($v_list);
        $remove_path = $GLOBALS["home_dir"];
        if ($dir) {
            $remove_path .= $dir . $GLOBALS['separator'];
        }
        for ($i = $startfrom; $i < $cnt_filelist && $i < $startfrom + $files_per_step; $i++) {
            $filelist[] = File_Archive::read($v_list[$i], str_replace($remove_path, '', $v_list[$i]));
        }
        //echo '<strong>Starting from: '.$startfrom.'</strong><br />';
        //echo '<strong>Files to process: '.$cnt_filelist.'</strong><br />';
        //print_r( $filelist );exit;
        // Do some setup stuff
        ini_set('memory_limit', '128M');
        @set_time_limit(0);
        error_reporting(E_ERROR | E_PARSE);
        $result = File_Archive::extract($filelist, $archive_name);
        if (PEAR::isError($result)) {
            echo $name . ": Failed saving Archive File. Error: " . $result->getMessage();
            nx_exit();
        }
        if ($cnt_filelist > $startfrom + $files_per_step) {
            echo "\n <script type=\"text/javascript\">document.archform.startfrom.value = '" . ($startfrom + $files_per_step) . "';</script>\n";
            echo '<script type="text/javascript"> doArchiving( \'' . $actionURL . '\' );</script>';
            printf($GLOBALS['messages']['processed_x_files'], $startfrom + $files_per_step, $cnt_filelist);
        } else {
            if ($GLOBALS['__POST']["type"] == 'tgz' || $GLOBALS['__POST']["type"] == 'tbz') {
                chmod($archive_name, 0644);
            }
            if ($download == "y") {
                echo '<script type="text/javascript">document.location=\'' . make_link('download', dirname($archive_name), basename($archive_name)) . '\';</script>';
            } else {
//.........这里部分代码省略.........
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:101,代码来源:fun_archive.php

示例13: cmdGetDoc

/**
 * cmdGetDoc()
 *
 * @param  string $sPath
 * @return void
 */
function cmdGetDoc($sPath)
{
    if (isset($_SERVER['PWD'])) {
        chdir($_SERVER['PWD']);
    }
    File_Archive::extract(File_Archive::read(BLOCKEN_DOC_DIR), File_Archive::toArchive('BlockenDoc.zip', File_Archive::toFiles($sPath)));
}
开发者ID:syttru,项目名称:blocken-test,代码行数:13,代码来源:BlockenCommand.php

示例14: _compressFile

 /**
  * 圧縮処理
  *
  * @return boolean
  * @access private
  */
 function _compressFile($parent_id, $folder_path = "")
 {
     $sql = "SELECT F.file_id, F.parent_id, F.file_type, F.file_name, F.extension, U.file_path, U.physical_file_name " . "FROM {cabinet_file} F " . "LEFT JOIN {uploads} U ON (F.upload_id=U.upload_id) ";
     $sql .= "WHERE F.cabinet_id = ? ";
     $sql .= "AND F.parent_id = ? ";
     $params = array("cabinet_id" => $this->_request->getParameter("cabinet_id"), "parent_id" => $parent_id);
     $files = $this->_db->execute($sql, $params);
     if ($files === false) {
         $this->_db->addError();
         return false;
     }
     if (empty($files)) {
         return true;
     }
     foreach ($files as $i => $db_file) {
         if ($db_file["file_type"] == CABINET_FILETYPE_FOLDER) {
             $result = $this->_compressFile($db_file["file_id"], $folder_path . mb_convert_encoding($db_file["file_name"], $this->encode, "auto") . "/");
             if ($result === false) {
                 return $result;
             }
         } else {
             $physical_file = FILEUPLOADS_DIR . $db_file["file_path"] . $db_file["physical_file_name"];
             $target_file = $folder_path . mb_convert_encoding($db_file["file_name"], $this->encode, "auto") . "." . $db_file["extension"];
             if (file_exists($physical_file)) {
                 $this->_source[] = File_Archive::read($physical_file, $target_file);
                 //File_Archive::extract(File_Archive::read($physical_file, $target_file), $this->archive_full_path);
             }
             $cabinet = $this->_request->getParameter("cabinet");
             if ($cabinet["compress_download"] == _ON) {
                 $this->setDownload($db_file["file_id"]);
             }
         }
     }
     return true;
 }
开发者ID:RikaFujiwara,项目名称:NetCommons2,代码行数:41,代码来源:Action.class.php

示例15: ZipFileRead

	function ZipFileRead($zip_file,$dtype) {
		$datas=array();
		$line=0;

		//ライブラリ
		set_include_path(get_include_path() .PATH_SEPARATOR. DIR_ARCH_LIB);
		require_once "File/Archive.php";

		//圧縮ファイル読み込み
		$arr=array();
		$source = File_Archive::read( "$zip_file/" );
		while( true ){
			$w=CommonComponent::ZipFileReadBuffer($source);
			if ( $w == "" ){ break; }
			if ( $dtype == "csv" ){
				$w=mb_convert_encoding(rtrim($w),"UTF-8","SJIS-WIN");
			}else{
				$w=rtrim($w);
			}
			$datas[]=array("data"=>$w);
			$line++;
			if ( $line >= RESULT_LINE_MAX ){ break; }
		}
		$source->close();

		return $datas;
	}
开发者ID:recruitcojp,项目名称:WebHive,代码行数:27,代码来源:common.php


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