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


PHP PclZip::extract方法代码示例

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


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

示例1: unzip

 /**
  * Unzip a file into the specified directory. Throws a RuntimeException
  * if the extraction failed.
  */
 public static function unzip($file, $to = 'cache/zip')
 {
     @ini_set('memory_limit', '256M');
     if (!is_dir($to)) {
         mkdir($to);
         chmod($to, 0777);
     }
     if (class_exists('ZipArchive')) {
         // use ZipArchive
         $zip = new ZipArchive();
         $res = $zip->open($file);
         if ($res === true) {
             $zip->extractTo($to);
             $zip->close();
         } else {
             throw new RuntimeException('Could not open zip file [ZipArchive].');
         }
     } else {
         // use PclZip
         $zip = new PclZip($file);
         if ($zip->extract(PCLZIP_OPT_PATH, $to) === 0) {
             throw new RuntimeException('Could not extract zip file [PclZip].');
         }
     }
     return true;
 }
开发者ID:nathanieltite,项目名称:elefant,代码行数:30,代码来源:Zipper.php

示例2: die

 function unzip_file($zip_archive, $archive_file, $to_dir, $forceOverwrite = false)
 {
     if (!is_dir($to_dir)) {
         if (!defined('SUGAR_PHPUNIT_RUNNER')) {
             die("Specified directory '{$to_dir}' for zip file '{$zip_archive}' extraction does not exist.");
         }
         return false;
     }
     $archive = new PclZip($zip_archive);
     if ($forceOverwrite) {
         if ($archive->extract(PCLZIP_OPT_BY_NAME, $archive_file, PCLZIP_OPT_PATH, $to_dir, PCLZIP_OPT_REPLACE_NEWER) == 0) {
             if (!defined('SUGAR_PHPUNIT_RUNNER')) {
                 die("Error: " . $archive->errorInfo(true));
             }
             return false;
         }
     } else {
         if ($archive->extract(PCLZIP_OPT_BY_NAME, $archive_file, PCLZIP_OPT_PATH, $to_dir) == 0) {
             if (!defined('SUGAR_PHPUNIT_RUNNER')) {
                 die("Error: " . $archive->errorInfo(true));
             }
             return false;
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:25,代码来源:zip_utils.php

示例3: unzip

 function unzip($zipfile, $destination_dir = false, $delete_old_dir = false)
 {
     //We check if the previous folder needs to be removed. If so, we do it with deltree() function that recursively deletes all files and then the empty folders from the target folder. if no destination_dir, then ignore this section.
     if ($destination_dir && $delete_old_dir) {
         if (file_exists($destination_dir)) {
             if (!is_writable($destination_dir)) {
                 $this->create_error("Error in deleting the old directory. Missing write permissions in '" . $destination_dir . "'");
             } else {
                 $this->deltree($destination_dir);
             }
         }
     }
     //if destination url, we need to check if it's there and writable, if now, we are going to make it. This script is meant to make the final directory, it will not create the necessary tree up the the folder.
     if (!$this->error() && $destination_dir) {
         if (file_exists($destination_dir)) {
             if (!is_writable($destination_dir)) {
                 $this->create_error("Missing write permissions in '" . $destination_dir . "'");
             }
         } else {
             if (!mkdir($destination_dir, 0775)) {
                 $this->create_error("Unable to create directory '" . $destination_dir . "'. Check writing permissions.");
             }
         }
     }
     //check if the archive file exists and is readable, then depending on destination_dir either just unpack it or unpack it into the destination_dir folder.
     if (!$this->error) {
         if (file_exists($zipfile)) {
             if (is_readable($zipfile)) {
                 $archive = new PclZip($zipfile);
                 if ($destination_dir) {
                     if ($archive->extract(PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_PATH, $destination_dir, PCLZIP_OPT_SET_CHMOD, 0777) == 0) {
                         $this->create_error("Error : " . $archive->errorInfo(true));
                     } else {
                         return true;
                     }
                 } else {
                     if ($archive->extract(PCLZIP_OPT_SET_CHMOD, 0777) == 0) {
                         $this->create_error("Error : " . $archive->errorInfo(true));
                     } else {
                         return true;
                     }
                 }
             } else {
                 $this->create_error("Unable to read ZIP file '" . $zipfile . "'. Check reading permissions.");
             }
         } else {
             $this->create_error("Missing ZIP file '.{$zipfile}.'");
         }
     }
     return $error;
 }
开发者ID:sauruscms,项目名称:Saurus-CMS-Community-Edition,代码行数:51,代码来源:archive.class.php

示例4: extract_files

function extract_files($archive, $dir, $type)
{
    if ($type != "zip") {
        switch ($type) {
            case "targz":
            case "tgz":
                $cmd = which("tar") . " xfz " . escapeshellarg($archive) . " -C " . escapeshellarg($dir);
                break;
            case "tarbz2":
                $cmd = which("tar") . " xfj " . escapeshellarg($archive) . " -C " . escapeshellarg($dir);
                break;
            case "tar":
                $cmd = which("tar") . " xf " . escapeshellarg($archive) . " -C " . escapeshellarg($dir);
                break;
            case "gz":
                $cmd = which("gzip") . " -dq " . escapeshellarg($archive);
                break;
            case "bz2":
                $cmd = which("bzip2") . " -dq " . escapeshellarg($archive);
                break;
            default:
                exit;
        }
        exec($cmd . " 2>&1", $res);
        return $res;
    }
    if ($type == "zip") {
        require_once "../../lib/pclzip/pclzip.lib.php";
        $ar = new PclZip($archive);
        return $ar->extract(PCLZIP_OPT_PATH, $dir);
    }
}
开发者ID:anboto,项目名称:xtreamer-web-sdk,代码行数:32,代码来源:func.php

示例5: restore

 public function restore($filename)
 {
     if (!file_exists($filename)) {
         $this->pushError(sprintf(langBup::_('Filesystem backup %s does not exists'), basename($filename)));
         return false;
     }
     if (!class_exists('PclZip', false)) {
         /** @var backupBup $backup */
         $backup = $this->getModule();
         $backup->loadLibrary('pcl');
     }
     $pcl = new PclZip($filename);
     if ($files = $pcl->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER) === 0) {
         $this->pushError(langBup::_('An error has occurred while unpacking the archive'));
         return false;
     }
     unset($pcl);
     // Unpack stacks
     $stacks = glob(realpath(ABSPATH) . '/BUP*');
     if (empty($stacks)) {
         return true;
     }
     foreach ($stacks as $stack) {
         if (file_exists($stack)) {
             $pcl = new PclZip($stack);
             $pcl->extract(PCLZIP_OPT_PATH, ABSPATH, PCLZIP_OPT_REPLACE_NEWER);
             unlink($stack);
             unset($pcl);
         }
     }
     return true;
 }
开发者ID:VSVS,项目名称:vs_wp_4.0,代码行数:32,代码来源:filesystem.php

示例6: restore

 /**
  * 数据库还原
  */
 public function restore()
 {
     set_time_limit(0);
     $data = array();
     if ($_POST) {
         if (!$_FILES['db_file']) {
             message('请上传文件!');
         }
         /**
          * 上传文件
          */
         $upload_path = BASEPATH . '/../cache/backup/';
         $txt = strtolower(end(explode('.', $_FILES['db_file']['name'])));
         if (!in_array($txt, array('sql', 'zip'))) {
             message('数据文件格式不符合要求!');
         }
         $file_name = microtime(true) . '.' . $txt;
         $upload_file = $upload_path . $file_name;
         if (!is_dir($upload_path)) {
             mkdir($upload_path, '0777', true);
         }
         if (!@move_uploaded_file($_FILES['db_file']['tmp_name'], $upload_file)) {
             message('文件处理失败,请重新上传文件!');
         } else {
             if ($txt == 'zip') {
                 require_once APPPATH . 'libraries/Pclzip.php';
                 $archive = new PclZip($upload_file);
                 $list = $archive->extract(PCLZIP_OPT_BY_NAME, $upload_file . "zmte.sql", PCLZIP_OPT_EXTRACT_AS_STRING);
                 pr($list, 1);
             }
         }
     }
     $this->load->view('dbmanage/restore', $data);
 }
开发者ID:Vincent-Shen,项目名称:origin,代码行数:37,代码来源:dbmanage.php

示例7: jimport

 function _extract($package, $target)
 {
     // First extract files
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $adapter =& JArchive::getAdapter('zip');
     $result = $adapter->extract($package, $target);
     if (!is_dir($target)) {
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         $extract = new PclZip($package);
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $result = $extract->extract(PCLZIP_OPT_PATH, $target);
     }
     return $result;
 }
开发者ID:atikahmed,项目名称:joomla-probid,代码行数:26,代码来源:admin_geomaps_install_controller.php

示例8: unzip

 function unzip($fn, $to, $suffix = false)
 {
     @set_time_limit(0);
     // Unzip uses a lot of memory
     @ini_set('memory_limit', '256M');
     require_once iPATH . 'include/pclzip.class.php';
     $files = array();
     $zip = new PclZip($fn);
     // Is the archive valid?
     if (false == ($archive_files = $zip->extract(PCLZIP_OPT_EXTRACT_AS_STRING))) {
         exit("ZIP包错误");
     }
     if (0 == count($archive_files)) {
         exit("空的ZIP文件");
     }
     $path = self::path($to);
     self::mkdir($path);
     foreach ($archive_files as $file) {
         $files[] = array('filename' => $file['filename'], 'isdir' => $file['folder']);
         $folder = $file['folder'] ? $file['filename'] : dirname($file['filename']);
         self::mkdir($path . '/' . $folder);
         if (empty($file['folder'])) {
             $fp = $path . '/' . $file['filename'];
             $suffix && ($fp = $fp . '.' . $suffix);
             self::write($fp, $file['content']);
         }
     }
     return $files;
 }
开发者ID:idreamsoft,项目名称:iCMS5.1,代码行数:29,代码来源:FileSystem.class.php

示例9: com_install

function com_install()
{
    $database =& JFactory::getDBO();
    $path = JPATH_SITE;
    @ini_set('max_execution_time', '180');
    if (!defined('DS')) {
        define('DS', DIRECTORY_SEPARATOR);
    }
    if (file_exists($path . DS . "administrator" . DS . "includes" . DS . "pcl" . DS . "pclzip.lib.php")) {
        require_once $path . DS . "administrator" . DS . "includes" . DS . "pcl" . DS . "pclzip.lib.php";
    }
    $archivename = $path . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "includes" . DS . "install" . DS . "crystalsvg.zip";
    $zipfile = new PclZip($archivename);
    $zipfile->extract(PCLZIP_OPT_PATH, $path . DS . "images" . DS . "stories" . DS);
    $archivename = $path . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "includes" . DS . "install" . DS . "langs.zip";
    $zipfile = new PclZip($archivename);
    $zipfile->extract(PCLZIP_OPT_PATH, $path . DS . "administrator" . DS . "components" . DS . "com_sobi2" . DS . "languages" . DS);
    @unlink($path . DS . "images" . DS . "stories" . DS . "folder_add_f2.png");
    @unlink($path . DS . "images" . DS . "stories" . DS . "properties_f2.png");
    @chdir($path . DS . "images" . DS);
    @mkdir("com_sobi2", 0777);
    @chdir($path . DS . images . DS . "com_sobi2" . DS);
    @mkdir("clients", 0777);
    $m = JFactory::getApplication('site');
    $m->redirect('index2.php?option=com_sobi2&sinstall=screen', 'A instalação do SOBI2 não está concluída. Por favor terminar a primeira instalação.');
}
开发者ID:patricmutwiri,项目名称:joomlaclube,代码行数:26,代码来源:install.sobi2.php

示例10: packageUnzip

 function packageUnzip($file, $target)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.archive');
     jimport('joomla.filesystem.path');
     $extract1 =& JArchive::getAdapter('zip');
     $result = @$extract1->extract($file, $target);
     if ($result != true) {
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclzip.lib.php';
         require_once PATH_ROOT . DS . 'administrator' . DS . 'includes' . DS . 'pcl' . DS . 'pclerror.lib.php';
         if (substr(PHP_OS, 0, 3) == 'WIN') {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 1);
             }
         } else {
             if (!defined('OS_WINDOWS')) {
                 define('OS_WINDOWS', 0);
             }
         }
         $extract2 = new PclZip($file);
         $result = @$extract2->extract(PCLZIP_OPT_PATH, $target);
     }
     unset($extract1, $extract2);
     return $result;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:26,代码来源:joomla15.php

