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


PHP PclZip类代码示例

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


在下文中一共展示了PclZip类的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: wpd_download

function wpd_download()
{
    if (!class_exists('PclZip')) {
        include ABSPATH . 'wp-admin/includes/class-pclzip.php';
    }
    $what = $_GET['wpd'];
    $object = $_GET['object'];
    switch ($what) {
        case 'plugin':
            if (strpos($object, '/')) {
                $object = dirname($object);
            }
            $root = WP_PLUGIN_DIR;
            break;
        case 'theme':
            $root = get_theme_root($object);
            break;
    }
    $path = $root . '/' . $object;
    $fileName = $object . '.zip';
    $archive = new PclZip($fileName);
    $archive->add($path, PCLZIP_OPT_REMOVE_PATH, $root);
    header('Content-type: application/zip');
    header('Content-Disposition: attachment; filename="' . $fileName . '"');
    readfile($fileName);
    // remove tmp zip file
    unlink($fileName);
    exit;
}
开发者ID:vrkansagara,项目名称:wordpress-plugin-construction,代码行数:29,代码来源:wp-downloader-3.7.php

示例3: extractTextContent

 public function extractTextContent()
 {
     $config = KTConfig::getSingleton();
     $temp_dir = $config->get('urls/tmpDirectory');
     $docid = $this->document->getId();
     $time = 'ktindexer_openoffice_' . time() . '-' . $docid;
     $this->openxml_dir = $temp_dir . '/' . $time;
     $this->sourcefile = str_replace('\\', '/', $this->sourcefile);
     $this->openxml_dir = str_replace('\\', '/', $this->openxml_dir);
     $archive = new PclZip($this->sourcefile);
     if ($archive->extract(PCLZIP_OPT_PATH, $this->openxml_dir) == 0) {
         $this->output = _kt('Failed to extract content');
         return false;
     }
     /* *** Original code using the unzip binary ***
     		$cmd = '"' . $this->unzip . '"' . ' ' . str_replace(
     			array('{source}','{part}', '{target_dir}'),
     			array($this->sourcefile, 'content.xml',$this->openxml_dir), $this->unzip_params);
     
     		$cmd = str_replace('\\','/', $cmd);
     
      		if (!$this->exec($cmd))
     		{
     			$this->output = _kt('Failed to execute command: ') . $cmd;
     			return false;
     		}
     		*** End unzip code *** */
     $filename = $this->openxml_dir . '/content.xml';
     if (!file_exists($filename)) {
         $this->output = _kt('Failed to find file: ') . $filename;
         return false;
     }
     $result = file_put_contents($this->targetfile, $this->filter(file_get_contents($filename)));
     return $result !== false;
 }
开发者ID:5haman,项目名称:knowledgetree,代码行数:35,代码来源:OpenOfficeTextExtractor.inc.php

示例4: guardarArchivo

 function guardarArchivo()
 {
     global $db, $t;
     // Copia el archivo del usuario al directorio ../files
     $tipoArchivo = $_FILES['userfile']['type'];
     //if( $tipoArchivo=="application/zip" ){
     if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
         copy($_FILES['userfile']['tmp_name'], "../facturas/facturas.zip");
         $msg[] = "<font color=green>El archivo fue cargado correctamente.</font>";
         // -------------------------------------------
         // Descomprimir los zip
         require_once '../include/pclzip.lib.php';
         $archive = new PclZip('../facturas/facturas.zip');
         //Ejecutamos la funcion extract
         //if ( $archive->extract(PCLZIP_OPT_PATH, ' ../files/facturas/',PCLZIP_OPT_REMOVE_PATH, '../files/facturas/') == 0) {
         if ($archive->extract(PCLZIP_OPT_PATH, '../facturas/', PCLZIP_OPT_REMOVE_PATH, '../facturas/') == 0) {
             die("Error : " . $archive->errorInfo(true));
         }
         // -------------------------------------------
         // Eliminar zip, ya no es necesario.
         unlink("../facturas/facturas.zip");
     } else {
         $msg[] = "<font color=red>ERROR : Possible file upload attack. Filename: " . $_FILES['userfile']['name'];
     }
     //}
     //else{
     //    $archivo = $_FILES['userfile']['name'];
     //    $msg[]= "<font color=red>ERROR : El archivo (<i>$archivo</i>) es incorrecto, debe cargar un formato ZIP, y dentro de él todas las facturas.";
     //}
     return $msg;
 }
