How do you Unzip file with PHP???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

How do you Unzip file with PHP???

Post by tstimple »

Hello to all,

I have tried several times in the past to find a solution to this. It should be simple.
I want to code a PHP page to unzip a file that has been transferred to my site. Here are the parameters:

1. I DO NOT have access to the servers (this is a hosted site).
2. PHP INFO() shows that the '--with-zlib' is enabled
3. The directory containing the zip file has chmod to 777


What code (class) etc. do I need to use to do this?

I have tried using the pclzip.lib.php class as mentioned in the PHP manual and nothing seems to happen
code looks like this:

Code: Select all

<?php
  require_once('pclzip.lib.php');
  $archive = new PclZip('uploads/peachsam.zip');
  $archive->extract();
	if ($archive->extract() == 0) {
	die("Error : ".$archive->errorInfo(true));
	}
?>
No error info is generated (it seems to ignore the code all together)
Any alternative suggestions would be GREATLY appreciated.
Thanks,
--Tim
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

make sure error reporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the archive twice. I'd store the return from the first one (line 4) ..porting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you haporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
error_reporting(E_ALL);
ini_set('display_errors','1');

next, you have asked pclzip to extractporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the archive twice. I'errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the archive twice. I'd store the return from _set('display_errors','1');

next, you have asked pclzporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the aporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');[/phpporting is on full and display errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the archive twice. I'd store the return from the first one (line 4) .. the return from the first one (line 4) .. errors is on:

Code: Select all

error_reporting(E_ALL);
ini_set('display_errors','1');
next, you have asked pclzip to extract the archive twice. I'd store the return from the first one (line 4) ..ting(E_ALL);
ini_set('display_errors','1');

next, you have asked pcerror_reporting(E_ALL);
ini_set('display_errors','1');

next, you have asked pclzip to extract the archive twice. I'd store the return from the first one (line 4) ..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

show us the extract function..
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

the extract function

Post by tstimple »

Ok Phenom,

