function privDuplicate($p_archive_filename)
 {
     PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='{$p_archive_filename}'");
     $v_result = 1;
     // ----- Look if the $p_archive_filename exists
     if (!is_file($p_archive_filename)) {
         PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
         // ----- Nothing to duplicate, so duplicate is a success.
         $v_result = 1;
         // ----- Return
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Open the zip file
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
     if (($v_result = $this->privOpenFd('wb')) != 1) {
         // ----- Return
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Open the temporary file in write mode
     PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
     if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) {
         $this->privCloseFd();
         PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \'' . $p_archive_filename . '\' in binary write mode');
         // ----- Return
         PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
         return PclZip::errorCode();
     }
     // ----- Copy the files from the archive to the temporary file
     // TBC : Here I should better append the file and go back to erase the central dir
     $v_size = filesize($p_archive_filename);
     while ($v_size != 0) {
         $v_read_size = $v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE;
         PclTraceFctMessage(__FILE__, __LINE__, 5, "Read {$v_read_size} bytes");
         $v_buffer = fread($v_zip_temp_fd, $v_read_size);
         @fwrite($this->zip_fd, $v_buffer, $v_read_size);
         $v_size -= $v_read_size;
     }
     // ----- Close
     $this->privCloseFd();
     // ----- Close the temporary file
     @fclose($v_zip_temp_fd);
     // ----- Return
     PclTraceFctEnd(__FILE__, __LINE__, $v_result);
     return $v_result;
 }
예제 #2
0
  function privDirCheck($p_dir, $p_is_dir=false)
  {
    $v_result = 1;

    PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");

    // ----- Remove the final '/'
    if (($p_is_dir) && (substr($p_dir, -1)=='/'))
    {
      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
    }
    PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");

    // ----- Check the directory availability
    if ((is_dir($p_dir)) || ($p_dir == ""))
    {
      PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
      return 1;
    }

    // ----- Extract parent directory
    $p_parent_dir = dirname($p_dir);
    PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");

    // ----- Just a check
    if ($p_parent_dir != $p_dir)
    {
      // ----- Look for parent directory
      if ($p_parent_dir != "")
      {
        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
        {
          PclTraceFctEnd(__FILE__, __LINE__, $v_result);
          return $v_result;
        }
      }
    }

    // ----- Create the directory
    PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
    if (!@mkdir($p_dir, 0777))
    {
      // ----- Error log
      PclErrorLog(-8, "Unable to create directory '$p_dir'");

      // ----- Return
      PclTraceFctEnd(__FILE__, __LINE__, PclErrorCode(), PclErrorString());
      return PclErrorCode();
    }

    // ----- Return
    PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
    return $v_result;
  }
 function privSwapBackMagicQuotes()
 {
     PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
     $v_result = 1;
     // ----- Look if function exists
     if (!function_exists("get_magic_quotes_runtime") || !function_exists("set_magic_quotes_runtime")) {
         PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Look if something to do
     if ($this->magic_quotes_status != -1) {
         PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
         PclTraceFctEnd(__FILE__, __LINE__, $v_result);
         return $v_result;
     }
     // ----- Swap back magic_quotes
     if ($this->magic_quotes_status == 1) {
         PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
         @set_magic_quotes_runtime($this->magic_quotes_status);
     }
     // ----- Return
     PclTraceFctEnd(__FILE__, __LINE__, $v_result);
     return $v_result;
 }
 function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc)
 {
     PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=" . $p_size . "");
     $v_result = 1;
     // ----- To Be Modified ;-)
     $v_pwd = "test";
     $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header, $p_crc, $v_pwd);
     // ----- Return
     PclTraceFctEnd(__FILE__, __LINE__, $v_result);
     return $v_result;
 }