开发者ID:nesmaster,项目名称:anakosta,代码行数:31,代码来源:facUploadFac.php

示例5: 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

示例6: 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

示例7: export

 function export()
 {
     header("Content-type: text/html; charset=utf-8");
     ob_end_clean();
     //在循环输出前,要关闭输出缓冲区
     echo str_pad('', 1024);
     //浏览器在接受输出一定长度内容之前不会显示缓冲输出
     echo '<h1>开始导出!</h1><hr/><h3>删除初始文件</h3><hr/>';
     flush();
     del_dir($this->path_to);
     echo '删除完成!<br/><h3>删除成功,开始编译less</h3><hr/>';
     flush();
     //$this->_less();
     echo '编译成功!<br/><h3>开始复制文件</h3><hr/>';
     flush();
     $this->_fileInit();
     echo '复制成功!<br/><h3>删除开发相关文件</h3><hr/>';
     flush();
     $this->_remove();
     echo '删除成功!<br/><h3>开始替换模板种less相关内容</h3><hr/>';
     flush();
     $this->_fileReplace();
     echo '替换成功!<br/><h3>打包程序</h3><hr/>';
     flush();
     load_class('pclzip');
     ini_set('memory_limit', '2028M');
     //2G;
     $archive = new PclZip($this->zip_to);
     $v_list = $archive->create($this->path_to, PCLZIP_OPT_REMOVE_PATH, $this->path_to);
     echo '打包成功!<br/><h3>初始化配置文件</h3><hr/>';
     flush();
     $this->_initUser();
     echo '更新成功!<br/><h1>导出处理完成!^_^</h1>';
     flush();
 }
开发者ID:longmore,项目名称:KODExplorer,代码行数:35,代码来源:debug.class.php

示例8: 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

示例9: 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

示例10: _extract

 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

示例11: restore_backup_file

 public function restore_backup_file()
 {
     $data = $this->input->stream();
     if (isset($data['filename']) && !empty($data['filename'])) {
         $back_file_path = './backup/' . $data['filename'];
         if (file_exists($back_file_path)) {
             $archive = new PclZip($back_file_path);
             $row = $archive->extract(PCLZIP_OPT_PATH, "./backup/zycms");
             $row = array_shift($row);
             $extract_file_path = './' . $row['filename'];
             if (($sql_content = file_get_contents($filename = $extract_file_path)) !== false) {
                 $sql = explode("\n\n", $sql_content);
                 foreach ($sql as $key => $s) {
                     if (trim($s)) {
                         $result = $this->db->query($s);
                     }
                 }
                 unlink($extract_file_path);
                 rmdir('./backup/zycms');
                 die(json_encode(array('code' => 200, 'message' => '还原成功')));
             } else {
                 unlink($extract_file_path);
                 rmdir('./backup/zycms');
                 die(json_encode(array('code' => 403, 'message' => '还原失败')));
             }
         }
     }
 }
开发者ID:jaya-project,项目名称:zycms,代码行数:28,代码来源:Tools.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: compress

 /**
  * Creates a compressed cache file for the chapter
  * 
  * @author Woxxy
  * @return url to compressed file
  */
 function compress($chapter)
 {
     $chapter->get_comic();
     $chapter->get_pages();
     $files = array();
     $this->where('chapter_id', $chapter->id)->get();
     if ($this->result_count() == 0 || !file_exists("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename)) {
         $this->remove_old();
         $CI =& get_instance();
         require_once FCPATH . 'assets/pclzip/pclzip.lib.php';
         $filename = $this->filename_compressed($chapter);
         $archive = new PclZip("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $filename . '.zip');
         $filearray = array();
         foreach ($chapter->pages as $page) {
             $filearray[] = "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $page["filename"];
         }
         $v_list = $archive->create(implode(',', $filearray), PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, $filename, PCLZIP_OPT_NO_COMPRESSION);
         $this->chapter_id = $chapter->id;
         $this->filename = $filename . '.zip';
         $this->size = filesize("content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $filename . '.zip');
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     } else {
         $this->lastdownload = date('Y-m-d H:i:s', time());
         $this->save();
     }
     return array("url" => site_url() . "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . urlencode($this->filename), "server_path" => FCPATH . "content/comics/" . $chapter->comic->directory() . "/" . $chapter->directory() . "/" . $this->filename);
 }
开发者ID:bonsoirval,项目名称:FoOlSlide,代码行数:34,代码来源:archive.php

示例14: 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

示例15: 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


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