]> git.mjollnir.org Git - moodle.git/commitdiff
Added Version 1.3 of PclZip to the distribution
authormoodler <moodler>
Sun, 6 Apr 2003 05:48:56 +0000 (05:48 +0000)
committermoodler <moodler>
Sun, 6 Apr 2003 05:48:56 +0000 (05:48 +0000)
lang/en/docs/credits.html
lib/pclzip/gnu-lgpl.txt [new file with mode: 0644]
lib/pclzip/pclzip.lib.php [new file with mode: 0644]
lib/pclzip/readme.txt [new file with mode: 0644]

index 427867017b9910f65557f6fcaec601bfedcc717c..1365d5e0629e2a8e52af48bd0e5a824d2dd9dc5f 100644 (file)
@@ -158,6 +158,19 @@ Interbase, Foxpro, Access, ADO, Sybase, DB2 and ODBC.</P>
   URL: <A HREF="http://www.xpenguin.com/ip-atlas.php" TARGET="newpage">http://www.xpenguin.com/ip-atlas.php</A><BR>\r
          </BLOCKQUOTE>\r
                            \r
+\r
+\r
+           <P><B>PclZip</B>&nbsp; - &nbsp; lib/pclzip</P>\r
+                       \r
+          <BLOCKQUOTE>Class to create, manage and unpack zip files.<BR>\r
+              <BR>\r
+  Version: 1.3<BR>\r
+ Copyright &copy; 2003 &nbsp;Vincent Blavet &lt;vincent@phpconcept.net&gt;<BR>\r
+ License: GNU GPL<BR>\r
+  URL: <A HREF="http://www.phpconcept.net" TARGET="newpage">http://www.phpconcept.net</A><BR>\r
+           </BLOCKQUOTE>\r
+\r
+\r
                \r
       <P><B>PHP mailer</B> &nbsp; - &nbsp;lib/class.phpmailer.php<BR>\r
         </P>\r