Here is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this->privErrorReset();

    // ----- Check archive
    if (!$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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remov is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------------------------------------------------------------------

?&amp is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // ---------------------------------------------------------- is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------------------------------------------------------------------

?&gt;[/php is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------------------------------------------------------------------

?&gt;[/php is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------------------------------------------------------------------

?&gt;
I am fairly new te pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // ----------------------------------------------------ly a small section of the entire lib...

Code: Select all

<?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
                                                   PCLZIP_OPT_BY_EREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_PREG =&gt; 'optional',
                                                   PCLZIP_OPT_BY_INDEX =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING =&gt; 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT =&gt; 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (isset($v_options&#1111;PCLZIP_OPT_PATH])) {
          $v_path = $v_options&#1111;PCLZIP_OPT_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_PATH])) {
          $v_remove_path = $v_options&#1111;PCLZIP_OPT_REMOVE_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH])) {
          $v_remove_all_path = $v_options&#1111;PCLZIP_OPT_REMOVE_ALL_PATH];
        }
        if (isset($v_options&#1111;PCLZIP_OPT_ADD_PATH])) {
          // ----- Check for '/' in last path char
          if ((strlen($v_path) &gt; 0) &amp;&amp; (substr($v_path, -1) != '/')) {
            $v_path .= '/';
          }
          $v_path .= $v_options&#1111;PCLZIP_OPT_ADD_PATH];
        }
      }

      // ----- 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&#1111;0];

        // ----- Look for the optional second argument
        if ($v_size == 2) {
          $v_remove_path = $v_arg_list&#1111;1];
        }
        else if ($v_size &gt; 2) {
          // ----- Error log
          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");

          // ----- Return
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this-&gt;privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result &lt; 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------- is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

<?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract([$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this->privErrorReset();

    // ----- Check archive
    if (!$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 arguments
    if ($v_size > 0) {
      // ----- Get the arguments
      $v_arg_list = &func_get_args();

      // ----- 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_ADD_PATH => 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
                                                   PCLZIP_OPT_BY_NAME => 'optional',
                                                   PCLZIP_OPT_BY_EREG => 'optional',
                                                   PCLZIP_OPT_BY_PREG => 'optional',
                                                   PCLZIP_OPT_BY_INDEX => 'optional',
                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional' ));
        if ($v_result != 1) {
          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
          return 0;
        }

        // ----- Set the arguments
        if (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];
        }
      }

      // ----- 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 argument
        if ($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__, 0, PclZip::errorInfo());
          return 0;
        }
      }
    }

    // ----- Trace
    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");

    // ----- Call the extracting fct
    $p_list = array();
    $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
	                                     $v_remove_all_path, $v_options);
    if ($v_result < 1) {
      unset($p_list);
      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
      return(0);
    }

    // ----- Return
    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
    return $p_list;
  }
  // --------------------------------------------------------------------------------

?>
I is the section of code from the pcl.zip.lib that concerns the extract funtion (this is only a small section of the entire lib...

Code: Select all

&lt;?php
  // --------------------------------------------------------------------------------
  // Function :
  //   extract($p_path="./", $p_remove_path="")
  //   extract(&#1111;$p_option, $p_option_value, ...])
  // Description :
  //   This method supports two synopsis. The first one is historical.
  //   This method extract all the files / directories from the archive to the
  //   folder indicated in $p_path.
  //   If you want to ignore the 'root' part of path of the memorized files
  //   you can indicate this in the optional $p_remove_path parameter.
  //   By default, if a newer file with the same name already exists, the
  //   file is not extracted.
  //
  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
  //   at the end of the path value of PCLZIP_OPT_PATH.
  // Parameters :
  //   $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_CB_PRE_EXTRACT :
  //   PCLZIP_CB_POST_EXTRACT :
  // Return Values :
  //   0 or a negative value on failure,
  //   The list of the extracted files, with a status of the action.
  //   (see PclZip::listContent() for list entry format)
  // --------------------------------------------------------------------------------
  //function extract($p_path="./", $p_remove_path="")
  function extract(/* options */)
  {
    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
    $v_result=1;

    // ----- Reset the error handler
    $this-&gt;privErrorReset();

    // ----- Check archive
    if (!$this-&gt;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&#1111;PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;

    // ----- Look for arguments
    if ($v_size &gt; 0) {
      // ----- Get the arguments
      $v_arg_list = &amp;func_get_args();

      // ----- Look for first arg
      if ((is_integer($v_arg_list&#1111;0])) &amp;&amp; ($v_arg_list&#1111;0] &gt; 77000)) {
        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");

        // ----- Parse the options
        $v_result = $this-&gt;privParseOptions($v_arg_list, $v_size, $v_options,
                                            array (PCLZIP_OPT_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_REMOVE_ALL_PATH =&gt; 'optional',
                                                   PCLZIP_OPT_ADD_PATH =&gt; 'optional',
                                                   PCLZIP_CB_PRE_EXTRACT =&gt; 'optional',
                                                   PCLZIP_CB_POST_EXTRACT =&gt; 'optional',
                                                   PCLZIP_OPT_SET_CHMOD =&gt; 'optional',
                                                   PCLZIP_OPT_BY_NAME =&gt; 'optional',
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

did changing your error reporting display any notices/errorS?
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Post by tstimple »

No. I added the suggested code and still no error displayed.
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Post by tstimple »

ALSO...

From the PHP manual:


Requirements
This module uses the functions of the ZZIPlib library by Guido Draheim. You need ZZIPlib version >= 0.10.6.

Note that ZZIPlib only provides a subset of functions provided in a full implementation of the ZIP compression algorithm and can only read ZIP file archives. A normal ZIP utility is needed to create the ZIP file archives read by this library.


--------------------------------------------------------------------------------

Installation
This PECL extension is not bundled with PHP. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here: http://pecl.php.net/package/zip.

In PHP 4 this PECL extensions source can be found in the ext/ directory within the PHP source or at the PECL link above. In order to use these functions you must compile PHP with zip support by using the --with-zip[=DIR] configure option.

Windows users will enable php_zip.dll inside of php.ini in order to use these functions. In PHP 4 this DLL resides in the extensions/ directory within the PHP Windows binaries download. You may download this PECL extensions DLL from the PHP Downloads page or at http://snaps.php.net/.

Note: Zip support before PHP 4.1.0 is experimental. This section reflects the Zip extension as it exists in PHP 4.1.0 and later.

-------------------------------------------------------------------

Because I do not have install rights on the hosted site, I cannot implement this.
Is there any other way to unzip???
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

Of course there is: Nicely ask your host to install it.
tstimple
Forum Commoner
Posts: 53
Joined: Wed Jan 21, 2004 10:12 pm

Post by tstimple »

I have tried asking (several times).
The only response I get is
"We're sorry, that module is not supported at this time..."

:(
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

time to start looking into your own implementation or find a php sourced class that'll do it.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Threaten to leave their service and mention you'll tell others about their poor customer service skills.

That'll get their mojo running. :twisted:
Post Reply