示例11: zip_fallback

function zip_fallback($player_package) {
  $player_found = false;
  require_once(ABSPATH . 'wp-admin/includes/class-pclzip.php');
  $zip = new PclZip($player_package);
  $archive_files = $zip->extract(PCLZIP_OPT_EXTRACT_AS_STRING);
  $dir = $archive_files[0]["filename"];
  foreach($archive_files as $file) {
    $result = true;
    if ($file["filename"] == $dir . "player.swf" || $file["filename"] == $dir . "player-licensed.swf") {
      $result = @file_put_contents(LongTailFramework::getPrimaryPlayerPath(), $file["content"]);
      if (!$result) {
        return WRITE_ERROR;
      }
      $player_found = true;
    } else if ($file["filename"] == $dir . "yt.swf") {
      $result = @file_put_contents(str_replace("player.swf", "yt.swf", LongTailFramework::getPrimaryPlayerPath()), $file["content"]);
      if (!$result) {
        return WRITE_ERROR;
      }
    } else if ($file["filename"] == $dir . "jwplayer.js") {
      $result = @file_put_contents(LongTailFramework::getEmbedderPath(), $file["content"]);
      if (!$result) {
         return WRITE_ERROR;
      }
    }
  }
  if ($player_found) {
    unlink($player_package);
    return SUCCESS;
  }
  return ZIP_ERROR;
}
开发者ID:ramo01,项目名称:1kapp,代码行数:32,代码来源:UpdatePage.php

