⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pclzip.php

📁 php版wap手机网站源码(英语) the best wap scripts from
💻 PHP
📖 第 1 页 / 共 5 页
字号:
 }
 function deleteByIndex($p_index)
 {
  $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
  return $p_list;
 }
 function properties()
 {
  $this->privErrorReset();
 if (!$this->privCheckFormat()) {
  return(0);
 }
 $v_prop = array();
 $v_prop['comment'] = '';
 $v_prop['nb'] = 0;
 $v_prop['status'] = 'not_exist';
 if (@is_file($this->zipname))
 {
  if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
 {
 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
  return 0;
 }
 $v_central_dir = array();
 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
 {
  return 0;
 }
 $this->privCloseFd();
 $v_prop['comment'] = $v_central_dir['comment'];
 $v_prop['nb'] = $v_central_dir['entries'];
 $v_prop['status'] = 'ok';
 }
  return $v_prop;
 }
 function duplicate($p_archive)
 {
  $v_result = 1;
 $this->privErrorReset();
 if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
 {
  $v_result = $this->privDuplicate($p_archive->zipname);
 }
 else if (is_string($p_archive))
 {
  if (!is_file($p_archive)) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
 $v_result = PCLZIP_ERR_MISSING_FILE;
 }
 else {
 $v_result = $this->privDuplicate($p_archive);
 }
 }
 else
 {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
 $v_result = PCLZIP_ERR_INVALID_PARAMETER;
 }
  return $v_result;
 }
 function merge($p_archive_to_add)
 {
  $v_result = 1;
 $this->privErrorReset();
 if (!$this->privCheckFormat()) {
  return(0);
 }
 if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
 {
  $v_result = $this->privMerge($p_archive_to_add);
 }
 else if (is_string($p_archive_to_add))
 {
  $v_object_archive = new PclZip($p_archive_to_add);
 $v_result = $this->privMerge($v_object_archive);
 }
 else
 {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
 $v_result = PCLZIP_ERR_INVALID_PARAMETER;
 }
  return $v_result;
 }
 function errorCode()
 {
 if (PCLZIP_ERROR_EXTERNAL == 1) {
 return(PclErrorCode());
 }
 else {
 return($this->error_code);
 }
 }
 function errorName($p_with_code=false)
 {
 $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
 PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
 PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
 PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
 PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
 PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
 PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
 PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
 PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
 PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
 PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
 PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
 PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
 PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
 PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
 PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
 PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
 PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
 PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION' );
 if (isset($v_name[$this->error_code])) {
 $v_value = $v_name[$this->error_code];
 }
 else {
 $v_value = 'NoName';
 }
 if ($p_with_code) {
 return($v_value.' ('.$this->error_code.')');
 }
 else {
 return($v_value);
 }
 }
 function errorInfo($p_full=false)
 {
 if (PCLZIP_ERROR_EXTERNAL == 1) {
 return(PclErrorString());
 }
 else {
 if ($p_full) {
 return($this->errorName(true)." : ".$this->error_string);
 }
 else {
 return($this->error_string." [code ".$this->error_code."]");
 }
 }
 }
 function privCheckFormat($p_level=0)
 {
  $v_result = true;
 clearstatcache();
 $this->privErrorReset();
 if (!is_file($this->zipname)) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
  return(false);
 }
 if (!is_readable($this->zipname)) {
 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
  return(false);
 }
  return $v_result;
 }
 function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
 {
  $v_result=1;
 $i=0;
 while ($i<$p_size) {
  if (!isset($v_requested_options[$p_options_list[$i]])) {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
  return PclZip::errorCode();
 }
 switch ($p_options_list[$i]) {
 case PCLZIP_OPT_PATH :
 case PCLZIP_OPT_REMOVE_PATH :
 case PCLZIP_OPT_ADD_PATH :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
  $i++;
 break;
 case PCLZIP_OPT_BY_NAME :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 if (is_string($p_options_list[$i+1])) {
 $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
 }
 else if (is_array($p_options_list[$i+1])) {
 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
 }
 else {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $i++;
 break;
 case PCLZIP_OPT_BY_EREG :
 case PCLZIP_OPT_BY_PREG :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 if (is_string($p_options_list[$i+1])) {
 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
 }
 else {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
  $i++;
 break;
 case PCLZIP_OPT_COMMENT :
 case PCLZIP_OPT_ADD_COMMENT :
 case PCLZIP_OPT_PREPEND_COMMENT :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
			 "Missing parameter value for option '"
								 .PclZipUtilOptionText($p_options_list[$i])
								 ."'");
  return PclZip::errorCode();
 }
 if (is_string($p_options_list[$i+1])) {
 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
 }
 else {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
			 "Wrong parameter value for option '"
								 .PclZipUtilOptionText($p_options_list[$i])
								 ."'");
  return PclZip::errorCode();
 }
  $i++;
 break;
 case PCLZIP_OPT_BY_INDEX :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_work_list = array();
 if (is_string($p_options_list[$i+1])) {
  $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
 $v_work_list = explode(",", $p_options_list[$i+1]);
 }
 else if (is_integer($p_options_list[$i+1])) {
  $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
 }
 else if (is_array($p_options_list[$i+1])) {
  $v_work_list = $p_options_list[$i+1];
 }
 else {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_sort_flag=false;
 $v_sort_value=0;
 for ($j=0; $j<sizeof($v_work_list); $j++) {
 $v_item_list = explode("-", $v_work_list[$j]);
 $v_size_item_list = sizeof($v_item_list);
 if ($v_size_item_list == 1) {
 $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
 $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
 }
 elseif ($v_size_item_list == 2) {
 $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
 $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
 }
 else {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
  if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
  $v_sort_flag=true;
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
 }
 if ($v_sort_flag) {
  }
 $i++;
 break;
 case PCLZIP_OPT_REMOVE_ALL_PATH :
 case PCLZIP_OPT_EXTRACT_AS_STRING :
 case PCLZIP_OPT_NO_COMPRESSION :
 case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
 case PCLZIP_OPT_REPLACE_NEWER :
 case PCLZIP_OPT_STOP_ON_ERROR :
 $v_result_list[$p_options_list[$i]] = true;
  break;
 case PCLZIP_OPT_SET_CHMOD :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
  $i++;
 break;
 case PCLZIP_CB_PRE_EXTRACT :
 case PCLZIP_CB_POST_EXTRACT :
 case PCLZIP_CB_PRE_ADD :
 case PCLZIP_CB_POST_ADD :
 if (($i+1) >= $p_size) {
 PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_function_name = $p_options_list[$i+1];
  if (!function_exists($v_function_name)) {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
  return PclZip::errorCode();
 }
 $v_result_list[$p_options_list[$i]] = $v_function_name;
 $i++;
 break;
 default :
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
		 "Unknown parameter '"
							 .$p_options_list[$i]."'");
  return PclZip::errorCode();
 }
 $i++;
 }
 if ($v_requested_options !== false) {
 for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
 if ($v_requested_options[$key] == 'mandatory') {
  if (!isset($v_result_list[$key])) {
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
  return PclZip::errorCode();
 }
 }
 }
 }
  return $v_result;
 }
 function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
 {
  $v_result=1;
 $v_list_detail = array();
 if (($v_result = $this->privOpenFd('wb')) != 1)
 {
  return $v_result;
 }
 $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
 $this->privCloseFd();
  return $v_result;
 }
 function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
 {
  $v_result=1;
 $v_list_detail = array();
 if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
 {
  $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);
  return $v_result;
 }
  if (($v_result=$this->privOpenFd('rb')) != 1)
 {
  return $v_result;
 }
 $v_central_dir = array();
 if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
 {
 $this->privCloseFd();
  return $v_result;
 }
  @rewind($this->zip_fd);
  $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
  if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
 {
 $this->privCloseFd();
 PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
  return PclZip::errorCode();
 }
 $v_size = $v_central_dir['offset'];
 while ($v_size != 0)
 {
 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  $v_buffer = fread($this->zip_fd, $v_read_size);
 @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
 $v_size -= $v_read_size;
 }
 $v_swap = $this->zip_fd;
 $this->zip_fd = $v_zip_temp_fd;
 $v_zip_temp_fd = $v_swap;
 $v_header_list = array();
 if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)
 {
 fclose($v_zip_temp_fd);
 $this->privCloseFd();
 @unlink($v_zip_temp_name);
  return $v_result;
 }
 $v_offset = @ftell($this->zip_fd);
  $v_size = $v_central_dir['size'];
 while ($v_size != 0)
 {
 $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
  $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
 @fwrite($this->zip_fd, $v_buffer, $v_read_size);
 $v_size -= $v_read_size;
 }
 for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
 {
 if ($v_header_list[$i]['status'] == 'ok') {
 if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
 fclose($v_zip_temp_fd);
 $this->privCloseFd();
 @unlink($v_zip_temp_name);
  return $v_result;
 }
 $v_count++;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -