<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[11993] trunk/wp-admin/includes/class-pclzip.php: Update pclzip to 2.8.
2 - Fixes #10650 and #10777.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/11993">11993</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2009-10-01 21:04:57 +0000 (Thu, 01 Oct 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update pclzip to 2.8.2 - Fixes <a href="http://trac.wordpress.org/ticket/10650">#10650</a> and <a href="http://trac.wordpress.org/ticket/10777">#10777</a>.
Includes:
* Removal of eval()s
* Merge WordPress 64 bit fix upstream</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesclasspclzipphp">trunk/wp-admin/includes/class-pclzip.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesclasspclzipphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/class-pclzip.php (11992 => 11993)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/class-pclzip.php        2009-10-01 19:59:35 UTC (rev 11992)
+++ trunk/wp-admin/includes/class-pclzip.php        2009-10-01 21:04:57 UTC (rev 11993)
</span><span class="lines">@@ -1,8 +1,8 @@
</span><span class="cx"> <?php
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><del>-// PhpConcept Library - Zip Module 2.8
</del><ins>+// PhpConcept Library - Zip Module 2.8.2
</ins><span class="cx"> // --------------------------------------------------------------------------------
</span><del>-// License GNU/LGPL - Vincent Blavet - March 2006
</del><ins>+// License GNU/LGPL - Vincent Blavet - August 2009
</ins><span class="cx"> // http://www.phpconcept.net
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> //
</span><span class="lines">@@ -22,14 +22,14 @@
</span><span class="cx"> // The use of this software is at the risk of the user.
</span><span class="cx"> //
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><del>-// $Id: pclzip.lib.php,v 1.55 2009/04/22 07:38:36 vblavet Exp $
</del><ins>+// $Id: pclzip.lib.php,v 1.60 2009/09/30 21:01:04 vblavet Exp $
</ins><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx">
</span><span class="cx"> // ----- Constants
</span><span class="cx"> if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
</span><span class="cx"> define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- File list separator
</span><span class="cx"> // In version 1.x of PclZip, the separator for file list is a space
</span><span class="cx"> // (which is not a very smart choice, specifically for windows paths !).
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx">
</span><span class="cx"> // ----- Optional threshold ratio for use of temporary files
</span><span class="cx"> // Pclzip sense the size of the file to add/extract and decide to
</span><del>- // use or not temporary file. The algorythm is looking for
</del><ins>+ // use or not temporary file. The algorythm is looking for
</ins><span class="cx"> // memory_limit of PHP and apply a ratio.
</span><span class="cx"> // threshold = memory_limit * ratio.
</span><span class="cx"> // Recommended values are under 0.5. Default 0.47.
</span><span class="lines">@@ -83,7 +83,7 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx">
</span><span class="cx"> // ----- Global variables
</span><del>- $g_pclzip_version = "2.8";
</del><ins>+ $g_pclzip_version = "2.8.2";
</ins><span class="cx">
</span><span class="cx"> // ----- Error codes
</span><span class="cx"> // -1 : Unable to open file in binary write mode
</span><span class="lines">@@ -152,7 +152,7 @@
</span><span class="cx"> define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
</span><span class="cx"> define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
</span><span class="cx"> define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- File description attributes
</span><span class="cx"> define( 'PCLZIP_ATT_FILE_NAME', 79001 );
</span><span class="cx"> define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx"> // ----- Internal error handling
</span><span class="cx"> var $error_code = 1;
</span><span class="cx"> var $error_string = '';
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Current status of the magic_quotes_runtime
</span><span class="cx"> // This value store the php configuration for magic_quotes
</span><span class="cx"> // The class can then disable the magic_quotes and reset it after
</span><span class="lines">@@ -214,12 +214,10 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZip($p_zipname)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
</del><span class="cx">
</span><span class="cx"> // ----- Tests the zlib
</span><span class="cx"> if (!function_exists('gzopen'))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
</del><span class="cx"> die('Abort '.basename(__FILE__).' : Missing zlib extensions');
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -229,7 +227,6 @@
</span><span class="cx"> $this->magic_quotes_status = -1;
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
</del><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -273,7 +270,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function create($p_filelist)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -285,7 +281,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for variable options arguments
</span><span class="cx"> $v_size = func_num_args();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
</del><span class="cx">
</span><span class="cx"> // ----- Look for arguments
</span><span class="cx"> if ($v_size > 1) {
</span><span class="lines">@@ -298,7 +293,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for first arg
</span><span class="cx"> if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
</del><span class="cx">
</span><span class="cx"> // ----- Parse the options
</span><span class="cx"> $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
</span><span class="lines">@@ -315,7 +309,6 @@
</span><span class="cx"> //, PCLZIP_OPT_CRYPT => 'optional'
</span><span class="cx"> ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -324,7 +317,6 @@
</span><span class="cx"> // Here we need to support the first historic synopsis of the
</span><span class="cx"> // method.
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
</del><span class="cx">
</span><span class="cx"> // ----- Get the first argument
</span><span class="cx"> $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
</span><span class="lines">@@ -336,12 +328,11 @@
</span><span class="cx"> else if ($v_size > 2) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
</span><span class="cx">                  "Invalid number / type of arguments");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for default option values
</span><span class="cx"> $this->privOptionDefaultThreshold($v_options);
</span><span class="cx">
</span><span class="lines">@@ -350,16 +341,16 @@
</span><span class="cx"> $v_att_list = array();
</span><span class="cx"> $v_filedescr_list = array();
</span><span class="cx"> $p_result_list = array();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look if the $p_filelist is really an array
</span><span class="cx"> if (is_array($p_filelist)) {
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look if the first element is also an array
</span><span class="cx"> // This will mean that this is a file description entry
</span><span class="cx"> if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
</span><span class="cx"> $v_att_list = $p_filelist;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- The list is a list of string names
</span><span class="cx"> else {
</span><span class="cx"> $v_string_list = $p_filelist;
</span><span class="lines">@@ -375,10 +366,9 @@
</span><span class="cx"> // ----- Invalid variable type for $p_filelist
</span><span class="cx"> else {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Reformat the string list
</span><span class="cx"> if (sizeof($v_string_list) != 0) {
</span><span class="cx"> foreach ($v_string_list as $v_string) {
</span><span class="lines">@@ -386,11 +376,10 @@
</span><span class="cx"> $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- For each file in the list check the attributes
</span><span class="cx"> $v_supported_attributes
</span><span class="cx"> = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
</span><span class="lines">@@ -406,7 +395,6 @@
</span><span class="cx"> $v_options,
</span><span class="cx"> $v_supported_attributes);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -414,19 +402,16 @@
</span><span class="cx"> // ----- Expand the filelist (expand directories)
</span><span class="cx"> $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Call the create fct
</span><span class="cx"> $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
</del><span class="cx"> return $p_result_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -468,7 +453,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function add($p_filelist)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -480,7 +464,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for variable options arguments
</span><span class="cx"> $v_size = func_num_args();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
</del><span class="cx">
</span><span class="cx"> // ----- Look for arguments
</span><span class="cx"> if ($v_size > 1) {
</span><span class="lines">@@ -493,7 +476,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for first arg
</span><span class="cx"> if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
</del><span class="cx">
</span><span class="cx"> // ----- Parse the options
</span><span class="cx"> $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
</span><span class="lines">@@ -512,7 +494,6 @@
</span><span class="cx"> //, PCLZIP_OPT_CRYPT => 'optional'
</span><span class="cx">                                                                                                  ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -521,7 +502,6 @@
</span><span class="cx"> // Here we need to support the first historic synopsis of the
</span><span class="cx"> // method.
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
</del><span class="cx">
</span><span class="cx"> // ----- Get the first argument
</span><span class="cx"> $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
</span><span class="lines">@@ -535,7 +515,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -549,16 +528,16 @@
</span><span class="cx"> $v_att_list = array();
</span><span class="cx"> $v_filedescr_list = array();
</span><span class="cx"> $p_result_list = array();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look if the $p_filelist is really an array
</span><span class="cx"> if (is_array($p_filelist)) {
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look if the first element is also an array
</span><span class="cx"> // This will mean that this is a file description entry
</span><span class="cx"> if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
</span><span class="cx"> $v_att_list = $p_filelist;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- The list is a list of string names
</span><span class="cx"> else {
</span><span class="cx"> $v_string_list = $p_filelist;
</span><span class="lines">@@ -574,17 +553,16 @@
</span><span class="cx"> // ----- Invalid variable type for $p_filelist
</span><span class="cx"> else {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Reformat the string list
</span><span class="cx"> if (sizeof($v_string_list) != 0) {
</span><span class="cx"> foreach ($v_string_list as $v_string) {
</span><span class="cx"> $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- For each file in the list check the attributes
</span><span class="cx"> $v_supported_attributes
</span><span class="cx"> = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
</span><span class="lines">@@ -600,7 +578,6 @@
</span><span class="cx"> $v_options,
</span><span class="cx"> $v_supported_attributes);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -608,19 +585,16 @@
</span><span class="cx"> // ----- Expand the filelist (expand directories)
</span><span class="cx"> $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Call the create fct
</span><span class="cx"> $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
</del><span class="cx"> return $p_result_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -668,7 +642,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function listContent()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -676,7 +649,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -685,12 +657,10 @@
</span><span class="cx"> if (($v_result = $this->privList($p_list)) != 1)
</span><span class="cx"> {
</span><span class="cx"> unset($p_list);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
</del><span class="cx"> return $p_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -729,7 +699,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function extract()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -737,7 +706,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -750,7 +718,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for variable options arguments
</span><span class="cx"> $v_size = func_num_args();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
</del><span class="cx">
</span><span class="cx"> // ----- Default values for option
</span><span class="cx"> $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
</span><span class="lines">@@ -762,7 +729,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for first arg
</span><span class="cx"> if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
</del><span class="cx">
</span><span class="cx"> // ----- Parse the options
</span><span class="cx"> $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
</span><span class="lines">@@ -787,7 +753,6 @@
</span><span class="cx"> PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
</span><span class="cx">                                                                                                  ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -814,7 +779,6 @@
</span><span class="cx"> // Here we need to support the first historic synopsis of the
</span><span class="cx"> // method.
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
</del><span class="cx">
</span><span class="cx"> // ----- Get the first argument
</span><span class="cx"> $v_path = $v_arg_list[0];
</span><span class="lines">@@ -828,7 +792,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -838,7 +801,6 @@
</span><span class="cx"> $this->privOptionDefaultThreshold($v_options);
</span><span class="cx">
</span><span class="cx"> // ----- Trace
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
</del><span class="cx">
</span><span class="cx"> // ----- Call the extracting fct
</span><span class="cx"> $p_list = array();
</span><span class="lines">@@ -846,12 +808,10 @@
</span><span class="cx">          $v_remove_all_path, $v_options);
</span><span class="cx"> if ($v_result < 1) {
</span><span class="cx"> unset($p_list);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
</del><span class="cx"> return $p_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -896,7 +856,6 @@
</span><span class="cx"> //function extractByIndex($p_index, options...)
</span><span class="cx"> function extractByIndex($p_index)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -904,7 +863,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -917,7 +875,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for variable options arguments
</span><span class="cx"> $v_size = func_num_args();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
</del><span class="cx">
</span><span class="cx"> // ----- Default values for option
</span><span class="cx"> $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
</span><span class="lines">@@ -933,7 +890,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for first arg
</span><span class="cx"> if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
</del><span class="cx">
</span><span class="cx"> // ----- Parse the options
</span><span class="cx"> $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
</span><span class="lines">@@ -953,7 +909,6 @@
</span><span class="cx"> PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
</span><span class="cx">                                                                                                  ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -976,10 +931,8 @@
</span><span class="cx"> }
</span><span class="cx"> if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
</span><span class="cx"> $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
</del><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -987,7 +940,6 @@
</span><span class="cx"> // Here we need to support the first historic synopsis of the
</span><span class="cx"> // method.
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
</del><span class="cx">
</span><span class="cx"> // ----- Get the first argument
</span><span class="cx"> $v_path = $v_arg_list[0];
</span><span class="lines">@@ -1001,14 +953,12 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Trace
</span><del>- //--(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')."'");
</del><span class="cx">
</span><span class="cx"> // ----- Trick
</span><span class="cx"> // Here I want to reuse extractByRule(), so I need to parse the $p_index
</span><span class="lines">@@ -1018,7 +968,6 @@
</span><span class="cx"> $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
</span><span class="cx"> array (PCLZIP_OPT_BY_INDEX => 'optional' ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
</span><span class="lines">@@ -1028,12 +977,10 @@
</span><span class="cx">
</span><span class="cx"> // ----- Call the extracting fct
</span><span class="cx"> if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
</del><span class="cx"> return $p_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1049,7 +996,7 @@
</span><span class="cx"> // Options :
</span><span class="cx"> // PCLZIP_OPT_BY_INDEX :
</span><span class="cx"> // PCLZIP_OPT_BY_NAME :
</span><del>- // PCLZIP_OPT_BY_EREG :
</del><ins>+ // PCLZIP_OPT_BY_EREG :
</ins><span class="cx"> // PCLZIP_OPT_BY_PREG :
</span><span class="cx"> // Return Values :
</span><span class="cx"> // 0 on failure,
</span><span class="lines">@@ -1058,7 +1005,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function delete()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -1066,7 +1012,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1075,7 +1020,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for variable options arguments
</span><span class="cx"> $v_size = func_num_args();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
</del><span class="cx">
</span><span class="cx"> // ----- Look for arguments
</span><span class="cx"> if ($v_size > 0) {
</span><span class="lines">@@ -1089,7 +1033,6 @@
</span><span class="cx"> PCLZIP_OPT_BY_PREG => 'optional',
</span><span class="cx"> PCLZIP_OPT_BY_INDEX => 'optional' ));
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -1102,7 +1045,6 @@
</span><span class="cx"> if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx"> unset($v_list);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1110,7 +1052,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
</del><span class="cx"> return $v_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1123,12 +1064,10 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function deleteByIndex($p_index)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
-
</del><ins>+
</ins><span class="cx"> $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
</del><span class="cx"> return $p_list;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1149,7 +1088,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function properties()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
</del><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="cx"> $this->privErrorReset();
</span><span class="lines">@@ -1160,7 +1098,6 @@
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1174,16 +1111,14 @@
</span><span class="cx"> if (@is_file($this->zipname))
</span><span class="cx"> {
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1192,7 +1127,6 @@
</span><span class="cx"> if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1209,7 +1143,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
</del><span class="cx"> return $v_prop;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1228,7 +1161,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function duplicate($p_archive)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
</del><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -1237,7 +1169,6 @@
</span><span class="cx"> // ----- Look if the $p_archive is a PclZip object
</span><span class="cx"> if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
</del><span class="cx">
</span><span class="cx"> // ----- Duplicate the archive
</span><span class="cx"> $v_result = $this->privDuplicate($p_archive->zipname);
</span><span class="lines">@@ -1246,7 +1177,6 @@
</span><span class="cx"> // ----- Look if the $p_archive is a string (so a filename)
</span><span class="cx"> else if (is_string($p_archive))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
</del><span class="cx">
</span><span class="cx"> // ----- Check that $p_archive is a valid zip file
</span><span class="cx"> // TBC : Should also check the archive format
</span><span class="lines">@@ -1270,7 +1200,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1291,7 +1220,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function merge($p_archive_to_add)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
</del><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> // ----- Reset the error handler
</span><span class="lines">@@ -1299,14 +1227,12 @@
</span><span class="cx">
</span><span class="cx"> // ----- Check archive
</span><span class="cx"> if (!$this->privCheckFormat()) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
</del><span class="cx"> return(0);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look if the $p_archive_to_add is a PclZip object
</span><span class="cx"> if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
</del><span class="cx">
</span><span class="cx"> // ----- Merge the archive
</span><span class="cx"> $v_result = $this->privMerge($p_archive_to_add);
</span><span class="lines">@@ -1315,7 +1241,6 @@
</span><span class="cx"> // ----- Look if the $p_archive_to_add is a string (so a filename)
</span><span class="cx"> else if (is_string($p_archive_to_add))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
</del><span class="cx">
</span><span class="cx"> // ----- Create a temporary archive
</span><span class="cx"> $v_object_archive = new PclZip($p_archive_to_add);
</span><span class="lines">@@ -1333,7 +1258,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1448,7 +1372,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privCheckFormat($p_level=0)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
</del><span class="cx"> $v_result = true;
</span><span class="cx">
</span><span class="cx">         // ----- Reset the file system cache
</span><span class="lines">@@ -1461,7 +1384,6 @@
</span><span class="cx"> if (!is_file($this->zipname)) {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
</del><span class="cx"> return(false);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1469,7 +1391,6 @@
</span><span class="cx"> if (!is_readable($this->zipname)) {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
</del><span class="cx"> return(false);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1483,7 +1404,6 @@
</span><span class="cx"> // TBC
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1505,13 +1425,11 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Read the options
</span><span class="cx"> $i=0;
</span><span class="cx"> while ($i<$p_size) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
</del><span class="cx">
</span><span class="cx"> // ----- Check if the option is supported
</span><span class="cx"> if (!isset($v_requested_options[$p_options_list[$i]])) {
</span><span class="lines">@@ -1519,7 +1437,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1535,13 +1452,11 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get the value
</span><span class="cx"> $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1549,28 +1464,24 @@
</span><span class="cx"> // ----- Check the number of parameters
</span><span class="cx"> if (($i+1) >= $p_size) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check for incompatible options
</span><span class="cx"> if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check the value
</span><span class="cx"> $v_value = $p_options_list[$i+1];
</span><span class="cx"> if ((!is_integer($v_value)) || ($v_value<0)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get the value (and convert it in bytes)
</span><span class="cx"> $v_result_list[$p_options_list[$i]] = $v_value*1048576;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1578,30 +1489,25 @@
</span><span class="cx"> // ----- Check for incompatible options
</span><span class="cx"> if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> $v_result_list[$p_options_list[$i]] = true;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case PCLZIP_OPT_TEMP_FILE_OFF :
</span><span class="cx"> // ----- Check for incompatible options
</span><span class="cx"> if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> // ----- Check for incompatible options
</span><span class="cx"> if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> $v_result_list[$p_options_list[$i]] = true;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
</span><span class="lines">@@ -1611,7 +1517,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1619,11 +1524,9 @@
</span><span class="cx"> if ( is_string($p_options_list[$i+1])
</span><span class="cx"> && ($p_options_list[$i+1] != '')) {
</span><span class="cx"> $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored.");
</del><span class="cx"> }
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1635,7 +1538,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1651,15 +1553,16 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> // ----- Look for options that request an EREG or PREG expression
</span><span class="cx"> case PCLZIP_OPT_BY_EREG :
</span><ins>+ // ereg() is deprecated starting with PHP 5.3. Move PCLZIP_OPT_BY_EREG
+ // to PCLZIP_OPT_BY_PREG
+ $p_options_list[$i] = PCLZIP_OPT_BY_PREG;
</ins><span class="cx"> case PCLZIP_OPT_BY_PREG :
</span><span class="cx"> //case PCLZIP_OPT_CRYPT :
</span><span class="cx"> // ----- Check the number of parameters
</span><span class="lines">@@ -1668,7 +1571,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1681,10 +1583,8 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1701,7 +1601,6 @@
</span><span class="cx">                                                                  ."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1717,10 +1616,8 @@
</span><span class="cx">                                                                  ."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1732,14 +1629,12 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get the value
</span><span class="cx"> $v_work_list = array();
</span><span class="cx"> if (is_string($p_options_list[$i+1])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
</del><span class="cx">
</span><span class="cx"> // ----- Remove spaces
</span><span class="cx"> $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
</span><span class="lines">@@ -1748,11 +1643,9 @@
</span><span class="cx"> $v_work_list = explode(",", $p_options_list[$i+1]);
</span><span class="cx"> }
</span><span class="cx"> else if (is_integer($p_options_list[$i+1])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
</del><span class="cx"> $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
</span><span class="cx"> }
</span><span class="cx"> else if (is_array($p_options_list[$i+1])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
</del><span class="cx"> $v_work_list = $p_options_list[$i+1];
</span><span class="cx"> }
</span><span class="cx"> else {
</span><span class="lines">@@ -1760,10 +1653,9 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Reduce the index list
</span><span class="cx"> // each index item in the list must be a couple with a start and
</span><span class="cx"> // an end value : [0,3], [5-5], [8-10], ...
</span><span class="lines">@@ -1774,10 +1666,10 @@
</span><span class="cx"> // ----- Explode the item
</span><span class="cx"> $v_item_list = explode("-", $v_work_list[$j]);
</span><span class="cx"> $v_size_item_list = sizeof($v_item_list);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- TBC : Here we might check that each item is a
</span><span class="cx"> // real integer ...
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for single value
</span><span class="cx"> if ($v_size_item_list == 1) {
</span><span class="cx"> // ----- Set the option value
</span><span class="lines">@@ -1794,15 +1686,12 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(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']."]");
</del><span class="cx">
</span><span class="cx"> // ----- Look for list sort
</span><span class="cx"> if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
</del><span class="cx"> $v_sort_flag=true;
</span><span class="cx">
</span><span class="cx"> // ----- TBC : An automatic sort should be writen ...
</span><span class="lines">@@ -1810,16 +1699,14 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Sort the items
</span><span class="cx"> if ($v_sort_flag) {
</span><span class="cx"> // TBC : To Be Completed
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Next option
</span><span class="lines">@@ -1834,7 +1721,6 @@
</span><span class="cx"> case PCLZIP_OPT_REPLACE_NEWER :
</span><span class="cx"> case PCLZIP_OPT_STOP_ON_ERROR :
</span><span class="cx"> $v_result_list[$p_options_list[$i]] = true;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> // ----- Look for options that request an octal value
</span><span class="lines">@@ -1845,13 +1731,11 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get the value
</span><span class="cx"> $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
</del><span class="cx"> $i++;
</span><span class="cx"> break;
</span><span class="cx">
</span><span class="lines">@@ -1872,13 +1756,11 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get the value
</span><span class="cx"> $v_function_name = $p_options_list[$i+1];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check that the value is a valid existing function
</span><span class="cx"> if (!function_exists($v_function_name)) {
</span><span class="lines">@@ -1886,7 +1768,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1902,7 +1783,6 @@
</span><span class="cx">                                                          .$p_options_list[$i]."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1915,28 +1795,24 @@
</span><span class="cx"> for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
</span><span class="cx"> // ----- Look for mandatory option
</span><span class="cx"> if ($v_requested_options[$key] == 'mandatory') {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
</del><span class="cx"> // ----- Look if present
</span><span class="cx"> if (!isset($v_result_list[$key])) {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for default values
</span><span class="cx"> if (!isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Calculate auto threshold");
-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -1949,21 +1825,18 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privOptionDefaultThreshold(&$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOptionDefaultThreshold", "");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
</span><span class="cx"> || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>-
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Create an auto-threshold for use of temporay files");
</del><ins>+
</ins><span class="cx"> // ----- Get 'memory_limit' configuration value
</span><span class="cx"> $v_memory_limit = ini_get('memory_limit');
</span><span class="cx"> $v_memory_limit = trim($v_memory_limit);
</span><span class="cx"> $last = strtolower(substr($v_memory_limit, -1));
</span><del>-
</del><ins>+
</ins><span class="cx"> if($last == 'g')
</span><span class="cx"> //$v_memory_limit = $v_memory_limit*1024*1024*1024;
</span><span class="cx"> $v_memory_limit = $v_memory_limit*1073741824;
</span><span class="lines">@@ -1972,20 +1845,16 @@
</span><span class="cx"> $v_memory_limit = $v_memory_limit*1048576;
</span><span class="cx"> if($last == 'k')
</span><span class="cx"> $v_memory_limit = $v_memory_limit*1024;
</span><del>-
</del><ins>+
</ins><span class="cx"> $p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] = floor($v_memory_limit*PCLZIP_TEMPORARY_FILE_RATIO);
</span><ins>+
</ins><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Current memory usage : ".memory_get_usage(TRUE)." bytes");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Threshold value is : ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]." bytes");
-
</del><span class="cx"> // ----- Sanity check : No threshold if value lower than 1M
</span><span class="cx"> if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Unset the threshold (value ".$p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD].") because under 1Mo sanity check)");
</del><span class="cx"> unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2000,19 +1869,17 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", "");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- For each file in the list check the attributes
</span><span class="cx"> foreach ($p_file_list as $v_key => $v_value) {
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check if the option is supported
</span><span class="cx"> if (!isset($v_requested_options[$v_key])) {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2021,16 +1888,13 @@
</span><span class="cx"> case PCLZIP_ATT_FILE_NAME :
</span><span class="cx"> if (!is_string($v_value)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
-
</del><ins>+
</ins><span class="cx"> if ($p_filedescr['filename'] == '') {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2039,16 +1903,13 @@
</span><span class="cx"> case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
</span><span class="cx"> if (!is_string($v_value)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
</del><span class="cx">
</span><span class="cx"> if ($p_filedescr['new_short_name'] == '') {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="lines">@@ -2056,16 +1917,13 @@
</span><span class="cx"> case PCLZIP_ATT_FILE_NEW_FULL_NAME :
</span><span class="cx"> if (!is_string($v_value)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
</del><span class="cx">
</span><span class="cx"> if ($p_filedescr['new_full_name'] == '') {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> break;
</span><span class="lines">@@ -2074,28 +1932,23 @@
</span><span class="cx"> case PCLZIP_ATT_FILE_COMMENT :
</span><span class="cx"> if (!is_string($v_value)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_filedescr['comment'] = $v_value;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case PCLZIP_ATT_FILE_MTIME :
</span><span class="cx"> if (!is_integer($v_value)) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_filedescr['mtime'] = $v_value;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> case PCLZIP_ATT_FILE_CONTENT :
</span><span class="cx"> $p_filedescr['content'] = $v_value;
</span><del>- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
</del><span class="cx"> break;
</span><span class="cx">
</span><span class="cx"> default :
</span><span class="lines">@@ -2104,7 +1957,6 @@
</span><span class="cx">                  "Unknown parameter '".$v_key."'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2113,22 +1965,19 @@
</span><span class="cx"> for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
</span><span class="cx"> // ----- Look for mandatory option
</span><span class="cx"> if ($v_requested_options[$key] == 'mandatory') {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
</del><span class="cx"> // ----- Look if present
</span><span class="cx"> if (!isset($p_file_list[$key])) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // end foreach
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2140,7 +1989,7 @@
</span><span class="cx"> // or a string to be added as file. For any other type of files (link, other)
</span><span class="cx"> // just ignore the item.
</span><span class="cx"> // Then prepare the information that will be stored for that file.
</span><del>- // When its a folder, expand the folder with all the files that are in that
</del><ins>+ // When its a folder, expand the folder with all the files that are in that
</ins><span class="cx"> // folder (recursively).
</span><span class="cx"> // Parameters :
</span><span class="cx"> // Return Values :
</span><span class="lines">@@ -2149,70 +1998,59 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privFileDescrExpand(&$p_filedescr_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", "");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Create a result list
</span><span class="cx"> $v_result_list = array();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look each entry
</span><span class="cx"> for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for file ".$i.".");
-
</del><ins>+
</ins><span class="cx"> // ----- Get filedescr
</span><span class="cx"> $v_descr = $p_filedescr_list[$i];
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Reduce the filename
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'");
</del><span class="cx"> $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
</span><span class="cx"> $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'");
-
</del><ins>+
</ins><span class="cx"> // ----- Look for real file or folder
</span><span class="cx"> if (file_exists($v_descr['filename'])) {
</span><span class="cx"> if (@is_file($v_descr['filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file");
</del><span class="cx"> $v_descr['type'] = 'file';
</span><span class="cx"> }
</span><span class="cx"> else if (@is_dir($v_descr['filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder");
</del><span class="cx"> $v_descr['type'] = 'folder';
</span><span class="cx"> }
</span><span class="cx"> else if (@is_link($v_descr['filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link");
</del><span class="cx"> // skip
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type");
</del><span class="cx"> // skip
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for string added as file
</span><span class="cx"> else if (isset($v_descr['content'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a string added as a file");
</del><span class="cx"> $v_descr['type'] = 'virtual_file';
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Missing file
</span><span class="cx"> else {
</span><span class="cx"> // ----- Error log
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exist");
</del><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Calculate the stored filename
</span><span class="cx"> $this->privCalculateStoredFilename($v_descr, $p_options);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Add the descriptor in result list
</span><span class="cx"> $v_result_list[sizeof($v_result_list)] = $v_descr;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for folder
</span><span class="cx"> if ($v_descr['type'] == 'folder') {
</span><span class="cx"> // ----- List of items in folder
</span><span class="lines">@@ -2220,20 +2058,20 @@
</span><span class="cx"> $v_dirlist_nb = 0;
</span><span class="cx"> if ($v_folder_handler = @opendir($v_descr['filename'])) {
</span><span class="cx"> while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory");
</del><span class="cx">
</span><span class="cx"> // ----- Skip '.' and '..'
</span><span class="cx"> if (($v_item_handler == '.') || ($v_item_handler == '..')) {
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Compose the full filename
</span><span class="cx"> $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for different stored filename
</span><span class="cx"> // Because the name of the folder was changed, the name of the
</span><span class="cx"> // files/sub-folders also change
</span><del>- if ($v_descr['stored_filename'] != $v_descr['filename']) {
</del><ins>+ if (($v_descr['stored_filename'] != $v_descr['filename'])
+ && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
</ins><span class="cx"> if ($v_descr['stored_filename'] != '') {
</span><span class="cx"> $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
</span><span class="cx"> }
</span><span class="lines">@@ -2241,44 +2079,38 @@
</span><span class="cx"> $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> $v_dirlist_nb++;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> @closedir($v_folder_handler);
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped.");
</del><span class="cx"> // TBC : unable to open folder in read mode
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Expand each element of the list
</span><span class="cx"> if ($v_dirlist_nb != 0) {
</span><span class="cx"> // ----- Expand
</span><span class="cx"> if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Concat the resulting list
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')");
</del><span class="cx"> $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'");
</del><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand.");
</del><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Free local array
</span><span class="cx"> unset($v_dirlist_descr);
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Get the result list
</span><span class="cx"> $p_filedescr_list = $v_result_list;
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2291,10 +2123,9 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list");
</del><span class="cx"> $v_result=1;
</span><span class="cx"> $v_list_detail = array();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Magic quotes trick
</span><span class="cx"> $this->privDisableMagicQuotes();
</span><span class="cx">
</span><span class="lines">@@ -2302,7 +2133,6 @@
</span><span class="cx"> if (($v_result = $this->privOpenFd('wb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2316,7 +2146,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2329,34 +2158,29 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list");
</del><span class="cx"> $v_result=1;
</span><span class="cx"> $v_list_detail = array();
</span><span class="cx">
</span><span class="cx"> // ----- Look if the archive exists or is empty
</span><span class="cx"> if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
</del><span class="cx">
</span><span class="cx"> // ----- Do a create
</span><span class="cx"> $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // ----- Magic quotes trick
</span><span class="cx"> $this->privDisableMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_result=$this->privOpenFd('rb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Magic quotes trick
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2366,20 +2190,16 @@
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Go to beginning of File
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Creates a temporay file
</span><span class="cx"> $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
</span><span class="cx">
</span><span class="cx"> // ----- Open the temporary file in write mode
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><span class="lines">@@ -2388,7 +2208,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2398,7 +2217,6 @@
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = fread($this->zip_fd, $v_read_size);
</span><span class="cx"> @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -2421,20 +2239,17 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Store the offset of the central dir
</span><span class="cx"> $v_offset = @ftell($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
</del><span class="cx">
</span><span class="cx"> // ----- Copy the block of file headers from the old archive
</span><span class="cx"> $v_size = $v_central_dir['size'];
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
</span><span class="cx"> @fwrite($this->zip_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -2452,7 +2267,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> $v_count++;
</span><span class="lines">@@ -2485,7 +2299,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2513,7 +2326,6 @@
</span><span class="cx"> PclZipUtilRename($v_zip_temp_name, $this->zipname);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2525,7 +2337,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privOpenFd($p_mode)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Look if already open
</span><span class="lines">@@ -2535,24 +2346,20 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
</del><span class="cx"> if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
</span><span class="cx"> {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2564,7 +2371,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privCloseFd()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> if ($this->zip_fd != 0)
</span><span class="lines">@@ -2572,7 +2378,6 @@
</span><span class="cx"> $this->zip_fd = 0;
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2593,7 +2398,6 @@
</span><span class="cx"> // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
</span><span class="cx"> function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Add the files
</span><span class="lines">@@ -2601,7 +2405,6 @@
</span><span class="cx"> if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2615,7 +2418,6 @@
</span><span class="cx"> if ($v_header_list[$i]['status'] == 'ok') {
</span><span class="cx"> if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> $v_count++;
</span><span class="lines">@@ -2641,12 +2443,10 @@
</span><span class="cx"> unset($v_header_list);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2655,42 +2455,36 @@
</span><span class="cx"> // Function : privAddFileList()
</span><span class="cx"> // Description :
</span><span class="cx"> // Parameters :
</span><del>- // $p_filedescr_list : An array containing the file description
</del><ins>+ // $p_filedescr_list : An array containing the file description
</ins><span class="cx"> // or directory names to add in the zip
</span><span class="cx"> // $p_result_list : list of added files with their properties (specially the status field)
</span><span class="cx"> // Return Values :
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");
</del><span class="cx"> $v_result=1;
</span><span class="cx"> $v_header = array();
</span><span class="cx">
</span><span class="cx"> // ----- Recuperate the current number of elt in list
</span><span class="cx"> $v_nb = sizeof($p_result_list);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");
</del><span class="cx">
</span><span class="cx"> // ----- Loop on the files
</span><span class="cx"> for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
</span><span class="cx"> // ----- Format the filename
</span><span class="cx"> $p_filedescr_list[$j]['filename']
</span><span class="cx"> = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
</span><ins>+
</ins><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'");
-
</del><span class="cx"> // ----- Skip empty file names
</span><span class="cx"> // TBC : Can this be possible ? not checked in DescrParseAtt ?
</span><span class="cx"> if ($p_filedescr_list[$j]['filename'] == "") {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
</del><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Check the filename
</span><span class="cx"> if ( ($p_filedescr_list[$j]['type'] != 'virtual_file')
</span><span class="cx"> && (!file_exists($p_filedescr_list[$j]['filename']))) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
</del><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2709,7 +2503,6 @@
</span><span class="cx"> $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
</span><span class="cx"> $p_options);
</span><span class="cx"> if ($v_result != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2717,10 +2510,8 @@
</span><span class="cx"> $p_result_list[$v_nb++] = $v_header;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");
</del><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -2733,9 +2524,8 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privAddFile($p_filedescr, &$p_header, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Working variable
</span><span class="cx"> $p_filename = $p_filedescr['filename'];
</span><span class="cx">
</span><span class="lines">@@ -2745,19 +2535,16 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>-
- // ----- Look for a stored different filename
</del><ins>+
+ // ----- Look for a stored different filename
</ins><span class="cx"> /* TBC : Removed
</span><span class="cx"> if (isset($p_filedescr['stored_filename'])) {
</span><span class="cx"> $v_stored_filename = $p_filedescr['stored_filename'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"');
</del><span class="cx"> }
</span><span class="cx"> else {
</span><span class="cx"> $v_stored_filename = $p_filedescr['stored_filename'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same');
</del><span class="cx"> }
</span><span class="cx"> */
</span><span class="cx">
</span><span class="lines">@@ -2786,30 +2573,27 @@
</span><span class="cx"> $p_header['external'] = 0x00000000;
</span><span class="cx"> $p_header['size'] = filesize($p_filename);
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for regular folder
</span><span class="cx"> else if ($p_filedescr['type']=='folder') {
</span><span class="cx"> $p_header['external'] = 0x00000010;
</span><span class="cx"> $p_header['mtime'] = filemtime($p_filename);
</span><span class="cx"> $p_header['size'] = filesize($p_filename);
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for virtual file
</span><span class="cx"> else if ($p_filedescr['type'] == 'virtual_file') {
</span><span class="cx"> $p_header['external'] = 0x00000000;
</span><span class="cx"> $p_header['size'] = strlen($p_filedescr['content']);
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");
-
</del><span class="cx"> // ----- Look for filetime
</span><span class="cx"> if (isset($p_filedescr['mtime'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3,"Overload mtime value with :'".$p_filedescr['mtime']."'");
</del><span class="cx"> $p_header['mtime'] = $p_filedescr['mtime'];
</span><span class="cx"> }
</span><span class="cx"> else if ($p_filedescr['type'] == 'virtual_file') {
</span><span class="cx"> $p_header['mtime'] = time();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Virtual file : use current time '".$p_header['mtime']."' for mtime value.");
</del><span class="cx"> }
</span><span class="cx"> else {
</span><span class="cx"> $p_header['mtime'] = filemtime($p_filename);
</span><span class="lines">@@ -2827,7 +2611,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for pre-add callback
</span><span class="cx"> if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -2836,7 +2619,7 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
</del><ins>+ $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
</ins><span class="cx"> if ($v_result == 0) {
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_header['status'] = "skipped";
</span><span class="lines">@@ -2847,7 +2630,6 @@
</span><span class="cx"> // Only some fields can be modified
</span><span class="cx"> if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
</span><span class="cx"> $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2855,7 +2637,7 @@
</span><span class="cx"> if ($p_header['stored_filename'] == "") {
</span><span class="cx"> $p_header['status'] = "filtered";
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check the path length
</span><span class="cx"> if (strlen($p_header['stored_filename']) > 0xFF) {
</span><span class="cx"> $p_header['status'] = 'filename_too_long';
</span><span class="lines">@@ -2867,7 +2649,7 @@
</span><span class="cx"> // ----- Look for a file
</span><span class="cx"> if ($p_filedescr['type'] == 'file') {
</span><span class="cx"> // ----- Look for using temporary file to zip
</span><del>- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
</del><ins>+ if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
</ins><span class="cx"> && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
</span><span class="cx"> || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
</span><span class="cx"> && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
</span><span class="lines">@@ -2876,57 +2658,45 @@
</span><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Use "in memory" zip algo
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"In memory compression.");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory usage : ".memory_get_usage(TRUE)." bytes");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Current memory peak : ".memory_get_peak_usage(TRUE)." bytes");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
</del><span class="cx">
</span><span class="cx"> // ----- Open the source file
</span><span class="cx"> if (($v_file = @fopen($p_filename, "rb")) == 0) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Read the file content
</span><span class="cx"> $v_content = @fread($v_file, $p_header['size']);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after reading file : ".memory_get_usage(TRUE)." bytes");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after reading file : ".memory_get_peak_usage(TRUE)." bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Close the file
</span><span class="cx"> @fclose($v_file);
</span><span class="cx">
</span><span class="cx"> // ----- Calculate the CRC
</span><span class="cx"> $p_header['crc'] = @crc32($v_content);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for no compression
</span><span class="cx"> if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
</del><span class="cx"> // ----- Set header parameters
</span><span class="cx"> $p_header['compressed_size'] = $p_header['size'];
</span><span class="cx"> $p_header['compression'] = 0;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for normal compression
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
</del><span class="cx"> // ----- Compress the content
</span><span class="cx"> $v_content = @gzdeflate($v_content);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory usage after gzdeflate : ".memory_get_usage(TRUE)." bytes");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2,"Memory peak after gzdeflate : ".memory_get_peak_usage(TRUE)." bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Set header parameters
</span><span class="cx"> $p_header['compressed_size'] = strlen($v_content);
</span><span class="cx"> $p_header['compression'] = 8;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Call the header generation
</span><span class="cx"> if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
</span><span class="cx"> @fclose($v_file);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2939,24 +2709,21 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for a virtual file (a file from string)
</span><span class="cx"> else if ($p_filedescr['type'] == 'virtual_file') {
</span><del>-
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Add by string");
</del><ins>+
</ins><span class="cx"> $v_content = $p_filedescr['content'];
</span><span class="cx">
</span><span class="cx"> // ----- Calculate the CRC
</span><span class="cx"> $p_header['crc'] = @crc32($v_content);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for no compression
</span><span class="cx"> if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
</del><span class="cx"> // ----- Set header parameters
</span><span class="cx"> $p_header['compressed_size'] = $p_header['size'];
</span><span class="cx"> $p_header['compression'] = 0;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for normal compression
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
</del><span class="cx"> // ----- Compress the content
</span><span class="cx"> $v_content = @gzdeflate($v_content);
</span><span class="cx">
</span><span class="lines">@@ -2964,11 +2731,10 @@
</span><span class="cx"> $p_header['compressed_size'] = strlen($v_content);
</span><span class="cx"> $p_header['compression'] = 8;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Call the header generation
</span><span class="cx"> if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
</span><span class="cx"> @fclose($v_file);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2978,7 +2744,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for a directory
</span><span class="cx"> else if ($p_filedescr['type'] == 'folder') {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder");
</del><span class="cx"> // ----- Look for directory last '/'
</span><span class="cx"> if (@substr($p_header['stored_filename'], -1) != '/') {
</span><span class="cx"> $p_header['stored_filename'] .= '/';
</span><span class="lines">@@ -2992,7 +2757,6 @@
</span><span class="cx"> // ----- Call the header generation
</span><span class="cx"> if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -3000,7 +2764,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for post-add callback
</span><span class="cx"> if (isset($p_options[PCLZIP_CB_POST_ADD])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -3009,7 +2772,7 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
</del><ins>+ $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
</ins><span class="cx"> if ($v_result == 0) {
</span><span class="cx"> // ----- Ignored
</span><span class="cx"> $v_result = 1;
</span><span class="lines">@@ -3020,7 +2783,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3033,18 +2795,15 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileUsingTempFile", "filename='".$p_filedescr['filename']."'");
</del><span class="cx"> $v_result=PCLZIP_ERR_NO_ERROR;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Working variable
</span><span class="cx"> $p_filename = $p_filedescr['filename'];
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
</del><span class="cx">
</span><span class="cx"> // ----- Open the source file
</span><span class="cx"> if (($v_file = @fopen($p_filename, "rb")) == 0) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3053,7 +2812,6 @@
</span><span class="cx"> if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
</span><span class="cx"> fclose($v_file);
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3061,7 +2819,6 @@
</span><span class="cx"> $v_size = filesize($p_filename);
</span><span class="cx"> while ($v_size != 0) {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read ".$v_read_size." bytes");
</del><span class="cx"> $v_buffer = @fread($v_file, $v_read_size);
</span><span class="cx"> //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
</span><span class="cx"> @gzputs($v_file_compressed, $v_buffer, $v_read_size);
</span><span class="lines">@@ -3073,17 +2830,14 @@
</span><span class="cx"> @gzclose($v_file_compressed);
</span><span class="cx">
</span><span class="cx"> // ----- Check the minimum file size
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size ".filesize($v_gzip_temp_name));
</del><span class="cx"> if (filesize($v_gzip_temp_name) < 18) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Extract the compressed attributes
</span><span class="cx"> if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3092,28 +2846,17 @@
</span><span class="cx"> $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);
</span><span class="cx">
</span><span class="cx"> // ----- Check some parameters
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]='.bin2hex($v_data_header['id1']));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]='.bin2hex($v_data_header['id2']));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]='.bin2hex($v_data_header['cm']));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]='.bin2hex($v_data_header['flag']));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]='.$v_data_header['mtime']);
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]='.bin2hex($v_data_header['xfl']));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[os]='.bin2hex($v_data_header['os']));
</del><span class="cx"> $v_data_header['os'] = bin2hex($v_data_header['os']);
</span><span class="cx">
</span><span class="cx"> // ----- Read the gzip file footer
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after header ".ftell($v_file_compressed));
</del><span class="cx"> @fseek($v_file_compressed, filesize($v_gzip_temp_name)-8);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position at beginning of footer ".ftell($v_file_compressed));
</del><span class="cx"> $v_binary_data = @fread($v_file_compressed, 8);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after footer ".ftell($v_file_compressed));
</del><span class="cx"> $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);
</span><span class="cx">
</span><span class="cx"> // ----- Set the attributes
</span><span class="cx"> $p_header['compression'] = ord($v_data_header['cm']);
</span><span class="cx"> //$p_header['mtime'] = $v_data_header['mtime'];
</span><span class="cx"> $p_header['crc'] = $v_data_footer['crc'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Compressed size ".(filesize($v_gzip_temp_name)-18));
</del><span class="cx"> $p_header['compressed_size'] = filesize($v_gzip_temp_name)-18;
</span><span class="cx">
</span><span class="cx"> // ----- Close the file
</span><span class="lines">@@ -3121,7 +2864,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Call the header generation
</span><span class="cx"> if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3129,19 +2871,15 @@
</span><span class="cx"> if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
</span><span class="cx"> {
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
</span><span class="cx"> fseek($v_file_compressed, 10);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position before reading compressed data ".ftell($v_file_compressed));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, ' '.$p_header['compressed_size'].' bytes to read');
</del><span class="cx"> $v_size = $p_header['compressed_size'];
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read ".$v_read_size." bytes");
</del><span class="cx"> $v_buffer = @fread($v_file_compressed, $v_read_size);
</span><span class="cx"> //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
</span><span class="cx"> @fwrite($this->zip_fd, $v_buffer, $v_read_size);
</span><span class="lines">@@ -3153,9 +2891,8 @@
</span><span class="cx">
</span><span class="cx"> // ----- Unlink the temporary file
</span><span class="cx"> @unlink($v_gzip_temp_name);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3170,9 +2907,8 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privCalculateStoredFilename(&$p_filedescr, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Working variables
</span><span class="cx"> $p_filename = $p_filedescr['filename'];
</span><span class="cx"> if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
</span><span class="lines">@@ -3187,7 +2923,6 @@
</span><span class="cx"> else {
</span><span class="cx"> $p_remove_dir = '';
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path ='".$p_remove_dir."'");
</del><span class="cx"> if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
</span><span class="cx"> $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
</span><span class="cx"> }
</span><span class="lines">@@ -3195,13 +2930,13 @@
</span><span class="cx"> $p_remove_all_dir = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> // ----- Look for full name change
</span><span class="cx"> if (isset($p_filedescr['new_full_name'])) {
</span><span class="cx"> // ----- Remove drive letter if any
</span><span class="cx"> $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'");
</del><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for path and/or short name change
</span><span class="cx"> else {
</span><span class="cx">
</span><span class="lines">@@ -3214,7 +2949,6 @@
</span><span class="cx"> $v_dir = $v_path_info['dirname'].'/';
</span><span class="cx"> }
</span><span class="cx"> $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");
</del><span class="cx"> }
</span><span class="cx"> else {
</span><span class="cx"> // ----- Calculate the stored filename
</span><span class="lines">@@ -3224,17 +2958,15 @@
</span><span class="cx"> // ----- Look for all path to remove
</span><span class="cx"> if ($p_remove_all_dir) {
</span><span class="cx"> $v_stored_filename = basename($p_filename);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");
</del><span class="cx"> }
</span><span class="cx"> // ----- Look for partial path remove
</span><span class="cx"> else if ($p_remove_dir != "") {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Partial path to remove");
</del><span class="cx"> if (substr($p_remove_dir, -1) != '/')
</span><span class="cx"> $p_remove_dir .= "/";
</span><span class="cx">
</span><span class="cx"> if ( (substr($p_filename, 0, 2) == "./")
</span><span class="cx"> || (substr($p_remove_dir, 0, 2) == "./")) {
</span><del>-
</del><ins>+
</ins><span class="cx"> if ( (substr($p_filename, 0, 2) == "./")
</span><span class="cx"> && (substr($p_remove_dir, 0, 2) != "./")) {
</span><span class="cx"> $p_remove_dir = "./".$p_remove_dir;
</span><span class="lines">@@ -3250,37 +2982,31 @@
</span><span class="cx"> if ($v_compare > 0) {
</span><span class="cx"> if ($v_compare == 2) {
</span><span class="cx"> $v_stored_filename = "";
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
</del><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");
</del><span class="cx"> $v_stored_filename = substr($v_stored_filename,
</span><span class="cx"> strlen($p_remove_dir));
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Remove drive letter if any
</span><span class="cx"> $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for path to add
</span><span class="cx"> if ($p_add_dir != "") {
</span><span class="cx"> if (substr($p_add_dir, -1) == "/")
</span><span class="cx"> $v_stored_filename = $p_add_dir.$v_stored_filename;
</span><span class="cx"> else
</span><span class="cx"> $v_stored_filename = $p_add_dir."/".$v_stored_filename;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Filename (reduce the path of stored name)
</span><span class="cx"> $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
</span><span class="cx"> $p_filedescr['stored_filename'] = $v_stored_filename;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));
-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3293,15 +3019,12 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privWriteFileHeader(&$p_header)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Store the offset position of the file
</span><span class="cx"> $p_header['offset'] = ftell($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
</del><span class="cx">
</span><span class="cx"> // ----- Transform UNIX mtime to DOS format mdate/mtime
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> $v_date = getdate($p_header['mtime']);
</span><span class="cx"> $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
</span><span class="cx"> $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
</span><span class="lines">@@ -3329,7 +3052,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3342,21 +3064,17 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privWriteCentralFileHeader(&$p_header)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // TBC
</span><span class="cx"> //for(reset($p_header); $key = key($p_header); next($p_header)) {
</span><del>- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
</del><span class="cx"> //}
</span><span class="cx">
</span><span class="cx"> // ----- Transform UNIX mtime to DOS format mdate/mtime
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> $v_date = getdate($p_header['mtime']);
</span><span class="cx"> $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
</span><span class="cx"> $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$p_header['comment_len'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Packed data
</span><span class="cx"> $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
</span><span class="lines">@@ -3387,7 +3105,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3400,7 +3117,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Packed data
</span><span class="lines">@@ -3418,7 +3134,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3431,24 +3146,21 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privList(&$p_list)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Magic quotes trick
</span><span class="cx"> $this->privDisableMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
</span><span class="cx"> {
</span><span class="cx"> // ----- Magic quotes trick
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3457,15 +3169,11 @@
</span><span class="cx"> if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Go to beginning of Central Dir
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx"> if (@fseek($this->zip_fd, $v_central_dir['offset']))
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="lines">@@ -3474,10 +3182,8 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Read each entry
</span><span class="cx"> for ($i=0; $i<$v_central_dir['entries']; $i++)
</span><span class="lines">@@ -3486,7 +3192,6 @@
</span><span class="cx"> if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> $v_header['index'] = $i;
</span><span class="lines">@@ -3503,7 +3208,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3529,7 +3233,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privConvertHeader2FileInfo($p_header, &$p_info)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Get the interesting attributes
</span><span class="lines">@@ -3547,7 +3250,6 @@
</span><span class="cx"> $p_info['crc'] = $p_header['crc'];
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3570,7 +3272,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Magic quotes trick
</span><span class="lines">@@ -3589,9 +3290,7 @@
</span><span class="cx"> // ----- Look for the path end '/'
</span><span class="cx"> while (substr($p_path, -1) == "/")
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
</del><span class="cx"> $p_path = substr($p_path, 0, strlen($p_path)-1);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3603,11 +3302,9 @@
</span><span class="cx"> $p_remove_path_size = strlen($p_remove_path);
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_result = $this->privOpenFd('rb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3619,7 +3316,6 @@
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3630,12 +3326,9 @@
</span><span class="cx"> $j_start = 0;
</span><span class="cx"> for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
</del><span class="cx">
</span><span class="cx"> // ----- Read next Central dir entry
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> if (@fseek($this->zip_fd, $v_pos_entry))
</span><span class="cx"> {
</span><span class="cx"> // ----- Close the zip file
</span><span class="lines">@@ -3646,10 +3339,8 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="cx"> $v_header = array();
</span><span class="lines">@@ -3659,7 +3350,6 @@
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3675,49 +3365,43 @@
</span><span class="cx"> // ----- Look for extract by name rule
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
</del><span class="cx">
</span><span class="cx"> // ----- Look if the filename is in the list
</span><span class="cx"> for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
</del><span class="cx">
</span><span class="cx"> // ----- Look for a directory
</span><span class="cx"> if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
</del><span class="cx">
</span><span class="cx"> // ----- Look if the directory is in the filename path
</span><span class="cx"> if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
</span><span class="cx"> && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> // ----- Look for a filename
</span><span class="cx"> elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look for extract by ereg rule
</span><ins>+ // ereg() is deprecated with PHP 5.3
+ /*
</ins><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
</del><span class="cx">
</span><span class="cx"> if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ */
</ins><span class="cx">
</span><span class="cx"> // ----- Look for extract by preg rule
</span><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
</del><span class="cx">
</span><span class="cx"> if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -3725,23 +3409,18 @@
</span><span class="cx"> // ----- Look for extract by index rule
</span><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
-
</del><ins>+
</ins><span class="cx"> // ----- Look if the index is in the list
</span><span class="cx"> for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
</del><span class="cx">
</span><span class="cx"> if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx"> if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
</del><span class="cx"> $j_start = $j+1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
</del><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -3749,7 +3428,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for no rule, which means extract all the archive
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
</del><span class="cx"> $v_extract = true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3757,35 +3435,30 @@
</span><span class="cx">          if ( ($v_extract)
</span><span class="cx">          && ( ($v_header['compression'] != 8)
</span><span class="cx">                  && ($v_header['compression'] != 0))) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");
</del><span class="cx"> $v_header['status'] = 'unsupported_compression';
</span><span class="cx">
</span><span class="cx"> // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
</del><span class="cx">
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>-
</del><ins>+
</ins><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
</span><span class="cx">                          "Filename '".$v_header['stored_filename']."' is "
</span><span class="cx">                                                             ."compressed by an unsupported compression "
</span><span class="cx">                                                             ."method (".$v_header['compression'].") ");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-
</del><ins>+        
</ins><span class="cx">          // ----- Check encrypted files
</span><span class="cx">          if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");
</del><span class="cx"> $v_header['status'] = 'unsupported_encryption';
</span><span class="cx">
</span><span class="cx"> // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
</del><span class="cx">
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="lines">@@ -3794,35 +3467,29 @@
</span><span class="cx">                                                             ." filename '".$v_header['stored_filename']
</span><span class="cx">                                                                  ."'");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">                  }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look for real extraction
</span><span class="cx"> if (($v_extract) && ($v_header['status'] != 'ok')) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");
</del><span class="cx"> $v_result = $this->privConvertHeader2FileInfo($v_header,
</span><span class="cx">                  $p_file_list[$v_nb_extracted++]);
</span><span class="cx"> if ($v_result != 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $v_extract = false;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for real extraction
</span><span class="cx"> if ($v_extract)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
</del><span class="cx">
</span><span class="cx"> // ----- Go to the file position
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> if (@fseek($this->zip_fd, $v_header['offset']))
</span><span class="cx"> {
</span><span class="cx"> // ----- Close the zip file
</span><span class="lines">@@ -3834,20 +3501,19 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Look for extraction as string
</span><span class="cx"> if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
</span><span class="cx">
</span><ins>+ $v_string = '';
+
</ins><span class="cx"> // ----- Extracting the file
</span><del>- $v_result1 = $this->privExtractFileAsString($v_header, $v_string);
</del><ins>+ $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
</ins><span class="cx"> if ($v_result1 < 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
</del><span class="cx"> return $v_result1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3858,7 +3524,6 @@
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3867,7 +3532,7 @@
</span><span class="cx">
</span><span class="cx"> // ----- Next extracted file
</span><span class="cx"> $v_nb_extracted++;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for user callback abort
</span><span class="cx"> if ($v_result1 == 2) {
</span><span class="cx">         break;
</span><span class="lines">@@ -3881,7 +3546,6 @@
</span><span class="cx"> if ($v_result1 < 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
</del><span class="cx"> return $v_result1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3889,7 +3553,6 @@
</span><span class="cx"> if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3908,7 +3571,6 @@
</span><span class="cx"> if ($v_result1 < 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
</del><span class="cx"> return $v_result1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3919,7 +3581,6 @@
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3936,7 +3597,6 @@
</span><span class="cx"> $this->privSwapBackMagicQuotes();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -3952,18 +3612,15 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="cx"> if (($v_result = $this->privReadFileHeader($v_header)) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check that the file header is coherent with $p_entry info
</span><span class="cx"> if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
</span><span class="lines">@@ -3974,15 +3631,12 @@
</span><span class="cx"> if ($p_remove_all_path == true) {
</span><span class="cx"> // ----- Look for folder entry that not need to be extracted
</span><span class="cx"> if (($p_entry['external']&0x00000010)==0x00000010) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered");
</del><span class="cx">
</span><span class="cx"> $p_entry['status'] = "filtered";
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");
</del><span class="cx"> // ----- Get the basename of the path
</span><span class="cx"> $p_entry['filename'] = basename($p_entry['filename']);
</span><span class="cx"> }
</span><span class="lines">@@ -3990,28 +3644,23 @@
</span><span class="cx"> // ----- Look for path to remove
</span><span class="cx"> else if ($p_remove_path != "")
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");
</del><span class="cx"> if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "filtered";
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $p_remove_path_size = strlen($p_remove_path);
</span><span class="cx"> if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Remove the path
</span><span class="cx"> $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4019,28 +3668,24 @@
</span><span class="cx"> if ($p_path != '') {
</span><span class="cx"> $p_entry['filename'] = $p_path."/".$p_entry['filename'];
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check a base_dir_restriction
</span><span class="cx"> if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction");
</del><span class="cx"> $v_inclusion
</span><span class="cx"> = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
</span><del>- $p_entry['filename']);
</del><ins>+ $p_entry['filename']);
</ins><span class="cx"> if ($v_inclusion == 0) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction");
</del><span class="cx">
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
</span><span class="cx">                          "Filename '".$p_entry['filename']."' is "
</span><span class="cx">                                                                  ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look for pre-extract callback
</span><span class="cx"> if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -4049,16 +3694,15 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
</del><ins>+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
</ins><span class="cx"> if ($v_result == 0) {
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "skipped";
</span><span class="cx"> $v_result = 1;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for abort result
</span><span class="cx"> if ($v_result == 2) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
</del><span class="cx"> // ----- This status is internal and will be changed in 'skipped'
</span><span class="cx"> $p_entry['status'] = "aborted";
</span><span class="cx">         $v_result = PCLZIP_ERR_USER_ABORTED;
</span><span class="lines">@@ -4067,10 +3711,8 @@
</span><span class="cx"> // ----- Update the informations
</span><span class="cx"> // Only some fields can be modified
</span><span class="cx"> $p_entry['filename'] = $v_local_header['filename'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
</del><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
</del><span class="cx">
</span><span class="cx"> // ----- Look if extraction should be done
</span><span class="cx"> if ($p_entry['status'] == 'ok') {
</span><span class="lines">@@ -4078,35 +3720,30 @@
</span><span class="cx"> // ----- Look for specific actions while the file exist
</span><span class="cx"> if (file_exists($p_entry['filename']))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
</del><span class="cx">
</span><span class="cx"> // ----- Look if file is a directory
</span><span class="cx"> if (is_dir($p_entry['filename']))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
</del><span class="cx">
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "already_a_directory";
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
</span><span class="cx"> // For historical reason first PclZip implementation does not stop
</span><span class="cx"> // when this kind of error occurs.
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
</del><span class="cx">
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
</span><span class="cx">                          "Filename '".$p_entry['filename']."' is "
</span><span class="cx">                                                                  ."already used by an existing directory");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">                  }
</span><span class="cx"> }
</span><span class="cx"> // ----- Look if file is write protected
</span><span class="cx"> else if (!is_writeable($p_entry['filename']))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
</del><span class="cx">
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "write_protected";
</span><span class="lines">@@ -4116,13 +3753,11 @@
</span><span class="cx"> // when this kind of error occurs.
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
</del><span class="cx">
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
</span><span class="cx">                          "Filename '".$p_entry['filename']."' exists "
</span><span class="cx">                                                                  ."and is write protected");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">                  }
</span><span class="cx"> }
</span><span class="lines">@@ -4130,14 +3765,11 @@
</span><span class="cx"> // ----- Look if the extracted file is older
</span><span class="cx"> else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
</del><span class="cx"> // ----- Change the file status
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");
</del><span class="cx">                   }
</span><span class="cx">                  else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced");
</del><span class="cx"> $p_entry['status'] = "newer_exist";
</span><span class="cx">
</span><span class="cx"> // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
</span><span class="lines">@@ -4145,19 +3777,16 @@
</span><span class="cx"> // when this kind of error occurs.
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
</span><span class="cx">                  && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
</del><span class="cx">
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
</span><span class="cx">                          "Newer version of '".$p_entry['filename']."' exists "
</span><span class="cx">                                          ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">                  }
</span><span class="cx">                  }
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4171,13 +3800,11 @@
</span><span class="cx"> $v_dir_to_check = dirname($p_entry['filename']);
</span><span class="cx">
</span><span class="cx"> if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
-
</del><ins>+
</ins><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "path_creation_fail";
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> //return $v_result;
</span><span class="cx"> $v_result = 1;
</span><span class="cx"> }
</span><span class="lines">@@ -4192,35 +3819,30 @@
</span><span class="cx"> {
</span><span class="cx"> // ----- Look for not compressed file
</span><span class="cx"> if ($p_entry['compression'] == 0) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
</del><span class="cx">
</span><span class="cx">                  // ----- Opening destination file
</span><span class="cx"> if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
</del><span class="cx">
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "write_error";
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
</span><span class="cx"> $v_size = $p_entry['compressed_size'];
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($this->zip_fd, $v_read_size);
</span><span class="cx"> /* Try to speed up the code
</span><span class="cx"> $v_binary_data = pack('a'.$v_read_size, $v_buffer);
</span><span class="cx"> @fwrite($v_dest_file, $v_binary_data, $v_read_size);
</span><span class="cx"> */
</span><del>- @fwrite($v_dest_file, $v_buffer, $v_read_size);
</del><ins>+ @fwrite($v_dest_file, $v_buffer, $v_read_size);
</ins><span class="cx"> $v_size -= $v_read_size;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4229,23 +3851,20 @@
</span><span class="cx">
</span><span class="cx"> // ----- Change the file mtime
</span><span class="cx"> touch($p_entry['filename'], $p_entry['mtime']);
</span><ins>+
</ins><span class="cx">
</span><del>-
</del><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");
</del><span class="cx"> // ----- TBC
</span><span class="cx"> // Need to be finished
</span><span class="cx"> if (($p_entry['flag'] & 1) == 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");
</del><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> // ----- Look for using temporary file to unzip
</span><del>- if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
</del><ins>+ if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
</ins><span class="cx"> && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
</span><span class="cx"> || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
</span><span class="cx"> && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
</span><span class="lines">@@ -4254,47 +3873,42 @@
</span><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for extract in memory
</span><span class="cx"> else {
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");
-
</del><ins>+
</ins><span class="cx"> // ----- Read the compressed file in a buffer (one shot)
</span><span class="cx"> $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Decompress the file
</span><span class="cx"> $v_file_content = @gzinflate($v_buffer);
</span><span class="cx"> unset($v_buffer);
</span><span class="cx"> if ($v_file_content === FALSE) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");
-
</del><ins>+
</ins><span class="cx"> // ----- Change the file status
</span><span class="cx"> // TBC
</span><span class="cx"> $p_entry['status'] = "error";
</span><del>-
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><ins>+
</ins><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Opening destination file
</span><span class="cx"> if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
-
</del><ins>+
</ins><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "write_error";
</span><del>-
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><ins>+
</ins><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Write the uncompressed data
</span><span class="cx"> @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
</span><span class="cx"> unset($v_file_content);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Closing the destination file
</span><span class="cx"> @fclose($v_dest_file);
</span><del>-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Change the file mtime
</span><span class="lines">@@ -4303,24 +3917,21 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for chmod option
</span><span class="cx"> if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
</del><span class="cx">
</span><span class="cx"> // ----- Change the mode of the file
</span><span class="cx"> @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-        // ----- Change abort status
-        if ($p_entry['status'] == "aborted") {
- $p_entry['status'] = "skipped";
-        }
-
</del><ins>+         // ----- Change abort status
+         if ($p_entry['status'] == "aborted") {
+ $p_entry['status'] = "skipped";
+         }
+        
</ins><span class="cx"> // ----- Look for post-extract callback
</span><span class="cx"> elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -4329,17 +3940,15 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
</del><ins>+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
</ins><span class="cx">
</span><span class="cx"> // ----- Look for abort result
</span><span class="cx"> if ($v_result == 2) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
</del><span class="cx">         $v_result = PCLZIP_ERR_USER_ABORTED;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4352,19 +3961,16 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privExtractFileUsingTempFile(&$p_entry, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileUsingTempFile', "filename='".$p_entry['filename']."'");
</del><span class="cx"> $v_result=1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Creates a temporary file
</span><span class="cx"> $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
</span><span class="cx"> if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
</span><span class="cx"> fclose($v_file);
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Start extraction of '".$p_entry['filename']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Write gz file format header
</span><span class="cx"> $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));
</span><span class="lines">@@ -4372,11 +3978,9 @@
</span><span class="cx">
</span><span class="cx"> // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
</span><span class="cx"> $v_size = $p_entry['compressed_size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Compressed Size :".$v_size."");
</del><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read ".$v_read_size." bytes");
</del><span class="cx"> $v_buffer = @fread($this->zip_fd, $v_read_size);
</span><span class="cx"> //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
</span><span class="cx"> @fwrite($v_dest_file, $v_buffer, $v_read_size);
</span><span class="lines">@@ -4392,9 +3996,7 @@
</span><span class="cx">
</span><span class="cx"> // ----- Opening destination file
</span><span class="cx"> if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
</del><span class="cx"> $p_entry['status'] = "write_error";
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4403,19 +4005,14 @@
</span><span class="cx"> @fclose($v_dest_file);
</span><span class="cx"> $p_entry['status'] = "read_error";
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File size is '.filesize($v_gzip_temp_name));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
</span><span class="cx"> $v_size = $p_entry['size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size :".$v_size."");
</del><span class="cx"> while ($v_size != 0) {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read ".$v_read_size." bytes");
</del><span class="cx"> $v_buffer = @gzread($v_src_file, $v_read_size);
</span><span class="cx"> //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
</span><span class="cx"> @fwrite($v_dest_file, $v_buffer, $v_read_size);
</span><span class="lines">@@ -4426,9 +4023,8 @@
</span><span class="cx">
</span><span class="cx"> // ----- Delete the temporary file
</span><span class="cx"> @unlink($v_gzip_temp_name);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4441,16 +4037,13 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privExtractFileInOutput(&$p_entry, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="cx"> if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check that the file header is coherent with $p_entry info
</span><span class="cx"> if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
</span><span class="lines">@@ -4459,7 +4052,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for pre-extract callback
</span><span class="cx"> if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -4468,7 +4060,8 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
</del><ins>+// eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
</ins><span class="cx"> if ($v_result == 0) {
</span><span class="cx"> // ----- Change the file status
</span><span class="cx"> $p_entry['status'] = "skipped";
</span><span class="lines">@@ -4477,7 +4070,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for abort result
</span><span class="cx"> if ($v_result == 2) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
</del><span class="cx"> // ----- This status is internal and will be changed in 'skipped'
</span><span class="cx"> $p_entry['status'] = "aborted";
</span><span class="cx">         $v_result = PCLZIP_ERR_USER_ABORTED;
</span><span class="lines">@@ -4486,11 +4078,9 @@
</span><span class="cx"> // ----- Update the informations
</span><span class="cx"> // Only some fields can be modified
</span><span class="cx"> $p_entry['filename'] = $v_local_header['filename'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Trace
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
</del><span class="cx">
</span><span class="cx"> // ----- Look if extraction should be done
</span><span class="cx"> if ($p_entry['status'] == 'ok') {
</span><span class="lines">@@ -4499,8 +4089,6 @@
</span><span class="cx"> if (!(($p_entry['external']&0x00000010)==0x00000010)) {
</span><span class="cx"> // ----- Look for not compressed file
</span><span class="cx"> if ($p_entry['compressed_size'] == $p_entry['size']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file in a buffer (one shot)
</span><span class="cx"> $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
</span><span class="lines">@@ -4510,12 +4098,10 @@
</span><span class="cx"> unset($v_buffer);
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
</del><span class="cx">
</span><span class="cx"> // ----- Read the compressed file in a buffer (one shot)
</span><span class="cx"> $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Decompress the file
</span><span class="cx"> $v_file_content = gzinflate($v_buffer);
</span><span class="cx"> unset($v_buffer);
</span><span class="lines">@@ -4524,7 +4110,6 @@
</span><span class="cx"> echo $v_file_content;
</span><span class="cx"> unset($v_file_content);
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4535,7 +4120,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look for post-extract callback
</span><span class="cx"> elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
</del><span class="cx">
</span><span class="cx"> // ----- Generate a local information
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -4544,16 +4128,14 @@
</span><span class="cx"> // ----- Call the callback
</span><span class="cx"> // Here I do not use call_user_func() because I need to send a reference to the
</span><span class="cx"> // header.
</span><del>- eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
</del><ins>+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
</ins><span class="cx">
</span><span class="cx"> // ----- Look for abort result
</span><span class="cx"> if ($v_result == 2) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
</del><span class="cx">         $v_result = PCLZIP_ERR_USER_ABORTED;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4564,9 +4146,8 @@
</span><span class="cx"> // Parameters :
</span><span class="cx"> // Return Values :
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><del>- function privExtractFileAsString(&$p_entry, &$p_string)
</del><ins>+ function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
</ins><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="lines">@@ -4574,52 +4155,108 @@
</span><span class="cx"> if (($v_result = $this->privReadFileHeader($v_header)) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check that the file header is coherent with $p_entry info
</span><span class="cx"> if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
</span><span class="cx"> // TBC
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
</del><ins>+ // ----- Look for pre-extract callback
+ if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
</ins><span class="cx">
</span><del>- // ----- Do the extraction (if not a folder)
- if (!(($p_entry['external']&0x00000010)==0x00000010))
- {
- // ----- Look for not compressed file
-// if ($p_entry['compressed_size'] == $p_entry['size'])
- if ($p_entry['compression'] == 0) {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
</del><ins>+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
</ins><span class="cx">
</span><del>- // ----- Reading the file
- $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
</del><ins>+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
+ if ($v_result == 0) {
+ // ----- Change the file status
+ $p_entry['status'] = "skipped";
+ $v_result = 1;
</ins><span class="cx"> }
</span><del>- else {
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')");
</del><ins>+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+ // ----- This status is internal and will be changed in 'skipped'
+ $p_entry['status'] = "aborted";
+         $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
</ins><span class="cx">
</span><del>- // ----- Reading the file
- $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
</del><ins>+ // ----- Update the informations
+ // Only some fields can be modified
+ $p_entry['filename'] = $v_local_header['filename'];
+ }
</ins><span class="cx">
</span><del>- // ----- Decompress the file
- if (($p_string = @gzinflate($v_data)) === FALSE) {
- // TBC
</del><ins>+
+ // ----- Look if extraction should be done
+ if ($p_entry['status'] == 'ok') {
+
+ // ----- Do the extraction (if not a folder)
+ if (!(($p_entry['external']&0x00000010)==0x00000010)) {
+ // ----- Look for not compressed file
+ // if ($p_entry['compressed_size'] == $p_entry['size'])
+ if ($p_entry['compression'] == 0) {
+
+ // ----- Reading the file
+ $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
</ins><span class="cx"> }
</span><ins>+ else {
+
+ // ----- Reading the file
+ $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
+
+ // ----- Decompress the file
+ if (($p_string = @gzinflate($v_data)) === FALSE) {
+ // TBC
+ }
+ }
+
+ // ----- Trace
</ins><span class="cx"> }
</span><ins>+ else {
+ // TBC : error : can not extract a folder in a string
+ }
+
+ }
</ins><span class="cx">
</span><del>- // ----- Trace
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
</del><ins>+         // ----- Change abort status
+         if ($p_entry['status'] == "aborted") {
+ $p_entry['status'] = "skipped";
+         }
+        
+ // ----- Look for post-extract callback
+ elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
+
+ // ----- Generate a local information
+ $v_local_header = array();
+ $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
+
+ // ----- Swap the content to header
+ $v_local_header['content'] = $p_string;
+ $p_string = '';
+
+ // ----- Call the callback
+ // Here I do not use call_user_func() because I need to send a reference to the
+ // header.
+ $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
+
+ // ----- Swap back the content to header
+ $p_string = $v_local_header['content'];
+ unset($v_local_header['content']);
+
+ // ----- Look for abort result
+ if ($v_result == 2) {
+         $v_result = PCLZIP_ERR_USER_ABORTED;
+ }
</ins><span class="cx"> }
</span><del>- else {
- // TBC : error : can not extract a folder in a string
- }
</del><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4632,25 +4269,20 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privReadFileHeader(&$p_header)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Read the 4 bytes signature
</span><span class="cx"> $v_binary_data = @fread($this->zip_fd, 4);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
</del><span class="cx"> $v_data = unpack('Vid', $v_binary_data);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check signature
</span><span class="cx"> if ($v_data['id'] != 0x04034b50)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4662,53 +4294,36 @@
</span><span class="cx"> {
</span><span class="cx"> $p_header['filename'] = "";
</span><span class="cx"> $p_header['status'] = "invalid_header";
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Extract the values
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
</del><span class="cx"> $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
</span><span class="cx">
</span><span class="cx"> // ----- Get filename
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
</del><span class="cx"> $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Get extra_fields
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
</del><span class="cx"> if ($v_data['extra_len'] != 0) {
</span><span class="cx"> $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
</span><span class="cx"> }
</span><span class="cx"> else {
</span><span class="cx"> $p_header['extra'] = '';
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Extract properties
</span><span class="cx"> $p_header['version_extracted'] = $v_data['version'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
</del><span class="cx"> $p_header['compression'] = $v_data['compression'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');
</del><span class="cx"> $p_header['size'] = $v_data['size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
</del><span class="cx"> $p_header['compressed_size'] = $v_data['compressed_size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
</del><span class="cx"> $p_header['crc'] = $v_data['crc'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
</del><span class="cx"> $p_header['flag'] = $v_data['flag'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag bit 11 (from right) : \''.($p_header['flag']&0x0400).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag bit 11 (from left) : \''.($p_header['flag']&0x0020).'\'');
</del><span class="cx"> $p_header['filename_len'] = $v_data['filename_len'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Recuperate date in UNIX format
</span><span class="cx"> $p_header['mdate'] = $v_data['mdate'];
</span><span class="lines">@@ -4728,17 +4343,14 @@
</span><span class="cx"> // ----- Get UNIX date format
</span><span class="cx"> $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> }
</span><span class="cx"> else
</span><span class="cx"> {
</span><span class="cx"> $p_header['mtime'] = time();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // TBC
</span><span class="cx"> //for(reset($v_data); $key = key($v_data); next($v_data)) {
</span><del>- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
</del><span class="cx"> //}
</span><span class="cx">
</span><span class="cx"> // ----- Set the stored filename
</span><span class="lines">@@ -4748,7 +4360,6 @@
</span><span class="cx"> $p_header['status'] = "ok";
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4761,25 +4372,20 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privReadCentralFileHeader(&$p_header)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Read the 4 bytes signature
</span><span class="cx"> $v_binary_data = @fread($this->zip_fd, 4);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
</del><span class="cx"> $v_data = unpack('Vid', $v_binary_data);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check signature
</span><span class="cx"> if ($v_data['id'] != 0x02014b50)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4791,53 +4397,36 @@
</span><span class="cx"> {
</span><span class="cx"> $p_header['filename'] = "";
</span><span class="cx"> $p_header['status'] = "invalid_header";
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Extract the values
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
</del><span class="cx"> $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
</span><span class="cx">
</span><span class="cx"> // ----- Get filename
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
</del><span class="cx"> if ($p_header['filename_len'] != 0)
</span><span class="cx"> $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
</span><span class="cx"> else
</span><span class="cx"> $p_header['filename'] = '';
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Get extra
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
</del><span class="cx"> if ($p_header['extra_len'] != 0)
</span><span class="cx"> $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
</span><span class="cx"> else
</span><span class="cx"> $p_header['extra'] = '';
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Get comment
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
</del><span class="cx"> if ($p_header['comment_len'] != 0)
</span><span class="cx"> $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
</span><span class="cx"> else
</span><span class="cx"> $p_header['comment'] = '';
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Extract properties
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Recuperate date in UNIX format
</span><span class="cx"> //if ($p_header['mdate'] && $p_header['mtime'])
</span><span class="lines">@@ -4857,12 +4446,10 @@
</span><span class="cx"> // ----- Get UNIX date format
</span><span class="cx"> $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> }
</span><span class="cx"> else
</span><span class="cx"> {
</span><span class="cx"> $p_header['mtime'] = time();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Set the stored filename
</span><span class="lines">@@ -4872,18 +4459,13 @@
</span><span class="cx"> $p_header['status'] = 'ok';
</span><span class="cx">
</span><span class="cx"> // ----- Look if it is a directory
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
</del><span class="cx"> if (substr($p_header['filename'], -1) == '/') {
</span><span class="cx"> //$p_header['external'] = 0x41FF0010;
</span><span class="cx"> $p_header['external'] = 0x00000010;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');
</del><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4898,44 +4480,31 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privCheckFileHeaders(&$p_local_header, &$p_central_header)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx">         // ----- Check the static values
</span><span class="cx">         // TBC
</span><span class="cx">         if ($p_local_header['filename'] != $p_central_header['filename']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');
</del><span class="cx">         }
</span><span class="cx">         if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');
</del><span class="cx">         }
</span><span class="cx">         if ($p_local_header['flag'] != $p_central_header['flag']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');
</del><span class="cx">         }
</span><span class="cx">         if ($p_local_header['compression'] != $p_central_header['compression']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');
</del><span class="cx">         }
</span><span class="cx">         if ($p_local_header['mtime'] != $p_central_header['mtime']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');
</del><span class="cx">         }
</span><span class="cx">         if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');
</del><span class="cx">         }
</span><del>-
</del><ins>+
</ins><span class="cx">         // ----- Look for flag bit 3
</span><span class="cx">         if (($p_local_header['flag'] & 8) == 8) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');
</del><span class="cx"> $p_local_header['size'] = $p_central_header['size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');
</del><span class="cx"> $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');
</del><span class="cx"> $p_local_header['crc'] = $p_central_header['crc'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -4948,21 +4517,17 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privReadEndCentralDir(&$p_central_dir)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Go to the end of the zip file
</span><span class="cx"> $v_size = filesize($this->zipname);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
</del><span class="cx"> @fseek($this->zip_fd, $v_size);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
</del><span class="cx"> if (@ftell($this->zip_fd) != $v_size)
</span><span class="cx"> {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4970,28 +4535,22 @@
</span><span class="cx"> // in this case the end of central dir is at 22 bytes of the file end
</span><span class="cx"> $v_found = 0;
</span><span class="cx"> if ($v_size > 26) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
</del><span class="cx"> @fseek($this->zip_fd, $v_size-22);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
</del><span class="cx"> if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
</span><span class="cx"> {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Read for bytes
</span><span class="cx"> $v_binary_data = @fread($this->zip_fd, 4);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
</del><span class="cx"> $v_data = @unpack('Vid', $v_binary_data);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
</del><span class="cx">
</span><span class="cx"> // ----- Check signature
</span><span class="cx"> if ($v_data['id'] == 0x06054b50) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
</del><span class="cx"> $v_found = 1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5000,7 +4559,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Go back to the maximum possible size of the Central Dir End Record
</span><span class="cx"> if (!$v_found) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
</del><span class="cx"> $v_maximum_size = 65557; // 0xFFFF + 22;
</span><span class="cx"> if ($v_maximum_size > $v_size)
</span><span class="cx"> $v_maximum_size = $v_size;
</span><span class="lines">@@ -5011,10 +4569,8 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
</del><span class="cx">
</span><span class="cx"> // ----- Read byte per byte in order to find the signature
</span><span class="cx"> $v_pos = ftell($this->zip_fd);
</span><span class="lines">@@ -5025,15 +4581,14 @@
</span><span class="cx"> $v_byte = @fread($this->zip_fd, 1);
</span><span class="cx">
</span><span class="cx"> // ----- Add the byte
</span><del>- // $v_bytes = ($v_bytes << 8) | Ord($v_byte);
- // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
- // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
- $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
</del><ins>+ //$v_bytes = ($v_bytes << 8) | Ord($v_byte);
+ // Note we mask the old value down such that once shifted we can never end up with more than a 32bit number
+ // Otherwise on systems where we have 64bit integers the check below for the magic number will fail.
+ $v_bytes = ( ($v_bytes & 0xFFFFFF) << 8) | Ord($v_byte);
</ins><span class="cx">
</span><span class="cx"> // ----- Compare the bytes
</span><span class="cx"> if ($v_bytes == 0x504b0506)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
</del><span class="cx"> $v_pos++;
</span><span class="cx"> break;
</span><span class="cx"> }
</span><span class="lines">@@ -5044,13 +4599,11 @@
</span><span class="cx"> // ----- Look if not found end of central dir
</span><span class="cx"> if ($v_pos == $v_size)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -5061,25 +4614,19 @@
</span><span class="cx"> // ----- Look for invalid block size
</span><span class="cx"> if (strlen($v_binary_data) != 18)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
</del><span class="cx">
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Extract the values
</span><del>- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
</del><span class="cx"> $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
</span><span class="cx">
</span><span class="cx"> // ----- Check the global size
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
</del><span class="cx"> if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");
</del><span class="cx">
</span><span class="cx">          // ----- Removed in release 2.2 see readme file
</span><span class="cx">          // The check of the file size is a little too strict.
</span><span class="lines">@@ -5092,40 +4639,29 @@
</span><span class="cx">                                                  .' Some trailing bytes exists after the archive.');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx">          }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Get comment
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment size : \''.$v_data['comment_size'].'\'');
</del><span class="cx"> if ($v_data['comment_size'] != 0) {
</span><span class="cx"> $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
</span><span class="cx"> }
</span><span class="cx"> else
</span><span class="cx"> $p_central_dir['comment'] = '';
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
</del><span class="cx">
</span><span class="cx"> $p_central_dir['entries'] = $v_data['entries'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
</del><span class="cx"> $p_central_dir['disk_entries'] = $v_data['disk_entries'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
</del><span class="cx"> $p_central_dir['offset'] = $v_data['offset'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
</del><span class="cx"> $p_central_dir['size'] = $v_data['size'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
</del><span class="cx"> $p_central_dir['disk'] = $v_data['disk'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
</del><span class="cx"> $p_central_dir['disk_start'] = $v_data['disk_start'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
</del><span class="cx">
</span><span class="cx"> // TBC
</span><span class="cx"> //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
</span><del>- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
</del><span class="cx"> //}
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5138,16 +4674,13 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privDeleteByRule(&$p_result_list, &$p_options)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
</del><span class="cx"> $v_result=1;
</span><span class="cx"> $v_list_detail = array();
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_result=$this->privOpenFd('rb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5156,21 +4689,16 @@
</span><span class="cx"> if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Go to beginning of File
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Scan all the files
</span><span class="cx"> // ----- Start at beginning of Central Dir
</span><span class="cx"> $v_pos_entry = $v_central_dir['offset'];
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> if (@fseek($this->zip_fd, $v_pos_entry))
</span><span class="cx"> {
</span><span class="cx"> // ----- Close the zip file
</span><span class="lines">@@ -5180,17 +4708,14 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Read each entry
</span><span class="cx"> $v_header_list = array();
</span><span class="cx"> $j_start = 0;
</span><span class="cx"> for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="cx"> $v_header_list[$v_nb_extracted] = array();
</span><span class="lines">@@ -5199,11 +4724,9 @@
</span><span class="cx"> // ----- Close the zip file
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Store the index
</span><span class="cx"> $v_header_list[$v_nb_extracted]['index'] = $i;
</span><span class="lines">@@ -5214,54 +4737,47 @@
</span><span class="cx"> // ----- Look for extract by name rule
</span><span class="cx"> if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
</del><span class="cx">
</span><span class="cx"> // ----- Look if the filename is in the list
</span><span class="cx"> for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
</del><span class="cx">
</span><span class="cx"> // ----- Look for a directory
</span><span class="cx"> if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
</del><span class="cx">
</span><span class="cx"> // ----- Look if the directory is in the filename path
</span><span class="cx"> if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
</span><span class="cx"> && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
</span><span class="cx"> && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> // ----- Look for a filename
</span><span class="cx"> elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look for extract by ereg rule
</span><ins>+ // ereg() is deprecated with PHP 5.3
+ /*
</ins><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
</del><span class="cx">
</span><span class="cx"> if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><ins>+ */
</ins><span class="cx">
</span><span class="cx"> // ----- Look for extract by preg rule
</span><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
</del><span class="cx">
</span><span class="cx"> if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -5269,41 +4785,33 @@
</span><span class="cx"> // ----- Look for extract by index rule
</span><span class="cx"> else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
</span><span class="cx"> && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
</del><span class="cx">
</span><span class="cx"> // ----- Look if the index is in the list
</span><span class="cx"> for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
</del><span class="cx">
</span><span class="cx"> if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
</del><span class="cx"> $v_found = true;
</span><span class="cx"> }
</span><span class="cx"> if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
</del><span class="cx"> $j_start = $j+1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
</del><span class="cx"> break;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> else {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");
</del><span class="cx">         $v_found = true;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look for deletion
</span><span class="cx"> if ($v_found)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
</del><span class="cx"> unset($v_header_list[$v_nb_extracted]);
</span><span class="cx"> }
</span><span class="cx"> else
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
</del><span class="cx"> $v_nb_extracted++;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="lines">@@ -5318,24 +4826,18 @@
</span><span class="cx"> $v_temp_zip = new PclZip($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Open the temporary zip file in write mode
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
</del><span class="cx"> if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look which file need to be kept
</span><span class="cx"> for ($i=0; $i<sizeof($v_header_list); $i++) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Calculate the position of the header
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
</del><span class="cx"> if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
</span><span class="cx"> // ----- Close the zip file
</span><span class="cx"> $this->privCloseFd();
</span><span class="lines">@@ -5346,10 +4848,8 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Read the file header
</span><span class="cx"> $v_local_header = array();
</span><span class="lines">@@ -5360,10 +4860,9 @@
</span><span class="cx"> @unlink($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Check that local file header is same as central file header
</span><span class="cx"> if ($this->privCheckFileHeaders($v_local_header,
</span><span class="cx">                          $v_header_list[$i]) != 1) {
</span><span class="lines">@@ -5379,10 +4878,8 @@
</span><span class="cx"> @unlink($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
</del><span class="cx">
</span><span class="cx"> // ----- Read/write the data block
</span><span class="cx"> if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
</span><span class="lines">@@ -5392,27 +4889,22 @@
</span><span class="cx"> @unlink($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Store the offset of the central dir
</span><span class="cx"> $v_offset = @ftell($v_temp_zip->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
</del><span class="cx">
</span><span class="cx"> // ----- Re-Create the Central Dir files header
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
</del><span class="cx"> for ($i=0; $i<sizeof($v_header_list); $i++) {
</span><span class="cx"> // ----- Create the file header
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
</del><span class="cx"> if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
</span><span class="cx"> $v_temp_zip->privCloseFd();
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> @unlink($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5420,7 +4912,6 @@
</span><span class="cx"> $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
</span><span class="cx"> }
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
</del><span class="cx">
</span><span class="cx"> // ----- Zip file comment
</span><span class="cx"> $v_comment = '';
</span><span class="lines">@@ -5440,7 +4931,6 @@
</span><span class="cx"> @unlink($v_zip_temp_name);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5456,22 +4946,20 @@
</span><span class="cx"> // TBC : I should test the result ...
</span><span class="cx"> //@rename($v_zip_temp_name, $this->zipname);
</span><span class="cx"> PclZipUtilRename($v_zip_temp_name, $this->zipname);
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Destroy the temporary archive
</span><span class="cx"> unset($v_temp_zip);
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Remove every files : reset the file
</span><span class="cx"> else if ($v_central_dir['entries'] != 0) {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx">
</span><span class="cx"> if (($v_result = $this->privOpenFd('wb')) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5479,7 +4967,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5499,25 +4986,21 @@
</span><span class="cx"> {
</span><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
</del><span class="cx">
</span><span class="cx"> // ----- Remove the final '/'
</span><span class="cx"> if (($p_is_dir) && (substr($p_dir, -1)=='/'))
</span><span class="cx"> {
</span><span class="cx"> $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
</del><span class="cx">
</span><span class="cx"> // ----- Check the directory availability
</span><span class="cx"> if ((is_dir($p_dir)) || ($p_dir == ""))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
</del><span class="cx"> return 1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Extract parent directory
</span><span class="cx"> $p_parent_dir = dirname($p_dir);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
</del><span class="cx">
</span><span class="cx"> // ----- Just a check
</span><span class="cx"> if ($p_parent_dir != $p_dir)
</span><span class="lines">@@ -5527,26 +5010,22 @@
</span><span class="cx"> {
</span><span class="cx"> if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Create the directory
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
</del><span class="cx"> if (!@mkdir($p_dir, 0777))
</span><span class="cx"> {
</span><span class="cx"> // ----- Error log
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5560,41 +5039,34 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privMerge(&$p_archive_to_add)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Look if the archive_to_add exists
</span><span class="cx"> if (!is_file($p_archive_to_add->zipname))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
</del><span class="cx">
</span><span class="cx"> // ----- Nothing to merge, so merge is a success
</span><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Look if the archive exists
</span><span class="cx"> if (!is_file($this->zipname))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
</del><span class="cx">
</span><span class="cx"> // ----- Do a duplicate
</span><span class="cx"> $v_result = $this->privDuplicate($p_archive_to_add->zipname);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_result=$this->privOpenFd('rb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5603,23 +5075,18 @@
</span><span class="cx"> if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Go to beginning of File
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
</del><span class="cx"> @rewind($this->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Open the archive_to_add file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
</del><span class="cx"> if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5630,20 +5097,16 @@
</span><span class="cx"> $this->privCloseFd();
</span><span class="cx"> $p_archive_to_add->privCloseFd();
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Go to beginning of File
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
</del><span class="cx"> @rewind($p_archive_to_add->zip_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
</del><span class="cx">
</span><span class="cx"> // ----- Creates a temporay file
</span><span class="cx"> $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
</span><span class="cx">
</span><span class="cx"> // ----- Open the temporary file in write mode
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><span class="lines">@@ -5652,7 +5115,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5662,7 +5124,6 @@
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = fread($this->zip_fd, $v_read_size);
</span><span class="cx"> @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -5673,7 +5134,6 @@
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
</span><span class="cx"> @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -5681,14 +5141,12 @@
</span><span class="cx">
</span><span class="cx"> // ----- Store the offset of the central dir
</span><span class="cx"> $v_offset = @ftell($v_zip_temp_fd);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
</del><span class="cx">
</span><span class="cx"> // ----- Copy the block of file headers from the old archive
</span><span class="cx"> $v_size = $v_central_dir['size'];
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($this->zip_fd, $v_read_size);
</span><span class="cx"> @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -5699,7 +5157,6 @@
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
</span><span class="cx"> @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -5730,7 +5187,6 @@
</span><span class="cx"> unset($v_header_list);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5756,7 +5212,6 @@
</span><span class="cx"> PclZipUtilRename($v_zip_temp_name, $this->zipname);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5769,33 +5224,27 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privDuplicate($p_archive_filename)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Look if the $p_archive_filename exists
</span><span class="cx"> if (!is_file($p_archive_filename))
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
</del><span class="cx">
</span><span class="cx"> // ----- Nothing to duplicate, so duplicate is a success.
</span><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Open the zip file
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_result=$this->privOpenFd('wb')) != 1)
</span><span class="cx"> {
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Open the temporary file in write mode
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
</del><span class="cx"> if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
</span><span class="cx"> {
</span><span class="cx"> $this->privCloseFd();
</span><span class="lines">@@ -5803,7 +5252,6 @@
</span><span class="cx"> PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
</del><span class="cx"> return PclZip::errorCode();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -5813,7 +5261,6 @@
</span><span class="cx"> while ($v_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = fread($v_zip_temp_fd, $v_read_size);
</span><span class="cx"> @fwrite($this->zip_fd, $v_buffer, $v_read_size);
</span><span class="cx"> $v_size -= $v_read_size;
</span><span class="lines">@@ -5826,7 +5273,6 @@
</span><span class="cx"> @fclose($v_zip_temp_fd);
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5873,36 +5319,28 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privDisableMagicQuotes()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Look if function exists
</span><span class="cx"> if ( (!function_exists("get_magic_quotes_runtime"))
</span><span class="cx">          || (!function_exists("set_magic_quotes_runtime"))) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> // ----- Look if already done
</span><span class="cx"> if ($this->magic_quotes_status != -1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // ----- Get and memorize the magic_quote value
</span><span class="cx">         $this->magic_quotes_status = @get_magic_quotes_runtime();
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");
</del><span class="cx">
</span><span class="cx">         // ----- Disable magic_quotes
</span><span class="cx">         if ($this->magic_quotes_status == 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");
</del><span class="cx">          @set_magic_quotes_runtime(0);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5915,32 +5353,25 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function privSwapBackMagicQuotes()
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
</del><span class="cx"> $v_result=1;
</span><span class="cx">
</span><span class="cx"> // ----- Look if function exists
</span><span class="cx"> if ( (!function_exists("get_magic_quotes_runtime"))
</span><span class="cx">          || (!function_exists("set_magic_quotes_runtime"))) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> // ----- Look if something to do
</span><span class="cx"> if ($this->magic_quotes_status != -1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         // ----- Swap back magic_quotes
</span><span class="cx">         if ($this->magic_quotes_status == 1) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
</del><span class="cx">          @set_magic_quotes_runtime($this->magic_quotes_status);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -5957,7 +5388,6 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZipUtilPathReduction($p_dir)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
</del><span class="cx"> $v_result = "";
</span><span class="cx">
</span><span class="cx"> // ----- Look for not empty path
</span><span class="lines">@@ -5984,7 +5414,6 @@
</span><span class="cx">                  // ----- It is an invalid path, so the path is not modified
</span><span class="cx">                  // TBC
</span><span class="cx">                  $v_result = $p_dir;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");
</del><span class="cx"> $v_skip = 0;
</span><span class="cx">                  }
</span><span class="cx">                  }
</span><span class="lines">@@ -6008,7 +5437,7 @@
</span><span class="cx">                  }
</span><span class="cx"> }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for skip
</span><span class="cx"> if ($v_skip > 0) {
</span><span class="cx"> while ($v_skip > 0) {
</span><span class="lines">@@ -6019,7 +5448,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -6041,19 +5469,16 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZipUtilPathInclusion($p_dir, $p_path)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
</del><span class="cx"> $v_result = 1;
</span><del>-
</del><ins>+
</ins><span class="cx"> // ----- Look for path beginning by ./
</span><span class="cx"> if ( ($p_dir == '.')
</span><span class="cx"> || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
</span><span class="cx"> $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'");
</del><span class="cx"> }
</span><span class="cx"> if ( ($p_path == '.')
</span><span class="cx"> || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
</span><span class="cx"> $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'");
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Explode dir and path by directory separator
</span><span class="lines">@@ -6066,7 +5491,6 @@
</span><span class="cx"> $i = 0;
</span><span class="cx"> $j = 0;
</span><span class="cx"> while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
</del><span class="cx">
</span><span class="cx"> // ----- Look for empty dir (path reduction)
</span><span class="cx"> if ($v_list_dir[$i] == '') {
</span><span class="lines">@@ -6080,7 +5504,6 @@
</span><span class="cx">
</span><span class="cx"> // ----- Compare the items
</span><span class="cx"> if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
</del><span class="cx"> $v_result = 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -6091,11 +5514,9 @@
</span><span class="cx">
</span><span class="cx"> // ----- Look if everything seems to be the same
</span><span class="cx"> if ($v_result) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
</del><span class="cx"> // ----- Skip all the empty items
</span><span class="cx"> while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
</span><span class="cx"> while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
</del><span class="cx">
</span><span class="cx"> if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
</span><span class="cx"> // ----- There are exactly the same
</span><span class="lines">@@ -6108,7 +5529,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -6126,30 +5546,23 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
</del><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> if ($p_mode==0)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
</del><span class="cx"> while ($p_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($p_src, $v_read_size);
</span><span class="cx"> @fwrite($p_dest, $v_buffer, $v_read_size);
</span><span class="cx"> $p_size -= $v_read_size;
</span><span class="cx"> }
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
</del><span class="cx"> }
</span><span class="cx"> else if ($p_mode==1)
</span><span class="cx"> {
</span><span class="cx"> while ($p_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @gzread($p_src, $v_read_size);
</span><span class="cx"> @fwrite($p_dest, $v_buffer, $v_read_size);
</span><span class="cx"> $p_size -= $v_read_size;
</span><span class="lines">@@ -6160,7 +5573,6 @@
</span><span class="cx"> while ($p_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @fread($p_src, $v_read_size);
</span><span class="cx"> @gzwrite($p_dest, $v_buffer, $v_read_size);
</span><span class="cx"> $p_size -= $v_read_size;
</span><span class="lines">@@ -6171,7 +5583,6 @@
</span><span class="cx"> while ($p_size != 0)
</span><span class="cx"> {
</span><span class="cx"> $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
</del><span class="cx"> $v_buffer = @gzread($p_src, $v_read_size);
</span><span class="cx"> @gzwrite($p_dest, $v_buffer, $v_read_size);
</span><span class="cx"> $p_size -= $v_read_size;
</span><span class="lines">@@ -6179,7 +5590,6 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -6198,26 +5608,21 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZipUtilRename($p_src, $p_dest)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
</del><span class="cx"> $v_result = 1;
</span><span class="cx">
</span><span class="cx"> // ----- Try to rename the files
</span><span class="cx"> if (!@rename($p_src, $p_dest)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
</del><span class="cx">
</span><span class="cx"> // ----- Try to copy & unlink the src
</span><span class="cx"> if (!@copy($p_src, $p_dest)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
</del><span class="cx"> $v_result = 0;
</span><span class="cx"> }
</span><span class="cx"> else if (!@unlink($p_src)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
</del><span class="cx"> $v_result = 0;
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ----- Return
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="lines">@@ -6233,8 +5638,7 @@
</span><span class="cx"> // --------------------------------------------------------------------------------
</span><span class="cx"> function PclZipUtilOptionText($p_option)
</span><span class="cx"> {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
-
</del><ins>+
</ins><span class="cx"> $v_list = get_defined_constants();
</span><span class="cx"> for (reset($v_list); $v_key = key($v_list); next($v_list)) {
</span><span class="cx">          $v_prefix = substr($v_key, 0, 10);
</span><span class="lines">@@ -6242,14 +5646,12 @@
</span><span class="cx"> || ($v_prefix == 'PCLZIP_CB_')
</span><span class="cx"> || ($v_prefix == 'PCLZIP_ATT'))
</span><span class="cx">          && ($v_list[$v_key] == $p_option)) {
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
</del><span class="cx"> return $v_key;
</span><span class="cx">          }
</span><span class="cx"> }
</span><del>-
</del><ins>+
</ins><span class="cx"> $v_result = 'Unknown';
</span><span class="cx">
</span><del>- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
</del><span class="cx"> return $v_result;
</span><span class="cx"> }
</span><span class="cx"> // --------------------------------------------------------------------------------
</span></span></pre>
</div>
</div>
</body>
</html>