示例12: remoteinstall

 public function remoteinstall()
 {
     //安全验证 $this->checksafeauth();
     $url = $this->_get('url');
     $ext = strtolower(strrchr($url, '.'));
     $filepath = ltrim(strrchr($url, '/'), '/');
     if ($ext != '.zip') {
         //兼容旧版本
         $url = xbase64_decode($url);
         $ext = strtolower(strrchr($url, '.'));
         $filepath = ltrim(strrchr($url, '/'), '/');
         if ($ext != '.zip') {
             $this->error('远程文件格式必须为.zip');
         }
     }
     $content = fopen_url($url);
     if (empty($content)) {
         $this->error('远程获取文件失败!');
     }
     $filename = substr($filepath, 0, -4);
     File::write_file($filepath, $content);
     import('ORG.PclZip');
     $zip = new PclZip($filepath);
     $zip->extract(PCLZIP_OPT_PATH, './');
     @unlink($filepath);
     //删除安装文件
     $this->success('操作成功!', U('App/index'));
 }
开发者ID:google2013,项目名称:pppon,代码行数:28,代码来源:AppAction.class.php

示例13: rex_a22_extract_archive

function rex_a22_extract_archive($file, $destFolder = null)
{
    global $REX;
    if (!$destFolder) {
        $destFolder = '../files/' . $REX['TEMP_PREFIX'] . '/addon_framework';
    }
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $destFolder) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    echo '<div style="height:200px;width:770px;overflow:auto;margin-bottom:10px;text-align:center;">';
    echo '<h3>Archiv wird extrahiert...</h3>';
    echo '<table border="1" style="margin:0 auto 0 auto;">';
    echo '<tr><th>Datei</th><th>Gr&ouml;&szlig;e</th>';
    for ($i = 0; $i < count($list); $i++) {
        echo '<tr>';
        echo '<td>' . $list[$i]['filename'] . '</td><td>' . $list[$i]['size'] . ' bytes</td>';
        echo '</tr>';
    }
    echo '</table>';
    echo '</div>';
}
开发者ID:BackupTheBerlios,项目名称:redaxo-addons,代码行数:25,代码来源:function_pclzip.inc.php

