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


PHP PclZip::privOpenFd方法代码示例

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


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

示例1: privDeleteByRule

 function privDeleteByRule(&$p_result_list, &$p_options)
 {
     //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
     $v_result = 1;
     $v_list_detail = array();
     // ----- Open the zip file
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
     if (($v_result = $this->privOpenFd('rb')) != 1) {
         // ----- Return
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Read the central directory informations
     $v_central_dir = array();
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
         $this->privCloseFd();
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Go to beginning of File
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
     @rewind($this->zip_fd);
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
     // ----- Scan all the files
     // ----- Start at beginning of Central Dir
     $v_pos_entry = $v_central_dir['offset'];
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
     @rewind($this->zip_fd);
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
     if (@fseek($this->zip_fd, $v_pos_entry)) {
         // ----- Close the zip file
         $this->privCloseFd();
         // ----- Error log
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
         // ----- Return
         //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
         return PclZip::errorCode();
     }
     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
     // ----- Read each entry
     $v_header_list = array();
     $j_start = 0;
     for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
         // ----- Read the file header
         $v_header_list[$v_nb_extracted] = array();
         if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) {
             // ----- Close the zip file
             $this->privCloseFd();
             //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
             return $v_result;
         }
         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
         // ----- Store the index
         $v_header_list[$v_nb_extracted]['index'] = $i;
         // ----- Look for the specific extract rules
         $v_found = false;
         // ----- Look for extract by name rule
         if (isset($p_options[PCLZIP_OPT_BY_NAME]) && $p_options[PCLZIP_OPT_BY_NAME] != 0) {
             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
             // ----- Look if the filename is in the list
             for ($j = 0; $j < sizeof($p_options[PCLZIP_OPT_BY_NAME]) && !$v_found; $j++) {
                 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
                 // ----- Look for a directory
                 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
                     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
                     // ----- Look if the directory is in the filename path
                     if (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]) && substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
                         $v_found = true;
                     } elseif (($v_header_list[$v_nb_extracted]['external'] & 0x10) == 0x10 && $v_header_list[$v_nb_extracted]['stored_filename'] . '/' == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
                         $v_found = true;
                     }
                 } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
                     $v_found = true;
                 }
             }
         } else {
             if (isset($p_options[PCLZIP_OPT_BY_EREG]) && $p_options[PCLZIP_OPT_BY_EREG] != "") {
                 //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
                 if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
                     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
                     $v_found = true;
                 }
             } else {
                 if (isset($p_options[PCLZIP_OPT_BY_PREG]) && $p_options[PCLZIP_OPT_BY_PREG] != "") {
                     //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
                     if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
                         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
                         $v_found = true;
                     }
                 } else {
                     if (isset($p_options[PCLZIP_OPT_BY_INDEX]) && $p_options[PCLZIP_OPT_BY_INDEX] != 0) {
                         //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
                         // ----- Look if the index is in the list
                         for ($j = $j_start; $j < sizeof($p_options[PCLZIP_OPT_BY_INDEX]) && !$v_found; $j++) {
                             //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
                             if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] && $i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
//.........这里部分代码省略.........
开发者ID:kondrat-shmoylov,项目名称:Pagetest,代码行数:101,代码来源:pclzip.lib.php

示例2: privDeleteByRule

 function privDeleteByRule(&$p_result_list, &$p_options)
 {
     $v_result = 1;
     $v_list_detail = array();
     // ----- Open the zip file
     if (($v_result = $this->privOpenFd('rb')) != 1) {
         // ----- Return
         return $v_result;
     }
     // ----- Read the central directory informations
     $v_central_dir = array();
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
         $this->privCloseFd();
         return $v_result;
     }
     // ----- Go to beginning of File
     @rewind($this->zip_fd);
     // ----- Scan all the files
     // ----- Start at beginning of Central Dir
     $v_pos_entry = $v_central_dir['offset'];
     @rewind($this->zip_fd);
     if (@fseek($this->zip_fd, $v_pos_entry)) {
         // ----- Close the zip file
         $this->privCloseFd();
         // ----- Error log
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
         // ----- Return
         return PclZip::errorCode();
     }
     // ----- Read each entry
     $v_header_list = array();
     $j_start = 0;
     for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
         // ----- Read the file header
         $v_header_list[$v_nb_extracted] = array();
         if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) {
             // ----- Close the zip file
             $this->privCloseFd();
             return $v_result;
         }
         // ----- Store the index
         $v_header_list[$v_nb_extracted]['index'] = $i;
         // ----- Look for the specific extract rules
         $v_found = false;
         // ----- Look for extract by name rule
         if (isset($p_options[PCLZIP_OPT_BY_NAME]) && $p_options[PCLZIP_OPT_BY_NAME] != 0) {
             // ----- Look if the filename is in the list
             for ($j = 0; $j < sizeof($p_options[PCLZIP_OPT_BY_NAME]) && !$v_found; $j++) {
                 // ----- Look for a directory
                 if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
                     // ----- Look if the directory is in the filename path
                     if (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]) && substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                         $v_found = true;
                     } elseif (($v_header_list[$v_nb_extracted]['external'] & 0x10) == 0x10 && $v_header_list[$v_nb_extracted]['stored_filename'] . '/' == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                         $v_found = true;
                     }
                 } elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
                     $v_found = true;
                 }
             }
         } else {
             if (isset($p_options[PCLZIP_OPT_BY_PREG]) && $p_options[PCLZIP_OPT_BY_PREG] != "") {
                 if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
                     $v_found = true;
                 }
             } else {
                 if (isset($p_options[PCLZIP_OPT_BY_INDEX]) && $p_options[PCLZIP_OPT_BY_INDEX] != 0) {
                     // ----- Look if the index is in the list
                     for ($j = $j_start; $j < sizeof($p_options[PCLZIP_OPT_BY_INDEX]) && !$v_found; $j++) {
                         if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] && $i <= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
                             $v_found = true;
                         }
                         if ($i >= $p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
                             $j_start = $j + 1;
                         }
                         if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start'] > $i) {
                             break;
                         }
                     }
                 } else {
                     $v_found = true;
                 }
             }
         }
         // ----- Look for deletion
         if ($v_found) {
             unset($v_header_list[$v_nb_extracted]);
         } else {
             $v_nb_extracted++;
         }
     }
     // ----- Look if something need to be deleted
     if ($v_nb_extracted > 0) {
         // ----- Creates a temporay file
         $v_zip_temp_name = PCLZIP_TEMPORARY_DIR . uniqid('pclzip-') . '.tmp';
         // ----- Creates a temporary zip archive
         $v_temp_zip = new PclZip($v_zip_temp_name);
         // ----- Open the temporary zip file in write mode
         if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
             $this->privCloseFd();
//.........这里部分代码省略.........
开发者ID:belerweb,项目名称:pigcms,代码行数:101,代码来源:Update.class.php

示例3: privDeleteByIndex

 function privDeleteByIndex($p_index, &$p_result_list)
 {
     PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByIndex", "index='{$p_index}'");
     $v_result = 1;
     $v_list_detail = array();
     // ----- Open the zip file
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
     if (($v_result = $this->privOpenFd('rb')) != 1) {
         // ----- Return
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Read the central directory informations
     $v_central_dir = array();
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1) {
         $this->privCloseFd();
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Go to beginning of File
     PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : " . ftell($this->zip_fd) . "'");
     @rewind($this->zip_fd);
     PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : " . ftell($this->zip_fd) . "'");
     // ----- Scan all the files
     // ----- Manipulate the index list
     $p_index = strtr($p_index, ' ', '');
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Reduced index : '{$p_index}'");
     $v_index_list = explode(",", $p_index);
     // TBC : Here I should sort the index. However a simple sort is not enought.
     // look for the use of usort()
     //sort($v_index_list);
     // ----- Start at beginning of Central Dir
     $v_pos_entry = $v_central_dir['offset'];
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : " . ftell($this->zip_fd) . "'");
     @rewind($this->zip_fd);
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : " . ftell($this->zip_fd) . "'");
     if (@fseek($this->zip_fd, $v_pos_entry)) {
         // ----- Close the zip file
         $this->privCloseFd();
         // ----- Error log
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
         // ----- Return
         PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
         return PclZip::errorCode();
     }
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : " . ftell($this->zip_fd) . "'");
     // ----- Read each entry
     $v_header_list = array();
     for ($i = 0, $j_start = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
         PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : {$i}'");
         // ----- Read the file header
         $v_header_list[$v_nb_extracted] = array();
         if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1) {
             // ----- Close the zip file
             $this->privCloseFd();
             PclTraceFctEnd(__FILE__, __LINE__, $v_result);
             return $v_result;
         }
         // ----- Store the index
         $v_header_list[$v_nb_extracted]['index'] = $i;
         // ----- Look if the index is in the list
         for ($j = $j_start, $v_found = false; $j < sizeof($v_index_list) && !$v_found; $j++) {
             PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '{$i}' is in '" . $v_index_list[$j] . "'");
             // ----- Extract range
             $v_item_list = explode("-", $v_index_list[$j]);
             $v_size_item_list = sizeof($v_item_list);
             if ($v_size_item_list == 1) {
                 if ($i == $v_item_list[0]) {
                     PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as a single index");
                     $v_found = true;
                 }
                 if ($i >= $v_item_list[0]) {
                     $j_start = $j + 1;
                 }
             } else {
                 if ($v_size_item_list == 2) {
                     if ($i >= $v_item_list[0] && $i <= $v_item_list[1]) {
                         PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
                         $v_found = true;
                     }
                     if ($i >= $v_item_list[1]) {
                         $j_start = $j + 1;
                     }
                 }
             }
             if ($v_item_list[0] > $i) {
                 PclTraceFctMessage(__FILE__, __LINE__, 3, "Range is greater than index, stop loop");
                 break;
             }
         }
         // ----- Look for deletion
         if ($v_found) {
             PclTraceFctMessage(__FILE__, __LINE__, 2, "File '" . $v_header['filename'] . "', index '{$i}' need to be deleted");
             unset($v_header_list[$v_nb_extracted]);
         } else {
             PclTraceFctMessage(__FILE__, __LINE__, 2, "File '" . $v_header['filename'] . "', index '{$i}' will not be deleted");
             $v_nb_extracted++;
         }
     }
     // ----- Creates a temporay file
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:phreakpic,代码行数:101,代码来源:pclzip-trace.lib.php


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