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


PHP PclZip::listContent方法代码示例

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


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

示例1: open

 public function open($Path)
 {
     $this->PclZip = new PclZip($Path);
     $Result = $this->_Contents = $this->PclZip->listContent();
     if (!$Result) {
         return ZipArchive::ER_READ;
     }
     $this->_Names = array();
     foreach ($this->_Contents as $Content) {
         $this->_Names[$Content['filename']] = $Content;
     }
     $this->numFiles = count($this->_Contents);
     return TRUE;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:14,代码来源:class.pclzipadapter.php

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

示例3: extract

 /**
  * Extract files from archive to target directory
  *
  * @param string  $pathExtracted  Absolute path of target directory
  * @return mixed  Array of filenames if successful; or 0 if an error occurred
  */
 public function extract($pathExtracted)
 {
     $pathExtracted = str_replace('\\', '/', $pathExtracted);
     $list = $this->pclzip->listContent();
     if (empty($list)) {
         return 0;
     }
     foreach ($list as $entry) {
         $filename = str_replace('\\', '/', $entry['stored_filename']);
         $parts = explode('/', $filename);
         if (!strncmp($filename, '/', 1) || array_search('..', $parts) !== false || strpos($filename, ':') !== false) {
             return 0;
         }
     }
     // PCLZIP_CB_PRE_EXTRACT callback returns 0 to skip, 1 to resume, or 2 to abort
     return $this->pclzip->extract(PCLZIP_OPT_PATH, $pathExtracted, PCLZIP_OPT_STOP_ON_ERROR, PCLZIP_OPT_REPLACE_NEWER, PCLZIP_CB_PRE_EXTRACT, create_function('$p_event, &$p_header', "return strncmp(\$p_header['filename'], '{$pathExtracted}', strlen('{$pathExtracted}')) ? 0 : 1;"));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:23,代码来源:PclZip.php

示例4: rex_a52_extract_archive

function rex_a52_extract_archive($file, $msg = '', $path = '../files/tmp_')
{
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $path) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
}
开发者ID:BackupTheBerlios,项目名称:redaxo-svn,代码行数:10,代码来源:function_pclzip.inc.php

示例5: checkZip

 function checkZip()
 {
     include_once SERVER_ROOT . "core/inc/lib/pclzip.php";
     $zip = new PclZip(SERVER_ROOT . "cache/update.zip");
     $zip->listContent();
     if ($zip->errorName() != "PCLZIP_ERR_NO_ERROR") {
         return false;
     }
     return true;
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:10,代码来源:updater.php

示例6: time

 function on_submit()
 {
     if (isset($_FILES['zipfile']) && $_FILES['zipfile']['error'] == 0) {
         //$fileEXT=strtolower(substr($_FILES['zipfile']['name'],strlen($_FILES['zipfile']['name'])-4,4));
         $fileEXT = AZLib::getExtension($_FILES['zipfile']['name']);
         if ($fileEXT == '.zip') {
             $uploadPath = ROOT_PATH . 'promotion/';
             @chmod($uploadPath, 0777);
             $zipFilePath = $uploadPath . time() . $fileEXT;
             @chmod($zipFilePath, 0777);
             if (!move_uploaded_file($_FILES['zipfile']['tmp_name'], $zipFilePath)) {
                 $this->setFormError('zipfile', "Không Upload được file Zip !");
                 return;
             } else {
                 @chmod($zipFilePath, 0777);
                 require_once "includes/unzip.ncl.php";
                 if (file_exists($zipFilePath)) {
                     $txt = '';
                     //unzipping...
                     $zip = new PclZip($zipFilePath);
                     if (($list = $zip->listContent()) == 0) {
                         $this->setFormError('zipfile', "File Zip trống!");
                         @unlink($zipFilePath);
                         return;
                     }
                     //calculate statistics...
                     for ($i = 0; $i < sizeof($list); $i++) {
                         if ($list[$i]['folder'] == '1') {
                             $fold++;
                             $dirs[$fold] = $list[$i]['stored_filename'];
                             $dirname = $list[$i]['stored_filename'];
                             $dirname = substr($dirname, 0, strlen($dirname) - 1);
                             @mkdir($basedir . '/' . $dirname);
                             @chmod($basedir . '/' . $dirname, 0777);
                         }
                     }
                     if ($zip->extract('promotion/')) {
                         unset($zip);
                         @unlink($zipFilePath);
                     } else {
                         $this->setFormError('zipfile', "Không giải nén được!");
                         return;
                     }
                 }
             }
         } else {
             $this->setFormError('zipfile', "File Upload phải là file nén dạng .zip !");
             return;
         }
     }
     $this->setFormError('zipfile', "Bạn chưa chọn file up lên!");
     //Url::redirect_current();
 }
开发者ID:duynhan07,项目名称:elink,代码行数:53,代码来源:class.php

示例7: teleporter_http_charger_zip

/**
 * Charger un zip à partir d'un tableau d'options descriptives
 *
 * @uses  http_deballe_recherche_racine()
 *
 * @param array $quoi
 *     Tableau d'options
 * @return array|bool|int|string
 *     En cas de réussite, Tableau décrivant le zip, avec les index suivant :
 *     - files : la liste des fichiers présents dans le zip,
 *     - size : la taille décompressée
 *     - compressed_size : la taille compressée
 *     - dirname : répertoire où les fichiers devront être décompréssés
 *     - tmpname : répertoire temporaire où les fichiers sont décompressés
 *     - target : cible sur laquelle décompresser les fichiers...
 */
function teleporter_http_charger_zip($quoi = array())
{
    if (!$quoi) {
        return false;
    }
    foreach (array('remove' => 'spip', 'rename' => array(), 'edit' => array(), 'root_extract' => false, 'tmp' => sous_repertoire(_DIR_CACHE, 'chargeur')) as $opt => $def) {
        isset($quoi[$opt]) || ($quoi[$opt] = $def);
    }
    if (!@file_exists($fichier = $quoi['fichier'])) {
        return 0;
    }
    include_spip('inc/pclzip');
    $zip = new PclZip($fichier);
    $list = $zip->listContent();
    $racine = http_deballe_recherche_racine($list);
    $quoi['remove'] = $racine;
    // si pas de racine commune, reprendre le nom du fichier zip
    // en lui enlevant la racine h+md5 qui le prefixe eventuellement
    // cf action/charger_plugin L74
    if (!strlen($nom = basename($racine))) {
        $nom = preg_replace(",^h[0-9a-f]{8}-,i", "", basename($fichier, '.zip'));
    }
    $dir_export = $quoi['root_extract'] ? $quoi['dest'] : $quoi['dest'] . $nom;
    $dir_export = rtrim($dir_export, '/') . '/';
    $tmpname = $quoi['tmp'] . $nom . '/';
    // choisir la cible selon si on veut vraiment extraire ou pas
    $target = $quoi['extract'] ? $dir_export : $tmpname;
    // ici, il faut vider le rep cible si il existe deja, non ?
    if (is_dir($target)) {
        supprimer_repertoire($target);
    }
    // et enfin on extrait
    $ok = $zip->extract(PCLZIP_OPT_PATH, $target, PCLZIP_OPT_SET_CHMOD, _SPIP_CHMOD, PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_REMOVE_PATH, $quoi['remove']);
    if ($zip->error_code < 0) {
        spip_log('charger_decompresser erreur zip ' . $zip->error_code . ' pour paquet: ' . $quoi['archive'], "teleport" . _LOG_ERREUR);
        return $zip->errorName(true);
    }
    spip_log('charger_decompresser OK pour paquet: ' . $quoi['archive'], "teleport");
    $size = $compressed_size = 0;
    $removex = ',^' . preg_quote($quoi['remove'], ',') . ',';
    foreach ($list as $a => $f) {
        $size += $f['size'];
        $compressed_size += $f['compressed_size'];
        $list[$a] = preg_replace($removex, '', $f['filename']);
    }
    // Indiquer par un fichier install.log
    // a la racine que c'est chargeur qui a installe ce plugin
    ecrire_fichier($target . 'install.log', "installation: charger_plugin\n" . "date: " . gmdate('Y-m-d\\TH:i:s\\Z', time()) . "\n" . "source: " . $quoi['archive'] . "\n");
    return array('files' => $list, 'size' => $size, 'compressed_size' => $compressed_size, 'dirname' => $dir_export, 'tmpname' => $tmpname, 'target' => $target);
}
开发者ID:xablen,项目名称:Semaine14_SPIP_test,代码行数:66,代码来源:http_deballe_zip.php

示例8: rex_a52_extract_archive

function rex_a52_extract_archive($file, $msg = '', $path = null)
{
    global $REX;
    if (!$path) {
        $path = '../files/' . $REX['TEMP_PREFIX'];
    }
    $archive = new PclZip($file);
    if ($archive->extract(PCLZIP_OPT_PATH, $path) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
    if (($list = $archive->listContent()) == 0) {
        die("Error : " . $archive->errorInfo(true));
    }
}
开发者ID:BackupTheBerlios,项目名称:redaxo,代码行数:14,代码来源:function_pclzip.inc.php

示例9: execute

 protected function execute()
 {
     $this->loadParams();
     $archive = new PclZip($this->zipFile->getFileName());
     $listContent = $archive->listContent();
     $allFilesCount = count($listContent);
     $processedFiles = -self::UNZIP_STEP;
     while ($processedFiles < $allFilesCount) {
         $processedFiles += self::UNZIP_STEP;
         if ($this->isDone($processedFiles, $this->_('%s%% files unzipped', round($processedFiles / $allFilesCount * 100, 0)))) {
             continue;
         }
         $this->changePermissions($archive->extractByIndex($processedFiles . '-' . ($processedFiles + self::UNZIP_STEP - 1), $this->outputDirectory->getFileName()));
         $this->setDone($processedFiles);
     }
 }
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:16,代码来源:UnzipFileTask.class.php

示例10: unZip

function unZip($uid, $from_zip)
{
    $afety_tag = 'Safety first -- ts24';
    //
    require 'include/pclzip.lib.php';
    $to_dir = '../data/diamond/' . substr($uid, -1) . '/';
    //允许的非模板文件类型
    $file_type = array('jpg', 'gif', 'jpeg', 'js', 'css', 'mp3', 'wma');
    //解压文件条件判断
    $reg_type = '/^' . $uid . '\\/.+\\.(' . implode('|', $file_type) . ')$/i';
    //
    $reg_htm = '/^' . $uid . '\\/' . intval($uid) . '_.+\\.htm$/i';
    $zip = new PclZip($from_zip);
    //包内所有文件列表
    $all_list = $zip->listContent();
    //获取解压列表
    $out_index = array();
    $arr_ret = array();
    if (empty($all_list)) {
        $all_list = array();
    }
    foreach ($all_list as $k => $v) {
        if (substr($v['filename'], -1) != '/') {
            if ('htm' == substr($v['filename'], -3)) {
                $tmp = preg_match($reg_htm, $v['filename']);
            } else {
                $tmp = preg_match($reg_type, $v['filename']);
            }
            if ($tmp) {
                //合格文件,可解压
                $arr_ret[$v['filename']] = 1;
                $out_index[] = $k;
            } else {
                $arr_ret[$v['filename']] = 0;
            }
        }
    }
    //解压
    if (empty($out_index)) {
        return $arr_ret;
    }
    $ret = $zip->extract(PCLZIP_OPT_PATH, $to_dir, PCLZIP_OPT_BY_INDEX, $out_index);
    if ($ret == 0) {
        return array();
    }
    return $arr_ret;
}
开发者ID:noikiy,项目名称:zays,代码行数:47,代码来源:site_diamond.php

示例11: decompress

 function decompress($to)
 {
     if (!file_exists($this->zip)) {
         throw new \Fuse_Exception('File :file does not exist', array(':file' => $this->zip));
     }
     $zip = new PclZip($this->zip);
     if (($list = $zip->listContent()) == 0) {
         error_log($zip->errorInfo(true));
         throw new \Fuse_Exception('Invalid zip file');
     }
     $v_list = $zip->extract($to);
     if ($v_list == 0) {
         error_log($zip->errorInfo(true));
         throw new \Fuse_Exception('Zip extraction failed');
     }
     return true;
 }
开发者ID:BillingFuse,项目名称:BillingFuse,代码行数:17,代码来源:Zip.php

示例12: install

 public function install($id)
 {
     $entry = $this->getEntry($id);
     if ($entry && !empty($entry['url'])) {
         App::uses('File', 'Utility');
         copy($entry['url'], TMP . DS . $id);
         App::import('Vendor', 'PclZip', array('file' => 'pclzip-2-8-2/pclzip.lib.php'));
         $zip = new PclZip(TMP . DS . $id);
         $list = $zip->listContent();
         $zip->extract(TMP);
         unlink(TMP . DS . $id);
         rename(TMP . DS . $list[0]['filename'], APP . 'Plugin' . DS . Inflector::camelize($id));
         Cache::clear(false, '_cake_core_');
         CakePlugin::loadAll();
         return true;
     }
     return false;
 }
开发者ID:naokomc,项目名称:candycane,代码行数:18,代码来源:PluginContainer.php

示例13: GetGEDFromZIP

/**
 * find the name of the first GEDCOM file in a zipfile
 * @param string $zipfile	the path and filename
 * @param boolean $extract  true = extract and return filename, false = return filename
 * @return string		the path and filename of the gedcom file
 */
function GetGEDFromZIP($zipfile, $extract = true)
{
    global $INDEX_DIRECTORY;
    require_once PGV_ROOT . 'includes/pclzip.lib.php';
    $zip = new PclZip($zipfile);
    // if it's not a valid zip, just return the filename
    if (($list = $zip->listContent()) == 0) {
        return $zipfile;
    }
    // Determine the extract directory
    $slpos = strrpos($zipfile, "/");
    if (!$slpos) {
        $slpos = strrpos($zipfile, "\\");
    }
    if ($slpos) {
        $path = substr($zipfile, 0, $slpos + 1);
    } else {
        $path = $INDEX_DIRECTORY;
    }
    // Scan the files and return the first .ged found
    foreach ($list as $key => $listitem) {
        if (($listitem["status"] = "ok") && strstr(strtolower($listitem["filename"]), ".") == ".ged") {
            $filename = basename($listitem["filename"]);
            if ($extract == false) {
                return $filename;
            }
            // if the gedcom exists, save the old one. NOT to bak as it will be overwritten on import
            if (file_exists($path . $filename)) {
                if (file_exists($path . $filename . ".old")) {
                    unlink($path . $filename . ".old");
                }
                copy($path . $filename, $path . $filename . ".old");
                unlink($path . $filename);
            }
            if ($zip->extract(PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $path, PCLZIP_OPT_BY_NAME, $listitem["filename"]) == 0) {
                print "ERROR cannot extract ZIP";
            }
            return $filename;
        }
    }
    return $zipfile;
}
开发者ID:rathervague,项目名称:phpgedview,代码行数:48,代码来源:editconfig_gedcom.php

示例14: useLibPcl

		private function useLibPcl(){

      require_once('../../lib/pclzip.lib.php');
      $zip = new PclZip($this->file);
      $aff_fichiers = $zip->listContent();


      if ($zip->content = $zip->extract(PCLZIP_OPT_BY_NAME, $aff_fichiers[9]['filename'],  //on extrait content.xml
	                       PCLZIP_OPT_PATH, $aff_fichiers[9]['stored_filename']) == 0) { //de l'archive dans le dossier archive (id unique)
      echo "ERROR : ".$zip->errorInfo(true);
     }

      /*
      echo '<pre>';
      print_r($aff_fichiers);
      echo '</pre>';
      exit();
      */

    }
开发者ID:rhertzog,项目名称:lcs,代码行数:20,代码来源:courrier_ooo.class.php

示例15: getFileFromZip

/**
 * 查询解压缩文件的内容
 * $path example './zips/' 文件路径后面的斜线也请写上
 * $file example 1.zip
 */
function getFileFromZip($path)
{
    $zip = new PclZip($path);
    $list = $zip->listContent();
    return $list;
}
开发者ID:jksbill,项目名称:vadmin,代码行数:11,代码来源:function.php


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