示例14: unzip

 /**
  * Unzip a file into the specified directory. Throws a RuntimeException
  * if the extraction failed.
  */
 public static function unzip($source, $base = null)
 {
     $base = $base ? $base : self::$folder;
     @ini_set('memory_limit', '256M');
     if (!is_dir($base)) {
         mkdir($base);
         chmod($base, 0777);
     }
     if (class_exists('ZipArchive')) {
         // use ZipArchive
         $zip = new ZipArchive();
         $res = $zip->open($source);
         if ($res === true) {
             $zip->extractTo($base);
             $zip->close();
         } else {
             throw new RuntimeException('Could not open zip file [ZipArchive].');
         }
     } else {
         // use PclZip
         $zip = new PclZip($source);
         if ($zip->extract(PCLZIP_OPT_PATH, $base) === 0) {
             throw new RuntimeException('Could not extract zip file [PclZip].');
         }
     }
     return true;
 }
开发者ID:Selwyn-b,项目名称:elefant,代码行数:31,代码来源:Zipper.php

示例15: saveUploadedFile

    protected function saveUploadedFile() {
        
        $file = new Gpf_Db_File();
        $file->set('filename', $this->name);
        $file->set('filesize', $this->size);
        $file->set('filetype', $this->type);
        $file->save();
             
        $dir = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/');
        if ($dir->isExists()) {
            $dir->delete();
        }
        $dir->mkdir();
        $tmpZip = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip");
        $dir->copy(new Gpf_Io_File($this->tmpName),$tmpZip);
        
        $archive = new PclZip($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip");
        $err = $archive->extract($this->getZipFolderUrl().$file->getFileId().'/');
        if ($err <= 0) {
            throw new Gpf_Exception("code: ".$err);
        }

        $tmpZip->delete();
 
        return $file;
    }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:26,代码来源:Unziper.class.php


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