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

📄 pclzip.lib.php

📁 mambo的cms源代码
💻 PHP
📖 第 1 页 / 共 5 页
字号:
  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."]");      }    }  }  // --------------------------------------------------------------------------------// --------------------------------------------------------------------------------// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****// *****                                                        *****// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****// --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : privCheckFormat()  // Description :  //   This method check that the archive exists and is a valid zip archive.  //   Several level of check exists. (futur)  // Parameters :  //   $p_level : Level of check. Default 0.  //              0 : Check the first bytes (magic codes) (default value))  //              1 : 0 + Check the central directory (futur)  //              2 : 1 + Check each file header (futur)  // Return Values :  //   true on success,  //   false on error, the error code is set.  // --------------------------------------------------------------------------------  function privCheckFormat($p_level=0)  {    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");    $v_result = true;	// ----- Reset the file system cache    clearstatcache();    // ----- Reset the error handler    $this->privErrorReset();    // ----- Look if the file exits    if (!is_file($this->zipname)) {      // ----- Error log      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());      return(false);    }    // ----- Check that the file is readeable    if (!is_readable($this->zipname)) {      // ----- Error log      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());      return(false);    }    // ----- Check the magic code    // TBC    // ----- Check the central header    // TBC    // ----- Check each file header    // TBC    // ----- Return    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);    return $v_result;  }  // --------------------------------------------------------------------------------  // --------------------------------------------------------------------------------  // Function : privParseOptions()  // Description :  //   This internal methods reads the variable list of arguments ($p_options_list,  //   $p_size) and generate an array with the options and values ($v_result_list).  //   $v_requested_options contains the options that can be present and those that  //   must be present.  //   $v_requested_options is an array, with the option value as key, and 'optional',  //   or 'mandatory' as value.  // Parameters :  //   See above.  // Return Values :  //   1 on success.  //   0 on failure.  // --------------------------------------------------------------------------------  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)  {    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");    $v_result=1;    // ----- Read the options    $i=0;    while ($i<$p_size) {      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");      // ----- Check if the option is requested      if (!isset($v_requested_options[$p_options_list[$i]])) {        // ----- Error log        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");        // ----- Return        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());        return PclZip::errorCode();      }      // ----- Look for next option      switch ($p_options_list[$i]) {        // ----- Look for options that request a path value        case PCLZIP_OPT_PATH :        case PCLZIP_OPT_REMOVE_PATH :        case PCLZIP_OPT_ADD_PATH :          // ----- Check the number of parameters          if (($i+1) >= $p_size) {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          // ----- Get the value          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");          $i++;        break;        // ----- Look for options that request an array of string for value        case PCLZIP_OPT_BY_NAME :          // ----- Check the number of parameters          if (($i+1) >= $p_size) {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          // ----- Get the value          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 {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");          $i++;        break;        // ----- Look for options that request an EREG or PREG expression        case PCLZIP_OPT_BY_EREG :        case PCLZIP_OPT_BY_PREG :          // ----- Check the number of parameters          if (($i+1) >= $p_size) {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          // ----- Get the value          if (is_string($p_options_list[$i+1])) {              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];          }          else {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");          $i++;        break;        // ----- Look for options that takes a string        case PCLZIP_OPT_COMMENT :        case PCLZIP_OPT_ADD_COMMENT :        case PCLZIP_OPT_PREPEND_COMMENT :          // ----- Check the number of parameters          if (($i+1) >= $p_size) {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,			                     "Missing parameter value for option '"								 .PclZipUtilOptionText($p_options_list[$i])								 ."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          // ----- Get the value          if (is_string($p_options_list[$i+1])) {              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];          }          else {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,			                     "Wrong parameter value for option '"								 .PclZipUtilOptionText($p_options_list[$i])								 ."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");          $i++;        break;        // ----- Look for options that request an array of index        case PCLZIP_OPT_BY_INDEX :          // ----- Check the number of parameters          if (($i+1) >= $p_size) {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }          // ----- Get the value          $v_work_list = array();          if (is_string($p_options_list[$i+1])) {              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");              // ----- Remove spaces              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');              // ----- Parse items              $v_work_list = explode(",", $p_options_list[$i+1]);          }          else if (is_integer($p_options_list[$i+1])) {              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an 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])) {              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");              $v_work_list = $p_options_list[$i+1];          }          else {            // ----- Error log            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");            // ----- Return            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());            return PclZip::errorCode();          }                    // ----- Reduce the index list          // each index item in the list must be a couple with a start and          // an end value : [0,3], [5-5], [8-10], ...          // ----- Check the format of each item          $v_sort_flag=false;          $v_sort_value=0;          for ($j=0; $j<sizeof($v_work_list); $j++) {              // ----- Explode the item              $v_item_list = explode("-", $v_work_list[$j]);              $v_size_item_list = sizeof($v_item_list);                            // ----- TBC : Here we might check that each item is a              // real integer ...                            // ----- Look for single value              if ($v_size_item_list == 1) {                  // ----- Set the option value                  $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) {                  // ----- Set the option value                  $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 {                  // ----- Error log                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");                  // ----- Return                  //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());                  return PclZip::errorCode();              }              //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");              // ----- Look for list sort              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {                  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");                  $v_sort_flag=true;             

⌨️ 快捷键说明

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