diff --git a/lib/pclzip/gnu-lgpl.txt b/lib/pclzip/gnu-lgpl.txt
new file mode 100644 (file)
index 0000000..b1e3f5a
--- /dev/null
@@ -0,0 +1,504 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+\f
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+\f
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+\f
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+\f
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+\f
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+\f
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+\f
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+\f
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/lib/pclzip/pclzip.lib.php b/lib/pclzip/pclzip.lib.php
new file mode 100644 (file)
index 0000000..13b75d6
--- /dev/null
@@ -0,0 +1,4559 @@
+<?php\r
+// --------------------------------------------------------------------------------\r
+// PhpConcept Library - Zip Module 1.3\r
+// --------------------------------------------------------------------------------\r
+// License GNU/LGPL - Vincent Blavet - January 2003\r
+// http://www.phpconcept.net\r
+// --------------------------------------------------------------------------------\r
+//\r
+// Presentation :\r
+//   PclZip is a PHP library that manage ZIP archives.\r
+//   So far tests show that archives generated by PclZip are readable by\r
+//   WinZip application and other tools.\r
+//\r
+// Description :\r
+//   See readme.txt and http://www.phpconcept.net\r
+//\r
+// Warning :\r
+//   This library and the associated files are non commercial, non professional\r
+//   work.\r
+//   It should not have unexpected results. However if any damage is caused by\r
+//   this software the author can not be responsible.\r
+//   The use of this software is at the risk of the user.\r
+//\r
+// --------------------------------------------------------------------------------\r
+// $Id$\r
+// --------------------------------------------------------------------------------\r
+\r
+  // ----- Constants\r
+  define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );\r
+\r
+  // ----- Error configuration\r
+  // 0 : PclZip Class integrated error handling\r
+  // 1 : PclError external library error handling. By enabling this\r
+  //     you must ensure that you have included PclError library.\r
+  // [2,...] : reserved for futur use\r
+  define( 'PCLZIP_ERROR_EXTERNAL', 0 );\r
+\r
+  // ----- Optional static temporary directory\r
+  //       By default temporary files are generated in the script current\r
+  //       path.\r
+  //       If defined :\r
+  //       - MUST BE terminated by a '/'.\r
+  //       - MUST be a valid, already created directory\r
+  //       Samples :\r
+  // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );\r
+  // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );\r
+  define( 'PCLZIP_TEMPORARY_DIR', '' );\r
+\r
+// --------------------------------------------------------------------------------\r
+// ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****\r
+// --------------------------------------------------------------------------------\r
+\r
+  // ----- Global variables\r
+  $g_pclzip_version = "1.3";\r
+\r
+  // ----- Error codes\r
+  //   -1 : Unable to open file in binary write mode\r
+  //   -2 : Unable to open file in binary read mode\r
+  //   -3 : Invalid parameters\r
+  //   -4 : File does not exist\r
+  //   -5 : Filename is too long (max. 255)\r
+  //   -6 : Not a valid zip file\r
+  //   -7 : Invalid extracted file size\r
+  //   -8 : Unable to create directory\r
+  //   -9 : Invalid archive extension\r
+  //  -10 : Invalid archive format\r
+  //  -11 : Unable to delete file (unlink)\r
+  //  -12 : Unable to rename file (rename)\r
+  //  -13 : Invalid header checksum\r
+  //  -14 : Invalid archive size\r
+  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );\r
+  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );\r
+  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );\r
+  define( 'PCLZIP_ERR_MISSING_FILE', -4 );\r
+  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );\r
+  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );\r
+  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );\r
+  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );\r
+  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );\r
+  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );\r
+  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );\r
+  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );\r
+  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );\r
+  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );\r
+  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );\r
+  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );\r
+\r
+  // ----- Options values\r
+  define( 'PCLZIP_OPT_PATH', 77001 );\r
+  define( 'PCLZIP_OPT_ADD_PATH', 77002 );\r
+  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );\r
+  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );\r
+  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );\r
+\r
+  // ----- Call backs values\r
+  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );\r
+  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );\r
+  define( 'PCLZIP_CB_PRE_ADD', 78003 );\r
+  define( 'PCLZIP_CB_POST_ADD', 78004 );\r
+  /* For futur use\r
+  define( 'PCLZIP_CB_PRE_LIST', 78005 );\r
+  define( 'PCLZIP_CB_POST_LIST', 78006 );\r
+  define( 'PCLZIP_CB_PRE_DELETE', 78007 );\r
+  define( 'PCLZIP_CB_POST_DELETE', 78008 );\r
+  */\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Class : PclZip\r
+  // Description :\r
+  //   PclZip is the class that represent a Zip archive.\r
+  //   The public methods allow the manipulation of the archive.\r
+  // Attributes :\r
+  //   Attributes must not be accessed directly.\r
+  // Methods :\r
+  //   PclZip() : Object creator\r
+  //   create() : Creates the Zip archive\r
+  //   listContent() : List the content of the Zip archive\r
+  //   extract() : Extract the content of the archive\r
+  //   properties() : List the properties of the archive\r
+  // --------------------------------------------------------------------------------\r
+  class PclZip\r
+  {\r
+    // ----- Filename of the zip file\r
+    var $zipname = '';\r
+\r
+    // ----- File descriptor of the zip file\r
+    var $zip_fd = 0;\r
+\r
+    // ----- Internal error handling\r
+    var $error_code = 1;\r
+    var $error_string = '';\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZip()\r
+  // Description :\r
+  //   Creates a PclZip object and set the name of the associated Zip archive\r
+  //   filename.\r
+  //   Note that no real action is taken, if the archive does not exist it is not\r
+  //   created. Use create() for that.\r
+  // --------------------------------------------------------------------------------\r
+  function PclZip($p_zipname)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");\r
+\r
+    // ----- Tests the zlib\r
+    if (!function_exists('gzopen'))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");\r
+      die('Abort '.basename(__FILE__).' : Missing zlib extensions');\r
+    }\r
+\r
+    // ----- Set the attributes\r
+    $this->zipname = $p_zipname;\r
+    $this->zip_fd = 0;\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);\r
+    return;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function :\r
+  //   create($p_filelist, $p_add_dir="", $p_remove_dir="")\r
+  //   create($p_filelist, $p_option, $p_option_value, ...)\r
+  // Description :\r
+  //   This method supports two different synopsis. The first one is historical.\r
+  //   This method creates a Zip Archive. The Zip file is created in the\r
+  //   filesystem. The files and directories indicated in $p_filelist\r
+  //   are added in the archive. See the parameters description for the\r
+  //   supported format of $p_filelist.\r
+  //   When a directory is in the list, the directory and its content is added\r
+  //   in the archive.\r
+  //   In this synopsis, the function takes an optional variable list of\r
+  //   options. See bellow the supported options.\r
+  // Parameters :\r
+  //   $p_filelist : An array containing file or directory names, or\r
+  //                 a string containing one filename or one directory name, or\r
+  //                 a string containing a list of filenames and/or directory\r
+  //                 names separated by spaces.\r
+  //   $p_add_dir : A path to add before the real path of the archived file,\r
+  //                in order to have it memorized in the archive.\r
+  //   $p_remove_dir : A path to remove from the real path of the file to archive,\r
+  //                   in order to have a shorter path memorized in the archive.\r
+  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir\r
+  //                   is removed first, before $p_add_dir is added.\r
+  // Options :\r
+  //   PCLZIP_OPT_ADD_PATH :\r
+  //   PCLZIP_OPT_REMOVE_PATH :\r
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
+  //   PCLZIP_CB_PRE_ADD :\r
+  //   PCLZIP_CB_POST_ADD :\r
+  // Return Values :\r
+  //   0 on failure,\r
+  //   The list of the added files, with a status of the add action.\r
+  //   (see PclZip::listContent() for list entry format)\r
+  // --------------------------------------------------------------------------------\r
+//  function create($p_filelist, $p_add_dir="", $p_remove_dir="")\r
+  function create($p_filelist /*, options */)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Set default values\r
+    $v_options = array();\r
+    $v_add_path = "";\r
+    $v_remove_path = "";\r
+    $v_remove_all_path = false;\r
+\r
+    // ----- Look for variable options arguments\r
+    $v_size = func_num_args();\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
+\r
+    // ----- Look for arguments\r
+    if ($v_size > 1) {\r
+      // ----- Get the arguments\r
+      $v_arg_list = &func_get_args();\r
+\r
+      // ----- Remove form the options list the first argument\r
+      array_shift($v_arg_list);\r
+      $v_size--;\r
+\r
+      // ----- Look for first arg\r
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");\r
+\r
+        // ----- Parse the options\r
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
+                                                   PCLZIP_CB_PRE_ADD => 'optional',\r
+                                                   PCLZIP_CB_POST_ADD => 'optional' ));\r
+        if ($v_result != 1) {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+          return 0;\r
+        }\r
+\r
+        // ----- Set the arguments\r
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
+          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
+        }\r
+      }\r
+\r
+      // ----- Look for 2 args\r
+      // Here we need to support the first historic synopsis of the\r
+      // method.\r
+      else {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
+\r
+        // ----- Get the first argument\r
+        $v_add_path = $v_arg_list[0];\r
+\r
+        // ----- Look for the optional second argument\r
+        if ($v_size == 2) {\r
+          $v_remove_path = $v_arg_list[1];\r
+        }\r
+        else if ($v_size > 2) {\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return 0;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Trace\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");\r
+\r
+    // ----- Look if the $p_filelist is really an array\r
+    $p_result_list = array();\r
+    if (is_array($p_filelist))\r
+    {\r
+      // ----- Call the create fct\r
+      $v_result = $this->privCreate($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
+    }\r
+\r
+    // ----- Look if the $p_filelist is a string\r
+    else if (is_string($p_filelist))\r
+    {\r
+      // ----- Create a list with the elements from the string\r
+      $v_list = explode(" ", $p_filelist);\r
+\r
+      // ----- Call the create fct\r
+      $v_result = $this->privCreate($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");\r
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
+    }\r
+\r
+    if ($v_result != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return 0;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);\r
+    return $p_result_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function :\r
+  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")\r
+  //   add($p_filelist, $p_option, $p_option_value, ...)\r
+  // Description :\r
+  //   This method supports two synopsis. The first one is historical.\r
+  //   This methods add the list of files in an existing archive.\r
+  //   If a file with the same name already exists, it is added at the end of the\r
+  //   archive, the first one is still present.\r
+  //   If the archive does not exist, it is created.\r
+  // Parameters :\r
+  //   $p_filelist : An array containing file or directory names, or\r
+  //                 a string containing one filename or one directory name, or\r
+  //                 a string containing a list of filenames and/or directory\r
+  //                 names separated by spaces.\r
+  //   $p_add_dir : A path to add before the real path of the archived file,\r
+  //                in order to have it memorized in the archive.\r
+  //   $p_remove_dir : A path to remove from the real path of the file to archive,\r
+  //                   in order to have a shorter path memorized in the archive.\r
+  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir\r
+  //                   is removed first, before $p_add_dir is added.\r
+  // Options :\r
+  //   PCLZIP_OPT_ADD_PATH :\r
+  //   PCLZIP_OPT_REMOVE_PATH :\r
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
+  //   PCLZIP_CB_PRE_ADD :\r
+  //   PCLZIP_CB_POST_ADD :\r
+  // Return Values :\r
+  //   0 on failure,\r
+  //   The list of the added files, with a status of the add action.\r
+  //   (see PclZip::listContent() for list entry format)\r
+  // --------------------------------------------------------------------------------\r
+//  function add($p_filelist, $p_add_dir="", $p_remove_dir="")\r
+  function add($p_filelist /* options */)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Set default values\r
+    $v_options = array();\r
+    $v_add_path = "";\r
+    $v_remove_path = "";\r
+    $v_remove_all_path = false;\r
+\r
+    // ----- Look for variable options arguments\r
+    $v_size = func_num_args();\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
+\r
+    // ----- Look for arguments\r
+    if ($v_size > 1) {\r
+      // ----- Get the arguments\r
+      $v_arg_list = &func_get_args();\r
+\r
+      // ----- Remove form the options list the first argument\r
+      array_shift($v_arg_list);\r
+      $v_size--;\r
+\r
+      // ----- Look for first arg\r
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");\r
+\r
+        // ----- Parse the options\r
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
+                                            array (PCLZIP_OPT_REMOVE_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
+                                                   PCLZIP_CB_PRE_ADD => 'optional',\r
+                                                   PCLZIP_CB_POST_ADD => 'optional' ));\r
+        if ($v_result != 1) {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+          return 0;\r
+        }\r
+\r
+        // ----- Set the arguments\r
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
+          $v_add_path = $v_options[PCLZIP_OPT_ADD_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
+        }\r
+      }\r
+\r
+      // ----- Look for 2 args\r
+      // Here we need to support the first historic synopsis of the\r
+      // method.\r
+      else {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
+\r
+        // ----- Get the first argument\r
+        $v_add_path = $v_arg_list[0];\r
+\r
+        // ----- Look for the optional second argument\r
+        if ($v_size == 2) {\r
+          $v_remove_path = $v_arg_list[1];\r
+        }\r
+        else if ($v_size > 2) {\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return 0;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Trace\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "add_path='$v_add_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_all_path?'true':'false')."'");\r
+\r
+    // ----- Look if the $p_filelist is really an array\r
+    $p_result_list = array();\r
+    if (is_array($p_filelist))\r
+    {\r
+      // ----- Call the create fct\r
+      $v_result = $this->privAdd($p_filelist, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
+    }\r
+\r
+    // ----- Look if the $p_filelist is a string\r
+    else if (is_string($p_filelist))\r
+    {\r
+      // ----- Create a list with the elements from the string\r
+      $v_list = explode(" ", $p_filelist);\r
+\r
+      // ----- Call the create fct\r
+      $v_result = $this->privAdd($v_list, $p_result_list, $v_add_path, $v_remove_path, $v_remove_all_path, $v_options);\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");\r
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
+    }\r
+\r
+    if ($v_result != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return 0;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);\r
+    return $p_result_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : listContent()\r
+  // Description :\r
+  //   This public method, gives the list of the files and directories, with their\r
+  //   properties.\r
+  //   The properties of each entries in the list are (used also in other functions) :\r
+  //     filename : Name of the file. For a create or add action it is the filename\r
+  //                given by the user. For an extract function it is the filename\r
+  //                of the extracted file.\r
+  //     stored_filename : Name of the file / directory stored in the archive.\r
+  //     size : Size of the stored file.\r
+  //     compressed_size : Size of the file's data compressed in the archive\r
+  //                       (without the headers overhead)\r
+  //     mtime : Last known modification date of the file (UNIX timestamp)\r
+  //     comment : Comment associated with the file\r
+  //     folder : true | false\r
+  //     index : index of the file in the archive\r
+  //     status : status of the action (depending of the action) :\r
+  //              Values are :\r
+  //                ok : OK !\r
+  //                filtered : the file / dir is not extracted (filtered by user)\r
+  //                already_a_directory : the file can not be extracted because a\r
+  //                                      directory with the same name already exists\r
+  //                write_protected : the file can not be extracted because a file\r
+  //                                  with the same name already exists and is\r
+  //                                  write protected\r
+  //                newer_exist : the file was not extracted because a newer file exists\r
+  //                path_creation_fail : the file is not extracted because the folder\r
+  //                                     does not exists and can not be created\r
+  //                write_error : the file was not extracted because there was a\r
+  //                              error while writing the file\r
+  //                read_error : the file was not extracted because there was a error\r
+  //                             while reading the file\r
+  //                invalid_header : the file was not extracted because of an archive\r
+  //                                 format error (bad file header)\r
+  //   Note that each time a method can continue operating when there\r
+  //   is an action error on a file, the error is only logged in the file status.\r
+  // Return Values :\r
+  //   0 on an unrecoverable failure,\r
+  //   The list of the files in the archive.\r
+  // --------------------------------------------------------------------------------\r
+  function listContent()\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Call the extracting fct\r
+    $p_list = array();\r
+    if (($v_result = $this->privList($p_list)) != 1)\r
+    {\r
+      unset($p_list);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+      return(0);\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
+    return $p_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function :\r
+  //   extract($p_path="./", $p_remove_path="")\r
+  //   extract([$p_option, $p_option_value, ...])\r
+  // Description :\r
+  //   This method supports two synopsis. The first one is historical.\r
+  //   This method extract all the files / directories from the archive to the\r
+  //   folder indicated in $p_path.\r
+  //   If you want to ignore the 'root' part of path of the memorized files\r
+  //   you can indicate this in the optional $p_remove_path parameter.\r
+  //   By default, if a newer file with the same name already exists, the\r
+  //   file is not extracted.\r
+  //\r
+  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions\r
+  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append\r
+  //   at the end of the path value of PCLZIP_OPT_PATH.\r
+  // Parameters :\r
+  //   $p_path : Path where the files and directories are to be extracted\r
+  //   $p_remove_path : First part ('root' part) of the memorized path\r
+  //                    (if any similar) to remove while extracting.\r
+  // Options :\r
+  //   PCLZIP_OPT_PATH :\r
+  //   PCLZIP_OPT_ADD_PATH :\r
+  //   PCLZIP_OPT_REMOVE_PATH :\r
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
+  //   PCLZIP_CB_PRE_EXTRACT :\r
+  //   PCLZIP_CB_POST_EXTRACT :\r
+  // Return Values :\r
+  //   0 or a negative value on failure,\r
+  //   The list of the extracted files, with a status of the action.\r
+  //   (see PclZip::listContent() for list entry format)\r
+  // --------------------------------------------------------------------------------\r
+  //function extract($p_path="./", $p_remove_path="")\r
+  function extract(/* options */)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip:extract", "");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Set default values\r
+    $v_options = array();\r
+    $v_path = "./";\r
+    $v_remove_path = "";\r
+    $v_remove_all_path = false;\r
+\r
+    // ----- Look for variable options arguments\r
+    $v_size = func_num_args();\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
+\r
+    // ----- Look for arguments\r
+    if ($v_size > 0) {\r
+      // ----- Get the arguments\r
+      $v_arg_list = &func_get_args();\r
+\r
+      // ----- Look for first arg\r
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");\r
+\r
+        // ----- Parse the options\r
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
+                                            array (PCLZIP_OPT_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',\r
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',\r
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional' ));\r
+        if ($v_result != 1) {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+          return 0;\r
+        }\r
+\r
+        // ----- Set the arguments\r
+        if (isset($v_options[PCLZIP_OPT_PATH])) {\r
+          $v_path = $v_options[PCLZIP_OPT_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
+          // ----- Check for '/' in last path char\r
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {\r
+            $v_path .= '/';\r
+          }\r
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];\r
+        }\r
+      }\r
+\r
+      // ----- Look for 2 args\r
+      // Here we need to support the first historic synopsis of the\r
+      // method.\r
+      else {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
+\r
+        // ----- Get the first argument\r
+        $v_path = $v_arg_list[0];\r
+\r
+        // ----- Look for the optional second argument\r
+        if ($v_size == 2) {\r
+          $v_remove_path = $v_arg_list[1];\r
+        }\r
+        else if ($v_size > 2) {\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+          return 0;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Trace\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");\r
+\r
+    // ----- Call the extracting fct\r
+    $p_list = array();\r
+    if (($v_result = $this->privExtract($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)\r
+    {\r
+      unset($p_list);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+      return(0);\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
+    return $p_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function :\r
+  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")\r
+  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])\r
+  // Description :\r
+  //   This method supports two synopsis. The first one is historical.\r
+  //   This method is doing a partial extract of the archive.\r
+  //   The extracted files or folders are identified by their index in the\r
+  //   archive (from 0 to n).\r
+  //   Note that if the index identify a folder, only the folder entry is\r
+  //   extracted, not all the files included in the archive.\r
+  // Parameters :\r
+  //   $p_index : A single index (integer) or a string of indexes of files to\r
+  //              extract. The form of the string is "0,4-6,8-12" with only numbers\r
+  //              and '-' for range or ',' to separate ranges. No spaces or ';'\r
+  //              are allowed.\r
+  //   $p_path : Path where the files and directories are to be extracted\r
+  //   $p_remove_path : First part ('root' part) of the memorized path\r
+  //                    (if any similar) to remove while extracting.\r
+  // Options :\r
+  //   PCLZIP_OPT_PATH :\r
+  //   PCLZIP_OPT_ADD_PATH :\r
+  //   PCLZIP_OPT_REMOVE_PATH :\r
+  //   PCLZIP_OPT_REMOVE_ALL_PATH :\r
+  //   PCLZIP_CB_PRE_EXTRACT :\r
+  //   PCLZIP_CB_POST_EXTRACT :\r
+  // Return Values :\r
+  //   0 on failure,\r
+  //   The list of the extracted files, with a status of the action.\r
+  //   (see PclZip::listContent() for list entry format)\r
+  // --------------------------------------------------------------------------------\r
+//  function extractByIndex($p_index, $p_path="./", $p_remove_path="")\r
+  function extractByIndex($p_index /* $options */)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Set default values\r
+    $v_options = array();\r
+    $v_path = "./";\r
+    $v_remove_path = "";\r
+    $v_remove_all_path = false;\r
+\r
+    // ----- Look for variable options arguments\r
+    $v_size = func_num_args();\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");\r
+\r
+    // ----- Look for arguments\r
+    if ($v_size > 1) {\r
+      // ----- Get the arguments\r
+      $v_arg_list = &func_get_args();\r
+\r
+      // ----- Remove form the options list the first argument\r
+      array_shift($v_arg_list);\r
+      $v_size--;\r
+\r
+      // ----- Look for first arg\r
+      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");\r
+\r
+        // ----- Parse the options\r
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,\r
+                                            array (PCLZIP_OPT_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',\r
+                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',\r
+                                                   PCLZIP_OPT_ADD_PATH => 'optional',\r
+                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',\r
+                                                   PCLZIP_CB_POST_EXTRACT => 'optional',\r
+                                                   PCLZIP_OPT_SET_CHMOD => 'optional' ));\r
+        if ($v_result != 1) {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+          return 0;\r
+        }\r
+\r
+        // ----- Set the arguments\r
+        if (isset($v_options[PCLZIP_OPT_PATH])) {\r
+          $v_path = $v_options[PCLZIP_OPT_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {\r
+          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {\r
+          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];\r
+        }\r
+        if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {\r
+          // ----- Check for '/' in last path char\r
+          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {\r
+            $v_path .= '/';\r
+          }\r
+          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];\r
+        }\r
+      }\r
+\r
+      // ----- Look for 2 args\r
+      // Here we need to support the first historic synopsis of the\r
+      // method.\r
+      else {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");\r
+\r
+        // ----- Get the first argument\r
+        $v_path = $v_arg_list[0];\r
+\r
+        // ----- Look for the optional second argument\r
+        if ($v_size == 2) {\r
+          $v_remove_path = $v_arg_list[1];\r
+        }\r
+        else if ($v_size > 2) {\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return 0;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Trace\r
+    //--(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')."'");\r
+\r
+    // ----- Look if the $p_index is really an integer\r
+    if (is_integer($p_index))\r
+    {\r
+      // ----- Call the extracting fct\r
+      if (($v_result = $this->privExtractByIndex($p_list, "$p_index", $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+        return(0);\r
+      }\r
+    }\r
+\r
+    // ----- Look if the index is a string\r
+    else if (is_string($p_index))\r
+    {\r
+      // ----- Call the extracting fct\r
+      if (($v_result = $this->privExtractByIndex($p_list, $p_index, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+        return(0);\r
+      }\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type $p_index");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return 0;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
+    return $p_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : deleteByIndex()\r
+  // Description :\r
+  //   This method delete somes files or folder entries from the zip archive.\r
+  //   The entries (files or folders) are identified by their index in the\r
+  //   archive (0-n).\r
+  //   Note that if the index identify a folder entry, only the folder entry\r
+  //   is deleted, and not all the files included in the folder.\r
+  // Parameters :\r
+  //   $p_index : A single index (integer) or a string of indexes of files to\r
+  //              delete. The form of the string is "0,4-6,8-12" with only numbers\r
+  //              and '-' for range or ',' to separate ranges. No spaces or ';'\r
+  //              are allowed.\r
+  // Return Values :\r
+  //   0 on failure,\r
+  //   The list of the files which are still present in the archive.\r
+  //   (see PclZip::listContent() for list entry format)\r
+  // --------------------------------------------------------------------------------\r
+  function deleteByIndex($p_index)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");\r
+    $v_result=1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Look if the $p_index is really an integer\r
+    if (is_integer($p_index))\r
+    {\r
+      // ----- Call the delete fct\r
+      if (($v_result = $this->privDeleteByIndex("$p_index", $p_list)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+        return(0);\r
+      }\r
+    }\r
+\r
+    // ----- Look if the index is a string\r
+    else if (is_string($p_index))\r
+    {\r
+      // ----- Call the delete fct\r
+      if (($v_result = $this->privDeleteByIndex($p_index, $p_list)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());\r
+        return(0);\r
+      }\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type $p_index");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return 0;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);\r
+    return $p_list;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : properties()\r
+  // Description :\r
+  //   This method gives the properties of the archive.\r
+  //   The properties are :\r
+  //     nb : Number of files in the archive\r
+  //     comment : Comment associated with the archive file\r
+  //     status : not_exist, ok\r
+  // Parameters :\r
+  //   None\r
+  // Return Values :\r
+  //   0 on failure,\r
+  //   An array with the archive properties.\r
+  // --------------------------------------------------------------------------------\r
+  function properties()\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Default properties\r
+    $v_prop = array();\r
+    $v_prop['comment'] = '';\r
+    $v_prop['nb'] = 0;\r
+    $v_prop['status'] = 'not_exist';\r
+\r
+    // ----- Look if file exists\r
+    if (@is_file($this->zipname))\r
+    {\r
+      // ----- Open the zip file\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);\r
+        return 0;\r
+      }\r
+\r
+      // ----- Read the central directory informations\r
+      $v_central_dir = array();\r
+      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+        return 0;\r
+      }\r
+\r
+      // ----- Close the zip file\r
+      $this->privCloseFd();\r
+\r
+      // ----- Set the user attributes\r
+      $v_prop['comment'] = $v_central_dir['comment'];\r
+      $v_prop['nb'] = $v_central_dir['entries'];\r
+      $v_prop['status'] = 'ok';\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);\r
+    return $v_prop;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : duplicate()\r
+  // Description :\r
+  //   This method creates an archive by copying the content of an other one. If\r
+  //   the archive already exist, it is replaced by the new one without any warning.\r
+  // Parameters :\r
+  //   $p_archive : The filename of a valid archive, or\r
+  //                a valid PclZip object.\r
+  // Return Values :\r
+  //   1 on success.\r
+  //   0 or a negative value on error (error code).\r
+  // --------------------------------------------------------------------------------\r
+  function duplicate($p_archive)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");\r
+    $v_result = 1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Look if the $p_archive is a PclZip object\r
+    if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");\r
+\r
+      // ----- Duplicate the archive\r
+      $v_result = $this->privDuplicate($p_archive->zipname);\r
+    }\r
+\r
+    // ----- Look if the $p_archive is a string (so a filename)\r
+    else if (is_string($p_archive))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");\r
+\r
+      // ----- Check that $p_archive is a valid zip file\r
+      // TBC : Should also check the archive format\r
+      if (!is_file($p_archive)) {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");\r
+        $v_result = PCLZIP_ERR_MISSING_FILE;\r
+      }\r
+      else {\r
+        // ----- Duplicate the archive\r
+        $v_result = $this->privDuplicate($p_archive);\r
+      }\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");\r
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : merge()\r
+  // Description :\r
+  //   This method merge the $p_archive_to_add archive at the end of the current\r
+  //   one ($this).\r
+  //   If the archive ($this) does not exist, the merge becomes a duplicate.\r
+  //   If the $p_archive_to_add archive does not exist, the merge is a success.\r
+  // Parameters :\r
+  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,\r
+  //                       or a PclZip object archive.\r
+  // Return Values :\r
+  //   1 on success,\r
+  //   0 or negative values on error (see below).\r
+  // --------------------------------------------------------------------------------\r
+  function merge($p_archive_to_add)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");\r
+    $v_result = 1;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Check archive\r
+    if (!$this->privCheckFormat()) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);\r
+      return(0);\r
+    }\r
+\r
+    // ----- Look if the $p_archive_to_add is a PclZip object\r
+    if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");\r
+\r
+      // ----- Merge the archive\r
+      $v_result = $this->privMerge($p_archive_to_add);\r
+    }\r
+\r
+    // ----- Look if the $p_archive_to_add is a string (so a filename)\r
+    else if (is_string($p_archive_to_add))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");\r
+\r
+      // ----- Create a temporary archive\r
+      $v_object_archive = new PclZip($p_archive_to_add);\r
+\r
+      // ----- Merge the archive\r
+      $v_result = $this->privMerge($v_object_archive);\r
+    }\r
+\r
+    // ----- Invalid variable\r
+    else\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");\r
+      $v_result = PCLZIP_ERR_INVALID_PARAMETER;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : errorCode()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function errorCode()\r
+  {\r
+    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
+      return(PclErrorCode());\r
+    }\r
+    else {\r
+      return($this->error_code);\r
+    }\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : errorName()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function errorName($p_with_code=false)\r
+  {\r
+    $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',\r
+                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',\r
+                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',\r
+                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',\r
+                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',\r
+                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',\r
+                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',\r
+                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',\r
+                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',\r
+                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',\r
+                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',\r
+                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',\r
+                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',\r
+                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',\r
+                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',\r
+                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',\r
+                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE' );\r
+\r
+    if (isset($v_name[$this->error_code])) {\r
+      $v_value = $v_name[$this->error_code];\r
+    }\r
+    else {\r
+      $v_value = 'NoName';\r
+    }\r
+\r
+    if ($p_with_code) {\r
+      return($v_value.' ('.$this->error_code.')');\r
+    }\r
+    else {\r
+      return($v_value);\r
+    }\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : errorInfo()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function errorInfo($p_full=false)\r
+  {\r
+    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
+      return(PclErrorString());\r
+    }\r
+    else {\r
+      if ($p_full) {\r
+        return($this->errorName(true)." : ".$this->error_string);\r
+      }\r
+      else {\r
+        return($this->error_string." [code ".$this->error_code."]");\r
+      }\r
+    }\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+\r
+// --------------------------------------------------------------------------------\r
+// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****\r
+// *****                                                        *****\r
+// *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****\r
+// --------------------------------------------------------------------------------\r
+\r
+\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privCheckFormat()\r
+  // Description :\r
+  //   This method check that the archive exists and is a valid zip archive.\r
+  //   Several level of check exists. (futur)\r
+  // Parameters :\r
+  //   $p_level : Level of check. Default 0.\r
+  //              0 : Check the first bytes (magic codes) (default value))\r
+  //              1 : 0 + Check the central directory (futur)\r
+  //              2 : 1 + Check each file header (futur)\r
+  // Return Values :\r
+  //   true on success,\r
+  //   false on error, the error code is set.\r
+  // --------------------------------------------------------------------------------\r
+  function privCheckFormat($p_level=0)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");\r
+    $v_result = true;\r
+\r
+    // ----- Reset the error handler\r
+    $this->privErrorReset();\r
+\r
+    // ----- Look if the file exits\r
+    if (!is_file($this->zipname)) {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());\r
+      return(false);\r
+    }\r
+\r
+    // ----- Check that the file is readeable\r
+    if (!is_readable($this->zipname)) {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());\r
+      return(false);\r
+    }\r
+\r
+    // ----- Check the magic code\r
+    // TBC\r
+\r
+    // ----- Check the central header\r
+    // TBC\r
+\r
+    // ----- Check each file header\r
+    // TBC\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privParseOptions()\r
+  // Description :\r
+  //   This internal methods reads the variable list of arguments ($p_options_list,\r
+  //   $p_size) and generate an array with the options and values ($v_result_list).\r
+  //   $v_requested_options contains the options that can be present and those that\r
+  //   must be present.\r
+  //   $v_requested_options is an array, with the option value as key, and 'optional',\r
+  //   or 'mandatory' as value.\r
+  // Parameters :\r
+  //   See above.\r
+  // Return Values :\r
+  //   1 on success.\r
+  //   0 on failure.\r
+  // --------------------------------------------------------------------------------\r
+  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");\r
+    $v_result=1;\r
+\r
+    // ----- Read the options\r
+    $i=0;\r
+    while ($i<$p_size) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");\r
+\r
+      // ----- Check if the option is requested\r
+      if (!isset($v_requested_options[$p_options_list[$i]])) {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Look for next option\r
+      switch ($p_options_list[$i]) {\r
+        // ----- Look for options that request a path value\r
+        case PCLZIP_OPT_PATH :\r
+        case PCLZIP_OPT_REMOVE_PATH :\r
+        case PCLZIP_OPT_ADD_PATH :\r
+          // ----- Check the number of parameters\r
+          if (($i+1) >= $p_size) {\r
+            // ----- Error log\r
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
+\r
+            // ----- Return\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+            return PclZip::errorCode();\r
+          }\r
+\r
+          // ----- Get the value\r
+          $v_result_list[$p_options_list[$i]] = strtr($p_options_list[$i+1], '\\', '/');\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
+          $i++;\r
+        break;\r
+\r
+        // ----- Look for options that request no value\r
+        case PCLZIP_OPT_REMOVE_ALL_PATH :\r
+          $v_result_list[$p_options_list[$i]] = true;\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
+        break;\r
+\r
+        // ----- Look for options that request an octal value\r
+        case PCLZIP_OPT_SET_CHMOD :\r
+          // ----- Check the number of parameters\r
+          if (($i+1) >= $p_size) {\r
+            // ----- Error log\r
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
+\r
+            // ----- Return\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+            return PclZip::errorCode();\r
+          }\r
+\r
+          // ----- Get the value\r
+          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");\r
+          $i++;\r
+        break;\r
+\r
+        // ----- Look for options that request a call-back\r
+        case PCLZIP_CB_PRE_EXTRACT :\r
+        case PCLZIP_CB_POST_EXTRACT :\r
+        case PCLZIP_CB_PRE_ADD :\r
+        case PCLZIP_CB_POST_ADD :\r
+        /* for futur use\r
+        case PCLZIP_CB_PRE_DELETE :\r
+        case PCLZIP_CB_POST_DELETE :\r
+        case PCLZIP_CB_PRE_LIST :\r
+        case PCLZIP_CB_POST_LIST :\r
+        */\r
+          // ----- Check the number of parameters\r
+          if (($i+1) >= $p_size) {\r
+            // ----- Error log\r
+            PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
+\r
+            // ----- Return\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+            return PclZip::errorCode();\r
+          }\r
+\r
+          // ----- Get the value\r
+          $v_function_name = $p_options_list[$i+1];\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");\r
+\r
+          // ----- Check that the value is a valid existing function\r
+          if (!function_exists($v_function_name)) {\r
+            // ----- Error log\r
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");\r
+\r
+            // ----- Return\r
+            //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+            return PclZip::errorCode();\r
+          }\r
+\r
+          // ----- Set the attribute\r
+          $v_result_list[$p_options_list[$i]] = $v_function_name;\r
+          $i++;\r
+        break;\r
+\r
+        default :\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Unknown optional parameter '".$p_options_list[$i]."'");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Next options\r
+      $i++;\r
+    }\r
+\r
+    // ----- Look for mandatory options\r
+    for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {\r
+      // ----- Look for mandatory option\r
+      if ($v_requested_options[$key] == 'mandatory') {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");\r
+        // ----- Look if present\r
+        if (!isset($v_result_list[$key])) {\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return PclZip::errorCode();\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privCreate()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privCreate($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
+    $v_result=1;\r
+    $v_list_detail = array();\r
+\r
+    // ----- Open the file in write mode\r
+    if (($v_result = $this->privOpenFd('wb')) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Add the list of files\r
+    $v_result = $this->privAddList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
+\r
+    // ----- Close\r
+    $this->privCloseFd();\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privAdd()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privAdd($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list, result_list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
+    $v_result=1;\r
+    $v_list_detail = array();\r
+\r
+    // ----- Look if the archive exists\r
+    if (!is_file($this->zipname))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, create it.");\r
+\r
+      // ----- Do a create\r
+      $v_result = $this->privCreate($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result=$this->privOpenFd('rb')) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Go to beginning of File\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
+    @rewind($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
+\r
+    // ----- Creates a temporay file\r
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
+\r
+    // ----- Open the temporary file in write mode\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)\r
+    {\r
+      $this->privCloseFd();\r
+\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Copy the files from the archive to the temporary file\r
+    // TBC : Here I should better append the file and go back to erase the central dir\r
+    $v_size = $v_central_dir['offset'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = fread($this->zip_fd, $v_read_size);\r
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Swap the file descriptor\r
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use\r
+    // the following methods on the temporary fil and not the real archive\r
+    $v_swap = $this->zip_fd;\r
+    $this->zip_fd = $v_zip_temp_fd;\r
+    $v_zip_temp_fd = $v_swap;\r
+\r
+    // ----- Add the files\r
+    $v_header_list = array();\r
+    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
+    {\r
+      fclose($v_zip_temp_fd);\r
+      $this->privCloseFd();\r
+      @unlink($v_zip_temp_name);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Store the offset of the central dir\r
+    $v_offset = @ftell($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");\r
+\r
+    // ----- Copy the block of file headers from the old archive\r
+    $v_size = $v_central_dir['size'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);\r
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Create the Central Dir files header\r
+    for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)\r
+    {\r
+      // ----- Create the file header\r
+      if ($v_header_list[$i]['status'] == 'ok') {\r
+        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {\r
+          fclose($v_zip_temp_fd);\r
+          $this->privCloseFd();\r
+          @unlink($v_zip_temp_name);\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+        $v_count++;\r
+      }\r
+\r
+      // ----- Transform the header to a 'usable' info\r
+      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
+    }\r
+\r
+    // ----- Zip file comment\r
+    $v_comment = '';\r
+\r
+    // ----- Calculate the size of the central header\r
+    $v_size = @ftell($this->zip_fd)-$v_offset;\r
+\r
+    // ----- Create the central dir footer\r
+    if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)\r
+    {\r
+      // ----- Reset the file list\r
+      unset($v_header_list);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Swap back the file descriptor\r
+    $v_swap = $this->zip_fd;\r
+    $this->zip_fd = $v_zip_temp_fd;\r
+    $v_zip_temp_fd = $v_swap;\r
+\r
+    // ----- Close\r
+    $this->privCloseFd();\r
+\r
+    // ----- Close the temporary file\r
+    @fclose($v_zip_temp_fd);\r
+\r
+    // ----- Delete the zip file\r
+    // TBC : I should test the result ...\r
+    @unlink($this->zipname);\r
+\r
+    // ----- Rename the temporary file\r
+    // TBC : I should test the result ...\r
+    //@rename($v_zip_temp_name, $this->zipname);\r
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privOpenFd()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function privOpenFd($p_mode)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);\r
+    $v_result=1;\r
+\r
+    // ----- Look if already open\r
+    if ($this->zip_fd != 0)\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');\r
+    if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privCloseFd()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function privCloseFd()\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");\r
+    $v_result=1;\r
+\r
+    if ($this->zip_fd != 0)\r
+      @fclose($this->zip_fd);\r
+    $this->zip_fd = 0;\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privAddList()\r
+  // Description :\r
+  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is\r
+  //   different from the real path of the file. This is usefull if you want to have PclTar\r
+  //   running in any directory, and memorize relative path from an other directory.\r
+  // Parameters :\r
+  //   $p_list : An array containing the file or directory names to add in the tar\r
+  //   $p_result_list : list of added files with their properties (specially the status field)\r
+  //   $p_add_dir : Path to add in the filename path archived\r
+  //   $p_remove_dir : Path to remove in the filename path archived\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
+    $v_result=1;\r
+\r
+    // ----- Add the files\r
+    $v_header_list = array();\r
+    if (($v_result = $this->privAddFileList($p_list, $v_header_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Store the offset of the central dir\r
+    $v_offset = @ftell($this->zip_fd);\r
+\r
+    // ----- Create the Central Dir files header\r
+    for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)\r
+    {\r
+      // ----- Create the file header\r
+      if ($v_header_list[$i]['status'] == 'ok') {\r
+        if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+        $v_count++;\r
+      }\r
+\r
+      // ----- Transform the header to a 'usable' info\r
+      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
+    }\r
+\r
+    // ----- Zip file comment\r
+    $v_comment = '';\r
+\r
+    // ----- Calculate the size of the central header\r
+    $v_size = @ftell($this->zip_fd)-$v_offset;\r
+\r
+    // ----- Create the central dir footer\r
+    if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)\r
+    {\r
+      // ----- Reset the file list\r
+      unset($v_header_list);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privAddFileList()\r
+  // Description :\r
+  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is\r
+  //   different from the real path of the file. This is usefull if you want to\r
+  //   run the lib in any directory, and memorize relative path from an other directory.\r
+  // Parameters :\r
+  //   $p_list : An array containing the file or directory names to add in the tar\r
+  //   $p_result_list : list of added files with their properties (specially the status field)\r
+  //   $p_add_dir : Path to add in the filename path archived\r
+  //   $p_remove_dir : Path to remove in the filename path archived\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privAddFileList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "list, add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
+    $v_result=1;\r
+    $v_header = array();\r
+\r
+    // ----- Recuperate the current number of elt in list\r
+    $v_nb = sizeof($p_result_list);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have $v_nb elements");\r
+\r
+    // ----- Loop on the files\r
+    for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++)\r
+    {\r
+      // ----- Recuperate the filename\r
+      $p_filename = $p_list[$j];\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file [$p_filename]");\r
+\r
+      // ----- Skip empty file names\r
+      if ($p_filename == "")\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");\r
+        continue;\r
+      }\r
+\r
+      // ----- Check the filename\r
+      if (!file_exists($p_filename))\r
+      {\r
+        // ----- Error log\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '$p_filename' does not exists");\r
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '$p_filename' does not exists");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      /* This test is done later\r
+      // ----- Check the path length\r
+      if (strlen($p_filename) > 0xFF)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(-5, "File name is too long (max. 255) : '$p_filename'");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      */\r
+\r
+      // ----- Look if it is a file or a dir with no all pathnre move\r
+      if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) {\r
+        // ----- Add the file\r
+        if (($v_result = $this->privAddFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
+        {\r
+          // ----- Return status\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        // ----- Store the file infos\r
+        $p_result_list[$v_nb++] = $v_header;\r
+      }\r
+\r
+      // ----- Look for directory\r
+      if (is_dir($p_filename))\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "$p_filename is a directory");\r
+\r
+        // ----- Look for path\r
+        if ($p_filename != ".")\r
+          $v_path = $p_filename."/";\r
+        else\r
+          $v_path = "";\r
+\r
+        // ----- Read the directory for files and sub-directories\r
+        $p_hdir = opendir($p_filename);\r
+        $p_hitem = readdir($p_hdir); // '.' directory\r
+        $p_hitem = readdir($p_hdir); // '..' directory\r
+        while ($p_hitem = readdir($p_hdir))\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for $p_hitem in the directory");\r
+\r
+          // ----- Look for a file\r
+          if (is_file($v_path.$p_hitem))\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the file '".$v_path.$p_hitem."'");\r
+\r
+            // ----- Add the file\r
+            if (($v_result = $this->privAddFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options)) != 1)\r
+            {\r
+              // ----- Return status\r
+              //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+              return $v_result;\r
+            }\r
+\r
+            // ----- Store the file infos\r
+            $p_result_list[$v_nb++] = $v_header;\r
+          }\r
+\r
+          // ----- Recursive call to privAddFileList()\r
+          else\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Add the directory '".$v_path.$p_hitem."'");\r
+\r
+            // ----- Need an array as parameter\r
+            $p_temp_list[0] = $v_path.$p_hitem;\r
+            $v_result = $this->privAddFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_options);\r
+\r
+            // ----- Update the number of elements of the list\r
+            $v_nb = sizeof($p_result_list);\r
+          }\r
+        }\r
+\r
+        // ----- Free memory for the recursive loop\r
+        unset($p_temp_list);\r
+        unset($p_hdir);\r
+        unset($p_hitem);\r
+      }\r
+    }\r
+\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have $v_nb elements");\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privAddFile()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privAddFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='$p_filename', add_dir='$p_add_dir', remove_dir='$p_remove_dir'");\r
+    $v_result=1;\r
+\r
+    if ($p_filename == "")\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Calculate the stored filename\r
+    $v_stored_filename = $p_filename;\r
+\r
+    // ----- Look for all path to remove\r
+    if ($p_remove_all_dir) {\r
+      $v_stored_filename = basename($p_filename);\r
+    }\r
+    // ----- Look for partial path remove\r
+    else if ($p_remove_dir != "")\r
+    {\r
+      if (substr($p_remove_dir, -1) != '/')\r
+        $p_remove_dir .= "/";\r
+\r
+      if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./"))\r
+      {\r
+        if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./"))\r
+          $p_remove_dir = "./".$p_remove_dir;\r
+        if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./"))\r
+          $p_remove_dir = substr($p_remove_dir, 2);\r
+      }\r
+\r
+      if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir)\r
+      {\r
+        $v_stored_filename = substr($p_filename, strlen($p_remove_dir));\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Remove path '$p_remove_dir' in file '$p_filename' = '$v_stored_filename'");\r
+      }\r
+    }\r
+    // ----- Look for path to add\r
+    if ($p_add_dir != "")\r
+    {\r
+      if (substr($p_add_dir, -1) == "/")\r
+        $v_stored_filename = $p_add_dir.$v_stored_filename;\r
+      else\r
+        $v_stored_filename = $p_add_dir."/".$v_stored_filename;\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");\r
+    }\r
+\r
+    // ----- Filename (reduce the path of stored name)\r
+    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);\r
+\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Filename (reduced) '$v_stored_filename', strlen ".strlen($v_stored_filename));\r
+\r
+    /* filename length moved after call-back in release 1.3\r
+    // ----- Check the path length\r
+    if (strlen($v_stored_filename) > 0xFF)\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+    */\r
+\r
+    // ----- Set the file properties\r
+    clearstatcache();\r
+    $p_header['version'] = 20;\r
+    $p_header['version_extracted'] = 10;\r
+    $p_header['flag'] = 0;\r
+    $p_header['compression'] = 0;\r
+    $p_header['mtime'] = filemtime($p_filename);\r
+    $p_header['crc'] = 0;\r
+    $p_header['compressed_size'] = 0;\r
+    $p_header['size'] = filesize($p_filename);\r
+    $p_header['filename_len'] = strlen($p_filename);\r
+    $p_header['extra_len'] = 0;\r
+    $p_header['comment_len'] = 0;\r
+    $p_header['disk'] = 0;\r
+    $p_header['internal'] = 0;\r
+    $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);\r
+    $p_header['offset'] = 0;\r
+    $p_header['filename'] = $p_filename;\r
+    $p_header['stored_filename'] = $v_stored_filename;\r
+    $p_header['extra'] = '';\r
+    $p_header['comment'] = '';\r
+    $p_header['status'] = 'ok';\r
+    $p_header['index'] = -1;\r
+\r
+    // ----- Look for pre-add callback\r
+    if (isset($p_options[PCLZIP_CB_PRE_ADD])) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");\r
+\r
+      // ----- Generate a local information\r
+      $v_local_header = array();\r
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);\r
+\r
+      // ----- Call the callback\r
+      // Here I do not use call_user_func() because I need to send a reference to the\r
+      // header.\r
+      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');\r
+      if ($v_result == 0) {\r
+        // ----- Change the file status\r
+        $p_header['status'] = "skipped";\r
+        $v_result = 1;\r
+      }\r
+\r
+      // ----- Update the informations\r
+      // Only some fields can be modified\r
+      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {\r
+        $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");\r
+      }\r
+    }\r
+\r
+    // ----- Check the path length\r
+    if (strlen($p_header['stored_filename']) > 0xFF) {\r
+      $p_header['status'] = 'filename_too_long';\r
+    }\r
+\r
+    // ----- Look if no error, or file not skipped\r
+    if ($p_header['status'] == 'ok') {\r
+\r
+    // ----- Look for a file\r
+    if (is_file($p_filename))\r
+    {\r
+      // ----- Open the source file\r
+      if (($v_file = @fopen($p_filename, "rb")) == 0)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Creates a compressed temporary file\r
+      if (($v_file_compressed = @gzopen($p_filename.'.gz', "wb")) == 0)\r
+      {\r
+        // ----- Close the file\r
+        fclose($v_file);\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary write mode");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+      $v_size = filesize($p_filename);\r
+      while ($v_size != 0)\r
+      {\r
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+        $v_buffer = fread($v_file, $v_read_size);\r
+        $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+        @gzputs($v_file_compressed, $v_binary_data, $v_read_size);\r
+        $v_size -= $v_read_size;\r
+      }\r
+\r
+      // ----- Close the file\r
+      @fclose($v_file);\r
+      @gzclose($v_file_compressed);\r
+\r
+      // ----- Check the minimum file size\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "gzip file size ".filesize($p_filename.'.gz'));\r
+      if (filesize($p_filename.'.gz') < 18)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Invalid file "'.$p_filename.'.gz'.'" size (less than header size)');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Extract the compressed attributes\r
+      if (($v_file_compressed = @fopen($p_filename.'.gz', "rb")) == 0)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary read mode");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Read the gzip file header\r
+      $v_binary_data = @fread($v_file_compressed, 10);\r
+      $v_data_header = unpack('a1id1/a1id2/a1cm/a1flag/Vmtime/a1xfl/a1os', $v_binary_data);\r
+\r
+      // ----- Check some parameters\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id1]='.bin2hex($v_data_header['id1']));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[id2]='.bin2hex($v_data_header['id2']));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[cm]='.bin2hex($v_data_header['cm']));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[flag]='.bin2hex($v_data_header['flag']));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[mtime]='.$v_data_header['mtime']);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[xfl]='.bin2hex($v_data_header['xfl']));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, '$v_data_header[os]='.bin2hex($v_data_header['os']));\r
+      $v_data_header['os'] = bin2hex($v_data_header['os']);\r
+\r
+      // ----- Read the gzip file footer\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after header ".ftell($v_file_compressed));\r
+      @fseek($v_file_compressed, filesize($p_filename.'.gz')-8);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position at beginning of footer ".ftell($v_file_compressed));\r
+      $v_binary_data = @fread($v_file_compressed, 8);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position after footer ".ftell($v_file_compressed));\r
+      $v_data_footer = unpack('Vcrc/Vcompressed_size', $v_binary_data);\r
+\r
+      // ----- Set the attributes\r
+      $p_header['compression'] = ord($v_data_header['cm']);\r
+      //$p_header['mtime'] = $v_data_header['mtime'];\r
+      $p_header['crc'] = $v_data_footer['crc'];\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Compressed size ".(filesize($p_filename.'.gz')-18));\r
+      $p_header['compressed_size'] = filesize($p_filename.'.gz')-18;\r
+\r
+      // ----- Close the file\r
+      @fclose($v_file_compressed);\r
+\r
+      // ----- Call the header generation\r
+      if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
+      {\r
+        // ----- Return status\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Add the compressed data\r
+      if (($v_file_compressed = @fopen($p_filename.'.gz', "rb")) == 0)\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename.gz' in gz binary read mode");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+\r
+      // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+      fseek($v_file_compressed, 10);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File position before reading compressed data ".ftell($v_file_compressed));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, ' '.$p_header['compressed_size'].' bytes to read');\r
+      $v_size = $p_header['compressed_size'];\r
+      while ($v_size != 0)\r
+      {\r
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+        $v_buffer = fread($v_file_compressed, $v_read_size);\r
+        $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+        @fwrite($this->zip_fd, $v_binary_data, $v_read_size);\r
+        $v_size -= $v_read_size;\r
+      }\r
+\r
+      // ----- Close the file\r
+      @fclose($v_file_compressed);\r
+\r
+      // ----- Unlink the temporary file\r
+      @unlink($p_filename.'.gz');\r
+    }\r
+\r
+    // ----- Look for a directory\r
+    else\r
+    {\r
+      // ----- Set the file properties\r
+      $p_header['filename'] .= '/';\r
+      $p_header['filename_len']++;\r
+      $p_header['size'] = 0;\r
+      $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked\r
+\r
+      // ----- Call the header generation\r
+      if (($v_result = $this->privWriteFileHeader($p_header)) != 1)\r
+      {\r
+        // ----- Return status\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+    }\r
+    }\r
+\r
+    // ----- Look for pre-add callback\r
+    if (isset($p_options[PCLZIP_CB_POST_ADD])) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");\r
+\r
+      // ----- Generate a local information\r
+      $v_local_header = array();\r
+      $this->privConvertHeader2FileInfo($p_header, $v_local_header);\r
+\r
+      // ----- Call the callback\r
+      // Here I do not use call_user_func() because I need to send a reference to the\r
+      // header.\r
+      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');\r
+      if ($v_result == 0) {\r
+        // ----- Ignored\r
+        $v_result = 1;\r
+      }\r
+\r
+      // ----- Update the informations\r
+      // Nothing can be modified\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privWriteFileHeader()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privWriteFileHeader(&$p_header)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');\r
+    $v_result=1;\r
+\r
+    // TBC\r
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {\r
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);\r
+    //}\r
+\r
+    // ----- Store the offset position of the file\r
+    $p_header['offset'] = ftell($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);\r
+\r
+    // ----- Transform UNIX mtime to DOS format mdate/mtime\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    $v_date = getdate($p_header['mtime']);\r
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;\r
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];\r
+\r
+    // ----- Packed data\r
+    $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'],\r
+                          $p_header['compression'], $v_mtime, $v_mdate,\r
+                          $p_header['crc'], $p_header['compressed_size'], $p_header['size'],\r
+                          strlen($p_header['stored_filename']), $p_header['extra_len']);\r
+\r
+    // ----- Write the first 148 bytes of the header in the archive\r
+    fputs($this->zip_fd, $v_binary_data, 30);\r
+\r
+    // ----- Write the variable fields\r
+    if (strlen($p_header['stored_filename']) != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));\r
+    }\r
+    if ($p_header['extra_len'] != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privWriteCentralFileHeader()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privWriteCentralFileHeader(&$p_header)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');\r
+    $v_result=1;\r
+\r
+    // TBC\r
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {\r
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);\r
+    //}\r
+\r
+    // ----- Transform UNIX mtime to DOS format mdate/mtime\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    $v_date = getdate($p_header['mtime']);\r
+    $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;\r
+    $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];\r
+\r
+    // ----- Packed data\r
+    $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'],\r
+                          $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'],\r
+                          $p_header['compressed_size'], $p_header['size'],\r
+                          strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'],\r
+                          $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);\r
+\r
+    // ----- Write the 42 bytes of the header in the zip file\r
+    fputs($this->zip_fd, $v_binary_data, 46);\r
+\r
+    // ----- Write the variable fields\r
+    if (strlen($p_header['stored_filename']) != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));\r
+    }\r
+    if ($p_header['extra_len'] != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);\r
+    }\r
+    if ($p_header['comment_len'] != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privWriteCentralHeader()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');\r
+    $v_result=1;\r
+\r
+    // ----- Packed data\r
+    $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));\r
+\r
+    // ----- Write the 22 bytes of the header in the zip file\r
+    fputs($this->zip_fd, $v_binary_data, 22);\r
+\r
+    // ----- Write the variable fields\r
+    if (strlen($p_comment) != 0)\r
+    {\r
+      fputs($this->zip_fd, $p_comment, strlen($p_comment));\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privList()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privList(&$p_list)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");\r
+    $v_result=1;\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Go to beginning of Central Dir\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
+    @rewind($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
+    if (@fseek($this->zip_fd, $v_central_dir['offset']))\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");\r
+\r
+    // ----- Read each entry\r
+    for ($i=0; $i<$v_central_dir['entries']; $i++)\r
+    {\r
+      // ----- Read the file header\r
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+      $v_header['index'] = $i;\r
+\r
+      // ----- Get the only interesting attributes\r
+      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);\r
+      unset($v_header);\r
+    }\r
+\r
+    // ----- Close the zip file\r
+    $this->privCloseFd();\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privConvertHeader2FileInfo()\r
+  // Description :\r
+  //   This function takes the file informations from the central directory\r
+  //   entries and extract the interesting parameters that will be given back.\r
+  //   The resulting file infos are set in the array $p_info\r
+  //     $p_info['filename'] : Filename with full path. Given by user (add),\r
+  //                           extracted in the filesystem (extract).\r
+  //     $p_info['stored_filename'] : Stored filename in the archive.\r
+  //     $p_info['size'] = Size of the file.\r
+  //     $p_info['compressed_size'] = Compressed size of the file.\r
+  //     $p_info['mtime'] = Last modification date of the file.\r
+  //     $p_info['comment'] = Comment associated with the file.\r
+  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.\r
+  //     $p_info['status'] = status of the action on the file.\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privConvertHeader2FileInfo($p_header, &$p_info)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");\r
+    $v_result=1;\r
+\r
+    // ----- Get the interesting attributes\r
+    $p_info['filename'] = $p_header['filename'];\r
+    $p_info['stored_filename'] = $p_header['stored_filename'];\r
+    $p_info['size'] = $p_header['size'];\r
+    $p_info['compressed_size'] = $p_header['compressed_size'];\r
+    $p_info['mtime'] = $p_header['mtime'];\r
+    $p_info['comment'] = $p_header['comment'];\r
+    $p_info['folder'] = ($p_header['external']==0x41FF0010);\r
+    $p_info['index'] = $p_header['index'];\r
+    $p_info['status'] = $p_header['status'];\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privExtract()\r
+  // Description :\r
+  // Parameters :\r
+  //   $p_file_list : An array where will be placed the properties of each\r
+  //                  extracted file\r
+  //   $p_path : Path to add while writing the extracted files\r
+  //   $p_remove_path : Path to remove (from the file memorized path) while writing the\r
+  //                    extracted files. If the path does not match the file path,\r
+  //                    the file is extracted with its memorized path.\r
+  //                    $p_remove_path does not apply to 'list' mode.\r
+  //                    $p_path and $p_remove_path are commulative.\r
+  // Return Values :\r
+  //   1 on success,0 or less on error (see error code list)\r
+  // --------------------------------------------------------------------------------\r
+  function privExtract(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtract", "list, path=$p_path, remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
+    $v_result=1;\r
+\r
+    // ----- Check the path\r
+    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")))\r
+      $p_path = "./".$p_path;\r
+\r
+    // ----- Reduce the path last (and duplicated) '/'\r
+    if (($p_path != "./") && ($p_path != "/"))\r
+    {\r
+      // ----- Look for the path end '/'\r
+      while (substr($p_path, -1) == "/")\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");\r
+        $p_path = substr($p_path, 0, strlen($p_path)-1);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");\r
+      }\r
+    }\r
+\r
+    // ----- Look for path to remove format (should end by /)\r
+    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))\r
+    {\r
+      $p_remove_path .= '/';\r
+    }\r
+    $p_remove_path_size = strlen($p_remove_path);\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result = $this->privOpenFd('rb')) != 1)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      // ----- Close the zip file\r
+      $this->privCloseFd();\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Start at beginning of Central Dir\r
+    $v_pos_entry = $v_central_dir['offset'];\r
+\r
+    // ----- Read each entry\r
+    for ($i=0; $i<$v_central_dir['entries']; $i++)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file entry : $i'");\r
+\r
+      // ----- Read next Central dir entry\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+      @rewind($this->zip_fd);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+      if (@fseek($this->zip_fd, $v_pos_entry))\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+      // ----- Read the file header\r
+      $v_header = array();\r
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Store the index\r
+      $v_header['index'] = $i;\r
+\r
+      // ----- Store the file position\r
+      $v_pos_entry = ftell($this->zip_fd);\r
+\r
+      // ----- Go to the file position\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+      @rewind($this->zip_fd);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+      if (@fseek($this->zip_fd, $v_header['offset']))\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+      // ----- Extracting the file\r
+      if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Get the only interesting attributes\r
+      if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$i])) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+    }\r
+\r
+    // ----- Close the zip file\r
+    $this->privCloseFd();\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privExtractByIndex()\r
+  // Description :\r
+  // Parameters :\r
+  //   $p_file_list : An array where will be placed the properties of each\r
+  //                  extracted file\r
+  //   $p_index : A single index (integer) or a string of indexes of files to\r
+  //              extract. The form of the string is "0,4-6,8-12" with only numbers\r
+  //              and '-' for range or ',' to separate ranges. No spaces or ';'\r
+  //              are allowed.\r
+  //   $p_path : Path to add while writing the extracted files\r
+  //   $p_remove_path : Path to remove (from the file memorized path) while writing the\r
+  //                    extracted files. If the path does not match the file path,\r
+  //                    the file is extracted with its memorized path.\r
+  //                    $p_remove_path does not apply to 'list' mode.\r
+  //                    $p_path and $p_remove_path are commulative.\r
+  // Return Values :\r
+  //   1 on success,0 or less on error (see error code list)\r
+  // --------------------------------------------------------------------------------\r
+  function privExtractByIndex(&$p_file_list, $p_index, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByIndex", "list, index='$p_index', path=$p_path, remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
+    $v_result=1;\r
+\r
+    // ----- Check the path\r
+    if (($p_path == "") || ((substr($p_path, 0, 1) != "/") && (substr($p_path, 0, 3) != "../")))\r
+      $p_path = "./".$p_path;\r
+\r
+    // ----- Reduce the path last (and duplicated) '/'\r
+    if (($p_path != "./") && ($p_path != "/"))\r
+    {\r
+      // ----- Look for the path end '/'\r
+      while (substr($p_path, -1) == "/")\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");\r
+        $p_path = substr($p_path, 0, strlen($p_path)-1);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");\r
+      }\r
+    }\r
+\r
+    // ----- Look for path to remove format (should end by /)\r
+    if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))\r
+    {\r
+      $p_remove_path .= '/';\r
+    }\r
+    $p_remove_path_size = strlen($p_remove_path);\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result = $this->privOpenFd('rb')) != 1)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      // ----- Close the zip file\r
+      $this->privCloseFd();\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Manipulate the index list\r
+    $p_index = strtr($p_index, ' ', '');\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Reduced index : '$p_index'");\r
+    $v_index_list = explode(",", $p_index);\r
+    // TBC : Here I should sort the index. However a simple sort is not enought.\r
+    // look for the use of usort()\r
+    //sort($v_index_list);\r
+\r
+    // ----- Start at beginning of Central Dir\r
+    $v_pos_entry = $v_central_dir['offset'];\r
+\r
+    // ----- Read each entry\r
+    for ($i=0, $j_start=0, $v_nb_extracted=0; ($i<$v_central_dir['entries']) && ($j_start<sizeof($v_index_list)); $i++)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : $i'");\r
+\r
+      // ----- Read next Central dir entry\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+      @rewind($this->zip_fd);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+      if (@fseek($this->zip_fd, $v_pos_entry))\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+      // ----- Read the file header\r
+      $v_header = array();\r
+      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Store the index\r
+      $v_header['index'] = $i;\r
+\r
+      // ----- Store the file position\r
+      $v_pos_entry = ftell($this->zip_fd);\r
+\r
+      // ----- Look if the index is in the list\r
+      $v_extract = false;\r
+      for ($j=$j_start; ($j<sizeof($v_index_list)) && (!$v_extract); $j++)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in '".$v_index_list[$j]."'");\r
+\r
+        // ----- Extract range\r
+        $v_item_list = explode("-", $v_index_list[$j]);\r
+        $v_size_item_list = sizeof($v_item_list);\r
+        if ($v_size_item_list == 1)\r
+        {\r
+          if ($i==$v_item_list[0])\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as a single index");\r
+            $v_extract = true;\r
+          }\r
+          if ($i>=$v_item_list[0])\r
+          {\r
+            $j_start = $j+1;\r
+          }\r
+        }\r
+        else if ($v_size_item_list == 2)\r
+        {\r
+          if (($i>=$v_item_list[0]) && ($i<=$v_item_list[1]))\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");\r
+            $v_extract = true;\r
+          }\r
+          if ($i>=$v_item_list[1])\r
+          {\r
+            $j_start = $j+1;\r
+          }\r
+        }\r
+        if ($v_item_list[0]>$i)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Range is greater than index, stop loop");\r
+          break;\r
+        }\r
+      }\r
+\r
+      // ----- Look for real extraction\r
+      if ($v_extract)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");\r
+\r
+        // ----- Go to the file position\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+        @rewind($this->zip_fd);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+        if (@fseek($this->zip_fd, $v_header['offset']))\r
+        {\r
+          // ----- Close the zip file\r
+          $this->privCloseFd();\r
+\r
+          // ----- Error log\r
+          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+          return PclZip::errorCode();\r
+        }\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+        // ----- Extracting the file\r
+        if (($v_result = $this->privExtractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_options)) != 1)\r
+        {\r
+          // ----- Close the zip file\r
+          $this->privCloseFd();\r
+\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        // ----- Get the only interesting attributes\r
+        if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)\r
+        {\r
+          // ----- Close the zip file\r
+          $this->privCloseFd();\r
+\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Close the zip file\r
+    $this->privCloseFd();\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privExtractFile()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");\r
+    $v_result=1;\r
+\r
+    // ----- Read the file header\r
+    if (($v_result = $this->privReadFileHeader($v_header)) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");\r
+\r
+    // ----- Check that the file header is coherent with $p_entry info\r
+    // TBC\r
+\r
+    // ----- Look for all path to remove\r
+    if ($p_remove_all_path == true) {\r
+        // ----- Get the basename of the path\r
+        $p_entry['filename'] = basename($p_entry['filename']);\r
+    }\r
+\r
+    // ----- Look for path to remove\r
+    else if ($p_remove_path != "")\r
+    {\r
+      //if (strcmp($p_remove_path, $p_entry['filename'])==0)\r
+      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");\r
+\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "filtered";\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      $p_remove_path_size = strlen($p_remove_path);\r
+      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");\r
+\r
+        // ----- Remove the path\r
+        $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");\r
+      }\r
+    }\r
+\r
+    // ----- Add the path\r
+    if ($p_path != '')\r
+    {\r
+      $p_entry['filename'] = $p_path."/".$p_entry['filename'];\r
+    }\r
+\r
+    // ----- Look for pre-extract callback\r
+    if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");\r
+\r
+      // ----- Generate a local information\r
+      $v_local_header = array();\r
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);\r
+\r
+      // ----- Call the callback\r
+      // Here I do not use call_user_func() because I need to send a reference to the\r
+      // header.\r
+      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');\r
+      if ($v_result == 0) {\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "skipped";\r
+      }\r
+\r
+      // ----- Update the informations\r
+      // Only some fields can be modified\r
+      $p_entry['filename'] = $v_local_header['filename'];\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");\r
+    }\r
+\r
+    // ----- Trace\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");\r
+\r
+    // ----- Look if extraction should be done\r
+    if ($p_entry['status'] == 'ok') {\r
+\r
+    // ----- Look for specific actions while the file exist\r
+    if (file_exists($p_entry['filename']))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");\r
+\r
+      // ----- Look if file is a directory\r
+      if (is_dir($p_entry['filename']))\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");\r
+\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "already_a_directory";\r
+\r
+        // ----- Return\r
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        //return $v_result;\r
+      }\r
+      // ----- Look if file is write protected\r
+      else if (!is_writeable($p_entry['filename']))\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");\r
+\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "write_protected";\r
+\r
+        // ----- Return\r
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        //return $v_result;\r
+      }\r
+\r
+      // ----- Look if the extracted file is older\r
+      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])\r
+      {\r
+        //--(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']).")");\r
+\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "newer_exist";\r
+\r
+        // ----- Return\r
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        //return $v_result;\r
+      }\r
+    }\r
+\r
+    // ----- Check the directory availability and create it if necessary\r
+    else {\r
+      if (substr($p_entry['filename'], -1) == '/')\r
+        $v_dir_to_check = $p_entry['filename'];\r
+      else if (!strstr($p_entry['filename'], "/"))\r
+        $v_dir_to_check = "";\r
+      else\r
+        $v_dir_to_check = dirname($p_entry['filename']);\r
+\r
+      if (($v_result = $this->privDirCheck($v_dir_to_check, ($p_entry['external']==0x41FF0010))) != 1) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");\r
+\r
+        // ----- Change the file status\r
+        $p_entry['status'] = "path_creation_fail";\r
+\r
+        // ----- Return\r
+        ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        //return $v_result;\r
+        $v_result = 1;\r
+      }\r
+    }\r
+    }\r
+\r
+    // ----- Look if extraction should be done\r
+    if ($p_entry['status'] == 'ok') {\r
+\r
+    // ----- Do the extraction (if not a folder)\r
+    if (!($p_entry['external']==0x41FF0010))\r
+    {\r
+\r
+      // ----- Look for not compressed file\r
+      if ($p_entry['compressed_size'] == $p_entry['size'])\r
+      {\r
+        // ----- Trace\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");\r
+\r
+        // ----- Opening destination file\r
+        if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
+\r
+          // ----- Change the file status\r
+          $p_entry['status'] = "write_error";\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");\r
+\r
+        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+        $v_size = $p_entry['compressed_size'];\r
+        while ($v_size != 0)\r
+        {\r
+          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+          $v_buffer = fread($this->zip_fd, $v_read_size);\r
+          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
+          $v_size -= $v_read_size;\r
+        }\r
+\r
+        // ----- Closing the destination file\r
+        fclose($v_dest_file);\r
+\r
+        // ----- Change the file mtime\r
+        touch($p_entry['filename'], $p_entry['mtime']);\r
+      }\r
+      else\r
+      {\r
+        // ----- Trace\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");\r
+\r
+        // ----- Open the destination file in write mode\r
+        if (($v_dest_file = @fopen($p_entry['filename'].'.gz', 'wb')) == 0)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
+\r
+          // ----- Change the file status\r
+          $p_entry['status'] = "write_error";\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Start extraction of '".$p_entry['filename']."'");\r
+\r
+        // ----- Write gz file format header\r
+        $v_binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($p_entry['compression']), Chr(0x00), time(), Chr(0x00), Chr(3));\r
+        fwrite($v_dest_file, $v_binary_data, 10);\r
+\r
+        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+        $v_size = $p_entry['compressed_size'];\r
+        while ($v_size != 0)\r
+        {\r
+          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+          $v_buffer = fread($this->zip_fd, $v_read_size);\r
+          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
+          $v_size -= $v_read_size;\r
+        }\r
+\r
+        // ----- Write gz file format footer\r
+        $v_binary_data = pack('VV', $p_entry['crc'], $p_entry['size']);\r
+        fwrite($v_dest_file, $v_binary_data, 8);\r
+\r
+        // ----- Close the temporary file\r
+        fclose($v_dest_file);\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after extract [".ftell($this->zip_fd)."]");\r
+\r
+        // ----- Uncompress\r
+        if (($v_src_file = gzopen($p_entry['filename'].'.gz', 'rb')) == 0)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in read binary mode");\r
+\r
+          // ----- Change the file status\r
+          $p_entry['status'] = "read_error";\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");\r
+\r
+          // ----- Change the file status\r
+          $p_entry['status'] = "write_error";\r
+          gzclose($v_src_file);\r
+\r
+          // ----- Return\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File size is '.filesize($p_entry['filename'].'.gz'));\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '$p_entry[size]' bytes");\r
+\r
+        // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks\r
+        $v_size = $p_entry['size'];\r
+        while ($v_size != 0)\r
+        {\r
+          $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");\r
+          $v_buffer = gzread($v_src_file, $v_read_size);\r
+          $v_binary_data = pack('a'.$v_read_size, $v_buffer);\r
+          @fwrite($v_dest_file, $v_binary_data, $v_read_size);\r
+          $v_size -= $v_read_size;\r
+        }\r
+        fclose($v_dest_file);\r
+        gzclose($v_src_file);\r
+\r
+        // ----- Change the file mtime\r
+        touch($p_entry['filename'], $p_entry['mtime']);\r
+\r
+        // ----- Delete the temporary file\r
+        @unlink($p_entry['filename'].'.gz');\r
+      }\r
+\r
+      // ----- Look for chmod option\r
+      if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");\r
+\r
+        // ----- Change the mode of the file\r
+        chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);\r
+      }\r
+\r
+      // ----- Trace\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");\r
+    }\r
+    }\r
+\r
+    // ----- Look for post-extract callback\r
+    if (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");\r
+\r
+      // ----- Generate a local information\r
+      $v_local_header = array();\r
+      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);\r
+\r
+      // ----- Call the callback\r
+      // Here I do not use call_user_func() because I need to send a reference to the\r
+      // header.\r
+      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privReadFileHeader()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privReadFileHeader(&$p_header)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");\r
+    $v_result=1;\r
+\r
+    // ----- Read the 4 bytes signature\r
+    $v_binary_data = @fread($this->zip_fd, 4);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
+    $v_data = unpack('Vid', $v_binary_data);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
+\r
+    // ----- Check signature\r
+    if ($v_data['id'] != 0x04034b50)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Read the first 42 bytes of the header\r
+    $v_binary_data = fread($this->zip_fd, 26);\r
+\r
+    // ----- Look for invalid block size\r
+    if (strlen($v_binary_data) != 26)\r
+    {\r
+      $p_header['filename'] = "";\r
+      $p_header['status'] = "invalid_header";\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Extract the values\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");\r
+    $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);\r
+\r
+    // ----- Get filename\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);\r
+    $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');\r
+\r
+    // ----- Get extra_fields\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);\r
+    if ($v_data['extra_len'] != 0) {\r
+      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);\r
+    }\r
+    else {\r
+      $p_header['extra'] = '';\r
+    }\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');\r
+\r
+    // ----- Extract properties\r
+    $p_header['compression'] = $v_data['compression'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.bin2hex($p_header['compression']).'\'');\r
+    $p_header['size'] = $v_data['size'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');\r
+    $p_header['compressed_size'] = $v_data['compressed_size'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');\r
+    $p_header['crc'] = $v_data['crc'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\'');\r
+    $p_header['flag'] = $v_data['flag'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');\r
+\r
+    // ----- Recuperate date in UNIX format\r
+    $p_header['mdate'] = $v_data['mdate'];\r
+    $p_header['mtime'] = $v_data['mtime'];\r
+    if ($p_header['mdate'] && $p_header['mtime'])\r
+    {\r
+      // ----- Extract time\r
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;\r
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;\r
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;\r
+\r
+      // ----- Extract date\r
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;\r
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;\r
+      $v_day = $p_header['mdate'] & 0x001F;\r
+\r
+      // ----- Get UNIX date format\r
+      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    }\r
+    else\r
+    {\r
+      $p_header['mtime'] = time();\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    }\r
+\r
+    // ----- Other informations\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compression type : ".$v_data['compression']);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Version : ".$v_data['version']);\r
+\r
+    // TBC\r
+    //for(reset($v_data); $key = key($v_data); next($v_data)) {\r
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);\r
+    //}\r
+\r
+    // ----- Set the stored filename\r
+    $p_header['stored_filename'] = $p_header['filename'];\r
+\r
+    // ----- Set the status field\r
+    $p_header['status'] = "ok";\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privReadCentralFileHeader()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privReadCentralFileHeader(&$p_header)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");\r
+    $v_result=1;\r
+\r
+    // ----- Read the 4 bytes signature\r
+    $v_binary_data = @fread($this->zip_fd, 4);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
+    $v_data = unpack('Vid', $v_binary_data);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
+\r
+    // ----- Check signature\r
+    if ($v_data['id'] != 0x02014b50)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Read the first 42 bytes of the header\r
+    $v_binary_data = fread($this->zip_fd, 42);\r
+\r
+    // ----- Look for invalid block size\r
+    if (strlen($v_binary_data) != 42)\r
+    {\r
+      $p_header['filename'] = "";\r
+      $p_header['status'] = "invalid_header";\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Extract the values\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");\r
+    $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);\r
+\r
+    // ----- Get filename\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$p_header['filename_len']);\r
+    if ($p_header['filename_len'] != 0)\r
+      $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);\r
+    else\r
+      $p_header['filename'] = '';\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');\r
+\r
+    // ----- Get extra\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra length : ".$p_header['extra_len']);\r
+    if ($p_header['extra_len'] != 0)\r
+      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);\r
+    else\r
+      $p_header['extra'] = '';\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra : \''.$p_header['extra'].'\'');\r
+\r
+    // ----- Get comment\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$p_header['comment_len']);\r
+    if ($p_header['comment_len'] != 0)\r
+      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);\r
+    else\r
+      $p_header['comment'] = '';\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_header['comment'].'\'');\r
+\r
+    // ----- Extract properties\r
+    //$p_header['size'] = $v_data['size'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');\r
+    //$p_header['compressed_size'] = $v_data['compressed_size'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');\r
+    //$p_header['crc'] = $v_data['crc'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.$p_header['crc'].'\'');\r
+    //$p_header['flag'] = $v_data['flag'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset : \''.$p_header['offset'].'\'');\r
+\r
+    // ----- Recuperate date in UNIX format\r
+    if ($p_header['mdate'] && $p_header['mtime'])\r
+    {\r
+      // ----- Extract time\r
+      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;\r
+      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;\r
+      $v_seconde = ($p_header['mtime'] & 0x001F)*2;\r
+\r
+      // ----- Extract date\r
+      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;\r
+      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;\r
+      $v_day = $p_header['mdate'] & 0x001F;\r
+\r
+      // ----- Get UNIX date format\r
+      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    }\r
+    else\r
+    {\r
+      $p_header['mtime'] = time();\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');\r
+    }\r
+\r
+    // ----- Set the stored filename\r
+    $p_header['stored_filename'] = $p_header['filename'];\r
+\r
+    // ----- Set default status to ok\r
+    $p_header['status'] = 'ok';\r
+\r
+    // ----- Look if it is a directory\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "external (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".($p_header['external']==0x41FF0010?'is a folder':'is a file').')');\r
+    if (substr($p_header['filename'], -1) == '/')\r
+    {\r
+      $p_header['external'] = 0x41FF0010;\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Force folder external : \''.$p_header['external'].'\'');\r
+    }\r
+\r
+\r
+    // TBC\r
+    //for(reset($p_header); $key = key($p_header); next($p_header)) {\r
+    // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);\r
+    //}\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privReadEndCentralDir()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privReadEndCentralDir(&$p_central_dir)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");\r
+    $v_result=1;\r
+\r
+    // ----- Go to the end of the zip file\r
+    $v_size = filesize($this->zipname);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");\r
+    @fseek($this->zip_fd, $v_size);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');\r
+    if (@ftell($this->zip_fd) != $v_size)\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- First try : look if this is an archive with no commentaries (most of the time)\r
+    // in this case the end of central dir is at 22 bytes of the file end\r
+    $v_found = 0;\r
+    if ($v_size > 26) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');\r
+      @fseek($this->zip_fd, $v_size-22);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
+      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
+\r
+      // ----- Read for bytes\r
+      $v_binary_data = @fread($this->zip_fd, 4);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");\r
+      $v_data = unpack('Vid', $v_binary_data);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");\r
+\r
+      // ----- Check signature\r
+      if ($v_data['id'] == 0x06054b50) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");\r
+        $v_found = 1;\r
+      }\r
+\r
+      $v_pos = ftell($this->zip_fd);\r
+    }\r
+\r
+    // ----- Go back to the maximum possible size of the Central Dir End Record\r
+    if (!$v_found) {\r
+      $v_maximum_size = 65557; // 0xFFFF + 22;\r
+      if ($v_maximum_size > $v_size)\r
+        $v_maximum_size = $v_size;\r
+      @fseek($this->zip_fd, $v_size-$v_maximum_size);\r
+      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))\r
+      {\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');\r
+\r
+      // ----- Read byte per byte in order to find the signature\r
+      $v_pos = ftell($this->zip_fd);\r
+      $v_bytes = 0x00000000;\r
+      while ($v_pos < $v_size)\r
+      {\r
+        // ----- Read a byte\r
+        $v_byte = @fread($this->zip_fd, 1);\r
+\r
+        // -----  Add the byte\r
+        $v_bytes = ($v_bytes << 8) | Ord($v_byte);\r
+\r
+        // ----- Compare the bytes\r
+        if ($v_bytes == 0x504b0506)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature : \''.ftell($this->zip_fd).'\'');\r
+          $v_pos++;\r
+          break;\r
+        }\r
+\r
+        $v_pos++;\r
+      }\r
+\r
+      // ----- Look if not found end of central dir\r
+      if ($v_pos == $v_size)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+    }\r
+\r
+    // ----- Read the first 18 bytes of the header\r
+    $v_binary_data = fread($this->zip_fd, 18);\r
+\r
+    // ----- Look for invalid block size\r
+    if (strlen($v_binary_data) != 18)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Extract the values\r
+    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");\r
+    ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");\r
+    $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);\r
+\r
+    // ----- Check the global size\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);\r
+    if (($v_pos + $v_data['comment_size'] + 18) != $v_size)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Fail to find the right siganture");\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Fail to find the right signature");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Get comment\r
+    if ($v_data['comment_size'] != 0)\r
+      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);\r
+    else\r
+      $p_central_dir['comment'] = '';\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');\r
+\r
+    $p_central_dir['entries'] = $v_data['entries'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');\r
+    $p_central_dir['disk_entries'] = $v_data['disk_entries'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');\r
+    $p_central_dir['offset'] = $v_data['offset'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');\r
+    $p_central_dir['size'] = $v_data['size'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');\r
+    $p_central_dir['disk'] = $v_data['disk'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');\r
+    $p_central_dir['disk_start'] = $v_data['disk_start'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');\r
+\r
+    // TBC\r
+    //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {\r
+    //  //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);\r
+    //}\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privDeleteByIndex()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privDeleteByIndex($p_index, &$p_result_list)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByIndex", "index='$p_index'");\r
+    $v_result=1;\r
+    $v_list_detail = array();\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result=$this->privOpenFd('rb')) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Go to beginning of File\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
+    @rewind($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");\r
+\r
+    // ----- Scan all the files\r
+    // ----- Manipulate the index list\r
+    $p_index = strtr($p_index, ' ', '');\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Reduced index : '$p_index'");\r
+    $v_index_list = explode(",", $p_index);\r
+    // TBC : Here I should sort the index. However a simple sort is not enought.\r
+    // look for the use of usort()\r
+    //sort($v_index_list);\r
+\r
+    // ----- Start at beginning of Central Dir\r
+    $v_pos_entry = $v_central_dir['offset'];\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+    @rewind($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+    if (@fseek($this->zip_fd, $v_pos_entry))\r
+    {\r
+      // ----- Close the zip file\r
+      $this->privCloseFd();\r
+\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+    // ----- Read each entry\r
+    $v_header_list = array();\r
+    for ($i=0, $j_start=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : $i'");\r
+\r
+      // ----- Read the file header\r
+      $v_header_list[$v_nb_extracted] = array();\r
+      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Store the index\r
+      $v_header_list[$v_nb_extracted]['index'] = $i;\r
+\r
+      // ----- Look if the index is in the list\r
+      for ($j=$j_start, $v_found = false; ($j<sizeof($v_index_list)) && (!$v_found); $j++)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in '".$v_index_list[$j]."'");\r
+\r
+        // ----- Extract range\r
+        $v_item_list = explode("-", $v_index_list[$j]);\r
+        $v_size_item_list = sizeof($v_item_list);\r
+        if ($v_size_item_list == 1)\r
+        {\r
+          if ($i==$v_item_list[0])\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as a single index");\r
+            $v_found = true;\r
+          }\r
+          if ($i>=$v_item_list[0])\r
+          {\r
+            $j_start = $j+1;\r
+          }\r
+        }\r
+        else if ($v_size_item_list == 2)\r
+        {\r
+          if (($i>=$v_item_list[0]) && ($i<=$v_item_list[1]))\r
+          {\r
+            //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");\r
+            $v_found = true;\r
+          }\r
+          if ($i>=$v_item_list[1])\r
+          {\r
+            $j_start = $j+1;\r
+          }\r
+        }\r
+        if ($v_item_list[0]>$i)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Range is greater than index, stop loop");\r
+          break;\r
+        }\r
+      }\r
+\r
+      // ----- Look for deletion\r
+      if ($v_found)\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header['filename']."', index '$i' need to be deleted");\r
+        unset($v_header_list[$v_nb_extracted]);\r
+      }\r
+      else\r
+      {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header['filename']."', index '$i' will not be deleted");\r
+        $v_nb_extracted++;\r
+      }\r
+    }\r
+\r
+    // ----- Creates a temporay file\r
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
+\r
+    // ----- Creates a temporary zip archive\r
+    $v_temp_zip = new PclZip($v_zip_temp_name);\r
+\r
+    // ----- Open the temporary zip file in write mode\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");\r
+    if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Look which file need to be kept\r
+    for ($i=0; $i<sizeof($v_header_list); $i++)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry : $i'");\r
+\r
+      // ----- Calculate the position of the header\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Offset='". $v_header_list[$i]['offset']."'");\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");\r
+      @rewind($this->zip_fd);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");\r
+      if (@fseek($this->zip_fd,  $v_header_list[$i]['offset']))\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+        $v_temp_zip->privCloseFd();\r
+        @unlink($v_zip_temp_name);\r
+\r
+        // ----- Error log\r
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+        return PclZip::errorCode();\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");\r
+\r
+      // ----- Read the file header\r
+      if (($v_result = $this->privReadFileHeader($v_header_list[$i])) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+        $v_temp_zip->privCloseFd();\r
+        @unlink($v_zip_temp_name);\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Write the file header\r
+      if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+        $v_temp_zip->privCloseFd();\r
+        @unlink($v_zip_temp_name);\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset for this file is '".$v_header_list[$i]['offset']."'");\r
+\r
+      // ----- Read/write the data block\r
+      if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1)\r
+      {\r
+        // ----- Close the zip file\r
+        $this->privCloseFd();\r
+        $v_temp_zip->privCloseFd();\r
+        @unlink($v_zip_temp_name);\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+    }\r
+\r
+    // ----- Store the offset of the central dir\r
+    $v_offset = @ftell($v_temp_zip->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");\r
+\r
+    // ----- Re-Create the Central Dir files header\r
+    for ($i=0; $i<sizeof($v_header_list); $i++)\r
+    {\r
+      // ----- Create the file header\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Offset of file : ".$v_header_list[$i]['offset']);\r
+      if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1)\r
+      {\r
+        $v_temp_zip->privCloseFd();\r
+        $this->privCloseFd();\r
+        @unlink($v_zip_temp_name);\r
+\r
+        // ----- Return\r
+        //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+        return $v_result;\r
+      }\r
+\r
+      // ----- Transform the header to a 'usable' info\r
+      $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);\r
+    }\r
+\r
+    // ----- Zip file comment\r
+    $v_comment = '';\r
+\r
+    // ----- Calculate the size of the central header\r
+    $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;\r
+\r
+    // ----- Create the central dir footer\r
+    if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1)\r
+    {\r
+      // ----- Reset the file list\r
+      unset($v_header_list);\r
+      $v_temp_zip->privCloseFd();\r
+      $this->privCloseFd();\r
+      @unlink($v_zip_temp_name);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Close\r
+    $v_temp_zip->privCloseFd();\r
+    $this->privCloseFd();\r
+\r
+    // ----- Delete the zip file\r
+    // TBC : I should test the result ...\r
+    @unlink($this->zipname);\r
+\r
+    // ----- Rename the temporary file\r
+    // TBC : I should test the result ...\r
+    //@rename($v_zip_temp_name, $this->zipname);\r
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privDirCheck()\r
+  // Description :\r
+  //   Check if a directory exists, if not it creates it and all the parents directory\r
+  //   which may be useful.\r
+  // Parameters :\r
+  //   $p_dir : Directory path to check.\r
+  // Return Values :\r
+  //    1 : OK\r
+  //   -1 : Unable to create directory\r
+  // --------------------------------------------------------------------------------\r
+  function privDirCheck($p_dir, $p_is_dir=false)\r
+  {\r
+    $v_result = 1;\r
+\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");\r
+\r
+    // ----- Remove the final '/'\r
+    if (($p_is_dir) && (substr($p_dir, -1)=='/'))\r
+    {\r
+      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);\r
+    }\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");\r
+\r
+    // ----- Check the directory availability\r
+    if ((is_dir($p_dir)) || ($p_dir == ""))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");\r
+      return 1;\r
+    }\r
+\r
+    // ----- Extract parent directory\r
+    $p_parent_dir = dirname($p_dir);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");\r
+\r
+    // ----- Just a check\r
+    if ($p_parent_dir != $p_dir)\r
+    {\r
+      // ----- Look for parent directory\r
+      if ($p_parent_dir != "")\r
+      {\r
+        if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)\r
+        {\r
+          //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+          return $v_result;\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Create the directory\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");\r
+    if (!@mkdir($p_dir, 0777))\r
+    {\r
+      // ----- Error log\r
+      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privMerge()\r
+  // Description :\r
+  //   If $p_archive_to_add does not exist, the function exit with a success result.\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privMerge(&$p_archive_to_add)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");\r
+    $v_result=1;\r
+\r
+    // ----- Look if the archive_to_add exists\r
+    if (!is_file($p_archive_to_add->zipname))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");\r
+\r
+      // ----- Nothing to merge, so merge is a success\r
+      $v_result = 1;\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Look if the archive exists\r
+    if (!is_file($this->zipname))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");\r
+\r
+      // ----- Do a duplicate\r
+      $v_result = $this->privDuplicate($p_archive_to_add->zipname);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result=$this->privOpenFd('rb')) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir = array();\r
+    if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Go to beginning of File\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");\r
+    @rewind($this->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");\r
+\r
+    // ----- Open the archive_to_add file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");\r
+    if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Read the central directory informations\r
+    $v_central_dir_to_add = array();\r
+    if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+      $p_archive_to_add->privCloseFd();\r
+\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Go to beginning of File\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");\r
+    @rewind($p_archive_to_add->zip_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");\r
+\r
+    // ----- Creates a temporay file\r
+    $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';\r
+\r
+    // ----- Open the temporary file in write mode\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)\r
+    {\r
+      $this->privCloseFd();\r
+      $p_archive_to_add->privCloseFd();\r
+\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Copy the files from the archive to the temporary file\r
+    // TBC : Here I should better append the file and go back to erase the central dir\r
+    $v_size = $v_central_dir['offset'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = fread($this->zip_fd, $v_read_size);\r
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Copy the files from the archive_to_add into the temporary file\r
+    $v_size = $v_central_dir_to_add['offset'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);\r
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Store the offset of the central dir\r
+    $v_offset = @ftell($v_zip_temp_fd);\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");\r
+\r
+    // ----- Copy the block of file headers from the old archive\r
+    $v_size = $v_central_dir['size'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = @fread($this->zip_fd, $v_read_size);\r
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Copy the block of file headers from the archive_to_add\r
+    $v_size = $v_central_dir_to_add['size'];\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);\r
+      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Zip file comment\r
+    // TBC : I should merge the two comments\r
+    $v_comment = '';\r
+\r
+    // ----- Calculate the size of the (new) central header\r
+    $v_size = @ftell($v_zip_temp_fd)-$v_offset;\r
+\r
+    // ----- Swap the file descriptor\r
+    // Here is a trick : I swap the temporary fd with the zip fd, in order to use\r
+    // the following methods on the temporary fil and not the real archive fd\r
+    $v_swap = $this->zip_fd;\r
+    $this->zip_fd = $v_zip_temp_fd;\r
+    $v_zip_temp_fd = $v_swap;\r
+\r
+    // ----- Create the central dir footer\r
+    if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)\r
+    {\r
+      $this->privCloseFd();\r
+      $p_archive_to_add->privCloseFd();\r
+      @fclose($v_zip_temp_fd);\r
+      $this->zip_fd = null;\r
+\r
+      // ----- Reset the file list\r
+      unset($v_header_list);\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Swap back the file descriptor\r
+    $v_swap = $this->zip_fd;\r
+    $this->zip_fd = $v_zip_temp_fd;\r
+    $v_zip_temp_fd = $v_swap;\r
+\r
+    // ----- Close\r
+    $this->privCloseFd();\r
+    $p_archive_to_add->privCloseFd();\r
+\r
+    // ----- Close the temporary file\r
+    @fclose($v_zip_temp_fd);\r
+\r
+    // ----- Delete the zip file\r
+    // TBC : I should test the result ...\r
+    @unlink($this->zipname);\r
+\r
+    // ----- Rename the temporary file\r
+    // TBC : I should test the result ...\r
+    //@rename($v_zip_temp_name, $this->zipname);\r
+    PclZipUtilRename($v_zip_temp_name, $this->zipname);\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privDuplicate()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function privDuplicate($p_archive_filename)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");\r
+    $v_result=1;\r
+\r
+    // ----- Look if the $p_archive_filename exists\r
+    if (!is_file($p_archive_filename))\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");\r
+\r
+      // ----- Nothing to duplicate, so duplicate is a success.\r
+      $v_result = 1;\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Open the zip file\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_result=$this->privOpenFd('wb')) != 1)\r
+    {\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+      return $v_result;\r
+    }\r
+\r
+    // ----- Open the temporary file in write mode\r
+    //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");\r
+    if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)\r
+    {\r
+      $this->privCloseFd();\r
+\r
+      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');\r
+\r
+      // ----- Return\r
+      //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());\r
+      return PclZip::errorCode();\r
+    }\r
+\r
+    // ----- Copy the files from the archive to the temporary file\r
+    // TBC : Here I should better append the file and go back to erase the central dir\r
+    $v_size = filesize($p_archive_filename);\r
+    while ($v_size != 0)\r
+    {\r
+      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");\r
+      $v_buffer = fread($v_zip_temp_fd, $v_read_size);\r
+      @fwrite($this->zip_fd, $v_buffer, $v_read_size);\r
+      $v_size -= $v_read_size;\r
+    }\r
+\r
+    // ----- Close\r
+    $this->privCloseFd();\r
+\r
+    // ----- Close the temporary file\r
+    @fclose($v_zip_temp_fd);\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privErrorLog()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function privErrorLog($p_error_code=0, $p_error_string='')\r
+  {\r
+    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
+      PclError($p_error_code, $p_error_string);\r
+    }\r
+    else {\r
+      $this->error_code = $p_error_code;\r
+      $this->error_string = $p_error_string;\r
+    }\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : privErrorReset()\r
+  // Description :\r
+  // Parameters :\r
+  // --------------------------------------------------------------------------------\r
+  function privErrorReset()\r
+  {\r
+    if (PCLZIP_ERROR_EXTERNAL == 1) {\r
+      PclErrorReset();\r
+    }\r
+    else {\r
+      $this->error_code = 1;\r
+      $this->error_string = '';\r
+    }\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  }\r
+  // End of class\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilPathReduction()\r
+  // Description :\r
+  // Parameters :\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilPathReduction($p_dir)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");\r
+    $v_result = "";\r
+\r
+    // ----- Look for not empty path\r
+    if ($p_dir != "")\r
+    {\r
+      // ----- Explode path by directory names\r
+      $v_list = explode("/", $p_dir);\r
+\r
+      // ----- Study directories from last to first\r
+      for ($i=sizeof($v_list)-1; $i>=0; $i--)\r
+      {\r
+        // ----- Look for current path\r
+        if ($v_list[$i] == ".")\r
+        {\r
+          // ----- Ignore this directory\r
+          // Should be the first $i=0, but no check is done\r
+        }\r
+        else if ($v_list[$i] == "..")\r
+        {\r
+          // ----- Ignore it and ignore the $i-1\r
+          $i--;\r
+        }\r
+        else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0))\r
+        {\r
+          // ----- Ignore only the double '//' in path,\r
+          // but not the first and last '/'\r
+        }\r
+        else\r
+        {\r
+          $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");\r
+        }\r
+      }\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilPathInclusion()\r
+  // Description :\r
+  //   This function indicates if the path $p_path is under the $p_dir tree. Or,\r
+  //   said in an other way, if the file or sub-dir $p_path is inside the dir\r
+  //   $p_dir.\r
+  //   The function indicates also if the path is exactly the same as the dir.\r
+  //   This function supports path with duplicated '/' like '//', but does not\r
+  //   support '.' or '..' statements.\r
+  // Parameters :\r
+  // Return Values :\r
+  //   0 if $p_path is not inside directory $p_dir\r
+  //   1 if $p_path is inside directory $p_dir\r
+  //   2 if $p_path is exactly the same as $p_dir\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilPathInclusion($p_dir, $p_path)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");\r
+    $v_result = 1;\r
+\r
+    // ----- Explode dir and path by directory separator\r
+    $v_list_dir = explode("/", $p_dir);\r
+    $v_list_dir_size = sizeof($v_list_dir);\r
+    $v_list_path = explode("/", $p_path);\r
+    $v_list_path_size = sizeof($v_list_path);\r
+\r
+    // ----- Study directories paths\r
+    $i = 0;\r
+    $j = 0;\r
+    while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");\r
+\r
+      // ----- Look for empty dir (path reduction)\r
+      if ($v_list_dir[$i] == '') {\r
+        $i++;\r
+        continue;\r
+      }\r
+      if ($v_list_path[$j] == '') {\r
+        $j++;\r
+        continue;\r
+      }\r
+\r
+      // ----- Compare the items\r
+      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");\r
+        $v_result = 0;\r
+      }\r
+\r
+      // ----- Next items\r
+      $i++;\r
+      $j++;\r
+    }\r
+\r
+    // ----- Look if everything seems to be the same\r
+    if ($v_result) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");\r
+      // ----- Skip all the empty items\r
+      while (($v_list_path[$j] == '') && ($j < $v_list_path_size)) $j++;\r
+      while (($v_list_dir[$i] == '') && ($i < $v_list_dir_size)) $i++;\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");\r
+\r
+      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {\r
+        // ----- There are exactly the same\r
+        $v_result = 2;\r
+      }\r
+      else if ($i < $v_list_dir_size) {\r
+        // ----- The path is shorter than the dir\r
+        $v_result = 0;\r
+      }\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilCopyBlock()\r
+  // Description :\r
+  // Parameters :\r
+  //   $p_mode : read/write compression mode\r
+  //             0 : src & dest normal\r
+  //             1 : src gzip, dest normal\r
+  //             2 : src normal, dest gzip\r
+  //             3 : src & dest gzip\r
+  // Return Values :\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");\r
+    $v_result = 1;\r
+\r
+    if ($p_mode==0)\r
+    {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));\r
+      while ($p_size != 0)\r
+      {\r
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+        $v_buffer = @fread($p_src, $v_read_size);\r
+        @fwrite($p_dest, $v_buffer, $v_read_size);\r
+        $p_size -= $v_read_size;\r
+      }\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));\r
+    }\r
+    else if ($p_mode==1)\r
+    {\r
+      while ($p_size != 0)\r
+      {\r
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+        $v_buffer = @gzread($p_src, $v_read_size);\r
+        @fwrite($p_dest, $v_buffer, $v_read_size);\r
+        $p_size -= $v_read_size;\r
+      }\r
+    }\r
+    else if ($p_mode==2)\r
+    {\r
+      while ($p_size != 0)\r
+      {\r
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+        $v_buffer = @fread($p_src, $v_read_size);\r
+        @gzwrite($p_dest, $v_buffer, $v_read_size);\r
+        $p_size -= $v_read_size;\r
+      }\r
+    }\r
+    else if ($p_mode==3)\r
+    {\r
+      while ($p_size != 0)\r
+      {\r
+        $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");\r
+        $v_buffer = @gzread($p_src, $v_read_size);\r
+        @gzwrite($p_dest, $v_buffer, $v_read_size);\r
+        $p_size -= $v_read_size;\r
+      }\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilRename()\r
+  // Description :\r
+  //   This function tries to do a simple rename() function. If it fails, it\r
+  //   tries to copy the $p_src file in a new $p_dest file and then unlink the\r
+  //   first one.\r
+  // Parameters :\r
+  //   $p_src : Old filename\r
+  //   $p_dest : New filename\r
+  // Return Values :\r
+  //   1 on success, 0 on failure.\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilRename($p_src, $p_dest)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");\r
+    $v_result = 1;\r
+\r
+    // ----- Try to rename the files\r
+    if (!@rename($p_src, $p_dest)) {\r
+      //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");\r
+\r
+      // ----- Try to copy & unlink the src\r
+      if (!@copy($p_src, $p_dest)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");\r
+        $v_result = 0;\r
+      }\r
+      else if (!@unlink($p_src)) {\r
+        //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");\r
+        $v_result = 0;\r
+      }\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+  // --------------------------------------------------------------------------------\r
+  // Function : PclZipUtilOptionText()\r
+  // Description :\r
+  //   Translate option value in text. Mainly for debug purpose.\r
+  // Parameters :\r
+  //   $p_option : the option value.\r
+  // Return Values :\r
+  //   The option text value.\r
+  // --------------------------------------------------------------------------------\r
+  function PclZipUtilOptionText($p_option)\r
+  {\r
+    //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");\r
+\r
+    switch ($p_option) {\r
+      case PCLZIP_OPT_PATH :\r
+        $v_result = 'PCLZIP_OPT_PATH';\r
+      break;\r
+      case PCLZIP_OPT_ADD_PATH :\r
+        $v_result = 'PCLZIP_OPT_ADD_PATH';\r
+      break;\r
+      case PCLZIP_OPT_REMOVE_PATH :\r
+        $v_result = 'PCLZIP_OPT_REMOVE_PATH';\r
+      break;\r
+      case PCLZIP_OPT_REMOVE_ALL_PATH :\r
+        $v_result = 'PCLZIP_OPT_REMOVE_ALL_PATH';\r
+      break;\r
+      case PCLZIP_OPT_SET_CHMOD :\r
+        $v_result = 'PCLZIP_OPT_SET_CHMOD';\r
+      break;\r
+\r
+\r
+      case PCLZIP_CB_PRE_EXTRACT :\r
+        $v_result = 'PCLZIP_CB_PRE_EXTRACT';\r
+      break;\r
+      case PCLZIP_CB_POST_EXTRACT :\r
+        $v_result = 'PCLZIP_CB_POST_EXTRACT';\r
+      break;\r
+      case PCLZIP_CB_PRE_ADD :\r
+        $v_result = 'PCLZIP_CB_PRE_ADD';\r
+      break;\r
+      case PCLZIP_CB_POST_ADD :\r
+        $v_result = 'PCLZIP_CB_POST_ADD';\r
+      break;\r
+\r
+      default :\r
+        $v_result = 'Unknown';\r
+    }\r
+\r
+    // ----- Return\r
+    //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);\r
+    return $v_result;\r
+  }\r
+  // --------------------------------------------------------------------------------\r
+\r
+?>
\ No newline at end of file
diff --git a/lib/pclzip/readme.txt b/lib/pclzip/readme.txt
new file mode 100644 (file)
index 0000000..4d8b601
--- /dev/null
@@ -0,0 +1,219 @@
+// --------------------------------------------------------------------------------\r
+// PclZip 1.3 - readme.txt\r
+// --------------------------------------------------------------------------------\r
+// License GNU/GPL - january 2003\r
+// Vincent Blavet - vincent@phpconcept.net\r
+// http://www.phpconcept.net\r
+// --------------------------------------------------------------------------------\r
+// $Id$\r
+// --------------------------------------------------------------------------------\r
+\r
+\r
+\r
+0 - Sommaire\r
+============\r
+    1 - Introduction\r
+    2 - What's new\r
+    3 - Corrected bugs\r
+    4 - Known bugs or limitations\r
+    5 - License\r
+    6 - Warning\r
+    7 - Author\r
+    8 - Contribute\r
+\r
+1 - Introduction\r
+================\r
+\r
+  PclZip is a library that allow you to manage a Zip archive.\r
+\r
+  Full documentation about PclZip can be found here : http://www.phpconcept.net/pclzip\r
+\r
+2 - What's new\r
+==============\r
+\r
+  Version 1.3 :\r
+    - Removing the double include check. This is now done by include_once() and require_once()\r
+      PHP directives.\r
+    - Changing the error handling mecanism : Remove the use of an external error library.\r
+      The former PclError...() functions are replaced by internal equivalent methods.\r
+      By changing the environment variable PCLZIP_ERROR_EXTERNAL you can still use the former library.\r
+      Introducing the use of constants for error codes rather than integer values. This will help\r
+      in futur improvment.\r
+      Introduction of error handling functions like errorCode(), errorName() and errorInfo().\r
+    - Remove the deprecated use of calling function with arguments passed by reference.\r
+    - Add the calling of extract(), extractByIndex(), create() and add() functions\r
+      with variable options rather than fixed arguments.\r
+    - Add the ability to remove all the file path while extracting or adding,\r
+      without any need to specify the path to remove.\r
+      This is available for extract(), extractByIndex(), create() and add() functionS by using\r
+      the new variable options parameters :\r
+      - PCLZIP_OPT_REMOVE_ALL_PATH : by indicating this option while calling the fct.\r
+    - Ability to change the mode of a file after the extraction (chmod()).\r
+      This is available for extract() and extractByIndex() functionS by using\r
+      the new variable options parameters.\r
+      - PCLZIP_OPT_SET_CHMOD : by setting the value of this option.\r
+    - Ability to definition call-back options. These call-back will be called during the adding,\r
+      or the extracting of file (extract(), extractByIndex(), create() and add() functions) :\r
+      - PCLZIP_CB_PRE_EXTRACT : will be called before each extraction of a file. The user\r
+        can trigerred the change the filename of the extracted file. The user can triggered the\r
+        skip of the extraction. This is adding a 'skipped' status in the file list result value.\r
+      - PCLZIP_CB_POST_EXTRACT : will be called after each extraction of a file.\r
+        Nothing can be triggered from that point.\r
+      - PCLZIP_CB_PRE_ADD : will be called before each add of a file. The user\r
+        can trigerred the change the stored filename of the added file. The user can triggered the\r
+        skip of the add. This is adding a 'skipped' status in the file list result value.\r
+      - PCLZIP_CB_POST_ADD : will be called after each add of a file.\r
+        Nothing can be triggered from that point.\r
+    - Two status are added in the file list returned as function result : skipped & filename_too_long\r
+      'skipped' is used when a call-back function ask for skipping the file.\r
+      'filename_too_long' is used while adding a file with a too long filename to archive (the file is\r
+      not added)\r
+    - Adding the function PclZipUtilPathInclusion(), that check the inclusion of a path into\r
+      a directory.\r
+    - Add a check of the presence of the archive file before some actions (like list, ...)\r
+    - Add the initialisation of field "index" in header array. This means that by\r
+      default index will be -1 when not explicitly set by the methods.\r
+\r
+  Version 1.2 :\r
+    - Adding a duplicate function.\r
+    - Adding a merge function. The merge function is a "quick merge" function,\r
+      it just append the content of an archive at the end of the first one. There\r
+      is no check for duplicate files or more recent files.\r
+    - Improve the search of the central directory end.\r
+\r
+  Version 1.1.2 :\r
+\r
+    - Changing the license of PclZip. PclZip is now released under the GNU / LGPL license\r
+      (see License section).\r
+    - Adding the optional support of a static temporary directory. You will need to configure\r
+      the constant PCLZIP_TEMPORARY_DIR if you want to use this feature.\r
+    - Improving the rename() function. In some cases rename() does not work (different\r
+      Filesystems), so it will be replaced by a copy() + unlink() functions.\r
+\r
+  Version 1.1.1 :\r
+\r
+    - Maintenance release, no new feature.\r
+\r
+  Version 1.1 :\r
+\r
+    - New method Add() : adding files in the archive\r
+    - New method ExtractByIndex() : partial extract of the archive, files are identified by\r
+      their index in the archive\r
+    - New method DeleteByIndex() : delete some files/folder entries from the archive,\r
+      files are identified by their index in the archive.\r
+    - Adding a test of the zlib extension presence. If not present abort the script.\r
+\r
+  Version 1.0.1 :\r
+\r
+    - No new feature\r
+\r
+\r
+3 - Corrected bugs\r
+==================\r
+\r
+  Corrected in Version 1.3 :\r
+    - Corrected : Support of static synopsis for method extract() is broken.\r
+    - Corrected : invalid size of archive content field (0xFF) should be (0xFFFF).\r
+    - Corrected : When an extract is done with a remove_path parameter, the entry for\r
+      the directory with exactly the same path is not skipped/filtered.\r
+    - Corrected : extractByIndex() and deleteByIndex() were not managing index in the\r
+      right way. For example indexes '1,3-5,11' will only extract files 1 and 11. This\r
+      is due to a sort of the index resulting table that puts 11 before 3-5 (sort on\r
+      string and not interger). The sort is temporarilly removed, this means that\r
+      you must provide a sorted list of index ranges.\r
+\r
+  Corrected in Version 1.2 :\r
+\r
+    - Nothing.\r
+\r
+  Corrected in Version 1.1.2 :\r
+\r
+    - Corrected : Winzip is unable to delete or add new files in a PclZip created archives.\r
+\r
+  Corrected in Version 1.1.1 :\r
+\r
+    - Corrected : When archived file is not compressed (0% compression), the\r
+      extract method fails.\r
+\r
+  Corrected in Version 1.1 :\r
+\r
+    - Corrected : Adding a complete tree of folder may result in a bad archive\r
+      creation.\r
+\r
+  Corrected in Version 1.0.1 :\r
+\r
+    - Corrected : Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).\r
+\r
+\r
+4 - Known bugs or limitations\r
+=============================\r
+\r
+  Please publish bugs reports in SourceForge :\r
+    http://sourceforge.net/tracker/?group_id=40254&atid=427564\r
+\r
+  In Version 1.2 :\r
+\r
+    - merge() methods does not check for duplicate files or last date of modifications.\r
+\r
+  In Version 1.1 :\r
+\r
+    - Limitation : Using 'extract' fields in the file header in the zip archive is not supported.\r
+    - WinZip is unable to delete a single file in a PclZip created archive. It is also unable to\r
+      add a file in a PclZip created archive. (Corrected in v.1.2)\r
+\r
+  In Version 1.0.1 :\r
+\r
+    - Adding a complete tree of folder may result in a bad archive\r
+      creation. (Corrected in V.1.1).\r
+    - Path given to methods must be in the unix format (/) and not the Windows format (\).\r
+      Workaround : Use only / directory separators.\r
+    - PclZip is using temporary files that are sometime the name of the file with a .tmp or .gz\r
+      added suffix. Files with these names may already exist and may be overwritten.\r
+      Workaround : none.\r
+    - PclZip does not check if the zlib extension is present. If it is absent, the zip\r
+      file is not created and the lib abort without warning.\r
+      Workaround : enable the zlib extension on the php install\r
+\r
+  In Version 1.0 :\r
+\r
+    - Error while compressing files greater than PCLZIP_READ_BLOCK_SIZE (default=1024).\r
+      (Corrected in v.1.0.1)\r
+    - Limitation : Multi-disk zip archive are not supported.\r
+\r
+\r
+5 - License\r
+===========\r
+\r
+  Since version 1.1.2, PclZip Library is released under GNU/LGPL license.\r
+  This library is free, so you can use it at no cost.\r
+\r
+  HOWEVER, if you release a script, an application, a library or any kind of\r
+  code using PclZip library (or a part of it), YOU MUST :\r
+  - Indicate in the documentation (or a readme file), that your work\r
+    uses PclZip Library, and make a reference to the author and the web site\r
+    http://www.phpconcept.net\r
+  - Gives the ability to the final user to update the PclZip libary.\r
+\r
+  I will also appreciate that you send me a mail (vincent@phpconcept.net), just to\r
+  be aware that someone is using PclZip.\r
+\r
+  For more information about GNU/LGPL license : http://www.gnu.org\r
+\r
+6 - Warning\r
+=================\r
+\r
+  This library and the associated files are non commercial, non professional work.\r
+  It should not have unexpected results. However if any damage is caused by this software\r
+  the author can not be responsible.\r
+  The use of this software is at the risk of the user.\r
+\r
+7 - Author\r
+==========\r
+\r
+  This software was written by Vincent Blavet (vincent@phpconcept.net) on its leasure time.\r
+\r
+8 - Contribute\r
+==============\r
+  If you want to contribute to the development of PclZip, please contact vincent@phpconcept.net.\r
+  If you can help in financing PhpConcept hosting service, please go to\r
+  http://www.phpconcept.net/soutien.php
\ No newline at end of file