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

📄 pclzip.lib.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 5 页
字号:
  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function :  //	extractByIndex($p_index, $p_path="./", $p_remove_path="")  //	extractByIndex($p_index, [$p_option, $p_option_value, ...])  // Description :  //	This method supports two synopsis. The first one is historical.  //	This method is doing a partial extract of the archive.  //	The extracted files or folders are identified by their index in the  //	archive (from 0 to n).  //	Note that if the index identify a folder, only the folder entry is  //	extracted, not all the files included in the archive.  // Parameters :  //	$p_index : A single index (integer) or a string of indexes of files to  //  extract. The form of the string is "0,4-6,8-12" with only numbers  //  and '-' for range or ',' to separate ranges. No spaces or ';'  //  are allowed.  //	$p_path : Path where the files and directories are to be extracted  //	$p_remove_path : First part ('root' part) of the memorized path  //(if any similar) to remove while extracting.  // Options :  //	PCLZIP_OPT_PATH :  //	PCLZIP_OPT_ADD_PATH :  //	PCLZIP_OPT_REMOVE_PATH :  //	PCLZIP_OPT_REMOVE_ALL_PATH :  //	PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and  // not as files.  // The resulting content is in a new field 'content' in the file  // structure.  // This option must be used alone (any other options are ignored).  //	PCLZIP_CB_PRE_EXTRACT :  //	PCLZIP_CB_POST_EXTRACT :  // Return Values :  //	0 on failure,  //	The list of the extracted files, with a status of the action.  //	(see PclZip::listContent() for list entry format)  // --------------------------------------------------------------------------------  function extractByIndex($p_index /* $options */)  {//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");$v_result=1;// ----- Reset the error handler$this->privErrorReset();// ----- Check archiveif (!$this->privCheckFormat()) {  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  return(0);}// ----- Set default values$v_options = array();$v_path = "./";$v_remove_path = "";$v_remove_all_path = false;// ----- Look for variable options arguments$v_size = func_num_args();//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");// ----- Default values for option$v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;// ----- Look for argumentsif ($v_size > 1) {  // ----- Get the arguments  $v_arg_list = &func_get_args();  // ----- Remove form the options list the first argument  array_shift($v_arg_list);  $v_size--;  // ----- Look for first arg  if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");// ----- Parse the options$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,array (PCLZIP_OPT_PATH => 'optional',	PCLZIP_OPT_REMOVE_PATH => 'optional',	PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',	PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',	PCLZIP_OPT_ADD_PATH => 'optional',	PCLZIP_CB_PRE_EXTRACT => 'optional',	PCLZIP_CB_POST_EXTRACT => 'optional',	PCLZIP_OPT_SET_CHMOD => 'optional' ));if ($v_result != 1) {  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  return 0;}// ----- Set the argumentsif (isset($v_options[PCLZIP_OPT_PATH])) {  $v_path = $v_options[PCLZIP_OPT_PATH];}if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {  $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];}if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {  $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];}if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {  // ----- Check for '/' in last path char  if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {$v_path .= '/';  }  $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];}if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {  $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");}else {//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");}  }  // ----- Look for 2 args  // Here we need to support the first historic synopsis of the  // method.  else {//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");// ----- Get the first argument$v_path = $v_arg_list[0];// ----- Look for the optional second argumentif ($v_size == 2) {  $v_remove_path = $v_arg_list[1];}else if ($v_size > 2) {  // ----- Error log  PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");  // ----- Return  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());  return 0;}  }}// ----- Trace//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");// ----- Trick// Here I want to reuse extractByRule(), so I need to parse the $p_index// with privParseOptions()$v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);$v_options_trick = array();$v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,array (PCLZIP_OPT_BY_INDEX => 'optional' ));if ($v_result != 1) {//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);return 0;}$v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];// ----- Call the extracting fctif (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());return(0);}// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function :  //	delete([$p_option, $p_option_value, ...])  // Description :  // Parameters :  //	None  // Options :  //	PCLZIP_OPT_BY_INDEX :  // Return Values :  //	0 on failure,  //	The list of the files which are still present in the archive.  //	(see PclZip::listContent() for list entry format)  // --------------------------------------------------------------------------------  function delete(/* options */)  {//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");$v_result=1;// ----- Reset the error handler$this->privErrorReset();// ----- Check archiveif (!$this->privCheckFormat()) {  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  return(0);}// ----- Set default values$v_options = array();// ----- Look for variable options arguments$v_size = func_num_args();//--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");// ----- Look for no argumentsif ($v_size <= 0) {// ----- Error logPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing arguments");// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());return 0;}// ----- Get the arguments$v_arg_list = &func_get_args();// ----- Parse the options$v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,array (PCLZIP_OPT_BY_NAME => 'optional',	PCLZIP_OPT_BY_EREG => 'optional',	PCLZIP_OPT_BY_PREG => 'optional',	PCLZIP_OPT_BY_INDEX => 'optional' ));if ($v_result != 1) {//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);return 0;}// ----- Check that at least one rule is setif (	(!isset($v_options[PCLZIP_OPT_BY_NAME]))&& (!isset($v_options[PCLZIP_OPT_BY_EREG]))&& (!isset($v_options[PCLZIP_OPT_BY_PREG]))&& (!isset($v_options[PCLZIP_OPT_BY_INDEX]))) {// ----- Error logPclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "At least one filtering rule must be set");// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());return 0;}// ----- Call the delete fct$v_list = array();if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1){  unset($v_list);  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());  return(0);}// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);return $v_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : deleteByIndex()  // Description :  //	***** Deprecated *****  //	delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.  // --------------------------------------------------------------------------------  function deleteByIndex($p_index)  {//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");$p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);return $p_list;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : properties()  // Description :  //	This method gives the properties of the archive.  //	The properties are :  // nb : Number of files in the archive  // comment : Comment associated with the archive file  // status : not_exist, ok  // Parameters :  //	None  // Return Values :  //	0 on failure,  //	An array with the archive properties.  // --------------------------------------------------------------------------------  function properties()  {//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");// ----- Reset the error handler$this->privErrorReset();// ----- Check archiveif (!$this->privCheckFormat()) {  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);  return(0);}// ----- Default properties$v_prop = array();$v_prop['comment'] = '';$v_prop['nb'] = 0;$v_prop['status'] = 'not_exist';// ----- Look if file existsif (@is_file($this->zipname)){  // ----- Open the zip file  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");  if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)  {// ----- Error logPclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);return 0;  }  // ----- Read the central directory informations  $v_central_dir = array();  if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)  {//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);return 0;  }  // ----- Close the zip file  $this->privCloseFd();  // ----- Set the user attributes  $v_prop['comment'] = $v_central_dir['comment'];  $v_prop['nb'] = $v_central_dir['entries'];  $v_prop['status'] = 'ok';}// ----- Return//--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);return $v_prop;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : duplicate()  // Description :  //	This method creates an archive by copying the content of an other one. If  //	the archive already exist, it is replaced by the new one without any warning.  // Parameters :  //	$p_archive : The filename of a valid archive, or  //a valid PclZip object.  // Return Values :  //	1 on success.  //	0 or a negative value on error (error code).  // --------------------------------------------------------------------------------  function duplicate($p_archive)  {//--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");$v_result = 1;// ----- Reset the error handler$this->privErrorReset();

⌨️ 快捷键说明

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