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

📄 pclzip.php

📁 php版wap手机网站源码(英语) the best wap scripts from
💻 PHP
📖 第 1 页 / 共 5 页
字号:
 {
 $this->privCloseFd();
  return $v_result;
 }
 $v_pos_entry = $v_central_dir['offset'];
 $j_start = 0;
 for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
 {
   @rewind($this->zip_fd);
  if (@fseek($this->zip_fd, $v_pos_entry))
 {
 $this->privCloseFd();
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
  return PclZip::errorCode();
 }
  $v_header = array();
 if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
 {
 $this->privCloseFd();
  return $v_result;
 }
 $v_header['index'] = $i;
 $v_pos_entry = ftell($this->zip_fd);
 $v_extract = false;
 if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
 && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
  for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
  if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
  if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
 && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
  $v_extract = true;
 }
 }
 elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
  $v_extract = true;
 }
 }
 }
 else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
 && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
  if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
  $v_extract = 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['stored_filename'])) {
  $v_extract = true;
 }
 }
 else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
 && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
  for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
  if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
  $v_extract = 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_extract = true;
 }
	 if ( ($v_extract)
	 && ( ($v_header['compression'] != 8)
		 && ($v_header['compression'] != 0))) {
  $v_header['status'] = 'unsupported_compression';
 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
		 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
			 "Filename '".$v_header['stored_filename']."' is "
				 	 	 	 ."compressed by an unsupported compression "
				 	 	 	 ."method (".$v_header['compression'].") ");
  return PclZip::errorCode();
		 }
	 }
	 if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
  $v_header['status'] = 'unsupported_encryption';
 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
		 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
  PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
			 "Unsupported encryption for "
				 	 	 	 ." filename '".$v_header['stored_filename']
								 ."'");
  return PclZip::errorCode();
		 }
	 }
 if (($v_extract) && ($v_header['status'] != 'ok')) {
  $v_result = $this->privConvertHeader2FileInfo($v_header,
		 $p_file_list[$v_nb_extracted++]);
 if ($v_result != 1) {
 $this->privCloseFd();
  return $v_result;
 }
 $v_extract = false;
 }
 if ($v_extract)
 {
   @rewind($this->zip_fd);
  if (@fseek($this->zip_fd, $v_header['offset']))
 {
 $this->privCloseFd();
 PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
  return PclZip::errorCode();
 }
  if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
 $v_result1 = $this->privExtractFileAsString($v_header, $v_string);
 if ($v_result1 < 1) {
 $this->privCloseFd();
  return $v_result1;
 }
 if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
 {
 $this->privCloseFd();
  return $v_result;
 }
 $p_file_list[$v_nb_extracted]['content'] = $v_string;
 $v_nb_extracted++;
 if ($v_result1 == 2) {
 	break;
 }
 }
 elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
		 && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
 $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
 if ($v_result1 < 1) {
 $this->privCloseFd();
  return $v_result1;
 }
 if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
 $this->privCloseFd();
  return $v_result;
 }
 if ($v_result1 == 2) {
 	break;
 }
 }
 else {
 $v_result1 = $this->privExtractFile($v_header,
		 $p_path, $p_remove_path,
											 $p_remove_all_path,
											 $p_options);
 if ($v_result1 < 1) {
 $this->privCloseFd();
  return $v_result1;
 }
 if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
 {
 $this->privCloseFd();
  return $v_result;
 }
 if ($v_result1 == 2) {
 	break;
 }
 }
 }
 }
 $this->privCloseFd();
  return $v_result;
 }
 function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
 {
  $v_result=1;
 if (($v_result = $this->privReadFileHeader($v_header)) != 1)
 {
  return $v_result;
 }
  if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
 }
 if ($p_remove_all_path == true) {
  $p_entry['filename'] = basename($p_entry['filename']);
 }
 else if ($p_remove_path != "")
 {
  if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
 {
  $p_entry['status'] = "filtered";
  return $v_result;
 }
 $p_remove_path_size = strlen($p_remove_path);
 if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
 {
  $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
  }
 }
 if ($p_path != '')
 {
 $p_entry['filename'] = $p_path."/".$p_entry['filename'];
 }
 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
  $v_local_header = array();
 $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
 eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
 if ($v_result == 0) {
 $p_entry['status'] = "skipped";
 $v_result = 1;
 }
 if ($v_result == 2) {
  $p_entry['status'] = "aborted";
 	$v_result = PCLZIP_ERR_USER_ABORTED;
 }
 $p_entry['filename'] = $v_local_header['filename'];
  }
  if ($p_entry['status'] == 'ok') {
 if (file_exists($p_entry['filename']))
 {
  if (is_dir($p_entry['filename']))
 {
  $p_entry['status'] = "already_a_directory";
 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
		 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
  PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
			 "Filename '".$p_entry['filename']."' is "
								 ."already used by an existing directory");
  return PclZip::errorCode();
		}
 }
 else if (!is_writeable($p_entry['filename']))
 {
  $p_entry['status'] = "write_protected";
 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
		 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
			 "Filename '".$p_entry['filename']."' exists "
								 ."and is write protected");
  return PclZip::errorCode();
		}
 }
 else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
 {
  if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
		 && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
 		}
		else {
  $p_entry['status'] = "newer_exist";
 if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
		 && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
  PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
			 "Newer version of '".$p_entry['filename']."' exists "
					 ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
  return PclZip::errorCode();
		 }
		}
 }
 else {
  }
 }
 else {
 if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
 $v_dir_to_check = $p_entry['filename'];
 else if (!strstr($p_entry['filename'], "/"))
 $v_dir_to_check = "";
 else
 $v_dir_to_check = dirname($p_entry['filename']);
 if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
  $p_entry['status'] = "path_creation_fail";
 $v_result = 1;
 }
 }
 }
 if ($p_entry['status'] == 'ok') {
 if (!(($p_entry['external']&0x00000010)==0x00000010))
 {
 if ($p_entry['compression'] == 0) {
  if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
 {
  $p_entry['status'] = "write_error";
  return $v_result;
 }
  $v_size = $p_entry['compressed_size'];
 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);
 $v_binary_data = pack('a'.$v_read_size, $v_buffer);
 @fwrite($v_dest_file, $v_binary_data, $v_read_size);
 $v_size -= $v_read_size;
 }
 fclose($v_dest_file);
 touch($p_entry['filename'], $p_entry['mtime']);
 }
 else {
  if (($p_entry['flag'] & 1) == 1) {
  }
 else {
  $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
 }
 $v_file_content = @gzinflate($v_buffer);
 unset($v_buffer);
 if ($v_file_content === FALSE) {
  $p_entry['status'] = "error";
  return $v_result;
 }
 if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
  $p_entry['status'] = "write_error";
  return $v_result;
 }
 @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
 unset($v_file_content);
 @fclose($v_dest_file);
 @touch($p_entry['filename'], $p_entry['mtime']);
 }
 if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
  @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
 }
  }
 }
	if ($p_entry['status'] == "aborted") {
 $p_entry['status'] = "skipped";
	}
 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
  $v_local_header = array();
 $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
 eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
 if ($v_result == 2) {
  	$v_result = PCLZIP_ERR_USER_ABORTED;
 }
 }
  return $v_result;
 }
 function privExtractFileInOutput(&$p_entry, &$p_options)
 {
  $v_result=1;
 if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
  return $v_result;
 }
  if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
 }
 if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
  $v_local_header = array();
 $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
 eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
 if ($v_result == 0) {
 $p_entry['status'] = "skipped";
 $v_result = 1;
 }
 if ($v_result == 2) {
  $p_entry['status'] = "aborted";
 	$v_result = PCLZIP_ERR_USER_ABORTED;
 }
 $p_entry['filename'] = $v_local_header['filename'];
  }
  if ($p_entry['status'] == 'ok') {
 if (!(($p_entry['external']&0x00000010)==0x00000010)) {
 if ($p_entry['compressed_size'] == $p_entry['size']) {
   $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
 echo $v_buffer;
 unset($v_buffer);
 }
 else {
   $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
 $v_file_content = gzinflate($v_buffer);
 unset($v_buffer);
 echo $v_file_content;
 unset($v_file_content);
 }
  }
 }
	if ($p_entry['status'] == "aborted") {
 $p_entry['status'] = "skipped";
	}
 elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
  $v_local_header = array();
 $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
 eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
 if ($v_result == 2) {
  	$v_result = PCLZIP_ERR_USER_ABORTED;
 }
 }
  return $v_result;
 }
 function privExtractFileAsString(&$p_entry, &$p_string)
 {
  $v_result=1;
 $v_header = array();
 if (($v_result = $this->privReadFileHeader($v_header)) != 1)
 {
  return $v_result;
 }
  if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
 }
  if (!(($p_entry['external']&0x00000010)==0x00000010))
 {
 if ($p_entry['compressed_size'] == $p_entry['size'])
 {
   $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
 }
 else
 {
  $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
 if (($p_string = @gzinflate($v_data)) === FALSE) {
 }
 }
  }
 else {
 }
  return $v_result;
 }
 function privReadFileHeader(&$p_header)
 {
  $v_result=1;
 $v_binary_data = @fread($this->zip_fd, 4);

⌨️ 快捷键说明

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